OPAL (Object Oriented Parallel Accelerator Library)  2024.1
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  AmrPartBunch(const PartData* ref);
34 
35  AmrPartBunch(const PartData* ref, pbase_t* pbase_p);
36 
37  ~AmrPartBunch();
38 
40 
41  const pbase_t *getAmrParticleBase() const;
42 
43  void initialize(FieldLayout_t *fLayout);
44 
45  // does actually another repartition
46  void do_binaryRepart();
47 
48  Vector_t get_hr() const;
49 
50  void set_meshEnlargement(double dh);
51 
53 
54  double getRho(int x, int y, int z);
55 
57 
58  void boundp();
59 
60  void computeSelfFields();
61 
62  void computeSelfFields(int bin);
63 
64  void computeSelfFields_cycl(double gamma);
65 
66  void computeSelfFields_cycl(int bin);
67 
70  this->amrobj_mp = fs->getAmrObject();
71  }
72 
73  virtual void setBinCharge(int /*bin*/, double /*q*/) { };
74  virtual void setBinCharge(int /*bin*/) { };
75 
76  /*
77  * AmrPartBunch only
78  */
79 
80  const AmrObject* getAmrObject() const {
81  return this->amrobj_mp;
82  }
83 
85  return fs_m->solver_m;
86  }
87 
88  const PoissonSolver *getFieldSolver() const {
89  return fs_m->solver_m;
90  }
91 
93  for (int i = 0; i < 3; ++i)
94  hr_m[i] = hr[i];
95  }
96 
101  void setAmrDomainRatio(const std::vector<double>& ratio);
102 
103  void gatherLevelStatistics();
104 
109  const size_t& getLevelStatistics(int l) const;
110 
117  void updateLorentzFactor(int bin=0);
118 
126  void updateLorentzFactor(double gamma);
127 
128  //FIXME BCs
130  void setBCAllOpen() {}
131  void setBCForDCBeam() {}
132 
133 
134 private:
136 
138 
139  void updateFields(const Vector_t& hr, const Vector_t& origin);
140 
141 private:
142  /* pointer to AMR object that is part
143  * of solver_m (AmrPoissonSolver) in src/Structure/FieldSolver.h
144  */
147 
148  /* We need this due to H5PartWrapper etc, but it's always nullptr.
149  * Thus, don't use it.
150  */
152 
153  std::unique_ptr<size_t[]> globalPartPerLevel_m;
154 };
155 
156 #endif
Vector_t get_hr() const
std::unique_ptr< size_t[]> globalPartPerLevel_m
Definition: AmrPartBunch.h:153
void updateFields(const Vector_t &hr, const Vector_t &origin)
AmrObject * getAmrObject()
Definition: FieldSolver.h:114
Vector_t hr_m
meshspacing of cartesian mesh
double getRho(int x, int y, int z)
void setBCAllOpen()
Definition: AmrPartBunch.h:130
void updateDomainLength(Vektor< int, 3 > &grid)
pbase_t * getAmrParticleBase()
AmrPartBunch(const PartData *ref)
const PoissonSolver * getFieldSolver() const
Definition: AmrPartBunch.h:88
void setBCForDCBeam()
Definition: AmrPartBunch.h:131
FieldLayout_t & getFieldLayout()
PoissonSolver * getFieldSolver()
Definition: AmrPartBunch.h:84
FieldLayout_t * fieldlayout_m
Definition: AmrPartBunch.h:151
const size_t & getLevelStatistics(int l) const
virtual void setBinCharge(int)
Set the charge of all other the ones in bin to zero.
Definition: AmrPartBunch.h:74
FRONT * fs
Definition: hypervolume.cpp:59
VectorPair_t getEExtrema()
FieldSolver * fs_m
stores the used field solver
AmrParticle_t pbase_t
Definition: AmrPartBunch.h:30
void setSolver(FieldSolver *fs)
Definition: AmrPartBunch.h:68
void computeSelfFields_cycl(double gamma)
void updateLorentzFactor(int bin=0)
virtual void setBinCharge(int, double)
Set the charge of one bin to the value of q and all other to zero.
Definition: AmrPartBunch.h:73
void initialize(FieldLayout_t *fLayout)
AmrObject * amrobj_mp
Definition: AmrPartBunch.h:145
void setAmrDomainRatio(const std::vector< double > &ratio)
void do_binaryRepart()
const AmrObject * getAmrObject() const
Definition: AmrPartBunch.h:80
std::pair< Vector_t, Vector_t > VectorPair_t
Definition: PartBunchBase.h:57
PoissonSolver * solver_m
the actual solver, should be a base object
Definition: FieldSolver.h:124
void set_meshEnlargement(double dh)
void setBCAllPeriodic()
Definition: AmrPartBunch.h:129
void updateFieldContainers_m()
void gatherLevelStatistics()
void computeSelfFields()
virtual void setSolver(FieldSolver *fs)
pbase_t * amrpbase_mp
Definition: AmrPartBunch.h:146
void setBaseLevelMeshSpacing(const Vector_t &hr)
Definition: AmrPartBunch.h:92