OPALX (Object Oriented Parallel Accelerator Library for Exascal) MINIorX
OPALX
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 "Manager/BaseManager.h"
6#include "Manager/FieldSolverBase.h"
7
8// Define the FieldSolver class
9template <typename T, unsigned Dim>
10class FieldSolver : public ippl::FieldSolverBase<T, Dim> {
11private:
15 unsigned int call_counter_m;
16public:
17 FieldSolver(std::string solver, Field_t<Dim>* rho, VField_t<T, Dim>* E, Field<T, Dim>* phi)
18 : ippl::FieldSolverBase<T, Dim>(solver), rho_m(rho), E_m(E), phi_m(phi), call_counter_m(0) {
20 }
21
23 }
24
25 void dumpScalField(std::string what);
26 void dumpVectField(std::string what);
27
29 return rho_m;
30 }
31 void setRho(Field_t<Dim>* rho) {
32 rho_m = rho;
33 }
34
36 return E_m;
37 }
39 E_m = E;
40 }
41
43 return phi_m;
44 }
45 void setPhi(Field<T, Dim>* phi) {
46 phi_m = phi;
47 }
48
50
51 void initSolver() override ;
52
54
55 void runSolver() override;
56
57 template <typename Solver>
58 void initSolverWithParams(const ippl::ParameterList& sp) {
59 this->getSolver().template emplace<Solver>();
60 Solver& solver = std::get<Solver>(this->getSolver());
61
62 solver.mergeParameters(sp);
63
64 solver.setRhs(*rho_m);
65
66 if constexpr (std::is_same_v<Solver, CGSolver_t<T, Dim>>) {
67 // The CG solver computes the potential directly and
68 // uses this to get the electric field
69 solver.setLhs(*phi_m);
70 solver.setGradient(*E_m);
71 } else if constexpr (std::is_same_v<Solver, OpenSolver_t<T, Dim>>) {
72 // The periodic Poisson solver, Open boundaries solver,
73 // and the P3M solver compute the electric field directly
74 solver.setLhs(*E_m);
75 solver.setGradFD();
76 }
78 }
79
81
83 ippl::ParameterList sp;
84 sp.add("output_type", FFTSolver_t<double, 3>::GRAD);
85 sp.add("use_heffte_defaults", false);
86 sp.add("use_pencils", true);
87 sp.add("use_reorder", false);
88 sp.add("use_gpu_aware", true);
89 sp.add("comm", ippl::p2p_pl);
90 sp.add("r2c_direction", 0);
92 }
93
94 void initCGSolver() { }
95
96 void initP3MSolver() { }
97
98};
99
100// Explicit specialization declaration
101template<>
103
104#endif
ConditionalType< Dim==2||Dim==3, ippl::FFTPeriodicPoissonSolver< VField_t< T, Dim >, Field_t< Dim > > > FFTSolver_t
ippl::Field< double, Dim, ViewArgs... > Field_t
Definition PBunchDefs.h:30
ippl::Field< ippl::Vector< T, Dim >, Dim, ViewArgs... > VField_t
Definition PBunchDefs.h:33
ippl::Field< T, Dim, Mesh_t< Dim >, Centering_t< Dim >, ViewArgs... > Field
double T
Definition datatypes.h:7
constexpr unsigned Dim
Definition datatypes.h:6
VField_t< T, Dim > * getE() const
void initP3MSolver()
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 runSolver() override
void initSolverWithParams(const ippl::ParameterList &sp)
Field_t< Dim > * getRho()
Field< T, Dim > * getPhi() const
void initOpenSolver()
void setE(VField_t< T, Dim > *E)
VField_t< T, Dim > * E_m
void initNullSolver()
unsigned int call_counter_m
Field_t< Dim > * rho_m
FieldSolver(std::string solver, Field_t< Dim > *rho, VField_t< T, Dim > *E, Field< T, Dim > *phi)
void dumpScalField(std::string what)
void setPotentialBCs()
Field_t< Dim > * phi_m