OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
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 
24 class PartBunch: public PartBunchBase<double, 3> {
25 
26 public:
28  enum { Dim = Dimension };
29 
30 public:
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 runTests();
45 
46  void initialize(FieldLayout_t *fLayout);
47 
48  void do_binaryRepart();
49 
50  double getRho(int x, int y, int z);
51 
52  /*
53 
54  Mesh and Field Layout related functions
55 
56  */
57 
58  // MATTHIAS CHECK
59  const Mesh_t &getMesh() const;
60 
61 // void setMesh(Mesh_t* mesh);
62 
63  // MATTHIAS CHECK
64  Mesh_t &getMesh();
65 
66 // void setFieldLayout(FieldLayout_t* fLayout);
67 
68  // MATTHIAS CHECK
70 
71  void setBCAllPeriodic();
72  void setBCAllOpen();
73 
74  void setBCForDCBeam();
75 
76  /*
77  Compatibility function push_back
78 
79  */
80 
82 
83  void computeSelfFields();
84 
86  void computeSelfFields(int b);
87 
88  void computeSelfFields_cycl(double gamma);
89  void computeSelfFields_cycl(int b);
90 
91  void resetInterpolationCache(bool clearCache = false);
92 
93  void swap(unsigned int i, unsigned int j);
94 
97 
100 
101  Inform &print(Inform &os);
102 
103 private:
104 
106 
107  void updateFields(const Vector_t& hr, const Vector_t& origin);
108 
110  void resizeMesh();
111 
115 
116 
118 
120 
121  //FIXME
123  return pbase_m->getLayout();
124  }
125 
126  //FIXME
128  return pbase_m->getLayout();
129  }
130 };
131 
132 
133 
134 inline
135 double PartBunch::getRho(int x, int y, int z) {
136  return rho_m[x][y][z].get();
137 }
138 
139 inline
140 const Mesh_t &PartBunch::getMesh() const {
141  const Layout_t* layout = static_cast<const Layout_t*>(&getLayout());
142  return layout->getLayout().getMesh();
143 }
144 
145 inline
147  Layout_t* layout = static_cast<Layout_t*>(&getLayout());
148  return layout->getLayout().getMesh();
149 }
150 
151 // inline
152 
153 inline Inform &operator<<(Inform &os, PartBunch &p) {
154  return p.print(os);
155 }
156 
157 #endif // OPAL_PartBunch_HH
Inform & operator<<(Inform &os, PartBunch &p)
Definition: PartBunch.h:153
std::shared_ptr< AbstractParticle< double, Dim > > pbase_m
std::pair< Vector_t, Vector_t > VectorPair_t
Definition: PartBunchBase.h:75
static const unsigned Dimension
Definition: PartBunchBase.h:77
void resetInterpolationCache(bool clearCache=false)
Definition: PartBunch.cpp:837
BConds< double, 3, Mesh_t, Center_t > bc_m
for defining the boundary conditions
Definition: PartBunch.h:113
double getRho(int x, int y, int z)
Definition: PartBunch.h:135
void computeSelfFields()
Definition: PartBunch.cpp:373
void runTests()
Definition: PartBunch.cpp:62
IpplParticleBase< Layout_t > pbase_t
Definition: PartBunch.h:27
const ParticleLayout< double, 3 > & getLayout() const
Definition: PartBunch.h:127
ParticleLayout< double, 3 > & getLayout()
Definition: PartBunch.h:122
void do_binaryRepart()
Definition: PartBunch.cpp:92
PartBunch & operator=(const PartBunch &)=delete
Field_t rho_m
scalar potential
Definition: PartBunch.h:96
PartBunch()=delete
void swap(unsigned int i, unsigned int j)
Definition: PartBunch.cpp:844
void initialize(FieldLayout_t *fLayout)
Definition: PartBunch.cpp:57
void setBCAllOpen()
Definition: PartBunch.cpp:773
bool interpolationCacheSet_m
Definition: PartBunch.h:117
Inform & print(Inform &os)
Definition: PartBunch.cpp:854
void updateDomainLength(Vektor< int, 3 > &grid)
Definition: PartBunch.cpp:806
void setBCForDCBeam()
Definition: PartBunch.cpp:783
FieldLayout_t & getFieldLayout()
Definition: PartBunch.cpp:749
VField_t eg_m
vector field on the grid
Definition: PartBunch.h:99
VectorPair_t getEExtrema()
Definition: PartBunch.cpp:827
void setBCAllPeriodic()
Definition: PartBunch.cpp:754
const Mesh_t & getMesh() const
Definition: PartBunch.h:140
PartBunch(const PartBunch &)=delete
ParticleAttrib< CacheDataCIC< double, 3U > > interpolationCache_m
Definition: PartBunch.h:119
void resizeMesh()
resize mesh to geometry specified
Definition: PartBunch.cpp:321
BConds< Vector_t, 3, Mesh_t, Center_t > vbc_m
Definition: PartBunch.h:114
void computeSelfFields_cycl(double gamma)
Calculates the self electric field from the charge density distribution for use in cyclotrons.
Definition: PartBunch.cpp:493
void updateFields(const Vector_t &hr, const Vector_t &origin)
Definition: PartBunch.cpp:813
Particle reference data.
Definition: PartData.h:35
Definition: BCond.h:199
RegionLayout< T, Dim, Mesh > & getLayout()
Definition: Inform.h:42