OPALX (Object Oriented Parallel Accelerator Library for Exascal) MINIorX
OPALX
Component.cpp
Go to the documentation of this file.
1// ------------------------------------------------------------------------
2// $RCSfile: Component.cpp,v $
3// ------------------------------------------------------------------------
4// $Revision: 1.1.1.1 $
5// ------------------------------------------------------------------------
6// Copyright: see Copyright.readme
7// ------------------------------------------------------------------------
8//
9// Class: Component
10// An abstract base class which defines the common interface for all
11// CLASSIC components, i.e. beamline members which are not themselves
12// beamlines.
13//
14// ------------------------------------------------------------------------
15// Class category: AbsBeamline
16// ------------------------------------------------------------------------
17//
18// $Date: 2000/03/27 09:32:31 $
19// $Author: fci $
20// c
21// ------------------------------------------------------------------------
22
25
26// Class Component
27// ------------------------------------------------------------------------
28// Represents an arbitrary component in an accelerator. A component is
29// the basic element in the accelerator model, and can be thought of as
30// acting as a leaf in the Composite pattern. A Component is associated
31// with an electromagnetic field.
32// 2017-03-20 (Rogers) set default aperture to something huge; else we get a
33// segmentation fault by default from nullptr dereference during tracking
34
35const std::vector<double> Component::defaultAperture_m = std::vector<double>({1e6, 1e6, 1.0});
36
39
43
48
51
53 return *this;
54}
55
56void Component::trackBunch(PartBunch_t*, const PartData&, bool, bool) const {
57 throw LogicalError("Component::trackBunch()", "Called for component \"" + getName() + "\".");
58}
59
60void Component::trackMap(FVps<double, 6>&, const PartData&, bool, bool) const {
61 throw LogicalError("Component::trackMap()", "Called for component \"" + getName() + "\".");
62}
63
64void Component::goOnline(const double&) {
65 online_m = true;
66}
67
69 online_m = false;
70}
71
73 return online_m;
74}
75
79
80bool Component::apply(const size_t& i, const double&, Vector_t<double, 3>&, Vector_t<double, 3>&) {
81 /* const Vector_t<double, 3>& R = RefPartBunch_m->R[i];
82 if (R(2) >= 0.0 && R(2) < getElementLength()) {
83 if (!isInsideTransverse(R))
84 return true;
85 }
86 */
87 return false;
88}
89
91 const Vector_t<double, 3>& R, const Vector_t<double, 3>& /*P*/, const double& /*t*/,
93 if (R(2) >= 0.0 && R(2) < getElementLength()) {
94 if (!isInsideTransverse(R))
95 return true;
96 }
97 return false;
98}
99
101 const Vector_t<double, 3>& R, const Vector_t<double, 3>& /*P*/, const double& /*t*/,
103 if (R(2) >= 0.0 && R(2) < getElementLength()) {
104 if (!isInsideTransverse(R))
105 return true;
106 }
107 return false;
108}
ElementType
Definition ElementBase.h:88
PartBunch< PLayout_t< double, 3 >, double, 3 > PartBunch_t
ippl::Vector< T, Dim > Vector_t
virtual ElementType getType() const
Get element type std::string.
Definition Component.cpp:76
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)
bool online_m
Definition Component.h:186
virtual void goOnline(const double &kineticEnergy)
Definition Component.cpp:64
virtual void goOffline()
Definition Component.cpp:68
virtual void trackMap(FVps< double, 6 > &map, const PartData &, bool revBeam, bool revTrack) const
Track a map.
Definition Component.cpp:60
Component(const std::string &name)
Constructor with given name.
Definition Component.cpp:44
PartBunch_t * RefPartBunch_m
Definition Component.h:185
virtual ~Component()
Definition Component.cpp:49
static const std::vector< double > defaultAperture_m
Definition Component.h:181
virtual void trackBunch(PartBunch_t *bunch, const PartData &, bool revBeam, bool revTrack) const
Track particle bunch.
Definition Component.cpp:56
virtual bool Online()
Definition Component.cpp:72
double exit_face_slope_m
Definition Component.h:183
virtual const ElementBase & getDesign() const
Return design element.
Definition Component.cpp:52
virtual bool apply(const size_t &i, const double &t, Vector_t< double, 3 > &E, Vector_t< double, 3 > &B)
Definition Component.cpp:80
virtual const std::string & getName() const
Get element name.
void setAperture(const ApertureType &type, const std::vector< double > &args)
virtual double getElementLength() const
Get design length.
ElementBase(const std::string &name)
Constructor with given name.
bool isInsideTransverse(const Vector_t< double, 3 > &r) const
Particle reference data.
Definition PartData.h:37
Logical error exception.