OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
PartBunch.h
Go to the documentation of this file.
1//
2// Class PartBunch
3// Particle Bunch.
4// A representation of a particle bunch as a vector of particles.
5//
6// Copyright (c) 2008 - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland
7// All rights reserved
8//
9// This file is part of OPAL.
10//
11// OPAL is free software: you can redistribute it and/or modify
12// it under the terms of the GNU General Public License as published by
13// the Free Software Foundation, either version 3 of the License, or
14// (at your option) any later version.
15//
16// You should have received a copy of the GNU General Public License
17// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
18//
19#ifndef OPAL_PartBunch_HH
20#define OPAL_PartBunch_HH
21
23
24class PartBunch: public PartBunchBase<double, 3> {
25
26public:
28 enum { Dim = Dimension };
29
30public:
31
33 // Construct empty bunch.
34 explicit PartBunch(const PartData *ref);
35
36 PartBunch() = delete;
37 PartBunch(const PartBunch &) = delete;
38 PartBunch &operator=(const PartBunch &) = delete;
39
40 ~PartBunch();
41
42// pbase_t* clone();
43
44 void initialize(FieldLayout_t *fLayout);
45
46 void do_binaryRepart();
47
48 double getRho(int x, int y, int z);
49
50 /*
51
52 Mesh and Field Layout related functions
53
54 */
55
56 // MATTHIAS CHECK
57 const Mesh_t &getMesh() const;
58
59// void setMesh(Mesh_t* mesh);
60
61 // MATTHIAS CHECK
62 Mesh_t &getMesh();
63
64// void setFieldLayout(FieldLayout_t* fLayout);
65
66 // MATTHIAS CHECK
68
69 void setBCAllPeriodic();
70 void setBCAllOpen();
71
72 void setBCForDCBeam();
73
74 /*
75 Compatibility function push_back
76
77 */
78
80
81 void computeSelfFields();
82
84 void computeSelfFields(int b);
85
86 void computeSelfFields_cycl(double gamma);
87 void computeSelfFields_cycl(int b);
88
89 void resetInterpolationCache(bool clearCache = false);
90
91 void swap(unsigned int i, unsigned int j);
92
95
98
99 Inform &print(Inform &os);
100
101private:
102
104
105 void updateFields(const Vector_t& hr, const Vector_t& origin);
106
108 void resizeMesh();
109
113
114
116
118
119 //FIXME
121 return pbase_m->getLayout();
122 }
123
124 //FIXME
126 return pbase_m->getLayout();
127 }
128};
129
130
131
132inline
133double PartBunch::getRho(int x, int y, int z) {
134 return rho_m[x][y][z].get();
135}
136
137inline
139 const Layout_t* layout = static_cast<const Layout_t*>(&getLayout());
140 return layout->getLayout().getMesh();
141}
142
143inline
145 Layout_t* layout = static_cast<Layout_t*>(&getLayout());
146 return layout->getLayout().getMesh();
147}
148
149// inline
150
152 return p.print(os);
153}
154
155#endif // OPAL_PartBunch_HH
Inform & operator<<(Inform &os, PartBunch &p)
Definition: PartBunch.h:151
std::shared_ptr< AbstractParticle< double, Dim > > pbase_m
std::pair< Vector_t, Vector_t > VectorPair_t
Definition: PartBunchBase.h:57
static const unsigned Dimension
Definition: PartBunchBase.h:59
void resetInterpolationCache(bool clearCache=false)
Definition: PartBunch.cpp:848
BConds< double, 3, Mesh_t, Center_t > bc_m
for defining the boundary conditions
Definition: PartBunch.h:111
double getRho(int x, int y, int z)
Definition: PartBunch.h:133
void computeSelfFields()
Definition: PartBunch.cpp:349
PartBunch & operator=(const PartBunch &)=delete
IpplParticleBase< Layout_t > pbase_t
Definition: PartBunch.h:27
void do_binaryRepart()
Definition: PartBunch.cpp:63
Field_t rho_m
scalar potential
Definition: PartBunch.h:94
PartBunch()=delete
void swap(unsigned int i, unsigned int j)
Definition: PartBunch.cpp:855
const ParticleLayout< double, 3 > & getLayout() const
Definition: PartBunch.h:125
ParticleLayout< double, 3 > & getLayout()
Definition: PartBunch.h:120
void initialize(FieldLayout_t *fLayout)
Definition: PartBunch.cpp:57
void setBCAllOpen()
Definition: PartBunch.cpp:784
bool interpolationCacheSet_m
Definition: PartBunch.h:115
Inform & print(Inform &os)
Definition: PartBunch.cpp:865
void updateDomainLength(Vektor< int, 3 > &grid)
Definition: PartBunch.cpp:817
void setBCForDCBeam()
Definition: PartBunch.cpp:794
FieldLayout_t & getFieldLayout()
Definition: PartBunch.cpp:760
VField_t eg_m
vector field on the grid
Definition: PartBunch.h:97
VectorPair_t getEExtrema()
Definition: PartBunch.cpp:838
void setBCAllPeriodic()
Definition: PartBunch.cpp:765
const Mesh_t & getMesh() const
Definition: PartBunch.h:138
PartBunch(const PartBunch &)=delete
ParticleAttrib< CacheDataCIC< double, 3U > > interpolationCache_m
Definition: PartBunch.h:117
void resizeMesh()
resize mesh to geometry specified
Definition: PartBunch.cpp:297
BConds< Vector_t, 3, Mesh_t, Center_t > vbc_m
Definition: PartBunch.h:112
void computeSelfFields_cycl(double gamma)
Calculates the self electric field from the charge density distribution for use in cyclotrons.
Definition: PartBunch.cpp:481
void updateFields(const Vector_t &hr, const Vector_t &origin)
Definition: PartBunch.cpp:824
Particle reference data.
Definition: PartData.h:35
Definition: BCond.h:199
RegionLayout< T, Dim, Mesh > & getLayout()
Definition: Inform.h:42