C++ Bindings

namespace CPL


void init(int calling_realm, MPI_Comm &returned_realm_comm)

(cfd+md) Splits MPI_COMM_WORLD in both the CFD and MD code respectively and create intercommunicator between CFD and MD


Assumes MPI has been initialised MPI_init and communicator MPI_COMM_WORLD exists and contains all processors in both CFD and MD regions


CPL::init(callingrealm, RETURNED_REALM_COMM)    


  • callingrealm

    • Should identify calling processor as either CFD_REALM (integer with value 1) or MD_REALM (integer with value 2).



    • Communicator based on callingrealm value local to CFD or MD processor and resulting from the split of MPI_COMM_WORLD


#include "cpl.h"
#include "mpi.h"
#include <iostream>

using namespace std;

int main() {
   MPI_Init(NULL, NULL); 

   int CFD_realm = 1;
   CPL::init(CFD_realm, CFD_COMM);

   int nprocs; int rank;
   MPI_Comm_size(CFD_COMM, &nprocs);   
   MPI_Comm_rank(CFD_COMM, &rank);

   cout << "MD code processor " << rank+1 << " of " << nprocs << endl;


COUPLER_ERROR_REALM  = 1                wrong realm value
COUPLER_ERROR_ONE_REALM = 2             one realm missing
COUPLER_ERROR_INIT = 3                  initialisation error

void finalize()
void setup_cfd(MPI_Comm &icomm_grid, double xyzL[], double xyz_orig[], int ncxyz[])
void setup_md(MPI_Comm &icomm_grid, double xyzL[], double xyz_orig[])
void set_timing(int initialstep, int nsteps, double dt)
bool send(double *asend, int *asend_shape, int *limits)
bool recv(double *arecv, int *arecv_shape, int *limits)
bool send(CPL::ndArray<double> *asend, int *limits)
bool recv(CPL::ndArray<double> *arecv, int *limits)
bool send(CPL::ndArray<double> *asend)
bool recv(CPL::ndArray<double> *arecv)
void scatter(double *scatterarray, int *scatter_shape, int *limits, double *recvarray, int *recv_shape)
void gather(double *gatherarray, int *gather_shape, int *limits, double *recvarray, int *recv_shape)
void swaphalos(double *A, int *A_shape)
void proc_extents(int coord[], int realm, int extents[])
void my_proc_extents(int extents[])
void proc_portion(int coord[], int realm, int limits[], int portion[])
void my_proc_portion(int limits[], int portion[])
void map_cell2coord(int i, int j, int k, double coord_xyz[])
bool map_coord2cell(double x, double y, double z, int cell_ijk[])
void get_no_cells(int limits[], int no_cells[])
bool map_glob2loc_cell(int limits[], int glob_cell[], int loc_cell[])
void get_olap_limits(int limits[])
void get_cnst_limits(int limits[])
void get_bnry_limits(int limits[])
void get_arrays(CPL::ndArray<double>*, int, CPL::ndArray<double>*, int)
bool map_cfd2md_coord(double cfd_coord[], double md_coord[])
bool map_md2cfd_coord(double md_coord[], double cfd_coord[])
bool overlap()
bool is_proc_inside(int region[])
void set_output_mode(int mode)
double density_cfd()
template<class T>
T get(std::string name)


static const int cfd_realm = 1
static const int md_realm = 2