WarpX
ParticleBoundaryBuffer.H
Go to the documentation of this file.
1 /* Copyright 2021 Andrew Myers
2  *
3  * This file is part of WarpX.
4  *
5  * License: BSD-3-Clause-LBNL
6  */
7 #ifndef PARTICLEBOUNDARYBUFFER_H_
8 #define PARTICLEBOUNDARYBUFFER_H_
9 
12 
13 #include <vector>
14 
19 {
20 public:
22 
23  int numSpecies() const { return getSpeciesNames().size(); }
24 
25  const std::vector<std::string>& getSpeciesNames() const {
26  static bool initialized = false;
27  if (!initialized)
28  {
29  amrex::ParmParse pp_particles("particles");
30  pp_particles.queryarr("species_names", m_species_names);
31  initialized = true;
32  }
33  return m_species_names;
34  }
35 
37  const amrex::Vector<const amrex::MultiFab*>& distance_to_eb);
38 
39  void clearParticles ();
40 
41  void printNumParticles () const;
42 
43  int getNumParticlesInContainer(const std::string species_name, int boundary);
44 
45  ParticleBuffer::BufferType<amrex::PinnedArenaAllocator>& getParticleBuffer(const std::string species_name, int boundary);
46 
47  static constexpr int numBoundaries () {
48  return AMREX_SPACEDIM*2
49 #ifdef AMREX_USE_EB
50  + 1
51 #endif
52  ;
53  }
54 
55 private:
56  // over boundary, then number of species
57  std::vector<std::vector<ParticleBuffer::BufferType<amrex::PinnedArenaAllocator> > > m_particle_containers;
58 
59  // over boundary, then number of species
60  std::vector<std::vector<int> > m_do_boundary_buffer;
61 
62  mutable std::vector<std::string> m_species_names;
63 };
64 
65 #endif /*PARTICLEBOUNDARYBUFFER_H_*/
ParticleBuffer::BufferType< amrex::PinnedArenaAllocator > & getParticleBuffer(const std::string species_name, int boundary)
Definition: ParticleBoundaryBuffer.cpp:247
Definition: ParticleBoundaryBuffer.H:18
std::vector< std::string > m_species_names
Definition: ParticleBoundaryBuffer.H:62
Definition: MultiParticleContainer.H:64
std::vector< std::vector< ParticleBuffer::BufferType< amrex::PinnedArenaAllocator > > > m_particle_containers
Definition: ParticleBoundaryBuffer.H:57
static constexpr int numBoundaries()
Definition: ParticleBoundaryBuffer.H:47
void printNumParticles() const
Definition: ParticleBoundaryBuffer.cpp:89
int getNumParticlesInContainer(const std::string species_name, int boundary)
Definition: ParticleBoundaryBuffer.cpp:236
void gatherParticles(MultiParticleContainer &mypc, const amrex::Vector< const amrex::MultiFab *> &distance_to_eb)
Definition: ParticleBoundaryBuffer.cpp:127
amrex::AmrParticleContainer< 0, 0, PIdx::nattribs, 0, Allocator > BufferType
Definition: ParticleBuffer.H:17
const std::vector< std::string > & getSpeciesNames() const
Definition: ParticleBoundaryBuffer.H:25
std::vector< std::vector< int > > m_do_boundary_buffer
Definition: ParticleBoundaryBuffer.H:60
void clearParticles()
Definition: ParticleBoundaryBuffer.cpp:115
int numSpecies() const
Definition: ParticleBoundaryBuffer.H:23
ParticleBoundaryBuffer()
Definition: ParticleBoundaryBuffer.cpp:58