MOAB: Mesh Oriented datABase  (version 5.5.0)
ghost_thin_layers.cpp File Reference
#include "moab/ParallelComm.hpp"
#include "moab/Core.hpp"
#include "moab_mpi.h"
#include "TestUtil.hpp"
#include "MBTagConventions.hpp"
#include <iostream>
#include <sstream>
+ Include dependency graph for ghost_thin_layers.cpp:

Go to the source code of this file.

Functions

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

Variables

std::string filename = TestDir + "unittest/io/ln4.h5m"
 

Function Documentation

◆ main()

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

Definition at line 73 of file ghost_thin_layers.cpp.

74 {
75  MPI_Init( &argc, &argv );
76  int nproc, rank;
77  MPI_Comm_size( MPI_COMM_WORLD, &nproc );
78  MPI_Comm_rank( MPI_COMM_WORLD, &rank );
79  if( nproc <= 3 )
80  {
81  std::cout << " launch it on at least 4 processes. \n";
82  MPI_Finalize();
83  return 0;
84  }
85 
86  int result = 0;
87  if( argc >= 2 ) filename = argv[1]; // to be able to test other files too
88 
90  result += RUN_TEST( test_correct_ghost );
91 
92  MPI_Finalize();
93  return 0;
94 }

References filename, MPI_COMM_WORLD, rank, RUN_TEST, test_correct_ghost(), and test_read_with_thin_ghost_layer().

◆ test_correct_ghost()

void test_correct_ghost ( )

Definition at line 14 of file ghost_thin_layers.cpp.

15 {
16  int nproc, rank;
17  MPI_Comm_size( MPI_COMM_WORLD, &nproc );
18  MPI_Comm_rank( MPI_COMM_WORLD, &rank );
19  // Get MOAB instance
20  Interface* mb = new( std::nothrow ) Core;
21 
22  ErrorCode rval = MB_SUCCESS;
23 
24  // Get the ParallelComm instance
25  ParallelComm* pcomm = new ParallelComm( mb, MPI_COMM_WORLD );
26 
27  char read_opts[] = "PARALLEL=READ_PART;PARALLEL_RESOLVE_SHARED_ENTS;PARTITION=PARALLEL_"
28  "PARTITION;PARALLEL_GHOSTS=2.0.1";
29  rval = mb->load_file( filename.c_str(), 0, read_opts );CHECK_ERR( rval );
30 
31  if( nproc >= 3 )
32  {
33  rval = pcomm->correct_thin_ghost_layers();CHECK_ERR( rval );
34  }
35 
36  rval = pcomm->exchange_ghost_cells( 2, 0, 2, 0, true );CHECK_ERR( rval ); // true to store remote handles
37 
38  // write in serial the database , on each rank
39  std::ostringstream outfile;
40  outfile << "testReadThin_n" << nproc << "." << rank << ".h5m";
41 
42  rval = mb->write_file( outfile.str().c_str() ); // everything on local root
43  CHECK_ERR( rval );
44  delete mb;
45 }

References CHECK_ERR, moab::ParallelComm::correct_thin_ghost_layers(), ErrorCode, moab::ParallelComm::exchange_ghost_cells(), filename, moab::Core::load_file(), mb, MB_SUCCESS, MPI_COMM_WORLD, outfile, rank, and moab::Core::write_file().

Referenced by main().

◆ test_read_with_thin_ghost_layer()

void test_read_with_thin_ghost_layer ( )

Definition at line 47 of file ghost_thin_layers.cpp.

48 {
49  int nproc, rank;
50  MPI_Comm_size( MPI_COMM_WORLD, &nproc );
51  MPI_Comm_rank( MPI_COMM_WORLD, &rank );
52  moab::Core* mb = new moab::Core();
53 
54  ErrorCode rval = MB_SUCCESS;
55  // Get the ParallelComm instance
56  ParallelComm* pcomm = new ParallelComm( mb, MPI_COMM_WORLD );
57 
58  char read_opts[] = "PARALLEL=READ_PART;PARALLEL_RESOLVE_SHARED_ENTS;PARTITION=PARALLEL_"
59  "PARTITION;PARALLEL_GHOSTS=2.0.1;PARALLEL_THIN_GHOST_LAYER;";
60  rval = mb->load_file( filename.c_str(), 0, read_opts );CHECK_ERR( rval );
61 
62  rval = pcomm->exchange_ghost_cells( 2, 0, 2, 0, true );CHECK_ERR( rval ); // true to store remote handles
63 
64  // write in serial the database , on each rank
65  std::ostringstream outfile;
66  outfile << "testReadGhost_n" << nproc << "." << rank << ".h5m";
67 
68  rval = mb->write_file( outfile.str().c_str() ); // everything on local root
69  CHECK_ERR( rval );
70  delete mb;
71 }

References CHECK_ERR, ErrorCode, moab::ParallelComm::exchange_ghost_cells(), filename, moab::Core::load_file(), mb, MB_SUCCESS, MPI_COMM_WORLD, outfile, rank, and moab::Core::write_file().

Referenced by main().

Variable Documentation

◆ filename

std::string filename = TestDir + "unittest/io/ln4.h5m"

Definition at line 10 of file ghost_thin_layers.cpp.

Referenced by main(), test_correct_ghost(), and test_read_with_thin_ghost_layer().