MOAB: Mesh Oriented datABase  (version 5.5.0)
imoab_coupler_utils.hpp File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define CHECKIERR(rc, message)
 
#define PUSH_TIMER(operation)
 
#define POP_TIMER(localcomm, localrank)
 

Functions

int create_group_and_comm (int start, int end, MPI_Group worldGroup, MPI_Group *group, MPI_Comm *comm)
 
int create_joint_comm_group (MPI_Group agroup, MPI_Group bgroup, MPI_Group *abgroup, MPI_Comm *abcomm)
 
int setup_component_coupler_meshes (iMOAB_AppID cmpId, int cmpTag, iMOAB_AppID cplCmpId, int cmpcouTag, MPI_Comm *cmpcomm, MPI_Group *cmpPEGroup, MPI_Comm *coucomm, MPI_Group *cplPEGroup, MPI_Comm *cmpcoucomm, std::string &filename, std::string &readopts, int nghlay, int repartitioner_scheme)
 

Macro Definition Documentation

◆ CHECKIERR

#define CHECKIERR (   rc,
  message 
)
Value:
if( 0 != ( rc ) ) \
{ \
printf( "%s. ErrorCode = %d\n", message, rc ); \
return 1; \
}

Definition at line 14 of file imoab_coupler_utils.hpp.

◆ POP_TIMER

#define POP_TIMER (   localcomm,
  localrank 
)
Value:
{ \
double locElapsed = timer.time_since_birth() - timer_ops, minElapsed = 0, maxElapsed = 0; \
MPI_Reduce( &locElapsed, &maxElapsed, 1, MPI_DOUBLE, MPI_MAX, 0, localcomm ); \
MPI_Reduce( &locElapsed, &minElapsed, 1, MPI_DOUBLE, MPI_MIN, 0, localcomm ); \
if( !( localrank ) ) \
std::cout << "[LOG] Time taken to " << opName.c_str() << ": max = " << maxElapsed \
<< ", avg = " << ( maxElapsed + minElapsed ) / 2 << "\n"; \
opName.clear(); \
}

Definition at line 26 of file imoab_coupler_utils.hpp.

◆ PUSH_TIMER

#define PUSH_TIMER (   operation)
Value:
{ \
timer_ops = timer.time_since_birth(); \
opName = operation; \
}

Definition at line 21 of file imoab_coupler_utils.hpp.

Function Documentation

◆ create_group_and_comm()

int create_group_and_comm ( int  start,
int  end,
MPI_Group  worldGroup,
MPI_Group *  group,
MPI_Comm *  comm 
)

Definition at line 40 of file imoab_coupler_utils.hpp.

41 {
42  std::vector< int > groupTasks;
43  groupTasks.resize( end - start + 1, 0 );
44  for( int i = start; i <= end; i++ )
45  groupTasks[i - start] = i;
46 
47  int ierr = MPI_Group_incl( worldGroup, end - start + 1, &groupTasks[0], group );
48  CHECKIERR( ierr, "Cannot create group" )
49 
50  ierr = MPI_Comm_create( MPI_COMM_WORLD, *group, comm );
51  CHECKIERR( ierr, "Cannot create comm" )
52 
53  return 0;
54 }

References CHECKIERR, groupTasks, ierr, and MPI_COMM_WORLD.

Referenced by main().

◆ create_joint_comm_group()

int create_joint_comm_group ( MPI_Group  agroup,
MPI_Group  bgroup,
MPI_Group *  abgroup,
MPI_Comm *  abcomm 
)

Definition at line 56 of file imoab_coupler_utils.hpp.

57 {
58  int ierr = MPI_Group_union( agroup, bgroup, abgroup );
59  CHECKIERR( ierr, "Cannot create joint union group" )
60 
61  ierr = MPI_Comm_create( MPI_COMM_WORLD, *abgroup, abcomm );
62  CHECKIERR( ierr, "Cannot create joint communicator from union group" )
63 
64  return 0;
65 }

References CHECKIERR, ierr, and MPI_COMM_WORLD.

Referenced by main().

◆ setup_component_coupler_meshes()

int setup_component_coupler_meshes ( iMOAB_AppID  cmpId,
int  cmpTag,
iMOAB_AppID  cplCmpId,
int  cmpcouTag,
MPI_Comm *  cmpcomm,
MPI_Group *  cmpPEGroup,
MPI_Comm *  coucomm,
MPI_Group *  cplPEGroup,
MPI_Comm *  cmpcoucomm,
std::string &  filename,
std::string &  readopts,
int  nghlay,
int  repartitioner_scheme 
)

Definition at line 67 of file imoab_coupler_utils.hpp.

80 {
81  int ierr = 0;
82  if( *cmpcomm != MPI_COMM_NULL )
83  {
84  // load first mesh
85  ierr = iMOAB_LoadMesh( cmpId, filename.c_str(), readopts.c_str(), &nghlay );
86  CHECKIERR( ierr, "Cannot load component mesh" )
87 
88  // then send mesh to coupler pes
89  ierr = iMOAB_SendMesh( cmpId, cmpcoucomm, cplPEGroup, &cmpcouTag,
90  &repartitioner_scheme ); // send to coupler pes
91  CHECKIERR( ierr, "cannot send elements" )
92  }
93  // now, receive mesh, on coupler communicator; first mesh 1, atm
94  if( *coucomm != MPI_COMM_NULL )
95  {
96 
97  ierr = iMOAB_ReceiveMesh( cplCmpId, cmpcoucomm, cmpPEGroup,
98  &cmpTag ); // receive from component
99  CHECKIERR( ierr, "cannot receive elements on coupler app" )
100  }
101 
102  // we can now free the sender buffers
103  if( *cmpcomm != MPI_COMM_NULL )
104  {
105  int context_id = cmpcouTag;
106  ierr = iMOAB_FreeSenderBuffers( cmpId, &context_id );
107  CHECKIERR( ierr, "cannot free buffers used to send atm mesh" )
108  }
109  return 0;
110 }

References CHECKIERR, filename, ierr, iMOAB_LoadMesh(), nghlay, and readopts().

Referenced by main().