aboutsummaryrefslogtreecommitdiff
path: root/Source/Particles/ParticleBoundaryBuffer.cpp
diff options
context:
space:
mode:
authorGravatar Phil Miller <phil@intensecomputing.com> 2021-08-30 16:26:55 -0400
committerGravatar GitHub <noreply@github.com> 2021-08-30 13:26:55 -0700
commite130e57efcee4fb08cae9a5888c67c83db63abb4 (patch)
tree2e8cc1688c5842ba2d478c04887d8ba214bcd6f6 /Source/Particles/ParticleBoundaryBuffer.cpp
parentc17b786f935a52530e7d559b7bae4c6ab740ae85 (diff)
downloadWarpX-e130e57efcee4fb08cae9a5888c67c83db63abb4.tar.gz
WarpX-e130e57efcee4fb08cae9a5888c67c83db63abb4.tar.zst
WarpX-e130e57efcee4fb08cae9a5888c67c83db63abb4.zip
Make buffer of scraped particles available to Python code (#2164)
* Added wrapper to get number of particle species tracked by the scraper Not sure if this is going to be useful, but it demonstrates a method to get information from the ParticleBoundaryBuffer into Python. * Stubbed out the main wrapper functions * Added parameters to wrapper * Added wrapper for getting the number of particles scraped of a species on a boundary * added picmi arguments to scrape particles at the domain boundary * Added wrapper to get the full particle buffer into python * rearanged the getBuffer properties code a little * Added docstrings +other suggested changes * Added num_particles_impacted_boundary docstring * fixed mistake in docstring * Changed boundary parameter to be a string for clarity * Fixed issue with the boundary parameter for scraping * Fixed issue with the boundary input for scraping stats wrapper * Added demonstration of particle scraping wrapper * Added analysis.py file * Fix typo in one of the dimension maps Co-authored-by: Roelof Groenewald <40245517+roelof-groenewald@users.noreply.github.com> * Added before esolve to warpx evolve * added test for the scraped particle buffer wrappers * Moved python PICMI particle boundary scrape test * Renamed test file to the correct name * Removed old test * added special functionality to get the timestep at which particles were scraped * removed debug print * added python wrapper for the clearParticles() function of the scraper buffer * added special wrapper function to get the timesteps at which the particles in the boundary buffer were scraped * updated test to match the non-PICMI test for the particle scraper buffer * Fix uncaught rebase mistake * re-activated picmi test of accessing the scraped particle buffers via python * added documentation for the new parameters involved in the scraped particle buffer and fixed remaining issue with picmi test * changes requested during code review Co-authored-by: mkieburtz <michaelkieburtz@gmail.com> Co-authored-by: Roelof <roelof.groenewald@modernelectron.com> Co-authored-by: Roelof Groenewald <40245517+roelof-groenewald@users.noreply.github.com>
Diffstat (limited to 'Source/Particles/ParticleBoundaryBuffer.cpp')
-rw-r--r--Source/Particles/ParticleBoundaryBuffer.cpp27
1 files changed, 26 insertions, 1 deletions
diff --git a/Source/Particles/ParticleBoundaryBuffer.cpp b/Source/Particles/ParticleBoundaryBuffer.cpp
index f84d05b28..16465ac76 100644
--- a/Source/Particles/ParticleBoundaryBuffer.cpp
+++ b/Source/Particles/ParticleBoundaryBuffer.cpp
@@ -97,7 +97,7 @@ void ParticleBoundaryBuffer::printNumParticles () const {
int np = buffer[i].isDefined() ? buffer[i].TotalNumberOfParticles(false) : 0;
amrex::Print() << "Species " << getSpeciesNames()[i] << " has "
<< np << " particles in the boundary buffer "
- << " for side " << iside << " of dim " << idim << "\n";
+ << "for side " << iside << " of dim " << idim << "\n";
}
}
}
@@ -232,3 +232,28 @@ void ParticleBoundaryBuffer::gatherParticles (MultiParticleContainer& mypc,
amrex::ignore_unused(distance_to_eb, dxi);
#endif
}
+
+int ParticleBoundaryBuffer::getNumParticlesInContainer(
+ const std::string species_name, int boundary) {
+
+ auto& buffer = m_particle_containers[boundary];
+ auto index = WarpX::GetInstance().GetPartContainer().getSpeciesID(species_name);
+
+ if (buffer[index].isDefined()) return buffer[index].TotalNumberOfParticles(false);
+ else return 0;
+}
+
+ParticleBuffer::BufferType<amrex::PinnedArenaAllocator>&
+ParticleBoundaryBuffer::getParticleBuffer(const std::string species_name, int boundary) {
+
+ auto& buffer = m_particle_containers[boundary];
+ auto index = WarpX::GetInstance().GetPartContainer().getSpeciesID(species_name);
+
+ AMREX_ALWAYS_ASSERT_WITH_MESSAGE(m_do_boundary_buffer[boundary][index],
+ "Attempted to get particle buffer for boundary "
+ + boundary + ", which is not used!");
+ AMREX_ALWAYS_ASSERT_WITH_MESSAGE(buffer[index].isDefined(),
+ "Tried to get a buffer that is not defined!");
+
+ return buffer[index];
+}