OPAL (Object Oriented Parallel Accelerator Library) 2024.2
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
27class AmrPartBunch: public PartBunchBase<double, 3> {
28
29public:
31
32public:
33 AmrPartBunch(const PartData* ref);
34
35 AmrPartBunch(const PartData* ref, pbase_t* pbase_p);
36
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
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
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() {}
132
133
134private:
136
138
139 void updateFields(const Vector_t& hr, const Vector_t& origin);
140
141private:
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
BoxLibParticle< AmrLayout_t > AmrParticle_t
Definition PBunchDefs.h:38
CenteredFieldLayout< 3, Mesh_t, Center_t > FieldLayout_t
Definition PBunchDefs.h:28
PartBunchBase(AbstractParticle< double, Dim > *pb, const PartData *ref)
std::pair< Vector_t, Vector_t > VectorPair_t
virtual void setSolver(FieldSolver *fs)
void computeSelfFields_cycl(double gamma)
const AmrObject * getAmrObject() const
void setBCAllOpen()
void updateDomainLength(Vektor< int, 3 > &grid)
virtual void setBinCharge(int)
void initialize(FieldLayout_t *fLayout)
void updateLorentzFactor(int bin=0)
void computeSelfFields()
AmrPartBunch(const PartData *ref)
void setSolver(FieldSolver *fs)
const PoissonSolver * getFieldSolver() const
VectorPair_t getEExtrema()
FieldLayout_t * fieldlayout_m
void set_meshEnlargement(double dh)
void setBaseLevelMeshSpacing(const Vector_t &hr)
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.
Vector_t get_hr() const
pbase_t * amrpbase_mp
PoissonSolver * getFieldSolver()
AmrObject * amrobj_mp
std::unique_ptr< size_t[]> globalPartPerLevel_m
void gatherLevelStatistics()
AmrParticle_t pbase_t
void setBCAllPeriodic()
void updateFieldContainers_m()
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()
Vektor< double, 3 > Vector_t