ARTEMIS
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 
13 
14 #include <vector>
15 
20 {
21 public:
23 
24  int numSpecies() const { return getSpeciesNames().size(); }
25 
26  const std::vector<std::string>& getSpeciesNames() const {
27  static bool initialized = false;
28  if (!initialized)
29  {
30  amrex::ParmParse pp_particles("particles");
31  pp_particles.queryarr("species_names", m_species_names);
32  initialized = true;
33  }
34  return m_species_names;
35  }
36 
38  const amrex::Vector<const amrex::MultiFab*>& distance_to_eb);
39 
40  void redistribute ();
41  void clearParticles ();
42  void clearParticles (int const i);
43 
44  void printNumParticles () const;
45 
46  int getNumParticlesInContainer(const std::string species_name, int boundary, bool local);
47 
48  PinnedMemoryParticleContainer& getParticleBuffer(const std::string species_name, int boundary);
49 
50  PinnedMemoryParticleContainer* getParticleBufferPointer(const std::string species_name, int boundary);
51 
52  static constexpr int numBoundaries () {
53  return AMREX_SPACEDIM*2
54 #ifdef AMREX_USE_EB
55  + 1
56 #endif
57  ;
58  }
59 
60  bool isDefinedForAnySpecies (int const ibuffer) {return (m_do_any_boundary[ibuffer] != 0);}
61 
62  std::string boundaryName (int const ibuffer) {return m_boundary_names[ibuffer];}
63 
64 private:
65  // over boundary, then number of species
66  std::vector<std::vector<PinnedMemoryParticleContainer> > m_particle_containers;
67 
68  // over boundary, then number of species
69  std::vector<std::vector<int> > m_do_boundary_buffer;
70 
71  // over boundary
72  std::vector<int> m_do_any_boundary;
73  std::vector<std::string> m_boundary_names;
74 
75  mutable std::vector<std::string> m_species_names;
76 };
77 
78 #endif /*PARTICLEBOUNDARYBUFFER_H_*/
Definition: MultiParticleContainer.H:65
Definition: NamedComponentParticleContainer.H:47
Definition: ParticleBoundaryBuffer.H:20
const std::vector< std::string > & getSpeciesNames() const
Definition: ParticleBoundaryBuffer.H:26
std::string boundaryName(int const ibuffer)
Definition: ParticleBoundaryBuffer.H:62
int numSpecies() const
Definition: ParticleBoundaryBuffer.H:24
ParticleBoundaryBuffer()
Definition: ParticleBoundaryBuffer.cpp:64
void redistribute()
Definition: ParticleBoundaryBuffer.cpp:174
void printNumParticles() const
Definition: ParticleBoundaryBuffer.cpp:144
std::vector< std::vector< PinnedMemoryParticleContainer > > m_particle_containers
Definition: ParticleBoundaryBuffer.H:66
int getNumParticlesInContainer(const std::string species_name, int boundary, bool local)
Definition: ParticleBoundaryBuffer.cpp:359
std::vector< std::string > m_species_names
Definition: ParticleBoundaryBuffer.H:75
PinnedMemoryParticleContainer & getParticleBuffer(const std::string species_name, int boundary)
Definition: ParticleBoundaryBuffer.cpp:370
bool isDefinedForAnySpecies(int const ibuffer)
Definition: ParticleBoundaryBuffer.H:60
std::vector< int > m_do_any_boundary
Definition: ParticleBoundaryBuffer.H:72
void clearParticles()
Definition: ParticleBoundaryBuffer.cpp:189
std::vector< std::vector< int > > m_do_boundary_buffer
Definition: ParticleBoundaryBuffer.H:69
static constexpr int numBoundaries()
Definition: ParticleBoundaryBuffer.H:52
std::vector< std::string > m_boundary_names
Definition: ParticleBoundaryBuffer.H:73
PinnedMemoryParticleContainer * getParticleBufferPointer(const std::string species_name, int boundary)
Definition: ParticleBoundaryBuffer.cpp:385
void gatherParticles(MultiParticleContainer &mypc, const amrex::Vector< const amrex::MultiFab * > &distance_to_eb)
Definition: ParticleBoundaryBuffer.cpp:205
int queryarr(const char *name, std::vector< int > &ref, int start_ix=FIRST, int num_val=ALL) const
i
Definition: check_interp_points_and_weights.py:174