OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
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;
119 virtual Euclid3D getEntranceFrame() const;
124 virtual Euclid3D getExitFrame() const;
125private:
126 double length_m;
127 double rho_m;
128 double s_0_m;
131};
132
133// inlined (trivial) member functions
134
135inline
137 double rho,
138 double s_0,
139 double lambda_left,
140 double lambda_right):
141 length_m(length), rho_m(rho), s_0_m(s_0),
142 lambda_left_m(lambda_left), lambda_right_m(lambda_right) {
143}
144
145inline
147 BGeometryBase(rhs),
148 length_m(rhs.length_m), rho_m(rhs.rho_m), s_0_m(rhs.s_0_m),
149 lambda_left_m(rhs.lambda_left_m), lambda_right_m(rhs.lambda_right_m) {
150}
151
152
153inline
155 const VarRadiusGeometry &rhs) {
156 length_m = rhs.length_m;
157 rho_m = rhs.rho_m;
158 s_0_m = rhs.s_0_m;
161 return *this;
162}
163inline
165}
166inline
168 return length_m;
169}
170inline
172 return length_m;
173}
174inline
176 if (length < 0.0) {
177 throw GeneralClassicException("VarRadiusGeometry::setElementLength",
178 "The length of an element has to be positive");
179 }
180 length_m = std::max(0.0, length);
181}
182inline
184 return rho_m;
185}
186inline
187 void VarRadiusGeometry::setRadius(const double &rho) {
188 rho_m = rho;
189}
190inline
192 return s_0_m;
193}
194inline
195 void VarRadiusGeometry::setS0(const double &s_0) {
196 s_0_m = s_0;
197}
198inline
200 return lambda_left_m;
201}
202inline
203 void VarRadiusGeometry::setLambdaLeft(const double &lambda_left) {
204 lambda_left_m = lambda_left;
205}
206inline
208 return lambda_right_m;
209}
210inline
211 void VarRadiusGeometry::setLambdaRight(const double &lambda_right) {
212 lambda_right_m = lambda_right;
213}
214inline
217}
218inline
220 return getTransform(getOrigin(), getExit());
221}
222
223#endif
T::PETE_Expr_t::PETE_Return_t max(const PETE_Expr< T > &expr, NDIndex< D > &loc)
Definition: ReductionLoc.h:84
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
virtual ~VarRadiusGeometry()
void setS0(const double &s_0)
const VarRadiusGeometry & operator=(const VarRadiusGeometry &right)
virtual void setElementLength(double length)
virtual Euclid3D getEntranceFrame() const
void setLambdaRight(const double &lambda_right)
double getLambdaLeft() const
void setLambdaLeft(const double &lambda_left)
void setRadius(const double &rho)
double getS0() const
virtual double getArcLength() const
virtual double getElementLength() const
VarRadiusGeometry(double length, double rho, double s_0, double lambda_left, double lambda_right)
double getRadius() const
virtual Euclid3D getTransform(double fromS, double toS) const
double getLambdaRight() const