170 MPI_Init( &argc, &argv );
175 dbgprint(
"********** Exchange halos example **********\n" );
178 context.ParseCLOptions( argc, argv );
182 dbgprint(
" -- Input Parameters -- " );
192 double elapsed_times[4];
196 context.timer_push(
"Read input file" );
199 runchk(
context.load_file(
false ),
"MOAB::load_file failed for filename: " <<
context.input_filename );
202 elapsed_times[0] =
context.last_elapsed();
205 dbgprint(
"\n- Starting execution -\n" );
209 context.timer_push(
"Setup ghost layers" );
212 for(
int ighost = 0; ighost <
context.ghost_layers; ++ighost )
215 int ghost_dimension =
context.dimension;
216 int bridge_dimension =
context.dimension - 1;
219 ghost_dimension, bridge_dimension, ( ighost + 1 ), 0,
true ,
221 "Exchange ghost cells failed" );
225 if( ighost <
context.ghost_layers - 1 )
226 runchk(
context.parallel_communicator->correct_thin_ghost_layers(),
227 "Thin layer correction failed" );
231 elapsed_times[1] =
context.last_elapsed();
238 "Getting 2D entities failed" );
242 "Filtering pstatus failed" );
245 auto numEntities = dimEnts.
size();
246 int numTotalEntities = 0;
247 MPI_Reduce( &numEntities, &numTotalEntities, 1, MPI_INT, MPI_SUM, 0,
248 context.parallel_communicator->proc_config().proc_comm() );
252 dbgprint(
"Total number of " <<
context.dimension <<
"D elements in the mesh = " << numTotalEntities );
255 Tag tagScalar =
nullptr;
256 Tag tagVector =
nullptr;
260 runchk(
context.create_sv_tags( tagScalar, tagVector, dimEnts ),
"Unable to create scalar and vector tags" );
266 dbgprint(
"> Writing to file *before* ghost exchange " );
267 runchk(
context.moab_interface.write_file(
"exchangeHalos_output_rank0_pre.h5m",
"H5M",
"" ),
268 "Writing to disk failed" );
272 dbgprint(
"> Exchanging tags between processors " );
273 context.timer_push(
"Exchange scalar tag data" );
274 for(
auto irun = 0; irun <
context.num_max_exchange; ++irun )
277 runchk(
context.parallel_communicator->exchange_tags( tagScalar, dimEnts ),
278 "Exchanging scalar tag between processors failed" );
281 elapsed_times[2] =
context.last_elapsed();
283 context.timer_push(
"Exchange vector tag data" );
284 for(
auto irun = 0; irun <
context.num_max_exchange; ++irun )
287 runchk(
context.parallel_communicator->exchange_tags( tagVector, dimEnts ),
288 "Exchanging vector tag between processors failed" );
291 elapsed_times[3] =
context.last_elapsed();
297 dbgprint(
"> Writing to file *after* ghost exchange " );
298 runchk(
context.moab_interface.write_file(
"exchangeHalos_output_rank0_post.h5m",
"H5M",
"" ),
299 "Writing to disk failed" );
305 dbgprint(
"> Writing out the final mesh and data in MOAB h5m format. File = " <<
context.output_filename );
306 string write_options = (
context.num_procs > 1 ?
"PARALLEL=WRITE_PART;DEBUG_IO=0;" :
"" );
308 runchk(
context.moab_interface.write_file(
context.output_filename.c_str(),
"H5M", write_options.c_str() ),
309 "File write failed" );
315 dbgprint(
"\n> Consolidated: [" <<
context.num_procs <<
", " <<
context.ghost_layers <<
", " << elapsed_times[0]
316 <<
", " << elapsed_times[1] <<
", " << elapsed_times[2] <<
", "
317 << elapsed_times[3] <<
"]," );
320 dbgprint(
"\n********** ExchangeHalos Example DONE! **********" );