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

Go to the source code of this file.

Functions

void read_mesh_parallel (bool rcbzoltan, bool no_mixed_elements)
 
void test_read_mesh_parallel_trivial ()
 
void test_read_mesh_parallel_trivial_no_mixed_elements ()
 
void test_read_mesh_parallel_rcbzoltan ()
 
void test_read_mesh_parallel_rcbzoltan_no_mixed_elements ()
 
int main (int argc, char *argv[])
 

Variables

std::string example = TestDir + "unittest/io/ne4np4-esmf.nc"
 
std::string read_options
 
const double eps = 1e-20
 

Function Documentation

◆ main()

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

Definition at line 139 of file read_esmf.cpp.

140 {
141  MPI_Init( &argc, &argv );
142  int result = 0;
143 
146 #if defined( MOAB_HAVE_MPI ) && defined( MOAB_HAVE_ZOLTAN )
149 #endif
150 
151  MPI_Finalize();
152  return result;
153 }

References RUN_TEST, test_read_mesh_parallel_rcbzoltan(), test_read_mesh_parallel_rcbzoltan_no_mixed_elements(), test_read_mesh_parallel_trivial(), and test_read_mesh_parallel_trivial_no_mixed_elements().

◆ read_mesh_parallel()

void read_mesh_parallel ( bool  rcbzoltan,
bool  no_mixed_elements 
)

Definition at line 19 of file read_esmf.cpp.

20 {
21  Core moab;
22  Interface& mb = moab;
23 
24  read_options = "PARALLEL=READ_PART;PARTITION_METHOD=TRIVIAL;PARALLEL_RESOLVE_SHARED_ENTS;VARIABLE=";
25  if( rcbzoltan )
26  read_options = "PARALLEL=READ_PART;PARTITION_METHOD=RCBZOLTAN;PARALLEL_RESOLVE_SHARED_ENTS;VARIABLE=";
27 
28  if( no_mixed_elements ) read_options += ";NO_MIXED_ELEMENTS";
29 
30  ErrorCode rval = mb.load_file( example.c_str(), NULL, read_options.c_str() );CHECK_ERR( rval );
31 
32  ParallelComm* pcomm = ParallelComm::get_pcomm( &mb, 0 );
33  int procs = pcomm->proc_config().proc_size();
34  int rank = pcomm->proc_config().proc_rank();
35 
36  rval = pcomm->check_all_shared_handles();CHECK_ERR( rval );
37 
38  // Get local vertices
39  Range local_verts;
40  rval = mb.get_entities_by_type( 0, MBVERTEX, local_verts );CHECK_ERR( rval );
41 
42  int verts_num = local_verts.size();
43  if( 2 == procs )
44  {
45  if( rcbzoltan )
46  {
47  if( 0 == rank )
48  CHECK_EQUAL( 457, verts_num );
49  else if( 1 == rank )
50  CHECK_EQUAL( 457, verts_num ); // Not owned vertices included
51  }
52  else
53  {
54  if( 0 == rank )
55  CHECK_EQUAL( 485, verts_num );
56  else if( 1 == rank )
57  CHECK_EQUAL( 471, verts_num ); // Not owned vertices included
58  }
59  }
60 
61  rval = pcomm->filter_pstatus( local_verts, PSTATUS_NOT_OWNED, PSTATUS_NOT );CHECK_ERR( rval );
62 
63  verts_num = local_verts.size();
64  if( 2 == procs )
65  {
66  if( rcbzoltan )
67  {
68  if( 0 == rank )
69  CHECK_EQUAL( 457, verts_num );
70  else if( 1 == rank )
71  CHECK_EQUAL( 409, verts_num ); // Not owned vertices excluded
72  }
73  else
74  {
75  if( 0 == rank )
76  CHECK_EQUAL( 485, verts_num );
77  else if( 1 == rank )
78  CHECK_EQUAL( 381, verts_num ); // Not owned vertices excluded
79  }
80  }
81 
82  // Get local cells
83  Range local_cells;
84 
85  rval = mb.get_entities_by_dimension( 0, 2, local_cells );CHECK_ERR( rval );
86 
87  rval = pcomm->filter_pstatus( local_cells, PSTATUS_NOT_OWNED, PSTATUS_NOT );CHECK_ERR( rval );
88 
89  int cells_num = (int)local_cells.size();
90  if( 2 == procs )
91  {
92  CHECK_EQUAL( 468, cells_num );
93  }
94 
95  std::cout << "proc: " << rank << " cells:" << cells_num << "\n";
96 
97  int total_cells_num;
98  MPI_Reduce( &cells_num, &total_cells_num, 1, MPI_INT, MPI_SUM, 0, pcomm->proc_config().proc_comm() );
99  if( 0 == rank )
100  {
101  std::cout << "total cells: " << total_cells_num << "\n";
102  CHECK_EQUAL( 936, total_cells_num );
103  }
104 
105 #ifdef MOAB_HAVE_HDF5_PARALLEL
106  std::string write_options( "PARALLEL=WRITE_PART;" );
107 
108  std::string output_file = "test_esmf";
109  if( rcbzoltan ) output_file += "_rcbzoltan";
110  if( no_mixed_elements ) output_file += "_no_mixed_elements";
111  output_file += ".h5m";
112 
113  mb.write_file( output_file.c_str(), NULL, write_options.c_str() );
114 #endif
115 }

References moab::ParallelComm::check_all_shared_handles(), CHECK_EQUAL, CHECK_ERR, ErrorCode, example, moab::ParallelComm::filter_pstatus(), moab::Core::get_entities_by_dimension(), moab::Core::get_entities_by_type(), moab::ParallelComm::get_pcomm(), moab::Core::load_file(), mb, MBVERTEX, moab::ProcConfig::proc_comm(), moab::ParallelComm::proc_config(), moab::ProcConfig::proc_rank(), moab::ProcConfig::proc_size(), PSTATUS_NOT, PSTATUS_NOT_OWNED, rank, read_options, moab::Range::size(), and moab::Core::write_file().

Referenced by test_read_mesh_parallel_rcbzoltan(), test_read_mesh_parallel_rcbzoltan_no_mixed_elements(), test_read_mesh_parallel_trivial(), and test_read_mesh_parallel_trivial_no_mixed_elements().

◆ test_read_mesh_parallel_rcbzoltan()

void test_read_mesh_parallel_rcbzoltan ( )

Definition at line 128 of file read_esmf.cpp.

129 {
130  read_mesh_parallel( true, false );
131 }

References read_mesh_parallel().

Referenced by main().

◆ test_read_mesh_parallel_rcbzoltan_no_mixed_elements()

void test_read_mesh_parallel_rcbzoltan_no_mixed_elements ( )

Definition at line 133 of file read_esmf.cpp.

134 {
135  read_mesh_parallel( true, true );
136 }

References read_mesh_parallel().

Referenced by main().

◆ test_read_mesh_parallel_trivial()

void test_read_mesh_parallel_trivial ( )

Definition at line 118 of file read_esmf.cpp.

119 {
120  read_mesh_parallel( false, false );
121 }

References read_mesh_parallel().

Referenced by main().

◆ test_read_mesh_parallel_trivial_no_mixed_elements()

void test_read_mesh_parallel_trivial_no_mixed_elements ( )

Definition at line 123 of file read_esmf.cpp.

124 {
125  read_mesh_parallel( false, true );
126 }

References read_mesh_parallel().

Referenced by main().

Variable Documentation

◆ eps

const double eps = 1e-20

Definition at line 16 of file read_esmf.cpp.

◆ example

std::string example = TestDir + "unittest/io/ne4np4-esmf.nc"

Definition at line 13 of file read_esmf.cpp.

Referenced by read_mesh_parallel().

◆ read_options

std::string read_options

Definition at line 15 of file read_esmf.cpp.

Referenced by read_mesh_parallel().