IPPL API Reference
Independent Parallel Particle Layer C++ API
Loading...
Searching...
No Matches
Poisson.h
1//
2// Class Poisson
3// Base class for solvers for the Poisson problem
4//
5
6#ifndef IPPL_POISSON_H
7#define IPPL_POISSON_H
8
10
11#include "Field/Field.h"
12
13namespace ippl {
14
15 template <typename FieldLHS, typename FieldRHS>
16 class Poisson {
17 constexpr static unsigned Dim = FieldLHS::dim;
18 typedef typename FieldLHS::Mesh_t Mesh;
19 typedef typename FieldLHS::Centering_t Centering;
20 typedef typename Mesh::matrix_type Matrix_t;
22
23 public:
24 using lhs_type = FieldLHS;
25 using rhs_type = FieldRHS;
26 using Tlhs = typename FieldLHS::value_type;
27 using Trhs = typename FieldRHS::value_type;
28
29 using grad_type = Field<Vector<Tlhs, Dim>, Dim, Mesh, Centering>;
30
36 SOL = 0b01,
37 GRAD = 0b10,
38 SOL_AND_GRAD = 0b11
39 };
40
46 : grad_mp(nullptr) {
47 static_assert(std::is_floating_point<Trhs>::value, "Not a floating point type");
49 }
50
51 Poisson(lhs_type& lhs, rhs_type& rhs)
52 : grad_mp(nullptr) {
53 setLhs(lhs);
54 setRhs(rhs);
55
56 static_assert(std::is_floating_point<Trhs>::value, "Not a floating point type");
58 }
59
66 template <typename T>
67 void updateParameter(const std::string& key, const T& value) {
68 params_m.update<T>(key, value);
69 }
70
77 void updateParameters(const ParameterList& params) { params_m.update(params); }
78
84 void mergeParameters(const ParameterList& params) { params_m.merge(params); }
85
90 virtual void setLhs(lhs_type& lhs) { lhs_mp = &lhs; }
91
96 virtual void setRhs(rhs_type& rhs) { rhs_mp = &rhs; }
97
102 virtual MField_t* getHessian() { return nullptr; }
103
109 void setGradient(grad_type& grad) { grad_mp = &grad; }
110
115 virtual void solve() = 0;
116
117 virtual ~Poisson() {}
118
119 protected:
120 ParameterList params_m;
121
122 rhs_type* rhs_mp = nullptr;
123 lhs_type* lhs_mp = nullptr;
124
125 grad_type* grad_mp;
126
131 virtual void setDefaultParameters() { this->params_m.add("output_type", SOL); }
132 };
133} // namespace ippl
134
135#endif
Definition Centering.h:25
Definition Field.h:18
Definition ParameterList.h:29
void merge(const ParameterList &p) noexcept
Definition ParameterList.h:86
void add(const std::string &key, const T &value)
Definition ParameterList.h:44
void update(const ParameterList &p) noexcept
Definition ParameterList.h:97
Definition Poisson.h:16
Poisson()
Definition Poisson.h:45
virtual void solve()=0
virtual void setLhs(lhs_type &lhs)
Definition Poisson.h:90
virtual MField_t * getHessian()
Definition Poisson.h:102
OutputType
Definition Poisson.h:35
void mergeParameters(const ParameterList &params)
Definition Poisson.h:84
virtual void setDefaultParameters()
Definition Poisson.h:131
virtual void setRhs(rhs_type &rhs)
Definition Poisson.h:96
void updateParameters(const ParameterList &params)
Definition Poisson.h:77
void setGradient(grad_type &grad)
Definition Poisson.h:109
void updateParameter(const std::string &key, const T &value)
Definition Poisson.h:67
Definition Vector.h:23
Definition Archive.h:20
detail::meta_grad< Field > grad(Field &u)
Definition FieldOperations.hpp:12