OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
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 #include <map>
24 #include <string>
25 
26 class Statement;
27 
28 class OpalElement: public Element {
29 
30 public:
31 
33  enum {
34  TYPE, // The design type.
35  APERT, // The aperture data.
36  LENGTH, // The element length.
37  ELEMEDGE, // The position of the element (in path length)
38  WAKEF, // The wake function to be used
39  PARTICLEMATTERINTERACTION, // The particle mater interaction handler to be used
40  ORIGIN, // The location of the element in floor coordinates
41  ORIENTATION, // The orientation of the element (Tait Bryan angles)
42  X, // The x-coordinate of the location of the element in floor coordinates
43  Y, // The y-coordinate of the location of the element in floor coordinates
44  Z, // The z-coordinate of the location of the element in floor coordinates
45  THETA, // The rotation about the y-axis
46  PHI, // The rotation about the x-axis
47  PSI, // The rotation about the z-axis
48  DX, // Misalignment in x (local coordinate system)
49  DY, // Misalignment in y (local coordinate system)
50  DZ, // Misalignment in z (local coordinate system)
51  DTHETA, // The rotation around y axis in rad.
52  DPHI, // The rotation around x axis in rad.
53  DPSI, // The rotation around s axis in rad.
54  OUTFN, // Output filename
55  COMMON
56  };
57 
58  virtual ~OpalElement();
59 
61  virtual double getLength() const;
62 
64  const std::string getTypeName() const;
65 
66  //return the element aperture vector
67  std::pair<ElementBase::ApertureType, std::vector<double> > getApert() const;
68 
70  const std::string getWakeF() const;
71 
72  const std::string getParticleMatterInteraction() const;
73 
74  const std::string getWMaterial() const;
75 
76  const std::string getWakeGeom() const;
77 
78  std::vector<double> getWakeParam() const;
79 
80  const std::string getWakeConductivity() const;
81 
83  // This special version for elements handles unknown attributes by
84  // appending them to the attribute list.
85  virtual void parse(Statement&);
86 
88  // This special version handles special printing in OPAL-8 format.
89  virtual void print(std::ostream&) const;
90 
92  virtual void update();
93 
95  virtual void updateUnknown(ElementBase*);
96 
97 protected:
98 
100  OpalElement(int size, const char* name, const char* help);
101 
103  OpalElement(const std::string& name, OpalElement* parent);
104 
106  // This function is accessible to all multipole-like elements
107  // (RBend, SBend, Quadrupole, Sextupole, Octupole, Multipole).
108  static void printMultipoleStrength(std::ostream& os,
109  int order,
110  int& len,
111  const std::string& sName,
112  const std::string& tName,
113  const Attribute& length,
114  const Attribute& vNorm,
115  const Attribute& vSkew);
116 
118  static void printAttribute(std::ostream& os,
119  const std::string& name,
120  const std::string& image,
121  int& len);
122 
124  static void printAttribute(std::ostream& os,
125  const std::string& name,
126  double value,
127  int& len);
128 
129  void registerOwnership() const;
130 
131 private:
132 
133  // Not implemented.
135  void operator=(const OpalElement&);
136 
137  // The original size of the attribute list.
138  int itsSize;
139 };
140 
141 #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 &)
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.
std::vector< double > getWakeParam() const
virtual double getLength() const
Return element length.
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).
@ PARTICLEMATTERINTERACTION
Definition: OpalElement.h:39
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.
std::pair< ElementBase::ApertureType, std::vector< double > > getApert() const
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