OPAL (Object Oriented Parallel Accelerator Library) 2024.2
OPAL
DefaultVisitor.cpp
Go to the documentation of this file.
1//
2// Class DefaultVisitor
3// The default interface for a BeamlineVisitor.
4// A default implementation for all visitors that can iterate over a
5// beam line representation.
6// This abstract base class implements the default behaviour for the
7// structural classes Beamline and FlaggedElmPtr.
8// It also holds the data required for all visitors in a protected area.
9//
10// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland
11// All rights reserved
12//
13// This file is part of OPAL.
14//
15// OPAL is free software: you can redistribute it and/or modify
16// it under the terms of the GNU General Public License as published by
17// the Free Software Foundation, either version 3 of the License, or
18// (at your option) any later version.
19//
20// You should have received a copy of the GNU General Public License
21// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
22//
24
29#include "AbsBeamline/Drift.h"
32#include "AbsBeamline/Marker.h"
33#include "AbsBeamline/Monitor.h"
36#include "AbsBeamline/Offset.h"
38#include "AbsBeamline/Probe.h"
39#include "AbsBeamline/RBend.h"
40#include "AbsBeamline/RBend3D.h"
42#include "AbsBeamline/Ring.h"
43#include "AbsBeamline/SBend.h"
44#include "AbsBeamline/SBend3D.h"
46#include "AbsBeamline/Septum.h"
48#include "AbsBeamline/Source.h"
51#include "AbsBeamline/Vacuum.h"
55
56#ifdef ENABLE_OPAL_FEL
58#endif
59
60#include "Beamlines/Beamline.h"
62
63
64
66 bool backBeam, bool backTrack):
67 itsLine(beamline), back_beam(backBeam), back_track(backTrack) {
69 ( back_beam && ! back_track ) || ( back_track && ! back_beam );
70 flip_B = back_beam ? -1.0 : 1.0;
71 flip_s = back_path ? -1.0 : 1.0;
72}
73
74
77
78
80 local_flip = ( back_beam && ! back_track ) || ( back_track && ! back_beam );
81 itsLine.accept(*this);
82}
83
84
88
90 applyDefault(comp);
91}
92
94 applyDefault(corr);
95}
96
100
102 applyDefault(deg);
103}
104
106 applyDefault(drf);
107}
108
112
114 applyDefault(mark);
115}
116
118 applyDefault(mon);
119}
120
122 applyDefault(mult);
123}
124
126 applyDefault(multT);
127}
128
130 applyDefault(off);
131}
132
136
138 applyDefault(probe);
139}
140
142 applyDefault(bend);
143}
144
146 applyDefault(bend);
147}
148
150 applyDefault(cav);
151}
152
154 applyDefault(ring);
155}
156
158 applyDefault(bend);
159}
160
162 applyDefault(bend);
163}
164
168
170 applyDefault(sept);
171}
172
174 applyDefault(sol);
175}
176
178 applyDefault(sou);
179}
180
182 applyDefault(stripper);
183}
184
188
189#ifdef ENABLE_OPAL_FEL
190void DefaultVisitor::visitUndulator(const Undulator &u) {
191 applyDefault(u);
192}
193#endif
194
196 applyDefault(vac);
197}
198
202
207
211
212
214 // Default behaviour: Apply algorithm to all beamline members.
215 // If flip_local is true, track from right to left.
216 bl.iterate(*this, local_flip);
217}
218
219
221 if(fep.getReflectionFlag()) {
223 fep.getElement()->accept(*this);
225 } else {
226 fep.getElement()->accept(*this);
227 }
228}
229
230
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
virtual void visitProbe(const Probe &prob)
Apply the algorithm to a probe.
virtual ~DefaultVisitor()=0
virtual void visitOutputPlane(const OutputPlane &)
Apply the algorithm to an output plane.
virtual void visitDegrader(const Degrader &)
Apply the algorithm to a degrader.
virtual void visitOffset(const Offset &)
Apply the algorithm to an offset (placement).
virtual void visitDrift(const Drift &)
Apply the algorithm to a drift space.
virtual void visitRBend3D(const RBend3D &)
Apply the algorithm to a rectangular bend.
virtual void visitComponent(const Component &)
Apply the algorithm to an arbitrary component.
virtual void visitVariableRFCavity(const VariableRFCavity &vcav)
Apply the algorithm to a a variable RF cavity.
virtual void visitVacuum(const Vacuum &)
Apply the algorithm to a vacuum space.
virtual void visitFlexibleCollimator(const FlexibleCollimator &)
Apply the algorithm to a flexible collimator.
virtual void visitRFCavity(const RFCavity &)
Apply the algorithm to a RF cavity.
virtual void visitSBend3D(const SBend3D &)
Apply the algorithm to a sector bend with 3D field map.
virtual void visitScalingFFAMagnet(const ScalingFFAMagnet &)
Apply the algorithm to a scaling FFA magnet.
virtual void visitMarker(const Marker &)
Apply the algorithm to a marker.
virtual void visitVariableRFCavityFringeField(const VariableRFCavityFringeField &vcav)
Apply the algorithm to a a variable RF cavity with Fringe Field.
virtual void visitTravelingWave(const TravelingWave &)
Apply the algorithm to a traveling wave.
virtual void visitSeptum(const Septum &)
Apply the algorithm to a septum.
virtual void visitCorrector(const Corrector &)
Apply the algorithm to a closed orbit corrector.
virtual void visitMonitor(const Monitor &)
Apply the algorithm to a beam position monitor.
virtual void visitFlaggedElmPtr(const FlaggedElmPtr &)
Apply the algorithm to a FlaggedElmPtr.
virtual void visitSBend(const SBend &)
Apply the algorithm to a sector bend.
virtual void applyDefault(const ElementBase &)
virtual void visitCCollimator(const CCollimator &)
Apply the algorithm to a collimator.
virtual void visitSolenoid(const Solenoid &)
Apply the algorithm to a solenoid.
const Beamline & itsLine
virtual void visitSource(const Source &)
Apply the algorithm to a source.
virtual void visitBeamline(const Beamline &)
Apply the algorithm to a beam line.
virtual void visitRBend(const RBend &)
Apply the algorithm to a rectangular bend.
virtual void visitMultipoleT(const MultipoleT &)
Apply the algorithm to to an arbitrary multipole.
virtual void visitVerticalFFAMagnet(const VerticalFFAMagnet &)
Apply the algorithm to a vertical FFA magnet.
virtual void visitMultipole(const Multipole &)
Apply the algorithm to a multipole.
virtual void visitCyclotron(const Cyclotron &)
Apply the algorithm to an cyclotron.
virtual void execute()
Apply the algorithm to the top-level beamline.
virtual void visitRing(const Ring &)
Apply the algorithm to a ring.
virtual void visitStripper(const Stripper &)
Apply the algorithm to a particle stripper.
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.
bool getReflectionFlag() const
Get reflection flag.