OPAL (Object Oriented Parallel Accelerator Library) 2024.2
OPAL
FieldSolver.h
Go to the documentation of this file.
1//
2// Class FieldSolver
3// The class for the OPAL FIELDSOLVER command.
4// A FieldSolver definition is used by most physics commands to define the
5// particle charge and the reference momentum, together with some other data.
6//
7// Copyright (c) 200x - 2022, Paul Scherrer Institut, Villigen PSI, Switzerland
8//
9// All rights reserved
10//
11// This file is part of OPAL.
12//
13// OPAL is free software: you can redistribute it and/or modify
14// it under the terms of the GNU General Public License as published by
15// the Free Software Foundation, either version 3 of the License, or
16// (at your option) any later version.
17//
18// You should have received a copy of the GNU General Public License
19// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
20//
21#ifndef OPAL_FieldSolver_HH
22#define OPAL_FieldSolver_HH
23
25#include "Algorithms/PartData.h"
27#ifdef ENABLE_AMR
28 #include "Amr/AmrObject.h"
30 #include <memory>
31#endif
32
33#include <string>
34
35template <class T, unsigned Dim>
36class PartBunchBase;
37
38enum class FieldSolverType: short {
39 NONE = -1,
40 FFT,
41 FFTBOX,
42 SAAMG,
43 P3M,
44 FMG,
45 ML,
46 AMRMG,
47 HYPRE,
48 HPGMG
49};
50
51
52class FieldSolver: public Definition {
53
54public:
57
58 virtual ~FieldSolver();
59
61 virtual FieldSolver* clone(const std::string& name);
62
64 static FieldSolver* find(const std::string& name);
65
66 std::string getType();
67
69 double getMX() const;
70
72 double getMY() const;
73
75 double getMT() const;
76
78 void setMX(double);
79
81 void setMY(double);
82
84 void setMT(double);
85
87 virtual void update();
88
90 virtual void execute();
91
93
95
96 bool hasValidSolver();
97
98 void setFieldSolverType();
100
101 inline Layout_t& getParticleLayout() { return* PL_m; }
102
104
105 Inform& printInfo(Inform& os) const;
106
107 unsigned int getInteractionRadius() {return (unsigned int) rpp_m; }
108
109 const Attribute& getBCZAttribute() const;
110
111 bool hasPeriodicZ();
112
113 bool isAmrSolverType() const;
114
115#ifdef ENABLE_AMR
117 return itsAmrObject_mp.get();
118 }
119
120 const AmrObject* getAmrObject() const {
121 return itsAmrObject_mp.get();
122 }
123#endif
124
127
128private:
129#ifdef ENABLE_AMR
130
131 std::string getTagging_m() const;
132
133 void initAmrObject_m();
134
135 void initAmrSolver_m();
136
137 std::unique_ptr<AmrObject> itsAmrObject_mp;
138#endif
139
140 // Not implemented.
142 void operator=(const FieldSolver&);
143
144 // Clone constructor.
145 FieldSolver(const std::string& name, FieldSolver* parent);
146
149
152
154 std::unique_ptr<Layout_t> PL_m;
155
158
159 std::string fsName_m;
161
162 double rpp_m;
163};
164
165inline
169
170inline
172 return fs.printInfo(os);
173}
174
175#endif // OPAL_FieldSolver_HH
FieldSolverType
Definition FieldSolver.h:38
Inform & operator<<(Inform &os, const FieldSolver &fs)
const std::string name
A representation of an Object attribute.
Definition Attribute.h:52
The base class for all OPAL definitions.
Definition Definition.h:30
Layout_t & getParticleLayout()
virtual void update()
Update the field solver data.
std::unique_ptr< Layout_t > PL_m
The particle layout.
FieldSolverType fsType_m
void setMT(double)
Store emittance for mode 3.
unsigned int getInteractionRadius()
void initCartesianFields()
double getMY() const
Return meshsize.
FieldLayout_t * getFieldLayout()
std::string getTagging_m() const
Mesh_t * mesh_m
The cartesian mesh.
const AmrObject * getAmrObject() const
std::string fsName_m
PartBunchBase< double, 3 > * itsBunch_m
all the particles are here ...
std::string getType()
PoissonSolver * solver_m
the actual solver, should be a base object
Inform & printInfo(Inform &os) const
bool isAmrSolverType() const
static FieldSolver * find(const std::string &name)
Find named FieldSolver.
FieldSolver()
Exemplar constructor.
void setFieldSolverType()
virtual void execute()
Execute (init) the field solver data.
double getMX() const
Return meshsize.
void operator=(const FieldSolver &)
FieldLayout_t * FL_m
The field layout f.
FieldSolverType getFieldSolverType() const
bool hasPeriodicZ()
void initAmrObject_m()
AmrObject * getAmrObject()
std::unique_ptr< AmrObject > itsAmrObject_mp
const Attribute & getBCZAttribute() const
void setMY(double)
Store emittance for mode 2.
double getMT() const
Return meshsize.
virtual ~FieldSolver()
FieldSolver(const FieldSolver &)
bool hasValidSolver()
void setMX(double)
Store emittance for mode 1.
virtual FieldSolver * clone(const std::string &name)
Make clone.
void initSolver(PartBunchBase< double, 3 > *b)
void initAmrSolver_m()