MOAB: Mesh Oriented datABase  (version 5.5.0)
ucdtrvpart.cpp File Reference
+ Include dependency graph for ucdtrvpart.cpp:

Go to the source code of this file.

Functions

void test_read_parallel_ucd_trivial ()
 
void test_read_parallel_ucd_trivial_spectral ()
 
void test_read_parallel (int num_verts, bool test_nb_nodes)
 
void test_multiple_loads_of_same_file ()
 
int main (int argc, char *argv[])
 

Variables

std::string example = TestDir + "unittest/io/homme3x3458.t.3.nc"
 
std::string partition_method
 
const int levels = 3
 

Function Documentation

◆ main()

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

Definition at line 21 of file ucdtrvpart.cpp.

22 {
23  MPI_Init( &argc, &argv );
24  int result = 0;
25 
29 
30  MPI_Finalize();
31  return result;
32 }

References RUN_TEST, test_multiple_loads_of_same_file(), test_read_parallel_ucd_trivial(), and test_read_parallel_ucd_trivial_spectral().

◆ test_multiple_loads_of_same_file()

void test_multiple_loads_of_same_file ( )

Definition at line 131 of file ucdtrvpart.cpp.

132 {
133  Core moab;
134  Interface& mb = moab;
135  EntityHandle file_set;
136  ErrorCode rval;
137  rval = mb.create_meshset( MESHSET_SET, file_set );CHECK_ERR( rval );
138 
139  // Read first only header information, no mesh, no variable
140  std::string opts( "PARALLEL=READ_PART;PARTITION;NOMESH;VARIABLE=;PARTITION_METHOD=TRIVIAL" );
141  rval = mb.load_file( example.c_str(), &file_set, opts.c_str() );CHECK_ERR( rval );
142 
143  opts = "PARALLEL=READ_PART;PARTITION;PARALLEL_RESOLVE_SHARED_ENTS;PARTITION_METHOD=TRIVIAL;"
144  "VARIABLE=";
145  // Create gather set in processor 1
146  opts += std::string( ";GATHER_SET=1" );
147  rval = mb.load_file( example.c_str(), &file_set, opts.c_str() );CHECK_ERR( rval );
148 
149  opts = "PARALLEL=READ_PART;PARTITION;PARTITION_METHOD=TRIVIAL;NOMESH;VARIABLE=T;TIMESTEP=0";
150  rval = mb.load_file( example.c_str(), &file_set, opts.c_str() );CHECK_ERR( rval );
151 
152  // Check values of tag T0 (first level) at some strategically chosen places below
153  ParallelComm* pcomm = ParallelComm::get_pcomm( &mb, 0 );
154  int procs = pcomm->proc_config().proc_size();
155  int rank = pcomm->proc_config().proc_rank();
156 
157  // Make check runs this test in two processors
158  if( 2 == procs )
159  {
160  Range verts;
161  rval = mb.get_entities_by_type( 0, MBVERTEX, verts );CHECK_ERR( rval );
162 
163  int my_num = verts.size();
164  if( 0 == rank )
165  CHECK_EQUAL( 1825, my_num );
166  else if( 1 == rank )
167  {
168  CHECK_EQUAL( 5283,
169  my_num ); // Gather set vertices included; Not owned vertices included
170 
171  // Get gather set
172  EntityHandle gather_set;
173  ReadUtilIface* readUtilIface;
174  rval = mb.query_interface( readUtilIface );CHECK_ERR( rval );
175  rval = readUtilIface->get_gather_set( gather_set );CHECK_ERR( rval );
176 
177  // Get gather set entities
178  Range gather_ents;
179  rval = mb.get_entities_by_handle( gather_set, gather_ents );CHECK_ERR( rval );
180 
181  // Remove gather set vertices in processor 1
182  verts = subtract( verts, gather_ents );
183  my_num = verts.size();
184  CHECK_EQUAL( 1825,
185  my_num ); // Gather set vertices excluded; Not owned vertices included
186  }
187 
188  Tag Ttag0;
189  rval = mb.tag_get_handle( "T0", levels, MB_TYPE_DOUBLE, Ttag0, MB_TAG_DENSE );CHECK_ERR( rval );
190 
191  int count;
192  void* Tbuf;
193  rval = mb.tag_iterate( Ttag0, verts.begin(), verts.end(), count, Tbuf );CHECK_ERR( rval );
194  CHECK_EQUAL( count, my_num );
195 
196  const double eps = 0.0001;
197  double* data = (double*)Tbuf;
198 
199  if( 0 == rank )
200  {
201  CHECK_REAL_EQUAL( 233.1136, data[0 * levels], eps ); // First vert
202  CHECK_REAL_EQUAL( 237.1977, data[912 * levels], eps ); // Median vert
203  CHECK_REAL_EQUAL( 234.9711, data[1824 * levels], eps ); // Last vert
204  }
205  else if( 1 == rank )
206  {
207  CHECK_REAL_EQUAL( 233.1136, data[0 * levels], eps ); // First vert
208  CHECK_REAL_EQUAL( 231.0446, data[912 * levels], eps ); // Median vert
209  CHECK_REAL_EQUAL( 234.0416, data[1824 * levels], eps ); // Last vert
210  }
211  }
212 }

References moab::Range::begin(), CHECK_EQUAL, CHECK_ERR, CHECK_REAL_EQUAL, moab::Core::create_meshset(), moab::Range::end(), eps, ErrorCode, example, moab::Core::get_entities_by_handle(), moab::Core::get_entities_by_type(), moab::ReadUtilIface::get_gather_set(), moab::ParallelComm::get_pcomm(), levels, moab::Core::load_file(), mb, MB_TAG_DENSE, MB_TYPE_DOUBLE, MBVERTEX, MESHSET_SET, moab::ParallelComm::proc_config(), moab::ProcConfig::proc_rank(), moab::ProcConfig::proc_size(), moab::Interface::query_interface(), rank, moab::Range::size(), moab::subtract(), moab::Core::tag_get_handle(), and moab::Core::tag_iterate().

Referenced by main().

◆ test_read_parallel()

void test_read_parallel ( int  num_verts,
bool  test_nb_nodes 
)

Definition at line 46 of file ucdtrvpart.cpp.

47 {
48  Core moab;
49  Interface& mb = moab;
50  EntityHandle file_set;
51  ErrorCode rval;
52  rval = mb.create_meshset( MESHSET_SET, file_set );CHECK_ERR( rval );
53 
54  std::string opt = std::string( "PARALLEL=READ_PART" ) + partition_method;
55  // Create gather set in processor 0
56  opt += std::string( ";GATHER_SET=0" );
57  rval = mb.load_file( example.c_str(), &file_set, opt.c_str() );CHECK_ERR( rval );
58 
59  ParallelComm* pcomm = ParallelComm::get_pcomm( &mb, 0 );
60  int procs = pcomm->proc_config().proc_size();
61  int rank = pcomm->proc_config().proc_rank();
62 
63  rval = pcomm->check_all_shared_handles();CHECK_ERR( rval );
64 
65  // Get the total # owned verts
66  Range verts;
67  rval = mb.get_entities_by_type( 0, MBVERTEX, verts );CHECK_ERR( rval );
68 
69  int my_num = verts.size();
70  if( test_nb_nodes && 2 == procs )
71  {
72  if( 0 == rank )
73  CHECK_EQUAL( 5283, my_num ); // Gather set vertices included
74  else if( 1 == rank )
75  CHECK_EQUAL( 1825, my_num ); // Not owned vertices included
76  }
77 
78  rval = pcomm->filter_pstatus( verts, PSTATUS_NOT_OWNED, PSTATUS_NOT );CHECK_ERR( rval );
79 
80  my_num = verts.size();
81  if( test_nb_nodes && 2 == procs )
82  {
83  if( 0 == rank )
84  CHECK_EQUAL( 5283, my_num ); // Gather set vertices included
85  else if( 1 == rank )
86  CHECK_EQUAL( 1633, my_num ); // Not owned vertices excluded
87  }
88 
89  if( 0 == rank )
90  {
91  // Get gather set
92  EntityHandle gather_set;
93  ReadUtilIface* readUtilIface;
94  rval = mb.query_interface( readUtilIface );CHECK_ERR( rval );
95  rval = readUtilIface->get_gather_set( gather_set );CHECK_ERR( rval );
96 
97  // Get gather set entities
98  Range gather_ents;
99  rval = mb.get_entities_by_handle( gather_set, gather_ents );CHECK_ERR( rval );
100 
101  // Remove gather set vertices in processor 0
102  verts = subtract( verts, gather_ents );
103  }
104 
105  my_num = verts.size();
106  if( test_nb_nodes && 2 == procs )
107  {
108  if( 0 == rank )
109  CHECK_EQUAL( 1825, my_num ); // Gather set vertices excluded
110  else if( 1 == rank )
111  CHECK_EQUAL( 1633, my_num ); // Not owned vertices excluded
112  }
113 
114  std::cout << "proc: " << rank << " verts:" << my_num << "\n";
115 
116  int total_verts;
117  MPI_Reduce( &my_num, &total_verts, 1, MPI_INT, MPI_SUM, 0, pcomm->proc_config().proc_comm() );
118 
119  if( 0 == rank )
120  {
121  std::cout << "total vertices: " << total_verts << "\n";
122  if( test_nb_nodes ) CHECK_EQUAL( total_verts, num_verts );
123  }
124 
125 #ifdef MOAB_HAVE_HDF5_PARALLEL
126  std::string write_options( "PARALLEL=WRITE_PART;" );
127  mb.write_file( "test.h5m", NULL, write_options.c_str() );
128 #endif
129 }

References moab::ParallelComm::check_all_shared_handles(), CHECK_EQUAL, CHECK_ERR, moab::Core::create_meshset(), ErrorCode, example, moab::ParallelComm::filter_pstatus(), moab::Core::get_entities_by_handle(), moab::Core::get_entities_by_type(), moab::ReadUtilIface::get_gather_set(), moab::ParallelComm::get_pcomm(), moab::Core::load_file(), mb, MBVERTEX, MESHSET_SET, partition_method, moab::ProcConfig::proc_comm(), moab::ParallelComm::proc_config(), moab::ProcConfig::proc_rank(), moab::ProcConfig::proc_size(), PSTATUS_NOT, PSTATUS_NOT_OWNED, moab::Interface::query_interface(), rank, moab::Range::size(), moab::subtract(), and moab::Core::write_file().

Referenced by test_read_parallel_ucd_trivial(), and test_read_parallel_ucd_trivial_spectral().

◆ test_read_parallel_ucd_trivial()

void test_read_parallel_ucd_trivial ( )

Definition at line 34 of file ucdtrvpart.cpp.

35 {
36  partition_method = std::string( ";PARTITION_METHOD=TRIVIAL;PARALLEL_RESOLVE_SHARED_ENTS" );
37  test_read_parallel( 3458, true );
38 }

References partition_method, and test_read_parallel().

Referenced by main().

◆ test_read_parallel_ucd_trivial_spectral()

void test_read_parallel_ucd_trivial_spectral ( )

Definition at line 40 of file ucdtrvpart.cpp.

41 {
42  partition_method = std::string( ";PARTITION_METHOD=TRIVIAL;SPECTRAL_MESH;PARALLEL_RESOLVE_SHARED_ENTS" );
43  test_read_parallel( 3458, false );
44 }

References partition_method, and test_read_parallel().

Referenced by main().

Variable Documentation

◆ example

std::string example = TestDir + "unittest/io/homme3x3458.t.3.nc"

Definition at line 10 of file ucdtrvpart.cpp.

Referenced by test_multiple_loads_of_same_file(), and test_read_parallel().

◆ levels

const int levels = 3

Definition at line 19 of file ucdtrvpart.cpp.

Referenced by test_multiple_loads_of_same_file().

◆ partition_method

std::string partition_method