OPAL (Object Oriented Parallel Accelerator Library) 2024.2
OPAL
OpalElement.h
Go to the documentation of this file.
1//
2// Class OpalElement
3// Base class for all beam line elements.
4//
5// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland
6// All rights reserved
7//
8// This file is part of OPAL.
9//
10// OPAL is free software: you can redistribute it and/or modify
11// it under the terms of the GNU General Public License as published by
12// the Free Software Foundation, either version 3 of the License, or
13// (at your option) any later version.
14//
15// You should have received a copy of the GNU General Public License
16// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
17//
18#ifndef OPAL_OpalElement_HH
19#define OPAL_OpalElement_HH
20
23
24#include <map>
25#include <ostream>
26#include <string>
27#include <vector>
28
29class Statement;
30
31class OpalElement: public Element {
32
33public:
34
36 enum {
37 TYPE, // The design type.
38 APERT, // The aperture data.
39 LENGTH, // The element length.
40 ELEMEDGE, // The position of the element (in path length)
41 WAKEF, // The wake function to be used
42 PARTICLEMATTERINTERACTION, // The particle mater interaction handler to be used
43 ORIGIN, // The location of the element in floor coordinates
44 ORIENTATION, // The orientation of the element (Tait Bryan angles)
45 X, // The x-coordinate of the location of the element in floor coordinates
46 Y, // The y-coordinate of the location of the element in floor coordinates
47 Z, // The z-coordinate of the location of the element in floor coordinates
48 THETA, // The rotation about the y-axis
49 PHI, // The rotation about the x-axis
50 PSI, // The rotation about the z-axis
51 DX, // Misalignment in x (local coordinate system)
52 DY, // Misalignment in y (local coordinate system)
53 DZ, // Misalignment in z (local coordinate system)
54 DTHETA, // The rotation around y axis in rad.
55 DPHI, // The rotation around x axis in rad.
56 DPSI, // The rotation around s axis in rad.
57 OUTFN, // Output filename
58 DELETEONTRANSVERSEEXIT, // Flag whether particles should be deleted if exit transversally
59 COMMON
60 };
61
62 virtual ~OpalElement();
63
65 virtual double getLength() const;
66
68 const std::string getTypeName() const;
69
70 //return the element aperture vector
71 std::pair<ApertureType, std::vector<double> > getApert() const;
72
74 const std::string getWakeF() const;
75
76 const std::string getParticleMatterInteraction() const;
77
78 const std::string getWMaterial() const;
79
80 const std::string getWakeGeom() const;
81
82 std::vector<double> getWakeParam() const;
83
84 const std::string getWakeConductivity() const;
85
87 // This special version for elements handles unknown attributes by
88 // appending them to the attribute list.
89 virtual void parse(Statement&);
90
92 // This special version handles special printing in OPAL-8 format.
93 virtual void print(std::ostream&) const;
94
96 virtual void update();
97
99 virtual void updateUnknown(ElementBase*);
100
101protected:
102
104 OpalElement(int size, const char* name, const char* help);
105
107 OpalElement(const std::string& name, OpalElement* parent);
108
110 // This function is accessible to all multipole-like elements
111 // (RBend, SBend, Quadrupole, Sextupole, Octupole, Multipole).
112 static void printMultipoleStrength(std::ostream& os,
113 int order,
114 int& len,
115 const std::string& sName,
116 const std::string& tName,
117 const Attribute& length,
118 const Attribute& vNorm,
119 const Attribute& vSkew);
120
122 static void printAttribute(std::ostream& os,
123 const std::string& name,
124 const std::string& image,
125 int& len);
126
128 static void printAttribute(std::ostream& os,
129 const std::string& name,
130 double value,
131 int& len);
132
133 void registerOwnership() const;
134
135private:
136
137 // Not implemented.
139 void operator=(const OpalElement&);
140
141 // The original size of the attribute list.
143};
144
145#endif // OPAL_OpalElement_HH
const std::string name
A representation of an Object attribute.
Definition Attribute.h:52
Interface for statements.
Definition Statement.h:38
void operator=(const OpalElement &)
std::pair< ApertureType, std::vector< double > > getApert() const
static void printMultipoleStrength(std::ostream &os, int order, int &len, const std::string &sName, const std::string &tName, const Attribute &length, const Attribute &vNorm, const Attribute &vSkew)
Print multipole components in OPAL-8 format.
virtual double getLength() const
Return element length.
std::vector< double > getWakeParam() const
static void printAttribute(std::ostream &os, const std::string &name, const std::string &image, int &len)
Print an attribute with a OPAL-8 name (as an expression).
@ DELETEONTRANSVERSEEXIT
Definition OpalElement.h:58
@ PARTICLEMATTERINTERACTION
Definition OpalElement.h:42
virtual void parse(Statement &)
Parse the element.
const std::string getParticleMatterInteraction() const
const std::string getWMaterial() const
const std::string getWakeGeom() const
const std::string getWakeF() const
Return the element's type name.
virtual void updateUnknown(ElementBase *)
Transmit the `‘unknown’' (not known to OPAL) attributes to CLASSIC.
const std::string getTypeName() const
Return the element's type name.
const std::string getWakeConductivity() const
virtual void print(std::ostream &) const
Print the object.
virtual ~OpalElement()
virtual void update()
Update the embedded CLASSIC element.
void registerOwnership() const