OpenPFC  0.1.4
Phase Field Crystal simulation framework
Loading...
Searching...
No Matches
pfc::MPI_Worker Class Reference

An MPI worker class that wraps MPI_Init and MPI_Finalize. More...

#include <worker.hpp>

Public Member Functions

 MPI_Worker (int argc, char *argv[], MPI_Comm comm=MPI_COMM_WORLD, bool verbose=true)
 Constructs an MPI worker instance and initializes MPI if needed.
 
 ~MPI_Worker ()
 Destroys the MPI worker instance and finalizes MPI if it owns it.
 
int get_rank () const
 Returns the rank of this worker process in the MPI communicator.
 
int get_num_ranks () const
 Returns the number of processes in the MPI communicator.
 
void mute ()
 Mutes the standard output.
 
void unmute ()
 Unmutes the standard output.
 

Detailed Description

An MPI worker class that wraps MPI_Init and MPI_Finalize.

This class represents a single worker process in a MPI application. It wraps the MPI_Init and MPI_Finalize calls and provides helper functions to get the rank and number of processes in the MPI communicator.

Constructor & Destructor Documentation

◆ MPI_Worker()

pfc::MPI_Worker::MPI_Worker ( int  argc,
char argv[],
MPI_Comm  comm = MPI_COMM_WORLD,
bool  verbose = true 
)
inline

Constructs an MPI worker instance and initializes MPI if needed.

This constructor initializes MPI (if not already initialized) and retrieves the rank and number of processes in the given MPI communicator. If the rank is not zero, the standard output is muted to avoid duplicate output.

Parameters
argcPointer to the number of command-line arguments
argvPointer to an array of command-line arguments
commMPI communicator to use
verbosePrint initialization message if true (default: true)
Here is the call graph for this function:

◆ ~MPI_Worker()

pfc::MPI_Worker::~MPI_Worker ( )
inline

Destroys the MPI worker instance and finalizes MPI if it owns it.

This destructor finalizes MPI only if this worker initialized it.

Member Function Documentation

◆ get_num_ranks()

int pfc::MPI_Worker::get_num_ranks ( ) const
inline

Returns the number of processes in the MPI communicator.

Returns
The number of processes in the MPI communicator

◆ get_rank()

int pfc::MPI_Worker::get_rank ( ) const
inline

Returns the rank of this worker process in the MPI communicator.

Returns
The rank of this worker process

◆ mute()

void pfc::MPI_Worker::mute ( )
inline

Mutes the standard output.

This function sets the failbit of the standard output stream, effectively muting it.

Here is the caller graph for this function:

◆ unmute()

void pfc::MPI_Worker::unmute ( )
inline

Unmutes the standard output.

This function clears the failbit of the standard output stream, effectively unmuting it.


The documentation for this class was generated from the following file: