MOAB: Mesh Oriented datABase  (version 5.5.0)
pcomm_serial.cpp File Reference
#include "moab/ParallelComm.hpp"
#include "MBParallelConventions.h"
#include "MBTagConventions.hpp"
#include "moab/Core.hpp"
#include "moab/FileOptions.hpp"
#include "ReadParallel.hpp"
#include "TestUtil.hpp"
#include <vector>
+ Include dependency graph for pcomm_serial.cpp:

Go to the source code of this file.

Macros

#define MPI_COMM_WORLD   0
 

Functions

void print_usage (char *argv)
 
int main (int argc, char *argv[])
 

Macro Definition Documentation

◆ MPI_COMM_WORLD

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 17 of file pcomm_serial.cpp.

18 {
19 #ifdef MOAB_HAVE_MPI
20  MPI_Init( &argc, &argv );
21 #else
22 #define MPI_COMM_WORLD 0
23 #endif
24 
25  if( 1 < argc && !strcmp( argv[1], "-h" ) )
26  {
27  print_usage( argv[0] );
28  return 0;
29  }
30 
31  int nprocs = 2;
32  std::string ptag_name( "GEOM_DIMENSION" );
33  std::vector< int > partition_tag_vals;
34  std::string filename = TestDir + "unittest/ptest.cub";
35  if( argc > 1 ) nprocs = atoi( argv[1] );
36  if( argc > 2 ) filename = std::string( argv[2] );
37  if( argc > 3 )
38  {
39  ptag_name = argv[3];
40  if( argc > 4 ) partition_tag_vals.push_back( atoi( argv[4] ) );
41  }
42  else
43  partition_tag_vals.push_back( 3 );
44 
45  if( 0 == nprocs )
46  {
47  print_usage( argv[0] );
48  return 1;
49  }
50 
51  ErrorCode rval;
52  Core* moab = new Core[nprocs]();
53  std::vector< ParallelComm* > pc( nprocs );
54  for( int i = 0; i < nprocs; i++ )
55  {
56  pc[i] = new ParallelComm( &moab[i], MPI_COMM_WORLD );
57  pc[i]->set_rank( i );
58  pc[i]->set_size( nprocs );
59  }
60 
61  std::vector< int > pa_vec;
62  pa_vec.push_back( ReadParallel::PA_READ );
63  pa_vec.push_back( ReadParallel::PA_GET_FILESET_ENTS );
64  pa_vec.push_back( ReadParallel::PA_DELETE_NONLOCAL );
65  bool partition_distrib = true;
66 
67  FileOptions fopts( NULL );
68 
69  const char* fnames = filename.c_str();
70  for( int i = 0; i < nprocs; i++ )
71  {
72  ReadParallel rp( moab + i, pc[i] );
73  rval = rp.load_file( &fnames, 1, 0, ReadParallel::POPT_READ_DELETE, ptag_name, partition_tag_vals,
74  partition_distrib, false, pa_vec, fopts, NULL, NULL, i, false, -1, -1, -1, -1, 0, 0 );CHECK_ERR( rval );
75  }
76 
77  rval = ParallelComm::resolve_shared_ents( &pc[0], nprocs, 0, 3 );CHECK_ERR( rval );
78 
79  // exchange interface cells
80  rval = ParallelComm::exchange_ghost_cells( &pc[0], nprocs, -1, -1, 0, 0, true );CHECK_ERR( rval );
81 
82  // now 1 layer of hex ghosts
83  rval = ParallelComm::exchange_ghost_cells( &pc[0], nprocs, 3, 2, 1, 0, true );CHECK_ERR( rval );
84 
85  // now 1 layer of hex ghosts with face/edges
86  rval = ParallelComm::exchange_ghost_cells( &pc[0], nprocs, 3, 2, 1, 3, true );CHECK_ERR( rval );
87 
88  for( int i = 0; i < nprocs; i++ )
89  delete pc[i];
90 
91  delete[] moab;
92 
93 #ifdef MOAB_HAVE_MPI
94  MPI_Finalize();
95 #endif
96 
97  return 0;
98 }

References CHECK_ERR, ErrorCode, moab::ParallelComm::exchange_ghost_cells(), filename, moab::ReadParallel::load_file(), MPI_COMM_WORLD, moab::ReadParallel::PA_DELETE_NONLOCAL, moab::ReadParallel::PA_GET_FILESET_ENTS, moab::ReadParallel::PA_READ, moab::ReadParallel::POPT_READ_DELETE, print_usage(), and moab::ParallelComm::resolve_shared_ents().

◆ print_usage()

void print_usage ( char *  argv)

Definition at line 12 of file pcomm_serial.cpp.

13 {
14  std::cout << "Usage: " << argv << " nprocs filename" << std::endl;
15 }

Referenced by main().