Dune Core Modules (unstable)

A real mpi helper. More...

#include <dune/common/parallel/mpihelper.hh>

Public Types

typedef MPI_Comm MPICommunicator
 The type of the mpi communicator.
 

Public Member Functions

int rank () const
 return rank of process
 
int size () const
 return number of processes
 
 ~MPIHelper ()
 calls MPI_Finalize
 

Static Public Member Functions

static MPICommunicator getCommunicator ()
 get the default communicator More...
 
static MPICommunicator getLocalCommunicator ()
 get a local communicator More...
 
static Communication< MPICommunicatorgetCollectiveCommunication ()
 
static DUNE_EXPORT MPIHelperinstance (int &argc, char **&argv)
 Get the singleton instance of the helper. More...
 

Static Public Attributes

static constexpr bool isFake = false
 Are we fake (i. e. pretend to have MPI support but are compiled without.
 

Related Functions

(Note that these are not member functions.)

static DUNE_EXPORT MPIHelperinstance (int *argc=nullptr, char ***argv=nullptr)
 Get the singleton instance of the helper. More...
 

Detailed Description

A real mpi helper.

This helper should be used for parallel programs.

Examples
recipe-integration.cc, and recipe-iterate-over-grid.cc.

Member Function Documentation

◆ getCollectiveCommunication()

static Communication< MPICommunicator > Dune::MPIHelper::getCollectiveCommunication ( )
inlinestatic
Deprecated:
getCollectionCommunication is deprecated and will be removed after Dune 2.9.

Use getCommunication instead.

References getCommunicator().

◆ getCommunicator()

static MPICommunicator Dune::MPIHelper::getCommunicator ( )
inlinestatic

get the default communicator

Return a communicator to exchange data with all processes

Returns
MPI_COMM_WORLD

Referenced by getCollectiveCommunication().

◆ getLocalCommunicator()

static MPICommunicator Dune::MPIHelper::getLocalCommunicator ( )
inlinestatic

get a local communicator

Returns a communicator to exchange data with the local process only

Returns
MPI_COMM_SELF

Referenced by Dune::GridFactoryInterface< GridType >::comm().

◆ instance()

static DUNE_EXPORT MPIHelper & Dune::MPIHelper::instance ( int &  argc,
char **&  argv 
)
inlinestatic

Get the singleton instance of the helper.

This method has to be called with the same arguments that the main method of the program was called:

int main(int argc, char** argv){
MPIHelper::instance(argc, argv);
// program code comes here
...
}
static DUNE_EXPORT MPIHelper & instance(int &argc, char **&argv)
Get the singleton instance of the helper.
Definition: mpihelper.hh:252

The MPIHelper will be globally initialized on its first call. Afterwards, all arguments to this function will be ignored.

Parameters
argcThe number of arguments provided to main.
argvThe arguments provided to main.
Examples
recipe-integration.cc, and recipe-iterate-over-grid.cc.

References instance().

Referenced by instance().

Friends And Related Function Documentation

◆ instance()

static DUNE_EXPORT MPIHelper & instance ( int *  argc = nullptr,
char ***  argv = nullptr 
)
related

Get the singleton instance of the helper.

This method can be called either without any arguments, or with the same arguments that the main method of the program was called, passed as pointer:

int main(int argc, char** argv){
// or: MPIHelper::instance(&argc, &argv);
// program code comes here
...
}

The MPIHelper will be globally initialized on its first call. Afterwards, all arguments to this function will be ignored.

Note
This overload accepts all arguments by pointer similar to the MPI_Init function and allows to pass nullptr for all arguments.

(int&, char**&)

Parameters
argcThe number of arguments provided to main.
argvThe arguments provided to main.

References instance().


The documentation for this class was generated from the following file:
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 20, 23:30, 2024)