OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
P3MPoissonSolver.h
Go to the documentation of this file.
1//
2// Class P3MPoissonSolver
3// This class contains methods for solving Poisson's equation for the
4// space charge portion of the calculation including collisions.
5//
6// Copyright (c) 2016, Benjamin Ulmer, ETH Zürich
7// 2022, Sriramkrishnan Muralikrishnan, PSI
8// All rights reserved
9//
10// Implemented as part of the Master thesis
11// "The P3M Model on Emerging Computer Architectures With Application to Microbunching"
12// (http://amas.web.psi.ch/people/aadelmann/ETH-Accel-Lecture-1/projectscompleted/cse/thesisBUlmer.pdf)
13//
14// This file is part of OPAL.
15//
16// OPAL is free software: you can redistribute it and/or modify
17// it under the terms of the GNU General Public License as published by
18// the Free Software Foundation, either version 3 of the License, or
19// (at your option) any later version.
20//
21// You should have received a copy of the GNU General Public License
22// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
23//
24#ifndef P3M_POISSON_SOLVER_H_
25#define P3M_POISSON_SOLVER_H_
26const unsigned Dim = 3;
27
28#ifdef dontOPTIMIZE_FIELD_ASSIGNMENT
29#define FIELDASSIGNOPTIMIZATION __attribute__((optimize(0)))
30#else
31#define FIELDASSIGNOPTIMIZATION
32#endif
33
35#include "PoissonSolver.h"
36
37#include "FFT/FFT.h"
38
39#include <memory>
40
41//#include "Algorithms/PartBunchBase.h"
42
43template <class T, unsigned Dim>
44class PartBunchBase;
45
47
49public:
50
52
53 // constructor and destructor
55 double interaction_radius,
56 double alpha,
57 std::string greensFunction);
58
60
61 void initializeFields();
62
63 void calculatePairForces(PartBunchBase<double, 3> *bunch, double gammaz) override;
64
65 // given a charge-density field rho and a set of mesh spacings hr,
66 // compute the scalar potential in open space
67 void computePotential(Field_t &rho, Vector_t hr) override;
68
69 // given a charge-density field rho and a set of mesh spacings hr,
70 // compute the scalar potential with image charges at -z
71 void computePotential(Field_t &rho, Vector_t hr, double zshift) override;
72
73 void greensFunction();
74
76
77 void mirrorRhoField();
78
79 void test(PartBunchBase<double, 3> */*bunch*/) override {};
80
81 double getXRangeMin(unsigned short /*level*/) override {return 1.0;}
82 double getXRangeMax(unsigned short /*level*/) override {return 1.0;}
83 double getYRangeMin(unsigned short /*level*/) override {return 1.0;}
84 double getYRangeMax(unsigned short /*level*/) override {return 1.0;}
85 double getZRangeMin(unsigned short /*level*/) override {return 1.0;}
86 double getZRangeMax(unsigned short /*level*/) override {return 1.0;}
87 double getinteractionRadius() const override {return interaction_radius_m;}
88
89 Inform &print(Inform &os) const;
90
91private:
92 // original charge density
94 // rho2_m is the charge-density field with mesh doubled in each dimension
96
97 // rho2tr_m is the Fourier transformed charge-density field
98 // domain3_m and mesh3_mp are used
100
101 // Fields used to eliminate excess calculation in greensFunction()
102 // mesh2_mp and layout2_mp are used
104
105 // grntr_m is the Fourier transformed Green's function
106 // domain3_m and mesh3_mp are used
108
109 // the FFT object
110 std::unique_ptr<FFT_t> fft_mp;
111
112 // mesh and layout objects for rho_m
115
116 // mesh and layout objects for rho2_m
117 std::unique_ptr<Mesh_t> mesh2_mp;
118 std::unique_ptr<FieldLayout_t> layout2_mp;
119
120 std::unique_ptr<Mesh_t> mesh3_mp;
121 std::unique_ptr<FieldLayout_t> layout3_mp;
122
123 // mesh and layout for integrated greens function
124 std::unique_ptr<Mesh_t> mesh4_mp;
125 std::unique_ptr<FieldLayout_t> layout4_mp;
126
127 // tmp
129
130 // domains for the various fields
131 NDIndex<3> domain_m; // original domain, gridsize
132 NDIndex<3> domain2_m; // doubled gridsize (2*Nx,2*Ny,2*Nz)
133 NDIndex<3> domain3_m; // field for the complex values of the RC transformation
134 NDIndex<3> domain4_m; // domain for tmp in integrated Greens function
135 NDIndex<3> domainFFTConstruct_m; // domain for output of FFT
136
138 double alpha_m;
139
142 double ke_m;
143
145
149
150};
151
153 return fs.print(os);
154}
155
156
157
158#endif
const unsigned Dim
Inform & operator<<(Inform &os, const P3MPoissonSolver &fs)
constexpr double alpha
The fine structure constant, no dimension.
Definition: Physics.h:72
FRONT * fs
Definition: hypervolume.cpp:59
double getXRangeMin(unsigned short) override
void calculatePairForces(PartBunchBase< double, 3 > *bunch, double gammaz) override
IpplTimings::TimerRef CalculatePairForces_m
double getXRangeMax(unsigned short) override
double getinteractionRadius() const override
Vektor< int, 3 > nr_m
IpplTimings::TimerRef ComputePotential_m
void test(PartBunchBase< double, 3 > *) override
double getYRangeMin(unsigned short) override
NDIndex< 3 > domain2_m
std::unique_ptr< FieldLayout_t > layout4_mp
double getZRangeMin(unsigned short) override
FieldLayout_t * layout_mp
NDIndex< 3 > domain_m
std::unique_ptr< Mesh_t > mesh4_mp
std::unique_ptr< Mesh_t > mesh3_mp
std::unique_ptr< FFT_t > fft_mp
NDIndex< 3 > domain3_m
double getYRangeMax(unsigned short) override
void computePotential(Field_t &rho, Vector_t hr) override
NDIndex< 3 > domain4_m
IpplTimings::TimerRef GreensFunctionTimer_m
std::unique_ptr< FieldLayout_t > layout2_mp
IField_t grnIField_m[3]
FFT< RCTransform, 3, double > FFT_t
Inform & print(Inform &os) const
NDIndex< 3 > domainFFTConstruct_m
std::unique_ptr< FieldLayout_t > layout3_mp
double getZRangeMax(unsigned short) override
std::unique_ptr< Mesh_t > mesh2_mp
P3MPoissonSolver(Mesh_t *mesh, FieldLayout_t *fl, double interaction_radius, double alpha, std::string greensFunction)
Definition: FFT.h:48
Definition: Inform.h:42
Timing::TimerRef TimerRef
Definition: IpplTimings.h:176