OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
FieldSolver.hpp
Go to the documentation of this file.
1#ifndef OPAL_FIELD_SOLVER_H
2#define OPAL_FIELD_SOLVER_H
3
4#include <memory>
5#include "BCHandler.hpp"
6#include "Manager/BaseManager.h"
7#include "Manager/FieldSolverBase.h"
8
9// Define the FieldSolver class
10template <typename T, unsigned Dim>
11class FieldSolver : public ippl::FieldSolverBase<T, Dim> {
12private:
16
18 std::shared_ptr<BCHandler_t> bcHandler_m;
19
22
23public:
25 std::string solver, Field_t<Dim>* rho, VField_t<T, Dim>* E, Field_t<Dim>* phi,
26 std::shared_ptr<BCHandler_t> bcHandler)
27 : ippl::FieldSolverBase<T, Dim>(solver),
28 rho_m(rho),
29 E_m(E),
30 phi_m(phi),
31 bcHandler_m(bcHandler),
34 }
35
36 ~FieldSolver() override = default;
37
38 void dumpScalField(std::string what);
39 void dumpVectField(std::string what);
40
41 Field_t<Dim>* getRho() { return rho_m; }
42 void setRho(Field_t<Dim>* rho) { rho_m = rho; }
43
44 VField_t<T, Dim>* getE() const { return E_m; }
45 void setE(VField_t<T, Dim>* E) { E_m = E; }
46
47 Field<T, Dim>* getPhi() const { return phi_m; }
48 void setPhi(Field<T, Dim>* phi) { phi_m = phi; }
49
50 std::shared_ptr<BCHandler_t> getBCHandler() const { return bcHandler_m; }
51 void setBCHandler(std::shared_ptr<BCHandler_t> bcHandler) {
52 bcHandler_m = bcHandler;
54 }
55
67
69
70 void initSolver() override;
71
83
84 bool hasValidBCHandler() const { return (bcHandler_m != nullptr); }
85
86 void runSolver() override {
87 // The default runSolver should always count towards the call counter!
88 runSolver(false);
89 }
90
102
103 size_t getCallCounter() { return call_counter_m; }
104
121 void runSolver(bool force_skip_field_dump);
122
144 void runShiftedOpenSolver(const ippl::Vector<double, Dim>& shift);
145
146 template <typename Solver>
147 void initSolverWithParams(const ippl::ParameterList& sp);
148
150
152
153 void initCGSolver() {}
154
156};
157
158// Explicit specialization declaration
159template <>
161
162#endif
ippl::Field< T, Dim, Mesh_t< Dim >, Centering_t< Dim >, ViewArgs... > Field
double T
Definition OPALTypes.h:8
constexpr unsigned Dim
Definition OPALTypes.h:7
ippl::Field< double, Dim, ViewArgs... > Field_t
Definition PBunchDefs.h:28
ippl::Field< ippl::Vector< T, Dim >, Dim, ViewArgs... > VField_t
Definition PBunchDefs.h:31
Handler for boundary conditions per spatial dimension.
Definition BCHandler.hpp:29
VField_t< T, Dim > * getE() const
void runShiftedOpenSolver(const ippl::Vector< double, Dim > &shift)
Run an Open-solver solve with a shifted free-space Green's function.
void initP3MSolver()
void runSolver(bool force_skip_field_dump)
Execute the field solver for the current simulation state.
void setRho(Field_t< Dim > *rho)
void dumpVectField(std::string what)
void setPhi(Field< T, Dim > *phi)
void initSolver() override
void initFFTSolver()
void initCGSolver()
void setBCHandler(std::shared_ptr< BCHandler_t > bcHandler)
void runSolver() override
size_t getCallCounter()
~FieldSolver() override=default
void resetCallCounter()
Reset the solver call counter to zero.
void initSolverWithParams(const ippl::ParameterList &sp)
Field_t< Dim > * getRho()
Field< T, Dim > * getPhi() const
void initOpenSolver()
T getCouplingConstant() const
Get the solver's coupling constant.
void setE(VField_t< T, Dim > *E)
VField_t< T, Dim > * E_m
bool hasValidBCHandler() const
std::shared_ptr< BCHandler_t > getBCHandler() const
size_t call_counter_m
Counts number of times the solver has been called.
void initNullSolver()
Field_t< Dim > * rho_m
FieldSolver(std::string solver, Field_t< Dim > *rho, VField_t< T, Dim > *E, Field_t< Dim > *phi, std::shared_ptr< BCHandler_t > bcHandler)
std::shared_ptr< BCHandler_t > bcHandler_m
void dumpScalField(std::string what)
void setPotentialBCs()
Set boundary conditions for the electrostatic potential field.
Field_t< Dim > * phi_m