OPALX (Object Oriented Parallel Accelerator Library for Exascal) MINIorX
OPALX
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
25#include "AbsBeamline/Drift.h"
27#include "AbsBeamline/Marker.h"
28#include "AbsBeamline/Monitor.h"
34#include "AbsBeamline/Offset.h"
35#include "AbsBeamline/Probe.h"
37#include "AbsBeamline/Ring.h"
42
43#include "Beamlines/Beamline.h"
45
46DefaultVisitor::DefaultVisitor(const Beamline& beamline, bool backBeam, bool backTrack)
47 : itsLine(beamline), back_beam(backBeam), back_track(backTrack) {
49 flip_B = back_beam ? -1.0 : 1.0;
50 flip_s = back_path ? -1.0 : 1.0;
51}
52
55
58 itsLine.accept(*this);
59}
60
62 applyDefault(comp);
63}
64
66 applyDefault(drf);
67}
68
70 applyDefault(mark);
71}
72
74 applyDefault(mon);
75}
76
78 applyDefault(mult);
79}
80
82 applyDefault(multT);
83}
84
86 applyDefault(multTstraight);
87}
88
93
97
99 applyDefault(off);
100}
101
103 applyDefault(ring);
104}
105
107 applyDefault(cav);
108}
109
113
117
121
125
127 applyDefault(probe);
128}
129
131 // Default behaviour: Apply algorithm to all beamline members.
132 // If flip_local is true, track from right to left.
133 bl.iterate(*this, local_flip);
134}
135
137 if (fep.getReflectionFlag()) {
139 fep.getElement()->accept(*this);
141 } else {
142 fep.getElement()->accept(*this);
143 }
144}
145
Interface for a single beam element.
Definition Component.h:50
Interface for drift space.
Definition Drift.h:31
virtual void accept(BeamlineVisitor &visitor) const =0
Apply visitor.
Interface for a marker.
Definition Marker.h:32
Interface for general multipole.
Definition Multipole.h:45
Definition Probe.h:28
Ring describes a ring type geometry for tracking.
Definition Ring.h:62
Interface for solenoids.
Definition Solenoid.h:34
virtual void visitProbe(const Probe &prob)
Apply the algorithm to a Probe.
virtual ~DefaultVisitor()=0
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 visitComponent(const Component &)
Apply the algorithm to an arbitrary component.
virtual void visitRFCavity(const RFCavity &)
Apply the algorithm to a RF cavity.
virtual void visitMarker(const Marker &)
Apply the algorithm to a marker.
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 visitMonitor(const Monitor &)
Apply the algorithm to a beam position monitor.
virtual void visitFlaggedElmPtr(const FlaggedElmPtr &)
Apply the algorithm to a FlaggedElmPtr.
virtual void applyDefault(const ElementBase &)
virtual void visitSolenoid(const Solenoid &)
Apply the algorithm to a Solenoid.
virtual void visitScalingFFAMagnet(const ScalingFFAMagnet &spiral)
Apply the algorithm to a scaling FFA magnet.
const Beamline & itsLine
virtual void visitBeamline(const Beamline &)
Apply the algorithm to a beam line.
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 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.
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.