| 13 | |
| 14 | template <typename T_PC,template<class> class Allocator=amrex::PolymorphicArenaAllocator> |
| 15 | void addParticles () |
| 16 | { |
| 17 | int is_per[AMREX_SPACEDIM]; |
| 18 | for (int & d : is_per) { |
| 19 | d = 1; |
| 20 | } |
| 21 | |
| 22 | RealBox real_box; |
| 23 | for (int n = 0; n < AMREX_SPACEDIM; n++) |
| 24 | { |
| 25 | real_box.setLo(n, 0.0); |
| 26 | real_box.setHi(n, 100.0); |
| 27 | } |
| 28 | |
| 29 | IntVect domain_lo(AMREX_D_DECL(0, 0, 0)); |
| 30 | IntVect domain_hi(AMREX_D_DECL(127, 127, 127)); |
| 31 | const Box base_domain(domain_lo, domain_hi); |
| 32 | |
| 33 | Geometry geom(base_domain, &real_box, CoordSys::cartesian, is_per); |
| 34 | BoxArray ba(base_domain); |
| 35 | ba.maxSize(64); |
| 36 | |
| 37 | DistributionMapping dm(ba); |
| 38 | |
| 39 | T_PC pc(geom, dm, ba); |
| 40 | pc.SetArena(The_Arena()); |
| 41 | int const NArrayReal = pc.NArrayReal; |
| 42 | int const NArrayInt = pc.NArrayInt; |
| 43 | |
| 44 | using ParticleType = typename T_PC::ParticleType; |
| 45 | using ParticleTileDataType = typename T_PC::ParticleTileType::ParticleTileDataType; |
| 46 | |
| 47 | const int add_num_particles = 5; |
| 48 | |
| 49 | auto& ptile1 = pc.DefineAndReturnParticleTile(0, 0, 0); |
| 50 | ptile1.resize(add_num_particles); |
| 51 | |
| 52 | for (int i = 0; i < add_num_particles; ++i) |
| 53 | { |
| 54 | for (int d = 0; d < AMREX_SPACEDIM; d++) { |
| 55 | ptile1.pos(i, d) = 12.0; |
| 56 | } |
| 57 | ptile1.getParticleTileData().rdata(AMREX_SPACEDIM)[i] = 1.2; // w |
| 58 | |
| 59 | ptile1.push_back_int(0, ParticleType::NextID()); |
| 60 | ptile1.push_back_int(1, amrex::ParallelDescriptor::MyProc()); |
| 61 | } |
| 62 | |
| 63 | int lev=0; |
| 64 | // int numparticles=0; |
| 65 | using MyParIter = ParIter_impl<ParticleType, NArrayReal, NArrayInt, amrex::PolymorphicArenaAllocator>; |
| 66 | for (MyParIter pti(pc, lev); pti.isValid(); ++pti) { |
| 67 | const int np = pti.numParticles(); |
| 68 | // preparing access to particle data: SoA of Reals |
| 69 | auto& soa = pti.GetStructOfArrays(); |
| 70 | auto soa_real = soa.GetRealData(); |
| 71 | auto size = soa.size(); |
| 72 | amrex::ParticleReal* const AMREX_RESTRICT part_x = soa_real[0].dataPtr(); |
no test coverage detected