OPAL (Object Oriented Parallel Accelerator Library) 2024.2
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
30
31class AmrObject {
32
33public:
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
47
53 struct AmrInfo {
54 int grid[3];
55 int maxgrid[3];
56 int bf[3];
58 int refratio[3];
59 };
60
61public:
62 AmrObject();
63
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 */
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
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
178protected:
180
181 double scaling_m;
182 // (POTENTIAL, EFIELD)
184
186
188
190
194};
195
196#endif
virtual void initFineLevels()=0
void setMinNumParticles(size_t minNumPart)
Definition AmrObject.cpp:93
virtual ~AmrObject()
Definition AmrObject.cpp:47
TaggingCriteria
Methods for tagging cells for refinement.
Definition AmrObject.h:39
@ MAX_NUM_PARTICLES
max. particles per cell
Definition AmrObject.h:45
@ MIN_NUM_PARTICLES
min. particles per cell
Definition AmrObject.h:44
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:98
void setScalingFactor(double scaling)
Definition AmrObject.cpp:78
int refratio[3]
Mesh refinement ratio in x-, y- and z-direction.
Definition AmrObject.h:58
double scaling_m
Scaling factor for tagging [0, 1].
Definition AmrObject.h:181
IpplTimings::TimerRef amrRegridTimer_m
Definition AmrObject.h:193
std::pair< Vector_t, Vector_t > VectorPair_t
Definition AmrObject.h:35
void setMaxNumParticles(size_t maxNumPart)
Definition AmrObject.cpp:88
int grid[3]
Number of grid points in x-, y- and z-direction.
Definition AmrObject.h:54
virtual void computeSelfFields(int b)=0
virtual void computeSelfFields_cycl(double gamma)=0
virtual VectorPair_t getEExtrema()=0
static std::string getTaggingString(int number)
int maxgrid[3]
Maximum grid size in x-, y- and z-direction.
Definition AmrObject.h:55
virtual Vektor< int, 3 > getBaseLevelGridPoints() const =0
double chargedensity_m
Tagging value for CHARGE_DENSITY.
Definition AmrObject.h:183
int bf[3]
Grid blocking factor in x-, y- and z-direction.
Definition AmrObject.h:56
bool refined_m
Only set to true in AmrObject::initFineLevels().
Definition AmrObject.h:189
TaggingCriteria tagging_m
Tagging strategy.
Definition AmrObject.h:179
void setChargeDensity(double chargedensity)
Definition AmrObject.cpp:83
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:192
size_t minNumPart_m
Tagging value for MIN_NUM_PARTICLES.
Definition AmrObject.h:187
virtual void computeSelfFields_cycl(int b)=0
void setTagging(TaggingCriteria tagging)
Definition AmrObject.cpp:51
virtual void computeSelfFields()=0
int maxlevel
Maximum level for AMR (0: single-level).
Definition AmrObject.h:57
virtual const int & maxLevel() const =0
virtual const int & finestLevel() const =0
size_t maxNumPart_m
Tagging value for MAX_NUM_PARTICLES.
Definition AmrObject.h:185
virtual void regrid(double time)=0
virtual void redistributeGrids(int)
Definition AmrObject.h:161
Timing::TimerRef TimerRef