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

Function testFilter

Tests/Particles/ParticleTransformations/main.cpp:428–461  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

426
427template <typename PC>
428void testFilter (const PC& pc)
429{
430 using PType = typename PC::SuperParticleType;
431
432 auto np_old = pc.TotalNumberOfParticles();
433
434 PC pc2(pc.Geom(0), pc.ParticleDistributionMap(0), pc.ParticleBoxArray(0));
435 pc2.copyParticles(pc, KeepOddFilter());
436
437 auto np_new = pc2.TotalNumberOfParticles();
438
439 AMREX_ALWAYS_ASSERT(2*np_new == np_old);
440
441 auto all_odd = amrex::ReduceLogicalAnd(pc2, [=] AMREX_GPU_HOST_DEVICE (const PType& p) -> int { return p.id() % 2 == 1; });
442
443 AMREX_ALWAYS_ASSERT(all_odd);
444
445 pc2.clearParticles();
446 pc2.copyParticles(pc, KeepEvenFilter());
447
448 np_new = pc2.TotalNumberOfParticles();
449
450 AMREX_ALWAYS_ASSERT(2*np_new == np_old);
451
452 auto all_even = amrex::ReduceLogicalAnd(pc2, [=] AMREX_GPU_HOST_DEVICE (const PType& p) -> int { return p.id() % 2 == 0; });
453
454 AMREX_ALWAYS_ASSERT(all_even);
455
456 filterParticles(pc2, KeepOddFilter());
457
458 np_new = pc2.TotalNumberOfParticles();
459
460 AMREX_ALWAYS_ASSERT(np_new == 0);
461}
462
463template <typename PC>
464void testFilterAndTransformWithOffsets (const PC& pc)

Callers 1

testTransformationsFunction · 0.85

Calls 7

KeepOddFilterClass · 0.85
KeepEvenFilterClass · 0.85
GeomMethod · 0.80
filterParticlesFunction · 0.70
ReduceLogicalAndFunction · 0.50
idMethod · 0.45

Tested by

no test coverage detected