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 WARPX_PARTICLEBOUNDARYBUFFER_H_
8 #define WARPX_PARTICLEBOUNDARYBUFFER_H_
9 
13 #include "Utils/export.H"
14 
15 #include <vector>
16 
17 
21 class WARPX_EXPORT ParticleBoundaryBuffer
22 {
23 public:
25 
27 
31  ParticleBoundaryBuffer& operator= ( const ParticleBoundaryBuffer & ) = delete;
32 
36  ParticleBoundaryBuffer& operator= ( ParticleBoundaryBuffer && ) = default;
37 
38  int numSpecies() const { return static_cast<int>(getSpeciesNames().size()); }
39 
40  const std::vector<std::string>& getSpeciesNames() const;
41 
42  void gatherParticlesFromDomainBoundaries (MultiParticleContainer& mypc);
43  void gatherParticlesFromEmbeddedBoundaries (
45  );
46 
47  void redistribute ();
48  void clearParticles ();
49  void clearParticles (int i);
50 
51  void printNumParticles () const;
52 
53  int getNumParticlesInContainer(const std::string& species_name, int boundary, bool local);
54 
55  PinnedMemoryParticleContainer& getParticleBuffer(const std::string& species_name, int boundary);
56 
57  PinnedMemoryParticleContainer* getParticleBufferPointer(const std::string& species_name, int boundary);
58 
59  static constexpr int numBoundaries () {
60  return AMREX_SPACEDIM*2
61 #ifdef AMREX_USE_EB
62  + 1
63 #endif
64  ;
65  }
66 
67  bool isDefinedForAnySpecies (int const ibuffer) {return (m_do_any_boundary[ibuffer] != 0);}
68 
69  std::string boundaryName (int const ibuffer) {return m_boundary_names[ibuffer];}
70 
71 private:
72  // over boundary, then number of species
73  std::vector<std::vector<PinnedMemoryParticleContainer> > m_particle_containers;
74 
75  // over boundary, then number of species
76  std::vector<std::vector<int> > m_do_boundary_buffer;
77 
78  // over boundary
79  std::vector<int> m_do_any_boundary;
80  std::vector<std::string> m_boundary_names;
81 
82  mutable std::vector<std::string> m_species_names;
83 };
84 
85 #endif /*WARPX_PARTICLEBOUNDARYBUFFER_H_*/
Definition: MultiParticleContainer.H:66
Definition: NamedComponentParticleContainer.H:64
Definition: ParticleBoundaryBuffer.H:22
std::string boundaryName(int const ibuffer)
Definition: ParticleBoundaryBuffer.H:69
int numSpecies() const
Definition: ParticleBoundaryBuffer.H:38
~ParticleBoundaryBuffer()=default
std::vector< std::vector< PinnedMemoryParticleContainer > > m_particle_containers
Definition: ParticleBoundaryBuffer.H:73
std::vector< std::string > m_species_names
Definition: ParticleBoundaryBuffer.H:82
ParticleBoundaryBuffer(const ParticleBoundaryBuffer &)=delete
bool isDefinedForAnySpecies(int const ibuffer)
Definition: ParticleBoundaryBuffer.H:67
ParticleBoundaryBuffer(ParticleBoundaryBuffer &&)=default
std::vector< int > m_do_any_boundary
Definition: ParticleBoundaryBuffer.H:79
std::vector< std::vector< int > > m_do_boundary_buffer
Definition: ParticleBoundaryBuffer.H:76
static constexpr int numBoundaries()
Definition: ParticleBoundaryBuffer.H:59
std::vector< std::string > m_boundary_names
Definition: ParticleBoundaryBuffer.H:80
i
Definition: check_interp_points_and_weights.py:174