OPAL (Object Oriented Parallel Accelerator Library) 2024.2
OPAL
SpecificElementVisitor.h
Go to the documentation of this file.
1//
2// Class SpecificElementVisitor
3// :FIXME: Add file description
4//
5// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland
6// All rights reserved
7//
8// This file is part of OPAL.
9//
10// OPAL is free software: you can redistribute it and/or modify
11// it under the terms of the GNU General Public License as published by
12// the Free Software Foundation, either version 3 of the License, or
13// (at your option) any later version.
14//
15// You should have received a copy of the GNU General Public License
16// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
17//
18#ifndef SPECIFICELEMENTVISITOR_H
19#define SPECIFICELEMENTVISITOR_H
20
21#include <list>
22
27#include "AbsBeamline/Drift.h"
31#include "AbsBeamline/Offset.h"
32#include "AbsBeamline/Marker.h"
33#include "AbsBeamline/Monitor.h"
40#include "AbsBeamline/Probe.h"
41#include "AbsBeamline/RBend.h"
42#include "AbsBeamline/Ring.h"
44#include "AbsBeamline/SBend.h"
45#include "AbsBeamline/SBend3D.h"
47#include "AbsBeamline/Septum.h"
49#include "AbsBeamline/Source.h"
52#include "AbsBeamline/Vacuum.h"
56
57#ifdef ENABLE_OPAL_FEL
59#endif
60
61#include "Beamlines/Beamline.h"
63
64template <class ELEM1, class ELEM2>
65struct CastsTrait {
66 typedef std::list<const ELEM1*> ElementList_t;
67
68 static void apply(ElementList_t &, const ELEM2 &)
69 { }
70};
71
72template <class ELEM>
73struct CastsTrait<ELEM,ELEM> {
74 typedef std::list<const ELEM*> ElementList_t;
75
76 static void apply(ElementList_t &allElements, const ELEM &element)
77 {
78 allElements.push_back(dynamic_cast<const ELEM*>(&element));
79 }
80};
81
82template <class ELEM>
84public:
85 SpecificElementVisitor(const Beamline &beamline);
86
87 virtual void execute();
88
90 virtual void visitBeamline(const Beamline &);
91
93 virtual void visitCCollimator(const CCollimator &);
94
96 virtual void visitComponent(const Component &);
97
99 virtual void visitCorrector(const Corrector &);
100
102 virtual void visitCyclotron(const Cyclotron &);
103
105 virtual void visitDegrader(const Degrader &);
106
108 virtual void visitDrift(const Drift &);
109
111 virtual void visitFlaggedElmPtr(const FlaggedElmPtr &);
112
114 virtual void visitFlexibleCollimator(const FlexibleCollimator &);
115
117 virtual void visitMarker(const Marker &);
118
120 virtual void visitMonitor(const Monitor &);
121
123 virtual void visitMultipole(const Multipole &);
124
126 virtual void visitMultipoleT(const MultipoleT &);
127
129 virtual void visitMultipoleTStraight(const MultipoleTStraight &);
130
133
136
138 virtual void visitOffset(const Offset &);
139
141 virtual void visitOutputPlane(const OutputPlane &);
142
144 virtual void visitProbe(const Probe &prob);
145
147 virtual void visitRBend(const RBend &);
148
150 virtual void visitRBend3D(const RBend3D &);
151
153 virtual void visitRFCavity(const RFCavity &);
154
156 virtual void visitRing(const Ring &);
157
159 virtual void visitSBend(const SBend &);
160
162 virtual void visitSBend3D(const SBend3D &);
163
165 virtual void visitScalingFFAMagnet(const ScalingFFAMagnet &);
166
168 virtual void visitSeptum(const Septum &);
169
171 virtual void visitSolenoid(const Solenoid &);
172
174 virtual void visitSource(const Source &);
175
177 virtual void visitStripper(const Stripper &);
178
180 virtual void visitTravelingWave(const TravelingWave &);
181
182#ifdef ENABLE_OPAL_FEL
184 virtual void visitUndulator(const Undulator &);
185#endif
186
188 virtual void visitVacuum(const Vacuum &);
189
191 virtual void visitVariableRFCavity(const VariableRFCavity &vcav);
192
195 (const VariableRFCavityFringeField &vcav);
196
198 virtual void visitVerticalFFAMagnet(const VerticalFFAMagnet &);
199
200
201 size_t size() const;
202
203 typedef std::list<const ELEM*> ElementList_t;
204 typedef typename ElementList_t::iterator iterator_t;
205 typedef typename ElementList_t::const_iterator const_iterator_t;
206
207 typedef typename ElementList_t::reference reference_t;
208 typedef typename ElementList_t::const_reference const_reference_t;
209
211 const_iterator_t begin() const;
212
213 iterator_t end();
214 const_iterator_t end() const;
215
217 const_reference_t front() const;
218
219private:
221};
222
223template<class ELEM>
227{
228 beamline.iterate(*this, false);
229}
230
231template<class ELEM>
234
235template<class ELEM>
237 element.iterate(*this, false);
238}
239
240template<class ELEM>
244
245template<class ELEM>
249
250template<class ELEM>
254
255template<class ELEM>
259
260template<class ELEM>
264
265template<class ELEM>
269
270template<class ELEM>
272 const ElementBase* wrappedElement = element.getElement();
273 wrappedElement->accept(*this);
274}
275
276template<class ELEM>
280
281template<class ELEM>
285
286template<class ELEM>
290
291template<class ELEM>
295
296template<class ELEM>
300
301template<class ELEM>
305
306template<class ELEM>
310
311template<class ELEM>
315
316template<class ELEM>
320
321template<class ELEM>
325
326template<class ELEM>
330
331template<class ELEM>
335
336template<class ELEM>
340
341template<class ELEM>
345
346template<class ELEM>
350
351template<class ELEM>
355
356template<class ELEM>
360
361template<class ELEM>
365
366template<class ELEM>
370
371template<class ELEM>
375
376template<class ELEM>
380
381template<class ELEM>
385
386template<class ELEM>
390
391#ifdef ENABLE_OPAL_FEL
392template<class ELEM>
394 CastsTrait<ELEM, Undulator>::apply(allElementsOfTypeE, element);
395}
396#endif
397
398template<class ELEM>
402
403template<class ELEM>
408
409template<class ELEM>
415
416template<class ELEM>
420
421template<class ELEM>
423 return allElementsOfTypeE.size();
424}
425
426template<class ELEM>
430
431template<class ELEM>
435
436template<class ELEM>
440
441template<class ELEM>
445
446template<class ELEM>
450
451template<class ELEM>
455
456#endif
Interface for a single beam element.
Definition Component.h:50
Interface for general corrector.
Definition Corrector.h:35
Interface for drift space.
Definition Drift.h:33
virtual void accept(BeamlineVisitor &visitor) const =0
Apply visitor.
Interface for a marker.
Definition Marker.h:32
Interface for general multipole.
Definition Multipole.h:47
Definition Probe.h:28
Definition RBend.h:58
Interface for solenoids.
Definition RBend3D.h:39
Ring describes a ring type geometry for tracking.
Definition Ring.h:53
Definition SBend.h:68
Interface for solenoids.
Definition Solenoid.h:36
std::list< const ELEM1 * > ElementList_t
static void apply(ElementList_t &, const ELEM2 &)
std::list< const ELEM * > ElementList_t
static void apply(ElementList_t &allElements, const ELEM &element)
virtual void execute()
Execute the algorithm on the attached beam line.
virtual void visitRing(const Ring &)
Apply the algorithm to a ring.
virtual void visitBeamline(const Beamline &)
Apply the algorithm to a beam line.
virtual void visitStripper(const Stripper &)
Apply the algorithm to a particle stripper.
virtual void visitVariableRFCavity(const VariableRFCavity &vcav)
Apply the algorithm to a variable RF cavity.
virtual void visitFlaggedElmPtr(const FlaggedElmPtr &)
Apply the algorithm to a FlaggedElmPtr.
virtual void visitMarker(const Marker &)
Apply the algorithm to a marker.
virtual void visitRFCavity(const RFCavity &)
Apply the algorithm to a RF cavity.
virtual void visitVacuum(const Vacuum &)
Apply the algorithm to a vacuum space.
ElementList_t::reference reference_t
virtual void visitVariableRFCavityFringeField(const VariableRFCavityFringeField &vcav)
Apply the algorithm to a variable RF cavity with Fringe Field..
virtual void visitMultipoleTCurvedConstRadius(const MultipoleTCurvedConstRadius &)
Apply the algorithm to an arbitrary curved multipole of constant radius.
virtual void visitSource(const Source &)
Apply the algorithm to a source.
virtual void visitMultipole(const Multipole &)
Apply the algorithm to a multipole.
SpecificElementVisitor(const Beamline &beamline)
virtual void visitMultipoleT(const MultipoleT &)
Apply the algorithm to an arbitrary multipole.
virtual void visitTravelingWave(const TravelingWave &)
Apply the algorithm to a traveling wave.
virtual void visitMultipoleTCurvedVarRadius(const MultipoleTCurvedVarRadius &)
Apply the algorithm to an arbitrary curved multipole of variable radius.
ElementList_t::const_iterator const_iterator_t
virtual void visitDegrader(const Degrader &)
Apply the algorithm to a degrader.
virtual void visitSolenoid(const Solenoid &)
Apply the algorithm to a solenoid.
virtual void visitCorrector(const Corrector &)
Apply the algorithm to a closed orbit corrector.
virtual void visitRBend(const RBend &)
Apply the algorithm to a rectangular bend.
ElementList_t::const_reference const_reference_t
virtual void visitCCollimator(const CCollimator &)
Apply the algorithm to a collimator.
virtual void visitMultipoleTStraight(const MultipoleTStraight &)
Apply the algorithm to an arbitrary straight multipole.
virtual void visitSeptum(const Septum &)
Apply the algorithm to a septum.
virtual void visitScalingFFAMagnet(const ScalingFFAMagnet &)
Apply the algorithm to a scaling FFA magnet.
virtual void visitCyclotron(const Cyclotron &)
Apply the algorithm to an cyclotron.
virtual void visitRBend3D(const RBend3D &)
Apply the algorithm to a rectangular bend.
virtual void visitProbe(const Probe &prob)
Apply the algorithm to a probe.
virtual void visitSBend3D(const SBend3D &)
Apply the algorithm to a sector bend with 3D field map.
ElementList_t::iterator iterator_t
virtual void visitFlexibleCollimator(const FlexibleCollimator &)
Apply the algorithm to a flexible collimator.
virtual void visitMonitor(const Monitor &)
Apply the algorithm to a beam position monitor.
virtual void visitSBend(const SBend &)
Apply the algorithm to a sector bend.
virtual void visitDrift(const Drift &)
Apply the algorithm to a drift.
std::list< const ELEM * > ElementList_t
virtual void visitComponent(const Component &)
Apply the algorithm to an arbitrary component.
virtual void visitVerticalFFAMagnet(const VerticalFFAMagnet &)
Apply the algorithm to a vertical FFA magnet.
virtual void visitOutputPlane(const OutputPlane &)
Apply the algorithm to an output plane.
virtual void visitOffset(const Offset &)
Apply the algorithm to an offset (placement).
An abstract sequence of beam line components.
Definition Beamline.h:34
virtual void iterate(BeamlineVisitor &, bool reverse) const =0
Apply visitor to all elements of the line.
ElementBase * getElement() const
Get the element pointer.
Definition ElmPtr.h:58
A section of a beam line.