IPPL (Independent Parallel Particle Layer)
IPPL
Loading...
Searching...
No Matches
Poisson.h
Go to the documentation of this file.
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
30
36 SOL = 0b01,
37 GRAD = 0b10,
39 };
40
46 : grad_mp(nullptr) {
47 static_assert(std::is_floating_point<Trhs>::value, "Not a floating point type");
49 }
50
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 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
110
115 virtual void solve() = 0;
116
117 virtual ~Poisson() {}
118
119 protected:
121
122 rhs_type* rhs_mp = nullptr;
123 lhs_type* lhs_mp = nullptr;
124
126
131 virtual void setDefaultParameters() { this->params_m.add("output_type", SOL); }
132 };
133} // namespace ippl
134
135#endif
Definition Archive.h:20
detail::meta_grad< Field > grad(Field &u)
Vector< vector_type, Dim > matrix_type
Definition Mesh.h:23
Field< Vector< Tlhs, Dim >, Dim, Mesh, Centering > grad_type
Definition Poisson.h:29
virtual void solve()=0
virtual ~Poisson()
Definition Poisson.h:117
Poisson(lhs_type &lhs, rhs_type &rhs)
Definition Poisson.h:51
virtual MField_t * getHessian()
Definition Poisson.h:102
Mesh::matrix_type Matrix_t
Definition Poisson.h:20
lhs_type * lhs_mp
Definition Poisson.h:123
typename FieldRHS::value_type Trhs
Definition Poisson.h:27
FieldLHS::Mesh_t Mesh
Definition Poisson.h:18
static constexpr unsigned Dim
Definition Poisson.h:17
void mergeParameters(const ParameterList &params)
Definition Poisson.h:84
ParameterList params_m
Definition Poisson.h:120
grad_type * grad_mp
Definition Poisson.h:125
virtual void setDefaultParameters()
Definition Poisson.h:131
void setLhs(lhs_type &lhs)
Definition Poisson.h:90
Field< Matrix_t, Dim, Mesh, Centering > MField_t
Definition Poisson.h:21
FieldRHS rhs_type
Definition Poisson.h:25
FieldLHS::Centering_t Centering
Definition Poisson.h:19
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
rhs_type * rhs_mp
Definition Poisson.h:122
void updateParameter(const std::string &key, const T &value)
Definition Poisson.h:67
typename FieldLHS::value_type Tlhs
Definition Poisson.h:26
FieldLHS lhs_type
Definition Poisson.h:24
void add(const std::string &key, const T &value)