OPALX (Object Oriented Parallel Accelerator Library for Exascal) MINIorX
OPALX
RingSection.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2012-2014, Chris Rogers
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 RING_SECTION_H
29#define RING_SECTION_H
30
31#include <vector>
32
34
66
68public:
72
74 RingSection(const RingSection& sec);
75
77
80
87 bool isOnOrPastStartPlane(const Vector_t<double, 3>& pos) const;
88
94 bool isPastEndPlane(const Vector_t<double, 3>& pos) const;
95
110 bool getFieldValue(
111 const Vector_t<double, 3>& pos, const Vector_t<double, 3>& centroid, const double& t,
113
125 std::vector<Vector_t<double, 3>> getVirtualBoundingBox() const;
126
128 bool doesOverlap(double phiStart, double phiEnd) const;
129
134 inline void setComponent(Component* component) {
135 component_m = component;
136 }
137
142 inline Component* getComponent() const {
143 return component_m;
144 }
145
148 startPosition_m = pos;
149 }
150
153 return startPosition_m;
154 }
155
157 inline void setStartNormal(Vector_t<double, 3> orientation);
158
161 return startOrientation_m;
162 }
163
166 endPosition_m = pos;
167 }
168
171 return endPosition_m;
172 }
173
175 inline void setEndNormal(Vector_t<double, 3> orientation);
176
179 return endOrientation_m;
180 }
181
184 componentPosition_m = position;
185 }
186
191
193 inline void setComponentOrientation(Vector_t<double, 3> orientation);
194
199
200private:
201 void rotate(Vector_t<double, 3>& vector) const;
202 void rotate_back(Vector_t<double, 3>& vector) const;
204 inline void rotateToTCoordinates(Vector_t<double, 3>& vec) const;
205 inline void rotateToCyclCoordinates(Vector_t<double, 3>& vec) const;
206
208
211
214
217
219 double sin2_m;
220 double cos2_m;
221};
222
223typedef std::vector<RingSection*> RingSectionList;
224
229
231 startOrientation_m = normalise(orientation);
232}
233
235 endOrientation_m = normalise(orientation);
236}
237
239 double magnitude = sqrt(
240 orientation(0) * orientation(0) + orientation(1) * orientation(1)
241 + orientation(2) * orientation(2));
242 if (magnitude > 0.)
243 orientation = orientation / magnitude;
244 return orientation;
245}
246
248 vec = Vector_t<double, 3>({vec(1), vec(2), vec(0)});
249}
250
252 vec = Vector_t<double, 3>({vec(2), vec(0), vec(1)});
253}
254
255#endif // RING_SECTION_H
ippl::Vector< T, Dim > Vector_t
std::vector< RingSection * > RingSectionList
Interface for a single beam element.
Definition Component.h:50
void setComponentOrientation(Vector_t< double, 3 > orientation)
Vector_t< double, 3 > getStartPosition() const
RingSection & operator=(const RingSection &sec)
Vector_t< double, 3 > componentOrientation_m
void rotateToCyclCoordinates(Vector_t< double, 3 > &vec) const
void setEndPosition(Vector_t< double, 3 > pos)
Vector_t< double, 3 > getEndPosition() const
void setComponent(Component *component)
bool getFieldValue(const Vector_t< double, 3 > &pos, const Vector_t< double, 3 > &centroid, const double &t, Vector_t< double, 3 > &E, Vector_t< double, 3 > &B) const
Vector_t< double, 3 > & normalise(Vector_t< double, 3 > &vector) const
void setStartNormal(Vector_t< double, 3 > orientation)
Vector_t< double, 3 > getEndNormal() const
void setComponentPosition(Vector_t< double, 3 > position)
Vector_t< double, 3 > getStartNormal() const
std::vector< Vector_t< double, 3 > > getVirtualBoundingBox() const
Component * getComponent() const
void rotateToTCoordinates(Vector_t< double, 3 > &vec) const
bool isOnOrPastStartPlane(const Vector_t< double, 3 > &pos) const
double sin2_m
Component * component_m
bool doesOverlap(double phiStart, double phiEnd) const
Vector_t< double, 3 > endPosition_m
double cos2_m
void updateComponentOrientation()
void setEndNormal(Vector_t< double, 3 > orientation)
Vector_t< double, 3 > startOrientation_m
void setStartPosition(Vector_t< double, 3 > pos)
void rotate_back(Vector_t< double, 3 > &vector) const
Vector_t< double, 3 > componentPosition_m
bool isPastEndPlane(const Vector_t< double, 3 > &pos) const
void rotate(Vector_t< double, 3 > &vector) const
Vector_t< double, 3 > startPosition_m
Vector_t< double, 3 > endOrientation_m
Vector_t< double, 3 > getComponentOrientation() const
Vector_t< double, 3 > getComponentPosition() const