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 
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 
43  const amrex::Vector<const amrex::MultiFab*>& distance_to_eb);
44 
45  void redistribute ();
46  void clearParticles ();
47  void clearParticles (int i);
48 
49  void printNumParticles () const;
50 
51  int getNumParticlesInContainer(std::string species_name, int boundary, bool local);
52 
53  PinnedMemoryParticleContainer& getParticleBuffer(std::string species_name, int boundary);
54 
55  PinnedMemoryParticleContainer* getParticleBufferPointer(std::string species_name, int boundary);
56 
57  static constexpr int numBoundaries () {
58  return AMREX_SPACEDIM*2
59 #ifdef AMREX_USE_EB
60  + 1
61 #endif
62  ;
63  }
64 
65  bool isDefinedForAnySpecies (int const ibuffer) {return (m_do_any_boundary[ibuffer] != 0);}
66 
67  std::string boundaryName (int const ibuffer) {return m_boundary_names[ibuffer];}
68 
69 private:
70  // over boundary, then number of species
71  std::vector<std::vector<PinnedMemoryParticleContainer> > m_particle_containers;
72 
73  // over boundary, then number of species
74  std::vector<std::vector<int> > m_do_boundary_buffer;
75 
76  // over boundary
77  std::vector<int> m_do_any_boundary;
78  std::vector<std::string> m_boundary_names;
79 
80  mutable std::vector<std::string> m_species_names;
81 };
82 
83 #endif /*PARTICLEBOUNDARYBUFFER_H_*/
Definition: MultiParticleContainer.H:65
Definition: NamedComponentParticleContainer.H:49
Definition: ParticleBoundaryBuffer.H:22
std::string boundaryName(int const ibuffer)
Definition: ParticleBoundaryBuffer.H:67
int numSpecies() const
Definition: ParticleBoundaryBuffer.H:38
~ParticleBoundaryBuffer()
Definition: ParticleBoundaryBuffer.H:26
std::vector< std::vector< PinnedMemoryParticleContainer > > m_particle_containers
Definition: ParticleBoundaryBuffer.H:71
std::vector< std::string > m_species_names
Definition: ParticleBoundaryBuffer.H:80
ParticleBoundaryBuffer(const ParticleBoundaryBuffer &)=delete
bool isDefinedForAnySpecies(int const ibuffer)
Definition: ParticleBoundaryBuffer.H:65
ParticleBoundaryBuffer(ParticleBoundaryBuffer &&)=default
std::vector< int > m_do_any_boundary
Definition: ParticleBoundaryBuffer.H:77
std::vector< std::vector< int > > m_do_boundary_buffer
Definition: ParticleBoundaryBuffer.H:74
static constexpr int numBoundaries()
Definition: ParticleBoundaryBuffer.H:57
std::vector< std::string > m_boundary_names
Definition: ParticleBoundaryBuffer.H:78
void gatherParticles(PTile &dst, const PTile &src, N np, const Index *inds)
i
Definition: check_interp_points_and_weights.py:174