OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
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 OPALX_DefaultVisitor_HH
24#define OPALX_DefaultVisitor_HH
25
27
28class ElementBase;
29
31public:
33 // Arguments:
34 // [ol]
35 // [li]The beamline to be used.
36 // [li]If true, the beam runs backwards through the line.
37 // [li]If true, we track against the beam.
38 // [/ol]
39 DefaultVisitor(const Beamline& beamline, bool backBeam, bool backTrack);
40
41 ~DefaultVisitor() override = default;
42
44 void execute() override;
45
46 void visitComponent(const Component&) override;
47
49 void visitBeamline(const Beamline&) override;
50
53
55 void visitDrift(const Drift&) override;
56
58 void visitLaser(const Laser&) override;
59
61 void visitFlaggedElmPtr(const FlaggedElmPtr&) override;
62
64 void visitMarker(const Marker&) override;
65
67 void visitMonitor(const Monitor&) override;
68
70 void visitMultipole(const Multipole&) override;
71
73 void visitMultipoleT(const MultipoleT&) override;
74
76 void visitRBend(const RBend&) override;
77
79 void visitRing(const Ring&) override;
80
82 void visitSBend(const SBend&) override;
83
85 void visitRFCavity(const RFCavity&) override;
86
88 void visitSolenoid(const Solenoid&) override;
89
91 void visitTravelingWave(const TravelingWave&) override;
92
94 void visitScalingFFAMagnet(const ScalingFFAMagnet& spiral) override;
95
97 void visitVerticalFFAMagnet(const VerticalFFAMagnet&) override;
98
100 void visitVariableRFCavity(const VariableRFCavity&) override;
101
103 void visitProbe(const Probe& prob) override;
104
105protected:
106 // The top level beamline.
108
109 // The direction flags and corresponding factors.
110 bool back_beam; // true, if beam runs from right (s=C) to left (s=0).
111 bool back_track; // true, if tracking opposite to the beam direction.
112 bool back_path; // true, if tracking from right (s=C) to left (s=0).
113 // back_path = back_beam && ! back_track || back_track && ! back_beam.
114
115 double flip_B; // set to -1.0 to flip B fields, when back_beam is true.
116 double flip_s; // set to -1.0 to flip direction of s,
117 // when back_path is true.
118
119private:
120 // Not implemented.
121 DefaultVisitor() = delete;
123 void operator=(const DefaultVisitor&) = delete;
124
125 // Default do-nothing routine.
126 virtual void applyDefault(const ElementBase&);
127
128 // The element order flag. Initially set to back_path.
129 // This flag is reversed locally for reflected beam lines.
131};
132
133#endif // OPALX_DefaultVisitor_HH
An abstract sequence of beam line components.
Definition Beamline.h:34
Component applying a constant accelerating electric field (Ex,Ey,Ez).
void visitBeamline(const Beamline &) override
Apply the algorithm to a beam line.
void visitTravelingWave(const TravelingWave &) override
Apply the algorithm to a traveling wave.
void visitFlaggedElmPtr(const FlaggedElmPtr &) override
Apply the algorithm to a FlaggedElmPtr.
void visitSolenoid(const Solenoid &) override
Apply the algorithm to a Solenoid.
~DefaultVisitor() override=default
void visitRing(const Ring &) override
Apply the algorithm to a Ring.
void visitComponent(const Component &) override
Apply the algorithm to an arbitrary component.
void visitDrift(const Drift &) override
Apply the algorithm to a drift space.
void operator=(const DefaultVisitor &)=delete
void visitRFCavity(const RFCavity &) override
Apply the algorithm to a RF cavity.
void visitMonitor(const Monitor &) override
Apply the algorithm to a beam position monitor.
void visitRBend(const RBend &) override
Apply the algorithm to a rectangular bend.
void visitVariableRFCavity(const VariableRFCavity &) override
Apply the algorithm to a variable RF cavity.
void visitMultipoleT(const MultipoleT &) override
Apply the algorithm to an arbitrary multipole.
DefaultVisitor(const DefaultVisitor &)=delete
void visitMarker(const Marker &) override
Apply the algorithm to a marker.
void visitProbe(const Probe &prob) override
Apply the algorithm to a Probe.
virtual void applyDefault(const ElementBase &)
void visitMultipole(const Multipole &) override
Apply the algorithm to a multipole.
const Beamline & itsLine
void execute() override
Apply the algorithm to the top-level beamline.
void visitScalingFFAMagnet(const ScalingFFAMagnet &spiral) override
Apply the algorithm to a scaling FFA magnet.
void visitSBend(const SBend &) override
Apply the algorithm to a sector bend.
void visitVerticalFFAMagnet(const VerticalFFAMagnet &) override
Apply the algorithm to a vertical FFA magnet.
void visitLaser(const Laser &) override
Apply the algorithm to a laser.
void visitConstantEFieldCavity(const ConstantEFieldCavity &) override
Apply the algorithm to a constant E-field cavity element.
DefaultVisitor()=delete
Interface for drift space.
Definition Drift.h:31
A section of a beam line.
Passive OPALX laser element.
Definition Laser.h:25
Interface for a marker.
Definition Marker.h:31
Interface for general multipole.
Definition Multipole.h:30
Definition Probe.h:28
Abstract rectangular bend with straight body and curved reference path.
Definition RBend.h:16
Interface for standing wave cavities.
Definition RFCavity.h:34
Ring describes a ring type geometry for tracking.
Definition Ring.h:62
Abstract sector bend with planar-arc body geometry.
Definition SBend.h:15
Abstract class for a solenoid magnet.
Definition Solenoid.h:33
Interface for traveling wave cavities.