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

Wrap MPI comminitactor 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 comminitactor such that is destroyed when is out of scope.

Definition at line 29 of file Core.hpp.

Constructor & Destructor Documentation

◆ WrapMPIComm()

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

Definition at line 29 of file Core.cpp.

30  : comm(comm), isPetscComm(petsc) {
31  if (isPetscComm) {
32  ierr = PetscCommDuplicate(comm, &duplicatedComm, NULL);
33  CHKERRABORT(comm, ierr);
34  } else {
35  int ierr = MPI_Comm_dup(comm, &duplicatedComm);
36  if (ierr) {
37  THROW_MESSAGE("MPI_Comm_dup not working");
38  }
39  }
40 }
#define THROW_MESSAGE(msg)
Throw MoFEM exception.
Definition: definitions.h:574
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
Definition: Exceptions.hpp:87
MPI_Comm duplicatedComm
Definition: Core.hpp:37
MPI_Comm comm
Definition: Core.hpp:36
bool isPetscComm
Definition: Core.hpp:38

◆ ~WrapMPIComm()

MoFEM::WrapMPIComm::~WrapMPIComm ( )

Definition at line 41 of file Core.cpp.

41  {
42  if (isPetscComm) {
43  ierr = PetscCommDestroy(&duplicatedComm);
44  CHKERRABORT(comm, ierr);
45  } else {
46  int ierr = MPI_Comm_free(&duplicatedComm);
47  if (ierr) {
48  CHKERRABORT(comm, MOFEM_DATA_INCONSISTENCY);
49  }
50  }
51 }
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:44

Member Function Documentation

◆ get_comm()

auto MoFEM::WrapMPIComm::get_comm ( )

Definition at line 33 of file Core.hpp.

33 { return duplicatedComm; }

Member Data Documentation

◆ comm

MPI_Comm MoFEM::WrapMPIComm::comm
private

Definition at line 36 of file Core.hpp.

◆ duplicatedComm

MPI_Comm MoFEM::WrapMPIComm::duplicatedComm
private

Definition at line 37 of file Core.hpp.

◆ isPetscComm

bool MoFEM::WrapMPIComm::isPetscComm
private

Definition at line 38 of file Core.hpp.


The documentation for this struct was generated from the following files: