34#include "Utility/Inform.h"
96 "Ring::Ring(const Ring&)",
97 "Can't copy construct LossDataSink so copy constructor fails");
111 std::shared_ptr<ParticleContainer_t> pc =
RefPartBunch_m->getParticleContainer();
112 auto Rview = pc->R.getView();
113 auto Pview = pc->P.getView();
118 bool flagNeedUpdate =
apply(R, P, t, E, B);
119 if (flagNeedUpdate) {
120 Inform gmsgALL(
"OPAL ", INFORM_ALL_NODES);
122 auto Qview = pc->Q.getView();
123 auto Mview = pc->M.getView();
124 auto Binview = pc->Bin.getView();
126 const double Q = Qview(
id);
127 const double M = Mview(
id);
130 gmsgALL <<
getName() <<
": particle " <<
id <<
" at " << R
131 <<
" m out of the field map boundary" << endl;
137 return flagNeedUpdate;
146 std::vector<RingSection*> sections =
148 bool outOfBounds =
true;
151 double rSquared = R[0] * R[0] + R[1] * R[1];
152 if (rSquared < minR2_m || rSquared >
maxR2_m) {
157 for (
size_t i = 0; i < sections.size(); ++i) {
162 outOfBounds &= sections[i]->getFieldValue(
211 double deltaAngle = std::atan2(rotationTest(2), rotationTest(0));
213 return elementRotation;
221 "Ring::checkMidplane",
222 std::string(
"Placement of elements out of the ") +
"midplane is not supported by Ring");
230 Euclid3D euclid(v(2), v(0), -v(1), r(2), r(0), -r(1));
255 "Ring::appendElement",
256 "Attempt to append element " + element.
getName() +
" when ring is locked");
273 double startF = std::atan2(startNorm(1), startNorm(0));
277 +delta.
getVector()(0) * std::sin(startF) + delta.
getVector()(1) * std::cos(startF), 0})
284 {+startNorm(0) * std::cos(endF) + startNorm(1) * std::sin(endF),
285 -startNorm(0) * std::sin(endF) + startNorm(1) * std::cos(endF), 0});
293 double dphi = atan2(startNorm(0), startNorm(1));
295 msg <<
"* Added " << element.
getName() <<
" to Ring" << endl;
310 "Ring::lockRing",
"Attempt to lock ring when it is already locked");
314 if (sectionListSize == 0) {
320 msg <<
"Applying symmetry to Ring" << endl;
322 for (
size_t j = 0; j < sectionListSize; ++j) {
356 for (
int i = 0; i < 3; ++i) {
367 ringSections_m = std::vector<std::vector<RingSection*> >(nSections);
391 if (minR < 0 || maxR < 0) {
393 "Ring::setRingAperture",
"Could not parse negative or undefined aperture limit");
PartBunch< PLayout_t< double, 3 >, double, 3 > PartBunch_t
ippl::Vector< T, Dim > Vector_t
constexpr double e
The value of.
constexpr double pi
The value of.
virtual void visitRing(const Ring &)=0
Apply the algorithm to a Ring element.
Component(const std::string &name)
Constructor with given name.
PartBunch_t * RefPartBunch_m
virtual const std::string & getName() const
Get element name.
virtual ElementBase * clone() const =0
Return clone.
virtual BGeometryBase & getGeometry()=0
Get geometry.
virtual void initialise(PartBunch_t *bunch, double &startField, double &endField) override
Rotation3D getRotationStartToEnd(Euclid3D delta) const
static bool sectionCompare(RingSection const *const sec1, RingSection const *const sec2)
virtual void finalise() override
Vector_t< double, 3 > getNextPosition() const
Vector_t< double, 3 > getNextNormal() const
RingSection * getLastSectionPlaced() const
virtual bool apply(const size_t &id, const double &t, Vector_t< double, 3 > &E, Vector_t< double, 3 > &B) override
double latticeThetaInit_m
std::vector< RingSectionList > ringSections_m
virtual void accept(BeamlineVisitor &visitor) const override
void setRingAperture(double minR, double maxR)
RingSectionList section_list_m
std::vector< RingSection * > getSectionsAt(const Vector_t< double, 3 > &pos)
void checkMidplane(Euclid3D delta) const
void setLossDataSink(LossDataSink *sink)
PartBunch_t * refPartBunch_m
void setRefPartBunch(PartBunch_t *bunch)
PlanarArcGeometry planarArcGeometry_m
virtual void getDimensions(double &zBegin, double &zEnd) const override
void appendElement(const Component &element)
void rotateToCyclCoordinates(Euclid3D &euclid3d) const
static const double lengthTolerance_m
static const double angleTolerance_m
Displacement and rotation in space.
const Vector3D & getVector() const
Get displacement.
const Rotation3D & getRotation() const
Get rotation.
virtual Euclid3D getTotalTransform() const
Get transform.
Rotation in 3-dimensional space.
static Rotation3D ZRotation(double angle)
Make rotation.
Vector3D getAxis() const
Get axis vector.
Component placement handler in ring geometry.
void setComponentOrientation(Vector_t< double, 3 > orientation)
Vector_t< double, 3 > getStartPosition() const
void setEndPosition(Vector_t< double, 3 > pos)
Vector_t< double, 3 > getEndPosition() const
void setComponent(Component *component)
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
void setEndNormal(Vector_t< double, 3 > orientation)
void setStartPosition(Vector_t< double, 3 > pos)