OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
Component.h
Go to the documentation of this file.
1
12#ifndef OPALX_Component_HH
13#define OPALX_Component_HH
14
16#include "Fields/EMField.h"
17#include "OPALTypes.h"
18
19#include <memory>
20
22
23class PartData;
24
25template <class T, int N>
26class FVps;
27
28struct Point {
29 double x;
30 double y;
31};
32
33class Component : public ElementBase {
34public:
35 /* ============================== Constructors ============================== */
36 explicit Component(const std::string& name);
37 Component();
38 Component(const Component& right);
39 virtual ~Component();
40 /* ========================================================================== */
41 /* ============================== Field Functions =========================== */
43 // The representation of the electro-magnetic field of the component
44 // (version for non-constant object).
45 virtual EMField& getField() = 0;
46
48 // The representation of the electro-magnetic field of the component
49 // (version for constant object).
50 virtual const EMField& getField() const = 0;
51
53 // Return the value of the time-independent part of the electric
54 // field at point [b]P[/b].
55 EVector Efield(const Point3D& P) const;
56
58 // Return the value of the time-independent part of the magnetic
59 // field at point [b]P[/b].
60 BVector Bfield(const Point3D& P) const;
61
63 // Return the value of the time-dependent part of the electric
64 // field at point [b]P[/b] for time [b]t[/b].
65 EVector Efield(const Point3D& P, double t) const;
66
68 // Return the value of the time-dependent part of the magnetic
69 // field at point [b]P[/b] for time [b]t[/b].
70 BVector Bfield(const Point3D& P, double t) const;
71
73 // Return the value of the time-independent part of both electric
74 // and magnetic fields at point [b]P[/b].
75 EBVectors EBfield(const Point3D& P) const;
76
78 // Return the value of the time-dependent part of both electric
79 // and magnetic fields at point [b]P[/b] for time [b]t[/b].
80 EBVectors EBfield(const Point3D& P, double t) const;
81 /* ========================================================================== */
82 /* ============================== Apply Functions =========================== */
94 virtual bool apply(const std::shared_ptr<ParticleContainer_t>& pc);
95
106 virtual bool apply(
107 const size_t& i, const double& t, Vector_t<double, 3>& E, Vector_t<double, 3>& B);
108
120 virtual bool apply(
121 const Vector_t<double, 3>& R, const Vector_t<double, 3>& P, const double& t,
123
135 virtual bool applyToReferenceParticle(
136 const Vector_t<double, 3>& R, const Vector_t<double, 3>& P, const double& t,
138
139 /* ========================================================================== */
140 /* ============================== Functions ================================= */
155 virtual bool getPotential(
156 const Vector_t<double, 3>& /*R*/, const double& /*t*/, Vector_t<double, 3>& /*A*/,
157 double& /*phi*/) {
158 return false;
159 }
160
161 // Design energy for components such as RF-cavities
162 virtual double getDesignEnergy() const;
163 virtual void setDesignEnergy(const double& energy, bool changeable = true);
164
165 // Setup
166 virtual void initialise(PartBunch_t* bunch, double& startField, double& endField) = 0;
167
168 // Clean-up
169 virtual void finalise() = 0;
170
171 // Does the component bend?
172 virtual bool bends() const = 0;
173
174 // Read & free fieldmaps
175 virtual void goOnline(const double& kineticEnergy);
176 virtual void goOffline();
177
178 // Is the component online (been initialised)?
179 virtual bool Online();
180
192 virtual void getFieldExtend(double& zBegin, double& zEnd) const = 0;
193
194 // Gets the element type defined in ElementBase
195 virtual ElementType getType() const;
196
198 // If this method returns a pointer to this component.
199 // The default version returns ``this''.
200 virtual const ElementBase& getDesign() const;
201
209 virtual void trackBunch(PartBunch_t& bunch, const PartData&, bool revBeam, bool revTrack) const;
210
212 // This catch-all method implements a hook for tracking a transfer
213 // map through a non-standard component.
214 // The default version throws a LogicalError.
215 virtual void trackMap(FVps<double, 6>& map, const PartData&, bool revBeam, bool revTrack) const;
216
217 void setExitFaceSlope(const double&);
218 /* ========================================================================== */
219protected:
220 // Aperture - Needs to be changed to Kokkos::View
221 static const std::vector<double> defaultAperture_m;
223
224 // The reference bunch
227};
228
229// Inline access functions to fields.
230// ------------------------------------------------------------------------
231
232inline EVector Component::Efield(const Point3D& P) const { return getField().Efield(P); }
233
234inline BVector Component::Bfield(const Point3D& P) const { return getField().Bfield(P); }
235
236inline EVector Component::Efield(const Point3D& P, double t) const {
237 return getField().Efield(P, t);
238}
239
240inline BVector Component::Bfield(const Point3D& P, double t) const {
241 return getField().Bfield(P, t);
242}
243
244inline EBVectors Component::EBfield(const Point3D& P) const { return getField().EBfield(P); }
245
246inline EBVectors Component::EBfield(const Point3D& P, double t) const {
247 return getField().EBfield(P, t);
248}
249
250inline void Component::setExitFaceSlope(const double& m) { exit_face_slope_m = m; }
251
252inline void Component::setDesignEnergy(const double& /*energy*/, bool /*changeable*/) { return; }
253
254inline double Component::getDesignEnergy() const { return -1.0; }
255
256#endif // OPALX_Component_HH
double x
Definition Component.h:29
double y
Definition Component.h:30
ippl::Vector< T, Dim > Vector_t
ElementType
Definition ElementBase.h:94
A magnetic field vector.
Definition EMField.h:88
BVector Bfield(const Point3D &P) const
Return the field in a point.
Definition Component.h:234
virtual ElementType getType() const
Get element type std::string.
Definition Component.cpp:49
virtual bool applyToReferenceParticle(const Vector_t< double, 3 > &R, const Vector_t< double, 3 > &P, const double &t, Vector_t< double, 3 > &E, Vector_t< double, 3 > &B)
Apply to reference particle with position R and momemtum P.
virtual void finalise()=0
virtual const EMField & getField() const =0
Return field.
virtual bool getPotential(const Vector_t< double, 3 > &, const double &, Vector_t< double, 3 > &, double &)
Calculate the four-potential at some position relative to the component.
Definition Component.h:155
virtual double getDesignEnergy() const
Definition Component.h:254
bool online_m
Definition Component.h:226
virtual void trackBunch(PartBunch_t &bunch, const PartData &, bool revBeam, bool revTrack) const
Track a borrowed particle bunch through a non-standard component.
Definition Component.cpp:35
virtual void initialise(PartBunch_t *bunch, double &startField, double &endField)=0
virtual void goOnline(const double &kineticEnergy)
Definition Component.cpp:43
virtual void goOffline()
Definition Component.cpp:45
virtual void trackMap(FVps< double, 6 > &map, const PartData &, bool revBeam, bool revTrack) const
Track a map.
Definition Component.cpp:39
virtual EMField & getField()=0
Return field.
virtual void getFieldExtend(double &zBegin, double &zEnd) const =0
Return the field-support extent of the component.
virtual bool bends() const =0
PartBunch_t * RefPartBunch_m
Definition Component.h:225
virtual ~Component()
Definition Component.cpp:31
virtual void setDesignEnergy(const double &energy, bool changeable=true)
Definition Component.h:252
static const std::vector< double > defaultAperture_m
Definition Component.h:221
virtual bool Online()
Definition Component.cpp:47
EBVectors EBfield(const Point3D &P) const
Return the field in a point.
Definition Component.h:244
double exit_face_slope_m
Definition Component.h:222
virtual const ElementBase & getDesign() const
Return design element.
Definition Component.cpp:33
EVector Efield(const Point3D &P) const
Return the field in a point.
Definition Component.h:232
void setExitFaceSlope(const double &)
Definition Component.h:250
virtual bool apply(const std::shared_ptr< ParticleContainer_t > &pc)
Apply to all particles. Kernel launch moved inside the function.
Definition Component.cpp:57
A representation of an electromagnetic field.
Definition EMField.h:120
Abstract base class for electromagnetic fields.
Definition EMField.h:171
virtual BVector Bfield(const Point3D &P) const
Get field.
Definition EMField.cpp:121
virtual EVector Efield(const Point3D &P) const
Get field.
Definition EMField.cpp:119
virtual EBVectors EBfield(const Point3D &P) const
Get field.
Definition EMField.cpp:127
An electric field vector.
Definition EMField.h:58
Particle reference data.
Definition PartData.h:37
Container for all per-particle (and per-simulation) fields tracked during OPALX tracking.
A point in 3 dimensions.
Definition EMField.h:32