v0.14.0
Public Member Functions | Private Attributes | List of all members
MoFEM::WrapMPIComm Struct Reference

Wrap MPI communicator such that is destroyed when is out of scope. More...

#include <src/interfaces/Core.hpp>

Collaboration diagram for MoFEM::WrapMPIComm:
[legend]

Public Member Functions

 WrapMPIComm (MPI_Comm comm, bool petsc)
 
 ~WrapMPIComm ()
 
auto get_comm ()
 

Private Attributes

MPI_Comm comm
 
MPI_Comm duplicatedComm
 
bool isPetscComm
 

Detailed Description

Wrap MPI communicator such that is destroyed when is out of scope.

Definition at line 19 of file Core.hpp.

Constructor & Destructor Documentation

◆ WrapMPIComm()

MoFEM::WrapMPIComm::WrapMPIComm ( MPI_Comm  comm,
bool  petsc 
)

Definition at line 16 of file Core.cpp.

17  : comm(comm), isPetscComm(petsc) {
18  if (isPetscComm) {
19  ierr = PetscCommDuplicate(comm, &duplicatedComm, NULL);
20  CHKERRABORT(comm, ierr);
21  } else {
22  int ierr = MPI_Comm_dup(comm, &duplicatedComm);
23  if (ierr) {
24  THROW_MESSAGE("MPI_Comm_dup not working");
25  }
26  }
27 }

◆ ~WrapMPIComm()

MoFEM::WrapMPIComm::~WrapMPIComm ( )

Definition at line 28 of file Core.cpp.

28  {
29  if (isPetscComm) {
30  ierr = PetscCommDestroy(&duplicatedComm);
31  CHKERRABORT(comm, ierr);
32  } else {
33  int ierr = MPI_Comm_free(&duplicatedComm);
34  if (ierr) {
35  CHKERRABORT(comm, MOFEM_DATA_INCONSISTENCY);
36  }
37  }
38 }

Member Function Documentation

◆ get_comm()

auto MoFEM::WrapMPIComm::get_comm ( )
inline

Definition at line 23 of file Core.hpp.

23 { return duplicatedComm; }

Member Data Documentation

◆ comm

MPI_Comm MoFEM::WrapMPIComm::comm
private

Definition at line 26 of file Core.hpp.

◆ duplicatedComm

MPI_Comm MoFEM::WrapMPIComm::duplicatedComm
private

Definition at line 27 of file Core.hpp.

◆ isPetscComm

bool MoFEM::WrapMPIComm::isPetscComm
private

Definition at line 28 of file Core.hpp.


The documentation for this struct was generated from the following files:
THROW_MESSAGE
#define THROW_MESSAGE(msg)
Throw MoFEM exception.
Definition: definitions.h:574
MoFEM::WrapMPIComm::duplicatedComm
MPI_Comm duplicatedComm
Definition: Core.hpp:27
MoFEM::WrapMPIComm::comm
MPI_Comm comm
Definition: Core.hpp:26
MoFEM::Exceptions::ierr
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
Definition: Exceptions.hpp:76
MOFEM_DATA_INCONSISTENCY
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:31
MoFEM::WrapMPIComm::isPetscComm
bool isPetscComm
Definition: Core.hpp:28