OPAL (Object Oriented Parallel Accelerator Library)  2024.1
OPAL
SBendRep.cpp
Go to the documentation of this file.
1 //
2 // Class SBendRep
3 // Representation for a sector bend magnet.
4 // A sector bend magnet has a planar arc geometry about which its
5 // multipole components are specified.
6 //
7 // Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland
8 // All rights reserved
9 //
10 // This file is part of OPAL.
11 //
12 // OPAL is free software: you can redistribute it and/or modify
13 // it under the terms of the GNU General Public License as published by
14 // the Free Software Foundation, either version 3 of the License, or
15 // (at your option) any later version.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with OPAL. If not, see <https://www.gnu.org/licenses/>.
19 //
20 #include "BeamlineCore/SBendRep.h"
23 #include <cctype>
24 
25 namespace {
26  struct Entry {
27  const char *name;
28  double(SBendRep::*get)() const;
29  void (SBendRep::*set)(double);
30  };
31 
32  static const Entry entries[] = {
33  {
34  "L",
37  },
38  {
39  "BY",
42  },
43  {
44  "E1",
47  },
48  {
49  "E2",
52  },
53  {
54  "H1",
57  },
58  {
59  "H2",
62  },
63  { 0, 0, 0 }
64  };
65 }
66 
67 
69  SBend(),
70  geometry(0.0, 0.0),
71  field() {
72  rEntry = rExit = hEntry = hExit = 0.0;
73 }
74 
75 
77  SBend(rhs),
78  geometry(rhs.geometry),
79  field(rhs.field) {
80  rEntry = rhs.rEntry;
81  rExit = rhs.hExit;
82  hEntry = rhs.rEntry;
83  hExit = rhs.hExit;
84 }
85 
86 
87 SBendRep::SBendRep(const std::string &name):
88  SBend(name),
89  geometry(0.0, 0.0),
90  field() {
91  rEntry = rExit = hEntry = hExit = 0.0;
92 }
93 
94 
96 {}
97 
98 
100  return new SBendRep(*this);
101 }
102 
103 
104 Channel *SBendRep::getChannel(const std::string &aKey, bool create) {
105  if(aKey[0] == 'a' || aKey[0] == 'b') {
106  int n = 0;
107 
108  for(std::string::size_type k = 1; k < aKey.length(); k++) {
109  if(isdigit(aKey[k])) {
110  n = 10 * n + aKey[k] - '0';
111  } else {
112  return 0;
113  }
114  }
115 
116  if(aKey[0] == 'b') {
117  return new IndexedChannel<SBendRep>
120  } else {
121  return new IndexedChannel<SBendRep>
124  }
125  } else {
126  for(const Entry *table = entries; table->name != 0; ++table) {
127  if(aKey == table->name) {
128  return new IndirectChannel<SBendRep>(*this, table->get, table->set);
129  }
130  }
131 
132  return ElementBase::getChannel(aKey, create);
133  }
134 }
135 
136 
138  return field;
139 }
140 
142  return field;
143 }
144 
145 
147  return geometry;
148 }
149 
151  return geometry;
152 }
153 
154 
155 double SBendRep::getB() const {
156  return field.getNormalComponent(1);
157 }
158 
159 void SBendRep::setB(double B) {
161 }
162 
163 
165  return rEntry;
166 }
167 
168 
170  return rExit;
171 }
172 
174  rEntry = e1;
175 }
176 
178  rExit = e2;
179 }
180 
182  return hEntry;
183 }
184 
186  return hExit;
187 }
188 
190  hEntry = h1;
191 }
192 
194  hExit = h2;
195 }
196 
197 
198 double SBendRep::getSlices() const {
199  return slices;
200 }
201 
202 double SBendRep::getStepsize() const {
203  return stepsize;
204 }
205 
206 void SBendRep::setSlices(double sl) {
207  slices = sl;
208 }
209 
210 void SBendRep::setStepsize(double ds) {
211  stepsize = ds;
212 }
213 
214 
216  field = f;
217 }
virtual void setSlices(double sl)
Set number of slices.
Definition: SBendRep.cpp:206
double rExit
Definition: SBendRep.h:146
double stepsize
Definition: SBendRep.h:152
virtual double getEntryFaceCurvature() const
Get entry pole face curvature.
Definition: SBendRep.cpp:181
double getNormalComponent(int) const
Get normal component.
Definition: SBend.cpp:59
virtual void setEntryFaceCurvature(double h1)
Set entry pole face curvature.
Definition: SBendRep.cpp:189
virtual PlanarArcGeometry & getGeometry()
Get geometry.
Definition: SBendRep.cpp:146
virtual void setEntryFaceRotation(double e1)
Set pole entry face rotation.
Definition: SBendRep.cpp:173
virtual double getSlices() const
Get number of slices.
Definition: SBendRep.cpp:198
double hExit
Definition: SBendRep.h:148
double hEntry
Definition: SBendRep.h:147
A simple arc in the XZ plane.
void setNormalComponent(int n, double Bn)
Set component.
virtual Channel * getChannel(const std::string &aKey, bool=false)
Construct a read/write channel.
Definition: SBendRep.cpp:104
virtual void setExitFaceCurvature(double h2)
Set exit pole face curvature.
Definition: SBendRep.cpp:193
double getNormalComponent(int n) const
Get component.
virtual void setB(double By)
Set vertical component.
Definition: SBendRep.cpp:159
double rEntry
Definition: SBendRep.h:145
Definition: SBend.h:68
virtual Channel * getChannel(const std::string &aKey, bool create=false)
Construct a read/write channel.
c Accompany it with the information you received as to the offer to distribute corresponding source complete source code means all the source code for all modules it plus any associated interface definition plus the scripts used to control compilation and installation of the executable as a special the source code distributed need not include anything that is normally and so on of the operating system on which the executable unless that component itself accompanies the executable If distribution of executable or object code is made by offering access to copy from a designated then offering equivalent access to copy the source code from the same place counts as distribution of the source even though third parties are not compelled to copy the source along with the object code You may not or distribute the Program except as expressly provided under this License Any attempt otherwise to sublicense or distribute the Program is void
Definition: LICENSE:162
SBendRep()
Definition: SBendRep.cpp:68
void setSkewComponent(int, double)
Set skew component.
Definition: SBend.cpp:71
virtual void setField(const BMultipoleField &field)
Set field.
Definition: SBendRep.cpp:215
virtual double getStepsize() const
Get stepsize.
Definition: SBendRep.cpp:202
virtual double getExitFaceRotation() const
Get exit pole face rotation.
Definition: SBendRep.cpp:169
virtual ~SBendRep()
Definition: SBendRep.cpp:95
set(_SRCS Action.cpp Attribute.cpp AttributeBase.cpp AttributeHandler.cpp BeamSequence.cpp Definition.cpp Directory.cpp Element.cpp Invalidator.cpp OpalData.cpp Object.cpp ObjectFunction.cpp PlaceRep.cpp RangeRep.cpp Table.cpp TableRowRep.cpp ValueDefinition.cpp) include_directories($
Definition: CMakeLists.txt:1
Abstract interface for read/write access to variable.
Definition: Channel.h:32
Access to a [b]double[/b] data member.
virtual void setStepsize(double ds)
Set stepsize.
Definition: SBendRep.cpp:210
double getSkewComponent(int) const
Get skew component.
Definition: SBend.cpp:63
virtual double getElementLength() const
Get design length.
Definition: ElementBase.h:415
virtual double getExitFaceCurvature() const
Get exit pole face curvature.
Definition: SBendRep.cpp:185
const std::string name
virtual ElementBase * clone() const
Return clone.
Definition: SBendRep.cpp:99
virtual double getB() const
Get field.
Definition: SBendRep.cpp:155
virtual void setElementLength(double length)
Set design length.
Definition: ElementBase.h:419
virtual double getEntryFaceRotation() const
Get pole entry face rotation.
Definition: SBendRep.cpp:164
BMultipoleField field
The multipole expansion.
Definition: SBendRep.h:142
virtual void setExitFaceRotation(double e2)
Set exit pole face rotation.
Definition: SBendRep.cpp:177
void setNormalComponent(int, double)
Set normal component.
Definition: SBend.cpp:67
virtual BMultipoleField & getField()
Get field.
Definition: SBendRep.cpp:137
The magnetic field of a multipole.
Access to an indexed [b]double[/b] data member.
double slices
Definition: SBendRep.h:151
PlanarArcGeometry geometry
The bend geometry.
Definition: SBendRep.h:139