OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
AmrParticleBase.h
Go to the documentation of this file.
1 #ifndef AMR_PARTICLE_BASE_H
2 #define AMR_PARTICLE_BASE_H
3 
4 #include "Ippl.h"
5 
7 
9 
10 /* The derived classes need to extend the base class by subsequent methods.
11  *
12  * scatter the data from the given attribute onto the given Field, using
13  * the given Position attribute
14  *
15  * template <class FT, unsigned Dim, class PT>
16  * void scatter(const ParticleAttrib<FT>& attrib, AmrField_t& f,
17  * const ParticleAttrib<Vektor<PT, Dim> >& pp,
18  * int lbase = 0, int lfine = -1) const;
19  *
20  *
21  * gather the data from the given Field into the given attribute, using
22  * the given Position attribute
23  *
24  * template <class FT, unsigned Dim, class PT>
25  * void gather(ParticleAttrib<FT>& attrib, const AmrField_t& f,
26  * const ParticleAttrib<Vektor<PT, Dim> >& pp,
27  * int lbase = 0, int lfine = -1) const;
28  */
29 
30 
31 template<class PLayout>
32 class AmrParticleBase : public IpplParticleBase<PLayout> {
33 
34 public:
35  typedef typename PLayout::ParticlePos_t ParticlePos_t;
36  typedef typename PLayout::ParticleIndex_t ParticleIndex_t;
37  typedef typename PLayout::SingleParticlePos_t SingleParticlePos_t;
38  typedef typename PLayout::AmrField_t AmrField_t;
42 
43  typedef long SortListIndex_t;
44  typedef std::vector<SortListIndex_t> SortList_t;
45  typedef std::vector<ParticleAttribBase *> attrib_container_t;
46 
48  ParticleIndex_t Grid; // m_grid
49 
51 
52 public:
53 
55 
56  AmrParticleBase(PLayout* layout);
57 
59 
60  //initialize AmrParticleBase class - add level and grid variables to attribute list
61  void initializeAmr() {
62  this->addAttribute(Level);
63  this->addAttribute(Grid);
64  }
65 
67 
69 
70  void setLocalNumPerLevel(const ParticleLevelCounter_t& LocalNumPerLevel);
71 
72  /* Functions of IpplParticleBase<PLayout> adpated to
73  * work with AmrParticleLevelCounter:
74  * - createWithID()
75  * - create()
76  * - destroy()
77  * - performDestroy()
78  */
79 
80  void createWithID(unsigned id);
81 
82  void create(size_t M);
83 
84  void destroy(size_t M, size_t I, bool doNow = false);
85 
86  void performDestroy(bool updateLocalNum = false);
87 
88  // Update the particle object after a timestep. This routine will change
89  // our local, total, create particle counts properly.
90  void update();
91 
99  void update(int lev_min, int lev_max, bool isRegrid = false);
100 
101  // Update the particle object after a timestep. This routine will change
102  // our local, total, create particle counts properly.
103  void update(const ParticleAttrib<char>& canSwap);
104 
105  // sort particles based on the grid and level that they belong to
106  void sort();
107 
108  // sort the particles given a sortlist
109  void sort(SortList_t &sortlist);
110 
111  PLayout& getAmrLayout() { return this->getLayout(); }
112  const PLayout& getAmrLayout() const { return this->getLayout(); }
113 
122  inline void setForbidTransform(bool forbidTransform);
123 
128  inline bool isForbidTransform() const;
129 
139  const double& domainMapping(bool inverse = false);
140 
145  inline const double& getScalingFactor() const;
146 
147 
148  void setLorentzFactor(const Vector_t& lorentzFactor);
149 
150 // void lorentzTransform(bool inverse = false);
151 
152 private:
153  void getLocalBounds_m(Vector_t &rmin, Vector_t &rmax);
154  void getGlobalBounds_m(Vector_t &rmin, Vector_t &rmax);
155 
156 protected:
160 
162 
167  double scale_m;
168 
175 
176 // bool isLorentzTransformed_m;
177 
178 
179 private:
181 };
182 
183 #include "AmrParticleBase.hpp"
184 
185 #endif
PLayout & getAmrLayout()
PLayout::ParticlePos_t ParticlePos_t
ParticleIndex_t Level
Definition: TSVMeta.h:24
const double & getScalingFactor() const
PLayout::AmrField_t AmrField_t
void getGlobalBounds_m(Vector_t &rmin, Vector_t &rmax)
const PLayout & getAmrLayout() const
std::vector< ParticleAttribBase * > attrib_container_t
PLayout::SingleParticlePos_t SingleParticlePos_t
const ParticleLevelCounter_t & getLocalNumPerLevel() const
IpplTimings::TimerRef domainMappingTimer_m
bool isForbidTransform() const
void createWithID(unsigned id)
void getLocalBounds_m(Vector_t &rmin, Vector_t &rmax)
void create(size_t M)
std::vector< SortListIndex_t > SortList_t
PLayout::ParticleIndex_t ParticleIndex_t
PLayout::AmrVectorFieldContainer_t AmrVectorFieldContainer_t
void performDestroy(bool updateLocalNum=false)
void setForbidTransform(bool forbidTransform)
void setLorentzFactor(const Vector_t &lorentzFactor)
std::array< std::unique_ptr< AmrField_t >, AMREX_SPACEDIM > AmrVectorField_t
Definition: AmrDefs.h:17
Vector_t lorentzFactor_m
const double & domainMapping(bool inverse=false)
IpplTimings::TimerRef updateParticlesTimer_m
void addAttribute(ParticleAttribBase &pa)
PLayout::AmrScalarFieldContainer_t AmrScalarFieldContainer_t
void setLocalNumPerLevel(const ParticleLevelCounter_t &LocalNumPerLevel)
IpplTimings::TimerRef sortParticlesTimer_m
Timing::TimerRef TimerRef
Definition: IpplTimings.h:176
bool forbidTransform_m
To avoid multiple transformations during regrid.
amr::AmrScalarFieldContainer_t AmrScalarFieldContainer_t
Definition: PBunchDefs.h:60
PLayout::AmrVectorField_t AmrVectorField_t
ParticleLevelCounter_t LocalNumPerLevel_m
ParticleIndex_t Grid
void destroy(size_t M, size_t I, bool doNow=false)
PLayout & getLayout()
amr::AmrVectorFieldContainer_t AmrVectorFieldContainer_t
Definition: PBunchDefs.h:61
amr::AmrField_t AmrField_t
Definition: PBunchDefs.h:59
AmrParticleLevelCounter< size_t, size_t > ParticleLevelCounter_t