| 426 | |
| 427 | template <typename PC> |
| 428 | void 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 | |
| 463 | template <typename PC> |
| 464 | void testFilterAndTransformWithOffsets (const PC& pc) |
no test coverage detected