OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
AmrPartBunch.h
Go to the documentation of this file.
1 //
2 // Class AmrPartBunch
3 // This class is used to represent a bunch in AMR mode.
4 //
5 // Copyright (c) 2017 - 2019, Matthias Frey, Paul Scherrer Institut, Villigen PSI, Switzerland
6 // All rights reserved
7 //
8 // Implemented as part of the PhD thesis
9 // "Precise Simulations of Multibunches in High Intensity Cyclotrons"
10 //
11 // This file is part of OPAL.
12 //
13 // OPAL is free software: you can redistribute it and/or modify
14 // it under the terms of the GNU General Public License as published by
15 // the Free Software Foundation, either version 3 of the License, or
16 // (at your option) any later version.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with OPAL. If not, see <https://www.gnu.org/licenses/>.
20 //
21 #ifndef AMR_PART_BUNCH_H
22 #define AMR_PART_BUNCH_H
23 
25 #include "Amr/AmrObject.h"
26 
27 class AmrPartBunch : public PartBunchBase<double, 3>
28 {
29 public:
31 
32 public:
33 
34  AmrPartBunch(const PartData *ref);
35 
36  AmrPartBunch(const PartData *ref, pbase_t* pbase_p);
37 
38  ~AmrPartBunch();
39 
41 
42  const pbase_t *getAmrParticleBase() const;
43 
44  void initialize(FieldLayout_t *fLayout);
45 
46  // does actually another repartition
47  void do_binaryRepart();
48 
49  Vector_t get_hr() const;
50 
51  void set_meshEnlargement(double dh);
52 
54 
55  double getRho(int x, int y, int z);
56 
58 
59 
60  void boundp();
61 
62  void computeSelfFields();
63 
64  void computeSelfFields(int bin);
65 
66  void computeSelfFields_cycl(double gamma);
67 
68  void computeSelfFields_cycl(int bin);
69 
72  this->amrobj_mp = fs->getAmrObject();
73  }
74 
75  virtual void setBinCharge(int /*bin*/, double /*q*/) { };
76  virtual void setBinCharge(int /*bin*/) { };
77 
78  /*
79  * AmrPartBunch only
80  */
81 
82  const AmrObject* getAmrObject() const {
83  return this->amrobj_mp;
84  }
85 
87  return fs_m->solver_m;
88  }
89 
90  const PoissonSolver *getFieldSolver() const {
91  return fs_m->solver_m;
92  }
93 
95  for (int i = 0; i < 3; ++i)
96  hr_m[i] = hr[i];
97  }
98 
103  void setAmrDomainRatio(const std::vector<double>& ratio);
104 
105  void gatherLevelStatistics();
106 
111  const size_t& getLevelStatistics(int l) const;
112 
113 
120  void updateLorentzFactor(int bin=0);
121 
129  void updateLorentzFactor(double gamma);
130 
131  //FIXME BCs
133  void setBCAllOpen() {}
134  void setBCForDCBeam() {}
135 
136 
137 private:
139 
141 
142  void updateFields(const Vector_t& hr, const Vector_t& origin);
143 
144 private:
145 
146  /* pointer to AMR object that is part
147  * of solver_m (AmrPoissonSolver) in src/Structure/FieldSolver.h
148  */
151 
152  /* We need this due to H5PartWrapper etc, but it's always nullptr.
153  * Thus, don't use it.
154  */
156 
157  std::unique_ptr<size_t[]> globalPartPerLevel_m;
158 };
159 
160 #endif
FRONT * fs
Definition: hypervolume.cpp:59
FieldSolver * fs_m
stores the used field solver
std::pair< Vector_t, Vector_t > VectorPair_t
Definition: PartBunchBase.h:75
Vector_t hr_m
meshspacing of cartesian mesh
virtual void setSolver(FieldSolver *fs)
void computeSelfFields_cycl(double gamma)
void setBCAllOpen()
Definition: AmrPartBunch.h:133
void updateDomainLength(Vektor< int, 3 > &grid)
const AmrObject * getAmrObject() const
Definition: AmrPartBunch.h:82
virtual void setBinCharge(int)
Set the charge of all other the ones in bin to zero.
Definition: AmrPartBunch.h:76
void initialize(FieldLayout_t *fLayout)
void updateLorentzFactor(int bin=0)
void computeSelfFields()
AmrPartBunch(const PartData *ref)
const PoissonSolver * getFieldSolver() const
Definition: AmrPartBunch.h:90
void setSolver(FieldSolver *fs)
Definition: AmrPartBunch.h:70
VectorPair_t getEExtrema()
FieldLayout_t * fieldlayout_m
Definition: AmrPartBunch.h:155
void set_meshEnlargement(double dh)
void setBaseLevelMeshSpacing(const Vector_t &hr)
Definition: AmrPartBunch.h:94
void do_binaryRepart()
const size_t & getLevelStatistics(int l) const
virtual void setBinCharge(int, double)
Set the charge of one bin to the value of q and all other to zero.
Definition: AmrPartBunch.h:75
Vector_t get_hr() const
pbase_t * amrpbase_mp
Definition: AmrPartBunch.h:150
AmrObject * amrobj_mp
Definition: AmrPartBunch.h:149
std::unique_ptr< size_t[]> globalPartPerLevel_m
Definition: AmrPartBunch.h:157
void gatherLevelStatistics()
AmrParticle_t pbase_t
Definition: AmrPartBunch.h:30
void setBCAllPeriodic()
Definition: AmrPartBunch.h:132
void updateFieldContainers_m()
PoissonSolver * getFieldSolver()
Definition: AmrPartBunch.h:86
void setAmrDomainRatio(const std::vector< double > &ratio)
void updateFields(const Vector_t &hr, const Vector_t &origin)
pbase_t * getAmrParticleBase()
double getRho(int x, int y, int z)
FieldLayout_t & getFieldLayout()
void setBCForDCBeam()
Definition: AmrPartBunch.h:134
Particle reference data.
Definition: PartData.h:35
The FieldSolver definition.
Definition: FieldSolver.h:43
PoissonSolver * solver_m
the actual solver, should be a base object
Definition: FieldSolver.h:114
AmrObject * getAmrObject()
Definition: FieldSolver.h:104