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
57
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
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
238
239#endif //RING_SECTION_H
std::vector< RingSection * > RingSectionList
Tps< T > sec(const Tps< T > &x)
Secant.
Definition TpsMath.h:153
Interface for a single beam element.
Definition Component.h:50
Vector_t componentOrientation_m
void setStartNormal(Vector_t orientation)
RingSection & operator=(const RingSection &sec)
void rotate(Vector_t &vector) const
void setComponentPosition(Vector_t position)
void setComponent(Component *component)
void handleOffset()
void setStartPosition(Vector_t pos)
Vector_t getStartNormal() const
Vector_t startPosition_m
void setComponentOrientation(Vector_t orientation)
bool getFieldValue(const Vector_t &pos, const Vector_t &centroid, const double &t, Vector_t &E, Vector_t &B) const
void rotateToCyclCoordinates(Vector_t &vec) const
Vector_t endOrientation_m
void rotate_back(Vector_t &vector) const
Vector_t startOrientation_m
bool isOnOrPastStartPlane(const Vector_t &pos) const
Vector_t componentPosition_m
Component * getComponent() const
double sin2_m
Vector_t getComponentPosition() const
Component * component_m
bool doesOverlap(double phiStart, double phiEnd) const
Vector_t getEndPosition() const
double cos2_m
void updateComponentOrientation()
Vector_t getStartPosition() const
void setEndPosition(Vector_t pos)
Vector_t getEndNormal() const
void setEndNormal(Vector_t orientation)
Vector_t endPosition_m
Vector_t getComponentOrientation() const
Vector_t & normalise(Vector_t &vector) const
std::vector< Vector_t > getVirtualBoundingBox() const
void rotateToTCoordinates(Vector_t &vec) const
bool isPastEndPlane(const Vector_t &pos) const
Definition Vec.h:22
Vektor< double, 3 > Vector_t