diff options
author | 2021-11-05 10:49:27 -0700 | |
---|---|---|
committer | 2021-11-05 10:49:27 -0700 | |
commit | 443b75720bee307608d05514d30c89bbbf6360df (patch) | |
tree | 3363d6557dc2c4f0a05d8ec0add889884817dcf5 /Source/Python/WarpXWrappers.cpp | |
parent | bb0a9e38f461b89cd8370485a9bc4d83d74e2ae8 (diff) | |
download | WarpX-443b75720bee307608d05514d30c89bbbf6360df.tar.gz WarpX-443b75720bee307608d05514d30c89bbbf6360df.tar.zst WarpX-443b75720bee307608d05514d30c89bbbf6360df.zip |
added wrappers to get particle structs for the particles in the boundary buffers (#2498)
Diffstat (limited to 'Source/Python/WarpXWrappers.cpp')
-rw-r--r-- | Source/Python/WarpXWrappers.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/Source/Python/WarpXWrappers.cpp b/Source/Python/WarpXWrappers.cpp index 9ee99e8ab..66db34497 100644 --- a/Source/Python/WarpXWrappers.cpp +++ b/Source/Python/WarpXWrappers.cpp @@ -607,6 +607,30 @@ extern "C" return data; } + amrex::ParticleReal** warpx_getParticleBoundaryBufferStructs(const char* species_name, int boundary, int lev, + int* num_tiles, int** particles_per_tile) + { + const std::string name(species_name); + auto& particle_buffers = WarpX::GetInstance().GetParticleBoundaryBuffer(); + auto& particle_buffer = particle_buffers.getParticleBuffer(species_name, boundary); + + int i = 0; + for (amrex::ParIter<0,0,PIdx::nattribs, 0, amrex::PinnedArenaAllocator> pti(particle_buffer, lev); pti.isValid(); ++pti, ++i) {} + + // *num_tiles = myspc.numLocalTilesAtLevel(lev); + *num_tiles = i; + *particles_per_tile = (int*) malloc(*num_tiles*sizeof(int)); + + amrex::ParticleReal** data = (amrex::ParticleReal**) malloc(*num_tiles*sizeof(typename WarpXParticleContainer::ParticleType*)); + i = 0; + for (amrex::ParIter<0,0,PIdx::nattribs, 0, amrex::PinnedArenaAllocator> pti(particle_buffer, lev); pti.isValid(); ++pti, ++i) { + auto& aos = pti.GetArrayOfStructs(); + data[i] = (amrex::ParticleReal*) aos.data(); + (*particles_per_tile)[i] = pti.numParticles(); + } + return data; + } + void warpx_clearParticleBoundaryBuffer () { auto& particle_buffers = WarpX::GetInstance().GetParticleBoundaryBuffer(); particle_buffers.clearParticles(); |