OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
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.
5 //
6 // Copyright (c) 2016, Benjamin Ulmer, ETH Zürich
7 // All rights reserved
8 //
9 // Implemented as part of the Master thesis
10 // "The P3M Model on Emerging Computer Architectures With Application to Microbunching"
11 // (http://amas.web.psi.ch/people/aadelmann/ETH-Accel-Lecture-1/projectscompleted/cse/thesisBUlmer.pdf)
12 //
13 // This file is part of OPAL.
14 //
15 // OPAL is free software: you can redistribute it and/or modify
16 // it under the terms of the GNU General Public License as published by
17 // the Free Software Foundation, either version 3 of the License, or
18 // (at your option) any later version.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with OPAL. If not, see <https://www.gnu.org/licenses/>.
22 //
23 #ifndef P3M_POISSON_SOLVER_H_
24 #define P3M_POISSON_SOLVER_H_
25 const unsigned Dim = 3;
26 
27 #ifdef dontOPTIMIZE_FIELD_ASSIGNMENT
28 #define FIELDASSIGNOPTIMIZATION __attribute__((optimize(0)))
29 #else
30 #define FIELDASSIGNOPTIMIZATION
31 #endif
32 
33 #include <memory>
35 #include "PoissonSolver.h"
36 
37 #include "FFT/FFT.h"
38 
39 //#include "Algorithms/PartBunchBase.h"
40 
41 template <class T, unsigned Dim>
42 class PartBunchBase;
43 
45 
47 public:
48 
50 
51  // constructor and destructor
52  P3MPoissonSolver(Mesh_t *mesh, FieldLayout_t *fl, double interaction_radius, double alpha, double eps);
53 
55 
56  void initFields();
57 
58  void calculateGridForces(PartBunchBase<double, 3> *bunch, double interaction_radius, double alpha, double eps);
59 
60  void calculatePairForces(PartBunchBase<double, 3> *bunch, double interaction_radius, double alpha, double eps);
61 
62  // given a charge-density field rho and a set of mesh spacings hr,
63  // compute the scalar potential with image charges at -z
64  void computePotential(Field_t &rho, Vector_t hr, double zshift);
65 
66  // given a charge-density field rho and a set of mesh spacings hr,
67  // compute the scalar potential in open space
68  void computePotential(Field_t &rho, Vector_t hr);
69 
70  void applyConstantFocusing(PartBunchBase<double, 3> *bunch, double f, double r);
71  void test(PartBunchBase<double, 3> *bunch);
72 
73  double getXRangeMin(unsigned short /*level*/) {return 1.0;}
74  double getXRangeMax(unsigned short /*level*/) {return 1.0;}
75  double getYRangeMin(unsigned short /*level*/) {return 1.0;}
76  double getYRangeMax(unsigned short /*level*/) {return 1.0;}
77  double getZRangeMin(unsigned short /*level*/) {return 1.0;}
78  double getZRangeMax(unsigned short /*level*/) {return 1.0;}
79 
82  Inform &print(Inform &os) const;
83 private:
84 
88 
89  // rho_m is the charge-density field with mesh doubled in each dimension
92 
94 
95  // real field with layout of complex field: domain3_m
97 
100 
101  // grntr_m is the Fourier transformed Green's function
102  // domain3_m and mesh3_ are used
104 
105  // the FFT object
106  std::unique_ptr<FFTC_t> fft_m;
107 
108 
109  // Fields used to eliminate excess calculation in greensFunction()
110  // mesh2_m and layout2_m are used
112 
113 
114  // mesh and layout objects for rho_m
117 
118 
119  // tmp
121 
122  // domains for the various fields
123  NDIndex<3> domain_m; // original domain, gridsize
124  // mesh and gridsize defined outside of P3M class, given as
125 
126 
128 
129 
131  double alpha_m;
132  double eps_m;
133 
136 
137  // for tests
139  double globSumEf_m[Dim];
140 
141 
142 public:
145 
146 
147 };
148 
150  return fs.print(os);
151 }
152 
153 
154 
155 #endif
Inform & operator<<(Inform &os, const P3MPoissonSolver &fs)
const unsigned Dim
constexpr double alpha
The fine structure constant, no dimension.
Definition: Physics.h:78
FRONT * fs
Definition: hypervolume.cpp:59
Vektor< double, 3 > extend_l
BConds< Vector_t, Dim, Mesh_t, Center_t > vbc_m
double getYRangeMax(unsigned short)
Vektor< int, 3 > nr_m
double getXRangeMax(unsigned short)
void compute_temperature(PartBunchBase< double, 3 > *bunch)
void test(PartBunchBase< double, 3 > *bunch)
BConds< double, Dim, Mesh_t, Center_t > bc_m
BConds< double, Dim, Mesh_t, Center_t > bcp_m
NDIndex< 3 > domain_m
void calculatePairForces(PartBunchBase< double, 3 > *bunch, double interaction_radius, double alpha, double eps)
void applyConstantFocusing(PartBunchBase< double, 3 > *bunch, double f, double r)
double getYRangeMin(unsigned short)
double globSumEf_m[Dim]
Vektor< double, 3 > extend_r
NDIndex< 3 > domainP3MConstruct_m
void calculateGridForces(PartBunchBase< double, 3 > *bunch, double interaction_radius, double alpha, double eps)
double getZRangeMax(unsigned short)
Vektor< double, Dim > avgEF_m
std::unique_ptr< FFTC_t > fft_m
IField_t grnIField_m[3]
Inform & print(Inform &os) const
double getXRangeMin(unsigned short)
double getZRangeMin(unsigned short)
void computePotential(Field_t &rho, Vector_t hr, double zshift)
FFT< CCTransform, 3, double > FFTC_t
FieldLayout_t * layout_m
void computeAvgSpaceChargeForces(PartBunchBase< double, 3 > *bunch)
P3MPoissonSolver(Mesh_t *mesh, FieldLayout_t *fl, double interaction_radius, double alpha, double eps)
Definition: FFT.h:48
Definition: BCond.h:199
Definition: Inform.h:42