IPPL (Independent Parallel Particle Layer)
IPPL
Loading...
Searching...
No Matches
FFTPeriodicPoissonSolver.h
Go to the documentation of this file.
1//
2// Class FFTPeriodicPoissonSolver
3// Solves the periodic Poisson problem using Fourier transforms
4// cf. https://math.mit.edu/~stevenj/fft-deriv.pdf Algorithm 5
5//
6//
7
8#ifndef IPPL_FFT_PERIODIC_POISSON_SOLVER_H
9#define IPPL_FFT_PERIODIC_POISSON_SOLVER_H
10
11#include <Kokkos_MathematicalConstants.hpp>
12
13#include "Types/ViewTypes.h"
14
15#include "FFT/FFT.h"
17#include "Index/NDIndex.h"
18#include "Poisson.h"
19
20namespace ippl {
21
22 template <typename FieldLHS, typename FieldRHS>
23 class FFTPeriodicPoissonSolver : public Poisson<FieldLHS, FieldRHS> {
24 constexpr static unsigned Dim = FieldLHS::dim;
25 using Trhs = typename FieldRHS::value_type;
26 using mesh_type = typename FieldRHS::Mesh_t;
27
28 public:
29 using Field_t = FieldRHS;
31 using Complex_t = typename FFT_t::Complex_t;
32 using CxField_t = typename FFT_t::ComplexField;
35
37 using typename Base::lhs_type, typename Base::rhs_type;
38 using scalar_type = typename FieldLHS::Mesh_t::value_type;
39 using vector_type = typename FieldLHS::Mesh_t::vector_type;
40
42 : Base() {
43 using T = typename FieldLHS::value_type::value_type;
44 static_assert(std::is_floating_point<T>::value, "Not a floating point type");
45
47 }
48
50 : Base(lhs, rhs) {
51 using T = typename FieldLHS::value_type::value_type;
52 static_assert(std::is_floating_point<T>::value, "Not a floating point type");
53
55 }
56
57 //~FFTPeriodicPoissonSolver() {}
58
59 void setRhs(rhs_type& rhs) override;
60
61 void solve() override;
62
63 private:
64 void initialize();
65
66 std::shared_ptr<FFT_t> fft_mp;
70 std::shared_ptr<Layout_t> layoutComplex_mp;
71
72 protected:
73 virtual void setDefaultParameters() override {
74 using heffteBackend = typename FFT_t::heffteBackend;
75 heffte::plan_options opts = heffte::default_options<heffteBackend>();
76 this->params_m.add("use_pencils", opts.use_pencils);
77 this->params_m.add("use_reorder", opts.use_reorder);
78 this->params_m.add("use_gpu_aware", opts.use_gpu_aware);
79 this->params_m.add("r2c_direction", 0);
80
81 switch (opts.algorithm) {
82 case heffte::reshape_algorithm::alltoall:
83 this->params_m.add("comm", a2a);
84 break;
85 case heffte::reshape_algorithm::alltoallv:
86 this->params_m.add("comm", a2av);
87 break;
88 case heffte::reshape_algorithm::p2p:
89 this->params_m.add("comm", p2p);
90 break;
91 case heffte::reshape_algorithm::p2p_plined:
92 this->params_m.add("comm", p2p_pl);
93 break;
94 default:
95 throw IpplException("FFTPeriodicPoissonSolver::setDefaultParameters",
96 "Unrecognized heffte communication type");
97 }
98 }
99 };
100} // namespace ippl
101
103#endif
Definition Archive.h:20
@ p2p_pl
Definition FFT.h:59
@ a2av
Definition FFT.h:56
@ p2p
Definition FFT.h:58
@ a2a
Definition FFT.h:57
Poisson< FieldLHS, FieldRHS > Base
typename FieldLHS::Mesh_t::vector_type vector_type
virtual void setDefaultParameters() override
typename FieldRHS::value_type Trhs
void setRhs(rhs_type &rhs) override
std::shared_ptr< Layout_t > layoutComplex_mp
FFTPeriodicPoissonSolver(lhs_type &lhs, rhs_type &rhs)
typename FFT_t::ComplexField CxField_t
typename FieldLHS::Mesh_t::value_type scalar_type
FFT< RCTransform, FieldRHS > FFT_t
ParameterList params_m
Definition Poisson.h:120
FieldRHS rhs_type
Definition Poisson.h:25
FieldLHS lhs_type
Definition Poisson.h:24