OPALX (Object Oriented Parallel Accelerator Library for Exascale) MINIorX
OPALX
VarRadiusGeometry.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018, Martin Duy Tat
3 * All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * 1. Redistributions of source code must retain the above copyright notice,
7 * this list of conditions and the following disclaimer.
8 * 2. Redistributions in binary form must reproduce the above copyright notice,
9 * this list of conditions and the following disclaimer in the documentation
10 * and/or other materials provided with the distribution.
11 * 3. Neither the name of STFC nor the names of its contributors may be used to
12 * endorse or promote products derived from this software without specific
13 * prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#ifndef CLASSIC_VarRadiusGeometry_HH
29#define CLASSIC_VarRadiusGeometry_HH
30
55#include <algorithm>
56
58public:
67 VarRadiusGeometry(double length,
68 double rho,
69 double s_0,
70 double lambda_left,
71 double lambda_right);
75 virtual ~VarRadiusGeometry();
79 virtual double getArcLength() const;
81 virtual double getElementLength() const;
85 virtual void setElementLength(double length);
87 double getRadius() const;
91 void setRadius(const double &rho);
93 double getS0() const;
97 void setS0(const double &s_0);
99 double getLambdaLeft() const;
103 void setLambdaLeft(const double &lambda_left);
105 double getLambdaRight() const;
109 void setLambdaRight(const double &lambda_right);
114 virtual Euclid3D getTransform(double fromS, double toS) const;
120 virtual Euclid3D getTransform(double fromS) const;
126 virtual Euclid3D getEntranceFrame() const;
131 virtual Euclid3D getExitFrame() const;
132private:
133 double length_m;
134 double rho_m;
135 double s_0_m;
138};
139
140// inlined (trivial) member functions
141
142inline
144 double rho,
145 double s_0,
146 double lambda_left,
147 double lambda_right):
148 length_m(length), rho_m(rho), s_0_m(s_0),
149 lambda_left_m(lambda_left), lambda_right_m(lambda_right) {
150}
151
152inline
154 BGeometryBase(rhs),
155 length_m(rhs.length_m), rho_m(rhs.rho_m), s_0_m(rhs.s_0_m),
156 lambda_left_m(rhs.lambda_left_m), lambda_right_m(rhs.lambda_right_m) {
157}
158
159
160inline
162 const VarRadiusGeometry &rhs) {
163 length_m = rhs.length_m;
164 rho_m = rhs.rho_m;
165 s_0_m = rhs.s_0_m;
168 return *this;
169}
170inline
172}
173inline
175 return length_m;
176}
177inline
179 return length_m;
180}
181inline
183 if (length < 0.0) {
184 throw GeneralClassicException("VarRadiusGeometry::setElementLength",
185 "The length of an element has to be positive");
186 }
187 length_m = std::max(0.0, length);
188}
189inline
191 return rho_m;
192}
193inline
194 void VarRadiusGeometry::setRadius(const double &rho) {
195 rho_m = rho;
196}
197inline
199 return s_0_m;
200}
201inline
202 void VarRadiusGeometry::setS0(const double &s_0) {
203 s_0_m = s_0;
204}
205inline
207 return lambda_left_m;
208}
209inline
210 void VarRadiusGeometry::setLambdaLeft(const double &lambda_left) {
211 lambda_left_m = lambda_left;
212}
213inline
215 return lambda_right_m;
216}
217inline
218 void VarRadiusGeometry::setLambdaRight(const double &lambda_right) {
219 lambda_right_m = lambda_right;
220}
221inline
224}
225inline
227 return getTransform(getOrigin(), getExit());
228}
229
230#endif
KOKKOS_INLINE_FUNCTION Vector< T, Dim > max(const Vector< T, Dim > &a, const Vector< T, Dim > &b)
Definition: Vector.hpp:226
Displacement and rotation in space.
Definition: Euclid3D.h:68
Abstract base class for accelerator geometry classes.
Definition: Geometry.h:43
virtual double getEntrance() const
Get entrance position.
Definition: Geometry.cpp:41
virtual double getExit() const
Get exit position.
Definition: Geometry.cpp:46
virtual double getOrigin() const
Get origin position.
Definition: Geometry.cpp:36
virtual Euclid3D getExitFrame() const
Transform of the local coordinate system from the origin to the exit of the element Equivalent to get...
virtual ~VarRadiusGeometry()
Destructor.
void setS0(const double &s_0)
Set central fringe field length.
const VarRadiusGeometry & operator=(const VarRadiusGeometry &right)
Assigment operator.
virtual void setElementLength(double length)
Set arc length.
virtual Euclid3D getEntranceFrame() const
Transform of the local coordinate system from the origin to the entrance of the element Equivalent to...
void setLambdaRight(const double &lambda_right)
Set right end fringe field length.
double getLambdaLeft() const
Get left end fringe field length.
void setLambdaLeft(const double &lambda_left)
Set left end fringe field length.
void setRadius(const double &rho)
Set centre radius of curvature.
double getS0() const
Get central fringe field length.
virtual double getArcLength() const
Arc length along the design arc.
virtual double getElementLength() const
Get element length measured along hte design arc.
VarRadiusGeometry(double length, double rho, double s_0, double lambda_left, double lambda_right)
Build VarRadiusGeometry with given length, centre radius of curvature and fringe field.
double getRadius() const
Get centre radius of curvature.
virtual Euclid3D getTransform(double fromS, double toS) const
Transform of the local coordinate system.
double getLambdaRight() const
Get right end fringe field length.