OPALX (Object Oriented Parallel Accelerator Library for Exascal) MINIorX
OPALX
Offset.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 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
29#ifndef CLASSIC_ABSBEAMLINE_Offset_HH
30#define CLASSIC_ABSBEAMLINE_Offset_HH
31
32#include "Fields/EMField.h"
35
36#include <string>
37
66class Offset : public Component {
67 public:
71 explicit Offset(const std::string &name);
72
76 Offset();
77
81 Offset(std::string name, const Offset &);
82
86 Offset(const Offset &);
87
91 Offset& operator=(const Offset &);
92
102 static Offset localCylindricalOffset(std::string name,
103 double theta_in,
104 double theta_out,
105 double displacement);
106
116 static Offset globalCylindricalOffset(std::string name,
117 double radius_out,
118 double phi_out,
119 double theta_out);
120
127 static Offset localCartesianOffset(std::string name,
128 Vector_t<double, 3> end_position,
129 Vector_t<double, 3> end_direction);
130
139 static Offset globalCartesianOffset(std::string name,
140 Vector_t<double, 3> end_position,
141 Vector_t<double, 3> end_direction);
142
144 ~Offset();
145
150 void accept(BeamlineVisitor &) const override;
151
153 ElementBase* clone() const override;
154
158 bool bends() const override;
159
160 void initialise(PartBunch_t *bunch, double &startField,
161 double &endField) override;
162 void finalise() override;
163 void getDimensions(double &/*zBegin*/, double &/*zEnd*/) const override {}
164
165 void setEndPosition(Vector_t<double, 3> position);
167
168 void setEndDirection(Vector_t<double, 3> direction);
170
174 void setIsLocal(bool isLocal);
175
179 bool getIsLocal() const;
180
181 Euclid3DGeometry& getGeometry() override;
182 const Euclid3DGeometry& getGeometry() const override;
183 void updateGeometry(Vector_t<double, 3> startPosition, Vector_t<double, 3> startDirection);
184 void updateGeometry();
185 bool isGeometryAllocated() const;
186
188 EMField &getField() override;
190 const EMField &getField() const override;
199 static double getTheta(Vector_t<double, 3> vec1, Vector_t<double, 3> vec2);
200
204 static Vector_t<double, 3> rotate(Vector_t<double, 3> vec, double theta);
205
206 static double float_tolerance;
207 private:
211 // The offset's geometry.
213 static const double lengthUnits_m;
214};
215
218bool operator==(const Offset& off1, const Offset& off2);
219
221bool operator!=(const Offset& off1, const Offset& off2);
222
224std::ostream& operator<<(std::ostream& out, const Offset& off1);
225
226#endif // CLASSIC_ABSBEAMLINE_Offset_HH
bool operator!=(const Offset &off1, const Offset &off2)
Definition Offset.cpp:216
std::ostream & operator<<(std::ostream &out, const Offset &off1)
Definition Offset.cpp:220
bool operator==(const Offset &off1, const Offset &off2)
Definition Offset.cpp:193
PartBunch< PLayout_t< double, 3 >, double, 3 > PartBunch_t
ippl::Vector< T, Dim > Vector_t
Component(const std::string &name)
Constructor with given name.
Definition Component.cpp:44
ElementBase(const std::string &name)
Constructor with given name.
void updateGeometry()
Definition Offset.cpp:160
Vector_t< double, 3 > getEndDirection() const
Definition Offset.cpp:118
Euclid3DGeometry & getGeometry() override
Get geometry.
Definition Offset.cpp:130
void setEndDirection(Vector_t< double, 3 > direction)
Definition Offset.cpp:114
Offset & operator=(const Offset &)
Definition Offset.cpp:62
static Offset localCylindricalOffset(std::string name, double theta_in, double theta_out, double displacement)
Definition Offset.cpp:244
bool isGeometryAllocated() const
Definition Offset.cpp:189
void finalise() override
Definition Offset.cpp:98
static Vector_t< double, 3 > rotate(Vector_t< double, 3 > vec, double theta)
Definition Offset.cpp:154
bool _is_local
Definition Offset.h:210
Vector_t< double, 3 > _end_position
Definition Offset.h:208
static Offset globalCartesianOffset(std::string name, Vector_t< double, 3 > end_position, Vector_t< double, 3 > end_direction)
Definition Offset.cpp:280
~Offset()
Definition Offset.cpp:58
void getDimensions(double &, double &) const override
Definition Offset.h:163
Vector_t< double, 3 > _end_direction
Definition Offset.h:209
static const double lengthUnits_m
Definition Offset.h:213
EMField & getField() override
Not implemented - throws GeneralClassicException.
Definition Offset.cpp:86
Offset()
Definition Offset.cpp:44
static double getTheta(Vector_t< double, 3 > vec1, Vector_t< double, 3 > vec2)
Definition Offset.cpp:143
static double float_tolerance
Definition Offset.h:206
void initialise(PartBunch_t *bunch, double &startField, double &endField) override
Definition Offset.cpp:94
static Offset localCartesianOffset(std::string name, Vector_t< double, 3 > end_position, Vector_t< double, 3 > end_direction)
Definition Offset.cpp:269
Offset(const std::string &name)
Definition Offset.cpp:40
void setEndPosition(Vector_t< double, 3 > position)
Definition Offset.cpp:106
ElementBase * clone() const override
Definition Offset.cpp:102
void accept(BeamlineVisitor &) const override
Definition Offset.cpp:82
static Offset globalCylindricalOffset(std::string name, double radius_out, double phi_out, double theta_out)
Definition Offset.cpp:257
Vector_t< double, 3 > getEndPosition() const
Definition Offset.cpp:110
Euclid3DGeometry * geometry_m
Definition Offset.h:212
bool getIsLocal() const
Definition Offset.cpp:126
void setIsLocal(bool isLocal)
Definition Offset.cpp:122
bool bends() const override
Definition Offset.cpp:227
Abstract base class for electromagnetic fields.
Definition EMField.h:188