OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
AmrObject.h
Go to the documentation of this file.
1 //
2 // Class AmrObject
3 // The AMR interface to OPAL. A new AMR library needs
4 // to inherit from this class in order to work properly
5 // with OPAL. Among other things it specifies the refinement
6 // strategies.
7 //
8 // Copyright (c) 2016 - 2020, Matthias Frey, Paul Scherrer Institut, Villigen PSI, Switzerland
9 // All rights reserved
10 //
11 // Implemented as part of the PhD thesis
12 // "Precise Simulations of Multibunches in High Intensity Cyclotrons"
13 //
14 // This file is part of OPAL.
15 //
16 // OPAL is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with OPAL. If not, see <https://www.gnu.org/licenses/>.
23 //
24 #ifndef AMR_OBECT_H
25 #define AMR_OBECT_H
26 
27 #include "Index/NDIndex.h"
28 
29 #include "Algorithms/PBunchDefs.h"
30 
31 class AmrObject {
32 
33 public:
34  // FIXME Why not using typedef of PartBunchBase
35  typedef std::pair<Vector_t, Vector_t> VectorPair_t;
36 // using VectorPair_t = typename AmrPartBunch::VectorPair_t;
37 
40  CHARGE_DENSITY = 0, // default
46  };
47 
48 
54  struct AmrInfo {
55  int grid[3];
56  int maxgrid[3];
57  int bf[3];
58  int maxlevel;
59  int refratio[3];
60  };
61 
62 public:
63 
64  AmrObject();
65 
66  AmrObject(TaggingCriteria tagging,
67  double scaling,
68  double chargedensity);
69 
70  virtual ~AmrObject();
71 
77  virtual void getGridStatistics(std::map<int, long>& gridPtsPerCore,
78  std::vector<int>& gridsPerLevel) const = 0;
79 
83  virtual void initFineLevels() = 0;
84 
89  virtual void regrid(double time) = 0;
90 
96  void setTagging(TaggingCriteria tagging);
97 
103  void setTagging(const std::string& tagging);
104 
110  void setScalingFactor(double scaling);
111 
116  void setChargeDensity(double chargedensity);
117 
123  void setMaxNumParticles(size_t maxNumPart);
124 
130  void setMinNumParticles(size_t minNumPart);
131 
132  /* Methods that are needed by the
133  * bunch
134  */
135  virtual VectorPair_t getEExtrema() = 0;
136 
137  virtual double getRho(int x, int y, int z) = 0;
138 
139  virtual void computeSelfFields() = 0;
140 
141  virtual void computeSelfFields(int b) = 0;
142 
143  virtual void computeSelfFields_cycl(double gamma) = 0;
144 
145  virtual void computeSelfFields_cycl(int b) = 0;
146 
147  virtual void updateMesh() = 0;
148 
150 
151  virtual const int& maxLevel() const = 0;
152  virtual const int& finestLevel() const = 0;
153 
157  virtual double getT() const = 0;
158 
163  virtual void redistributeGrids(int /*how*/) { }
164 
170  const bool& isRefined() const;
171 
178  static std::string enum2string(int number);
179 
180 protected:
181 
183 
184  double scaling_m;
185  // (POTENTIAL, EFIELD)
187 
188  size_t maxNumPart_m;
189 
190  size_t minNumPart_m;
191 
192  bool refined_m;
193 
197 };
198 
199 #endif
virtual Vektor< int, 3 > getBaseLevelGridPoints() const =0
virtual void initFineLevels()=0
void setMinNumParticles(size_t minNumPart)
Definition: AmrObject.cpp:90
virtual ~AmrObject()
Definition: AmrObject.cpp:45
virtual void getGridStatistics(std::map< int, long > &gridPtsPerCore, std::vector< int > &gridsPerLevel) const =0
virtual double getRho(int x, int y, int z)=0
const bool & isRefined() const
Definition: AmrObject.cpp:95
virtual const int & finestLevel() const =0
void setScalingFactor(double scaling)
Definition: AmrObject.cpp:75
double scaling_m
Scaling factor for tagging [0, 1].
Definition: AmrObject.h:184
IpplTimings::TimerRef amrRegridTimer_m
Definition: AmrObject.h:196
TaggingCriteria
Methods for tagging cells for refinement.
Definition: AmrObject.h:39
@ MIN_NUM_PARTICLES
min. #particles per cell
Definition: AmrObject.h:44
@ CHARGE_DENSITY
Definition: AmrObject.h:40
@ MAX_NUM_PARTICLES
max. #particles per cell
Definition: AmrObject.h:45
@ POTENTIAL
Definition: AmrObject.h:41
std::pair< Vector_t, Vector_t > VectorPair_t
Definition: AmrObject.h:35
void setMaxNumParticles(size_t maxNumPart)
Definition: AmrObject.cpp:85
virtual void computeSelfFields(int b)=0
virtual void computeSelfFields_cycl(double gamma)=0
virtual VectorPair_t getEExtrema()=0
virtual const int & maxLevel() const =0
double chargedensity_m
Tagging value for CHARGE_DENSITY.
Definition: AmrObject.h:186
bool refined_m
Only set to true in AmrObject::initFineLevels()
Definition: AmrObject.h:192
TaggingCriteria tagging_m
Tagging strategy.
Definition: AmrObject.h:182
void setChargeDensity(double chargedensity)
Definition: AmrObject.cpp:80
static std::string enum2string(int number)
Definition: AmrObject.cpp:100
virtual void updateMesh()=0
virtual double getT() const =0
IpplTimings::TimerRef amrSolveTimer_m
timer for selfField calculation (used in concrete AmrObject classes)
Definition: AmrObject.h:195
size_t minNumPart_m
Tagging value for MIN_NUM_PARTICLES.
Definition: AmrObject.h:190
virtual void computeSelfFields_cycl(int b)=0
void setTagging(TaggingCriteria tagging)
Definition: AmrObject.cpp:49
virtual void computeSelfFields()=0
size_t maxNumPart_m
Tagging value for MAX_NUM_PARTICLES.
Definition: AmrObject.h:188
virtual void regrid(double time)=0
virtual void redistributeGrids(int)
Definition: AmrObject.h:163
int refratio[3]
Mesh refinement ratio in x-, y- and z-direction.
Definition: AmrObject.h:59
int grid[3]
Number of grid points in x-, y- and z-direction.
Definition: AmrObject.h:55
int maxgrid[3]
Maximum grid size in x-, y- and z-direction.
Definition: AmrObject.h:56
int bf[3]
Grid blocking factor in x-, y- and z-direction.
Definition: AmrObject.h:57
int maxlevel
Maximum level for AMR (0: single-level)
Definition: AmrObject.h:58
Timing::TimerRef TimerRef
Definition: IpplTimings.h:176