OPAL (Object Oriented Parallel Accelerator Library)  2024.1
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 
39  enum class TaggingCriteria: unsigned int {
40  CHARGE_DENSITY = 0,
41  POTENTIAL,
42  EFIELD,
43  MOMENTA,
46  };
47 
53  struct AmrInfo {
54  int grid[3];
55  int maxgrid[3];
56  int bf[3];
57  int maxlevel;
58  int refratio[3];
59  };
60 
61 public:
62  AmrObject();
63 
64  AmrObject(TaggingCriteria tagging,
65  double scaling,
66  double chargedensity);
67 
68  virtual ~AmrObject();
69 
75  virtual void getGridStatistics(std::map<int, long>& gridPtsPerCore,
76  std::vector<int>& gridsPerLevel) const = 0;
77 
81  virtual void initFineLevels() = 0;
82 
87  virtual void regrid(double time) = 0;
88 
94  void setTagging(TaggingCriteria tagging);
95 
101  void setTagging(const std::string& tagging);
102 
108  void setScalingFactor(double scaling);
109 
114  void setChargeDensity(double chargedensity);
115 
121  void setMaxNumParticles(size_t maxNumPart);
122 
128  void setMinNumParticles(size_t minNumPart);
129 
130  /* Methods that are needed by the
131  * bunch
132  */
133  virtual VectorPair_t getEExtrema() = 0;
134 
135  virtual double getRho(int x, int y, int z) = 0;
136 
137  virtual void computeSelfFields() = 0;
138 
139  virtual void computeSelfFields(int b) = 0;
140 
141  virtual void computeSelfFields_cycl(double gamma) = 0;
142 
143  virtual void computeSelfFields_cycl(int b) = 0;
144 
145  virtual void updateMesh() = 0;
146 
147  virtual Vektor<int, 3> getBaseLevelGridPoints() const = 0;
148 
149  virtual const int& maxLevel() const = 0;
150  virtual const int& finestLevel() const = 0;
151 
155  virtual double getT() const = 0;
156 
161  virtual void redistributeGrids(int /*how*/) { }
162 
168  const bool& isRefined() const;
169 
176  static std::string getTaggingString(int number);
177 
178 protected:
180 
181  double scaling_m;
182  // (POTENTIAL, EFIELD)
184 
185  size_t maxNumPart_m;
186 
187  size_t minNumPart_m;
188 
189  bool refined_m;
190 
194 };
195 
196 #endif
virtual void computeSelfFields_cycl(double gamma)=0
IpplTimings::TimerRef amrRegridTimer_m
Definition: AmrObject.h:193
void setMinNumParticles(size_t minNumPart)
Definition: AmrObject.cpp:93
virtual Vektor< int, 3 > getBaseLevelGridPoints() const =0
int grid[3]
Number of grid points in x-, y- and z-direction.
Definition: AmrObject.h:54
virtual void computeSelfFields()=0
std::pair< Vector_t, Vector_t > VectorPair_t
Definition: AmrObject.h:35
void setMaxNumParticles(size_t maxNumPart)
Definition: AmrObject.cpp:88
virtual void getGridStatistics(std::map< int, long > &gridPtsPerCore, std::vector< int > &gridsPerLevel) const =0
static std::string getTaggingString(int number)
Definition: AmrObject.cpp:103
int maxlevel
Maximum level for AMR (0: single-level)
Definition: AmrObject.h:57
void setTagging(TaggingCriteria tagging)
Definition: AmrObject.cpp:51
double scaling_m
Scaling factor for tagging [0, 1].
Definition: AmrObject.h:181
TaggingCriteria
Methods for tagging cells for refinement.
Definition: AmrObject.h:39
IpplTimings::TimerRef amrSolveTimer_m
timer for selfField calculation (used in concrete AmrObject classes)
Definition: AmrObject.h:192
int bf[3]
Grid blocking factor in x-, y- and z-direction.
Definition: AmrObject.h:56
int maxgrid[3]
Maximum grid size in x-, y- and z-direction.
Definition: AmrObject.h:55
virtual void regrid(double time)=0
virtual ~AmrObject()
Definition: AmrObject.cpp:47
virtual const int & maxLevel() const =0
Timing::TimerRef TimerRef
Definition: IpplTimings.h:176
virtual double getT() const =0
virtual void initFineLevels()=0
size_t minNumPart_m
Tagging value for MIN_NUM_PARTICLES.
Definition: AmrObject.h:187
TaggingCriteria tagging_m
Tagging strategy.
Definition: AmrObject.h:179
void setChargeDensity(double chargedensity)
Definition: AmrObject.cpp:83
virtual const int & finestLevel() const =0
virtual void redistributeGrids(int)
Definition: AmrObject.h:161
const bool & isRefined() const
Definition: AmrObject.cpp:98
double chargedensity_m
Tagging value for CHARGE_DENSITY.
Definition: AmrObject.h:183
int refratio[3]
Mesh refinement ratio in x-, y- and z-direction.
Definition: AmrObject.h:58
void setScalingFactor(double scaling)
Definition: AmrObject.cpp:78
virtual double getRho(int x, int y, int z)=0
size_t maxNumPart_m
Tagging value for MAX_NUM_PARTICLES.
Definition: AmrObject.h:185
virtual VectorPair_t getEExtrema()=0
bool refined_m
Only set to true in AmrObject::initFineLevels()
Definition: AmrObject.h:189
virtual void updateMesh()=0