OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
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 end_position,
129 Vector_t end_direction);
130
139 static Offset globalCartesianOffset(std::string name,
140 Vector_t end_position,
141 Vector_t 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(PartBunchBase<double, 3> *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 position);
166 Vector_t getEndPosition() const;
167
168 void setEndDirection(Vector_t 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 startPosition, Vector_t 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 vec1, Vector_t vec2);
200
204 static Vector_t rotate(Vector_t 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:223
std::ostream & operator<<(std::ostream &out, const Offset &off1)
Definition: Offset.cpp:227
bool operator==(const Offset &off1, const Offset &off2)
Definition: Offset.cpp:198
const std::string name
Interface for a single beam element.
Definition: Component.h:50
Definition: Offset.h:66
void updateGeometry()
Definition: Offset.cpp:166
static Vector_t rotate(Vector_t vec, double theta)
Definition: Offset.cpp:158
static double getTheta(Vector_t vec1, Vector_t vec2)
Definition: Offset.cpp:147
Euclid3DGeometry & getGeometry() override
Get geometry.
Definition: Offset.cpp:134
Offset & operator=(const Offset &)
Definition: Offset.cpp:64
static Offset localCylindricalOffset(std::string name, double theta_in, double theta_out, double displacement)
Definition: Offset.cpp:252
bool isGeometryAllocated() const
Definition: Offset.cpp:194
void finalise() override
Definition: Offset.cpp:102
bool _is_local
Definition: Offset.h:210
Vector_t _end_position
Definition: Offset.h:208
~Offset()
Definition: Offset.cpp:60
void getDimensions(double &, double &) const override
Definition: Offset.h:163
static const double lengthUnits_m
Definition: Offset.h:213
void setEndPosition(Vector_t position)
Definition: Offset.cpp:110
Vector_t getEndPosition() const
Definition: Offset.cpp:114
EMField & getField() override
Not implemented - throws GeneralClassicException.
Definition: Offset.cpp:88
Offset()
Definition: Offset.cpp:45
void setEndDirection(Vector_t direction)
Definition: Offset.cpp:118
static double float_tolerance
Definition: Offset.h:206
static Offset globalCartesianOffset(std::string name, Vector_t end_position, Vector_t end_direction)
Definition: Offset.cpp:295
Vector_t _end_direction
Definition: Offset.h:209
static Offset localCartesianOffset(std::string name, Vector_t end_position, Vector_t end_direction)
Definition: Offset.cpp:283
ElementBase * clone() const override
Definition: Offset.cpp:106
void accept(BeamlineVisitor &) const override
Definition: Offset.cpp:84
static Offset globalCylindricalOffset(std::string name, double radius_out, double phi_out, double theta_out)
Definition: Offset.cpp:267
Euclid3DGeometry * geometry_m
Definition: Offset.h:212
bool getIsLocal() const
Definition: Offset.cpp:130
void setIsLocal(bool isLocal)
Definition: Offset.cpp:126
bool bends() const override
Definition: Offset.cpp:234
void initialise(PartBunchBase< double, 3 > *bunch, double &startField, double &endField) override
Definition: Offset.cpp:98
Vector_t getEndDirection() const
Definition: Offset.cpp:122
Abstract base class for electromagnetic fields.
Definition: EMField.h:188
Definition: Vec.h:22