OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
DefaultVisitor.h
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//
23#ifndef CLASSIC_DefaultVisitor_HH
24#define CLASSIC_DefaultVisitor_HH
25
27
28class ElementBase;
29
31
32public:
33
35 // Arguments:
36 // [ol]
37 // [li]The beamline to be used.
38 // [li]If true, the beam runs backwards through the line.
39 // [li]If true, we track against the beam.
40 // [/ol]
41 DefaultVisitor(const Beamline &beamline, bool backBeam, bool backTrack);
42
43 virtual ~DefaultVisitor() = 0;
44
46 virtual void execute();
47
49 virtual void visitBeamline(const Beamline &);
50
52 virtual void visitCCollimator(const CCollimator &);
53
55 virtual void visitComponent(const Component &);
56
58 virtual void visitCorrector(const Corrector &);
59
61 virtual void visitCyclotron(const Cyclotron &);
62
64 virtual void visitDegrader(const Degrader &);
65
67 virtual void visitDrift(const Drift &);
68
70 virtual void visitFlaggedElmPtr(const FlaggedElmPtr &);
71
73 virtual void visitFlexibleCollimator(const FlexibleCollimator &);
74
76 virtual void visitMarker(const Marker &);
77
79 virtual void visitMonitor(const Monitor &);
80
82 virtual void visitMultipole(const Multipole &);
83
85 virtual void visitMultipoleT(const MultipoleT &);
86
88 virtual void visitMultipoleTStraight(const MultipoleTStraight &);
89
92
95
97 virtual void visitOffset(const Offset &);
98
100 virtual void visitProbe(const Probe &prob);
101
103 virtual void visitRBend(const RBend &);
104
106 virtual void visitRBend3D(const RBend3D &);
107
109 virtual void visitRFCavity(const RFCavity &);
110
112 virtual void visitRing(const Ring &);
113
115 virtual void visitSBend(const SBend &);
116
118 virtual void visitSBend3D(const SBend3D &);
119
121 virtual void visitScalingFFAMagnet(const ScalingFFAMagnet &);
122
124 virtual void visitSeptum(const Septum &);
125
127 virtual void visitSolenoid(const Solenoid &);
128
130 virtual void visitSource(const Source &);
131
133 virtual void visitStripper(const Stripper &);
134
136 virtual void visitTravelingWave(const TravelingWave &);
137
138#ifdef ENABLE_OPAL_FEL
140 virtual void visitUndulator(const Undulator &);
141#endif
142
144 virtual void visitVacuum(const Vacuum &);
145
147 virtual void visitVariableRFCavity(const VariableRFCavity &vcav);
148
151
153 virtual void visitVerticalFFAMagnet(const VerticalFFAMagnet &);
154
155protected:
156
157 // The top level beamline.
159
160 // The direction flags and corresponding factors.
161 bool back_beam; // true, if beam runs from right (s=C) to left (s=0).
162 bool back_track; // true, if tracking opposite to the beam direction.
163 bool back_path; // true, if tracking from right (s=C) to left (s=0).
164 // back_path = back_beam && ! back_track || back_track && ! back_beam.
165
166 double flip_B; // set to -1.0 to flip B fields, when back_beam is true.
167 double flip_s; // set to -1.0 to flip direction of s,
168 // when back_path is true.
169
170private:
171
172 // Not implemented.
176
177 // Default do-nothing routine.
178 virtual void applyDefault(const ElementBase &);
179
180 // The element order flag. Initially set to back_path.
181 // This flag is reversed locally for reflected beam lines.
183};
184
185#endif // CLASSIC_DefaultVisitor_HH
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
Interface for a marker.
Definition: Marker.h:32
Interface for general multipole.
Definition: Multipole.h:47
Definition: Offset.h:66
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:64
Definition: SBend.h:68
Definition: Septum.h:23
Interface for solenoids.
Definition: Solenoid.h:36
Definition: Source.h:30
Definition: Vacuum.h:61
virtual void visitProbe(const Probe &prob)
Apply the algorithm to a probe.
virtual ~DefaultVisitor()=0
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.
void operator=(const DefaultVisitor &)
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 visitMultipoleTCurvedVarRadius(const MultipoleTCurvedVarRadius &)
Apply the algorithm to an arbitrary curved multipole of variable radius.
virtual void visitTravelingWave(const TravelingWave &)
Apply the algorithm to a traveling wave.
virtual void visitMultipoleTCurvedConstRadius(const MultipoleTCurvedConstRadius &)
Apply the algorithm to an arbitrary curved multipole of constant radius.
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.
DefaultVisitor(const DefaultVisitor &)
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 visitMultipoleTStraight(const MultipoleTStraight &)
Apply the algorithm to an arbitrary straight multipole.
virtual void visitStripper(const Stripper &)
Apply the algorithm to a particle stripper.
An abstract sequence of beam line components.
Definition: Beamline.h:34
A section of a beam line.
Definition: FlaggedElmPtr.h:36