OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
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
26#include "AbsBeamline/Drift.h"
28#include "AbsBeamline/Laser.h"
29#include "AbsBeamline/Marker.h"
30#include "AbsBeamline/Monitor.h"
33#include "AbsBeamline/Probe.h"
34#include "AbsBeamline/RBend.h"
36#include "AbsBeamline/Ring.h"
37#include "AbsBeamline/SBend.h"
43
44#include "Beamlines/Beamline.h"
46
47DefaultVisitor::DefaultVisitor(const Beamline& beamline, bool backBeam, bool backTrack)
48 : itsLine(beamline), back_beam(backBeam), back_track(backTrack) {
50 flip_B = back_beam ? -1.0 : 1.0;
51 flip_s = back_path ? -1.0 : 1.0;
52}
53
58
60
64
66
67void DefaultVisitor::visitLaser(const Laser& laser) { applyDefault(laser); }
68
70
72
74
76
77void DefaultVisitor::visitRBend(const RBend& bend) { applyDefault(bend); }
78
79void DefaultVisitor::visitRing(const Ring& ring) { applyDefault(ring); }
80
82
83void DefaultVisitor::visitSBend(const SBend& bend) { applyDefault(bend); }
84
86
88
90
92
94
95void DefaultVisitor::visitProbe(const Probe& probe) { applyDefault(probe); }
96
98 // Default behaviour: Apply algorithm to all beamline members.
99 // If flip_local is true, track from right to left.
100 bl.iterate(*this, local_flip);
101}
102
104 if (fep.getReflectionFlag()) {
106 fep.getElement()->accept(*this);
108 } else {
109 fep.getElement()->accept(*this);
110 }
111}
112
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.
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.
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 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.
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
virtual void accept(BeamlineVisitor &visitor) const =0
Apply visitor.
ElementBase * getElement() const
Get the element pointer.
Definition ElmPtr.h:56
A section of a beam line.
bool getReflectionFlag() const
Get reflection flag.
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.