MCPcopy Create free account
hub / github.com/AMReX-Codes/amrex / testParallelContext

Function testParallelContext

Tests/Particles/ParallelContext/main.cpp:352–464  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

350}
351
352void testParallelContext ()
353{
354 BL_PROFILE("testParallelContext");
355
356 // we always make two subcommunicators.
357 // one takes the left half of the domain in direction 0, the other the right.
358 int rank_n = ParallelContext::NProcsSub();
359 int myproc = ParallelContext::MyProcSub();
360 int task_me = myproc / (amrex::max(rank_n, 2) / 2);
361
362 if (task_me > 1) { task_me = 1; }
363
364#ifdef BL_USE_MPI
365 MPI_Comm new_comm;
366 MPI_Comm_split(ParallelContext::CommunicatorSub(), task_me, myproc, &new_comm);
367#else
368 MPI_Comm new_comm = ParallelContext::CommunicatorSub();
369#endif
370
371 const int io_rank = 0;
372 ParallelContext::push(new_comm, task_me, io_rank);
373
374 {
375 TestParams params;
376 get_test_params(params, "redistribute");
377
378 int is_per[] = {AMREX_D_DECL(params.is_periodic,
379 params.is_periodic,
380 params.is_periodic)};
381
382 // Each comm gets a different domain
383 IntVect hs = params.size / 2;
384
385 RealBox real_box;
386 for (int n = 0; n < BL_SPACEDIM; n++)
387 {
388 Real physlo = (n == 0) ? task_me*hs[n] : 0.0;
389 Real physhi = (n == 0) ? task_me*hs[n] + hs[n] : params.size[n];
390 real_box.setLo(n, physlo);
391 real_box.setHi(n, physhi);
392 }
393
394 IntVect domain_lo(AMREX_D_DECL(task_me*hs[0], 0, 0));
395 IntVect domain_hi(AMREX_D_DECL(task_me*hs[0] + hs[0] - 1,
396 params.size[1] - 1,
397 params.size[2] - 1));
398 const Box base_domain(domain_lo, domain_hi);
399
400 Geometry geom;
401 geom.define(base_domain, &real_box, CoordSys::cartesian, is_per);
402
403 BoxArray ba;
404 ba.define(base_domain);
405 ba.maxSize(params.max_grid_size);
406
407 DistributionMapping dm;
408 dm.define(ba, ParallelContext::NProcsSub());
409

Callers 1

mainFunction · 0.85

Calls 15

NProcsSubFunction · 0.85
MyProcSubFunction · 0.85
CommunicatorSubFunction · 0.85
pushFunction · 0.85
popFunction · 0.85
SortParticlesByCellMethod · 0.80
get_test_paramsFunction · 0.70
setLoMethod · 0.45
setHiMethod · 0.45
defineMethod · 0.45
InitParticlesMethod · 0.45

Tested by

no test coverage detected