OpenPFC  0.1.4
Phase Field Crystal simulation framework
Loading...
Searching...
No Matches
worker.hpp File Reference

MPI worker process management. More...

#include <mpi.h>
#include <iostream>
Include dependency graph for worker.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  pfc::MPI_Worker
 An MPI worker class that wraps MPI_Init and MPI_Finalize. More...
 

Detailed Description

MPI worker process management.

This header provides the MPI_Worker class for managing individual MPI worker processes with automatic initialization and output management.

The MPI_Worker class:

  • Automatically initializes and finalizes MPI
  • Mutes stdout on non-root ranks to avoid duplicate output
  • Provides rank and process count queries
  • Manages MPI communicator

This is particularly useful for applications where only rank 0 should produce console output.

int main(int argc, char** argv) {
pfc::MPI_Worker worker(argc, argv, MPI_COMM_WORLD);
// Only rank 0 prints to stdout
std::cout << "Rank: " << worker.rank() << std::endl;
return 0;
}
An MPI worker class that wraps MPI_Init and MPI_Finalize.
Definition worker.hpp:55
MPI worker process management.
See also
mpi/environment.hpp for alternative RAII MPI management
mpi/communicator.hpp for communicator wrapper
Author
OpenPFC Development Team
Date
2025