OPAL (Object Oriented Parallel Accelerator Library) 2024.2
OPAL
RingSection.h
Go to the documentation of this file.
1//
2// Class RingSection
3// Defines the component placement handler in ring geometry.
4//
5// Copyright (c) 2012 - 2023, Chris Rogers, STFC Rutherford Appleton Laboratory, Didcot, UK
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 RING_SECTION_H
19#define RING_SECTION_H
20
22
23#include <cmath>
24#include <vector>
25
59
60public:
64
67
69
72
79 bool isOnOrPastStartPlane(const Vector_t& pos) const;
80
86 bool isPastEndPlane(const Vector_t& pos) const;
87
102 bool getFieldValue(const Vector_t& pos, const Vector_t& centroid,
103 const double& t, Vector_t& E, Vector_t& B) const;
104
116 std::vector<Vector_t> getVirtualBoundingBox() const;
117
119 bool doesOverlap(double phiStart, double phiEnd) const;
120
125 inline void setComponent(Component* component) {component_m = component;}
126
131 inline Component* getComponent() const {return component_m;}
132
134 inline void setStartPosition(Vector_t pos) {startPosition_m = pos;}
135
138
140 inline void setStartNormal(Vector_t orientation);
141
144
146 inline void setEndPosition(Vector_t pos) {endPosition_m = pos;}
147
149 inline Vector_t getEndPosition() const {return endPosition_m;}
150
152 inline void setEndNormal(Vector_t orientation);
153
155 inline Vector_t getEndNormal() const {return endOrientation_m;}
156
158 inline void setComponentPosition(Vector_t position) {componentPosition_m = position;}
159
162
164 inline void setComponentOrientation(Vector_t orientation);
165
168
180 void handleOffset();
181
182private:
183 void rotate(Vector_t& vector) const;
184 void rotate_back(Vector_t& vector) const;
185 inline Vector_t& normalise(Vector_t& vector) const;
186 inline void rotateToTCoordinates(Vector_t& vec) const;
187 inline void rotateToCyclCoordinates(Vector_t& vec) const;
188
190
193
196
199
201 double sin2_m;
202 double cos2_m;
203};
204
205typedef std::vector<RingSection*> RingSectionList;
206
208 componentOrientation_m = orientation;
210}
211
212inline void RingSection::setStartNormal(Vector_t orientation) {
213 startOrientation_m = normalise(orientation);
214}
215
216inline void RingSection::setEndNormal(Vector_t orientation) {
217 endOrientation_m = normalise(orientation);
218}
219
220inline Vector_t& RingSection::normalise(Vector_t& orientation) const {
221 double magnitude = std::sqrt(orientation(0) * orientation(0) +
222 orientation(1) * orientation(1) +
223 orientation(2) * orientation(2));
224 if (magnitude > 0.) {
225 orientation /= magnitude;
226 }
227 return orientation;
228}
229
230
232 vec = Vector_t(vec(1), vec(2), vec(0));
233}
234
236 vec = Vector_t(vec(2), vec(0), vec(1));
237}
238
239#endif //RING_SECTION_H
std::vector< RingSection * > RingSectionList
Definition: RingSection.h:205
Tps< T > sec(const Tps< T > &x)
Secant.
Definition: TpsMath.h:153
Tps< T > sqrt(const Tps< T > &x)
Square root.
Definition: TpsMath.h:91
static double magnitude(const Vector_t &v)
Interface for a single beam element.
Definition: Component.h:50
Component placement handler in ring geometry.
Definition: RingSection.h:58
Vector_t componentOrientation_m
Definition: RingSection.h:192
void setStartNormal(Vector_t orientation)
Set the normal vector to the section start plane.
Definition: RingSection.h:212
RingSection & operator=(const RingSection &sec)
Definition: RingSection.cpp:46
void rotate(Vector_t &vector) const
void setComponentPosition(Vector_t position)
Set the displacement for the component relative to the section start.
Definition: RingSection.h:158
void setComponent(Component *component)
Set the component wrapped by RingSection.
Definition: RingSection.h:125
void handleOffset()
Check whether component_m is a global offset and handle.
void setStartPosition(Vector_t pos)
Set a position on the plane of the section start.
Definition: RingSection.h:134
Vector_t getStartNormal() const
Get the normal vector to the section start plane.
Definition: RingSection.h:143
Vector_t startPosition_m
Definition: RingSection.h:194
void setComponentOrientation(Vector_t orientation)
Set the rotation for the component relative to the section start.
Definition: RingSection.h:207
bool getFieldValue(const Vector_t &pos, const Vector_t &centroid, const double &t, Vector_t &E, Vector_t &B) const
Return field value in global coordinate system.
Definition: RingSection.cpp:88
void rotateToCyclCoordinates(Vector_t &vec) const
Definition: RingSection.h:235
Vector_t endOrientation_m
Definition: RingSection.h:198
void rotate_back(Vector_t &vector) const
Vector_t startOrientation_m
Definition: RingSection.h:195
bool isOnOrPastStartPlane(const Vector_t &pos) const
Return true if pos is on or past start plane.
Definition: RingSection.cpp:63
Vector_t componentPosition_m
Definition: RingSection.h:191
Component * getComponent() const
Get the component wrapped by RingSection.
Definition: RingSection.h:131
double sin2_m
Definition: RingSection.h:201
Vector_t getComponentPosition() const
Get the displacement for the component relative to the section start.
Definition: RingSection.h:161
Component * component_m
Definition: RingSection.h:189
bool doesOverlap(double phiStart, double phiEnd) const
Return true if the phi range overlaps bounding box elements.
Vector_t getEndPosition() const
Get a position on the section end plane.
Definition: RingSection.h:149
double cos2_m
Definition: RingSection.h:202
void updateComponentOrientation()
Vector_t getStartPosition() const
Get a position on the plane of the section start.
Definition: RingSection.h:137
void setEndPosition(Vector_t pos)
Set a position on the section end plane.
Definition: RingSection.h:146
Vector_t getEndNormal() const
Get the normal vector to the section end plane.
Definition: RingSection.h:155
void setEndNormal(Vector_t orientation)
Set the normal vector to the section end plane
Definition: RingSection.h:216
Vector_t endPosition_m
Definition: RingSection.h:197
Vector_t getComponentOrientation() const
Get the rotation for the component relative to the section start.
Definition: RingSection.h:167
Vector_t & normalise(Vector_t &vector) const
Definition: RingSection.h:220
std::vector< Vector_t > getVirtualBoundingBox() const
Get the "Virtual" bounding box for the RingSection.
void rotateToTCoordinates(Vector_t &vec) const
Definition: RingSection.h:231
bool isPastEndPlane(const Vector_t &pos) const
Return true if pos is past end plane.
Definition: RingSection.cpp:76
RingSection()
Construct a ring section - positions, orientations etc default to 0.
Definition: RingSection.cpp:25
~RingSection()
Destructor - does nothing.
Definition: RingSection.cpp:40
Definition: Vec.h:22
Vektor< double, 3 > Vector_t