OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Attributes | Static Private Attributes | List of all members
Offset Class Reference

#include <Offset.h>

Inheritance diagram for Offset:
Inheritance graph
[legend]
Collaboration diagram for Offset:
Collaboration graph
[legend]

Public Member Functions

 Offset (const std::string &name)
 
 Offset ()
 
 Offset (std::string name, const Offset &)
 
 Offset (const Offset &)
 
Offsetoperator= (const Offset &)
 
 ~Offset ()
 
void accept (BeamlineVisitor &) const override
 
ElementBaseclone () const override
 
bool bends () const override
 
void initialise (PartBunchBase< double, 3 > *bunch, double &startField, double &endField) override
 
void finalise () override
 
void getDimensions (double &, double &) const override
 
void setEndPosition (Vector_t position)
 
Vector_t getEndPosition () const
 
void setEndDirection (Vector_t direction)
 
Vector_t getEndDirection () const
 
void setIsLocal (bool isLocal)
 
bool getIsLocal () const
 
Euclid3DGeometrygetGeometry () override
 Get geometry. More...
 
const Euclid3DGeometrygetGeometry () const override
 Get geometry. More...
 
void updateGeometry (Vector_t startPosition, Vector_t startDirection)
 
void updateGeometry ()
 
bool isGeometryAllocated () const
 
EMFieldgetField () override
 Not implemented - throws GeneralClassicException. More...
 
const EMFieldgetField () const override
 Not implemented - throws GeneralClassicException. More...
 
- Public Member Functions inherited from Component
 Component (const std::string &name)
 Constructor with given name. More...
 
 Component ()
 
 Component (const Component &right)
 
virtual ~Component ()
 
virtual EMFieldgetField ()=0
 Return field. More...
 
virtual const EMFieldgetField () const =0
 Return field. More...
 
EVector Efield (const Point3D &P) const
 Return the field in a point. More...
 
BVector Bfield (const Point3D &P) const
 Return the field in a point. More...
 
EVector Efield (const Point3D &P, double t) const
 Return the field in a point. More...
 
BVector Bfield (const Point3D &P, double t) const
 Return the field in a point. More...
 
EBVectors EBfield (const Point3D &P) const
 Return the field in a point. More...
 
EBVectors EBfield (const Point3D &P, double t) const
 Return the field in a point. More...
 
virtual bool apply (const size_t &i, const double &t, Vector_t &E, Vector_t &B)
 
virtual bool apply (const Vector_t &R, const Vector_t &P, const double &t, Vector_t &E, Vector_t &B)
 
virtual bool applyToReferenceParticle (const Vector_t &R, const Vector_t &P, const double &t, Vector_t &E, Vector_t &B)
 
virtual bool getPotential (const Vector_t &, const double &, Vector_t &, double &)
 
virtual double getDesignEnergy () const
 
virtual void setDesignEnergy (const double &energy, bool changeable=true)
 
virtual void initialise (PartBunchBase< double, 3 > *bunch, double &startField, double &endField)=0
 
virtual void finalise ()=0
 
virtual bool bends () const =0
 
virtual void goOnline (const double &kineticEnergy)
 
virtual void goOffline ()
 
virtual bool Online ()
 
virtual void getDimensions (double &zBegin, double &zEnd) const =0
 
virtual ElementType getType () const
 Get element type std::string. More...
 
virtual const ElementBasegetDesign () const
 Return design element. More...
 
virtual void trackBunch (PartBunchBase< double, 3 > *bunch, const PartData &, bool revBeam, bool revTrack) const
 Track particle bunch. More...
 
virtual void trackMap (FVps< double, 6 > &map, const PartData &, bool revBeam, bool revTrack) const
 Track a map. More...
 
void setExitFaceSlope (const double &)
 
- Public Member Functions inherited from ElementBase
 ElementBase (const std::string &name)
 Constructor with given name. More...
 
 ElementBase ()
 
 ElementBase (const ElementBase &)
 
virtual ~ElementBase ()
 
virtual const std::string & getName () const
 Get element name. More...
 
virtual void setName (const std::string &name)
 Set element name. More...
 
virtual ElementType getType () const =0
 Get element type std::string. More...
 
std::string getTypeString () const
 
virtual BGeometryBasegetGeometry ()=0
 Get geometry. More...
 
virtual const BGeometryBasegetGeometry () const =0
 Get geometry. More...
 
virtual double getArcLength () const
 Get arc length. More...
 
virtual double getElementLength () const
 Get design length. More...
 
virtual void setElementLength (double length)
 Set design length. More...
 
virtual void getElementDimensions (double &begin, double &end) const
 
virtual double getOrigin () const
 Get origin position. More...
 
virtual double getEntrance () const
 Get entrance position. More...
 
virtual double getExit () const
 Get exit position. More...
 
virtual Euclid3D getTransform (double fromS, double toS) const
 Get transform. More...
 
virtual Euclid3D getTransform (double s) const
 Get transform. More...
 
virtual Euclid3D getTotalTransform () const
 Get transform. More...
 
virtual Euclid3D getEntranceFrame () const
 Get transform. More...
 
virtual Euclid3D getExitFrame () const
 Get transform. More...
 
virtual Euclid3D getEntrancePatch () const
 Get patch. More...
 
virtual Euclid3D getExitPatch () const
 Get patch. More...
 
virtual double getAttribute (const std::string &aKey) const
 Get attribute value. More...
 
virtual bool hasAttribute (const std::string &aKey) const
 Test for existence of an attribute. More...
 
virtual void removeAttribute (const std::string &aKey)
 Remove an existing attribute. More...
 
virtual void setAttribute (const std::string &aKey, double val)
 Set value of an attribute. More...
 
virtual ChannelgetChannel (const std::string &aKey, bool create=false)
 Construct a read/write channel. More...
 
virtual const ConstChannelgetConstChannel (const std::string &aKey) const
 Construct a read-only channel. More...
 
virtual void accept (BeamlineVisitor &visitor) const =0
 Apply visitor. More...
 
virtual ElementBaseclone () const =0
 Return clone. More...
 
virtual ElementBasecopyStructure ()
 Make a structural copy. More...
 
bool isSharable () const
 Test if the element can be shared. More...
 
virtual void makeSharable ()
 Set sharable flag. More...
 
bool update (const AttributeSet &)
 Update element. More...
 
virtual void setBoundaryGeometry (BoundaryGeometry *geo)
 
virtual BoundaryGeometrygetBoundaryGeometry () const
 return the attached boundary geometrt object if there is any More...
 
virtual bool hasBoundaryGeometry () const
 
virtual void setWake (WakeFunction *wf)
 attach a wake field to the element More...
 
virtual WakeFunctiongetWake () const
 return the attached wake object if there is any More...
 
virtual bool hasWake () const
 
virtual void setParticleMatterInteraction (ParticleMatterInteractionHandler *spys)
 
virtual ParticleMatterInteractionHandlergetParticleMatterInteraction () const
 
virtual bool hasParticleMatterInteraction () const
 
void setCSTrafoGlobal2Local (const CoordinateSystemTrafo &ori)
 
CoordinateSystemTrafo getCSTrafoGlobal2Local () const
 
void releasePosition ()
 
void fixPosition ()
 
bool isPositioned () const
 
virtual CoordinateSystemTrafo getEdgeToBegin () const
 
virtual CoordinateSystemTrafo getEdgeToEnd () const
 
void setAperture (const ApertureType &type, const std::vector< double > &args)
 
std::pair< ApertureType, std::vector< double > > getAperture () const
 
virtual bool isInside (const Vector_t &r) const
 
void setMisalignment (const CoordinateSystemTrafo &cst)
 
void getMisalignment (double &x, double &y, double &s) const
 
CoordinateSystemTrafo getMisalignment () const
 
void setActionRange (const std::queue< std::pair< double, double > > &range)
 
void setCurrentSCoordinate (double s)
 
void setRotationAboutZ (double rotation)
 Set rotation about z axis in bend frame. More...
 
double getRotationAboutZ () const
 
virtual BoundingBox getBoundingBoxInLabCoords () const
 
virtual int getRequiredNumberOfTimeSteps () const
 
void setOutputFN (std::string fn)
 Set output filename. More...
 
std::string getOutputFN () const
 Get output filename. More...
 
void setFlagDeleteOnTransverseExit (bool=true)
 
bool getFlagDeleteOnTransverseExit () const
 
void setElementPosition (double elemedge)
 Access to ELEMEDGE attribute. More...
 
double getElementPosition () const
 
bool isElementPositionSet () const
 
- Public Member Functions inherited from RCObject
int addReference () const
 Increment reference count. More...
 
int removeReference () const
 Decrement the reference count. More...
 
bool isShared () const
 Test for sharing. More...
 

Static Public Member Functions

static Offset localCylindricalOffset (std::string name, double theta_in, double theta_out, double displacement)
 
static Offset globalCylindricalOffset (std::string name, double radius_out, double phi_out, double theta_out)
 
static Offset localCartesianOffset (std::string name, Vector_t end_position, Vector_t end_direction)
 
static Offset globalCartesianOffset (std::string name, Vector_t end_position, Vector_t end_direction)
 
static double getTheta (Vector_t vec1, Vector_t vec2)
 
static Vector_t rotate (Vector_t vec, double theta)
 
- Static Public Member Functions inherited from ElementBase
static std::string getTypeString (ElementType type)
 

Static Public Attributes

static double float_tolerance = 1e-12
 

Private Attributes

Vector_t _end_position
 
Vector_t _end_direction
 
bool _is_local
 
Euclid3DGeometrygeometry_m = nullptr
 

Static Private Attributes

static const double lengthUnits_m = 1e3
 

Additional Inherited Members

- Protected Member Functions inherited from ElementBase
bool isInsideTransverse (const Vector_t &r) const
 
- Protected Member Functions inherited from RCObject
 RCObject ()
 Default constructor. More...
 
 RCObject (const RCObject &)
 Copy constructor. More...
 
virtual ~RCObject ()=0
 
RCObjectoperator= (const RCObject &right)
 
- Protected Attributes inherited from Component
double exit_face_slope_m
 
PartBunchBase< double, 3 > * RefPartBunch_m
 
bool online_m
 
- Protected Attributes inherited from ElementBase
bool shareFlag
 
CoordinateSystemTrafo csTrafoGlobal2Local_m
 
CoordinateSystemTrafo misalignment_m
 
std::pair< ApertureType, std::vector< double > > aperture_m
 
double elementEdge_m
 
double rotationZAxis_m
 
- Static Protected Attributes inherited from Component
static const std::vector< double > defaultAperture_m
 

Detailed Description

@Class Offset

Enables user to define a placement, either in global coordinates or in the coordinate system of the previously placed object

Parameters
_end_positionfinal position of the offset
_end_directionnormal vector to entry face
_is_localparameter is True if everything is in the coordinate system of the last placed object. It is expected that everything will be in a local coordinate system before tracking begins (this is expected by, for example, Ring). This is expected to be set by the visit function in e.g. ParallelCyclotronTracker.
geometrythe geometry that RingSection uses to do displacements This has to be a pointer because SRotatedGeometry does not have an defined assignment op. SRotatedGeometry does not have a assignment op because BGeometryBase does not have an assignment op... and there is no way (I think) to reassign a previously assigned variable in C++ without using =
wrappedGeometrySomething to do with the reference handling in SRotatedGeometry - looks like it doesn't make a copy but holds a reference, so unless I keep that alive in Offset I get memory errors (seg fault) @float_tolerance bends() and operator==(...) use float_tolerance when evaluating equality between doubles. @lengthUnits_m conversion factor from user interface to get to mm

WARNING: this object uses a default aperture that is large. It will screw up any calculation based on aperture (e.g. wakefields etc)

Definition at line 66 of file Offset.h.

Constructor & Destructor Documentation

◆ Offset() [1/4]

Offset::Offset ( const std::string &  name)
explicit

Constructor sets everything to 0., makes a default geometry with everything set to 0.

Definition at line 40 of file Offset.cpp.

References geometry_m.

◆ Offset() [2/4]

Offset::Offset ( )

Default constructor sets everything to 0., makes a default geometry with everything set to 0.

Definition at line 45 of file Offset.cpp.

Referenced by clone().

◆ Offset() [3/4]

Offset::Offset ( std::string  name,
const Offset rhs 
)

Copy constructor; deep copies geometry_m; all other stuff is copied as well

Definition at line 49 of file Offset.cpp.

References name, and ElementBase::setName().

Here is the call graph for this function:

◆ Offset() [4/4]

Offset::Offset ( const Offset rhs)

Copy constructor; deep copies geometry_m; all other stuff is copied as well

Definition at line 55 of file Offset.cpp.

◆ ~Offset()

Offset::~Offset ( )

deletes geometry and wrappedGeometry

Definition at line 60 of file Offset.cpp.

References geometry_m.

Member Function Documentation

◆ accept()

void Offset::accept ( BeamlineVisitor visitor) const
overridevirtual

Apply visitor to Offset.

Sets ring radius

Implements ElementBase.

Definition at line 84 of file Offset.cpp.

References BeamlineVisitor::visitOffset().

Here is the call graph for this function:

◆ bends()

bool Offset::bends ( ) const
overridevirtual

Returns true if either input angle or output angle are greater than float_tolerance

Implements Component.

Definition at line 234 of file Offset.cpp.

References abs(), float_tolerance, geometry_m, Rotation3D::getAxis(), Euclid3D::getRotation(), Euclid3DGeometry::getTotalTransform(), and Euclid3D::getVector().

Here is the call graph for this function:

◆ clone()

ElementBase * Offset::clone ( ) const
overridevirtual

Just calls the copy constructor on *this

Implements ElementBase.

Definition at line 106 of file Offset.cpp.

References Offset().

Here is the call graph for this function:

◆ finalise()

void Offset::finalise ( )
overridevirtual

Implements Component.

Definition at line 102 of file Offset.cpp.

References Component::RefPartBunch_m.

◆ getDimensions()

void Offset::getDimensions ( double &  ,
double &   
) const
inlineoverridevirtual

Implements Component.

Definition at line 163 of file Offset.h.

◆ getEndDirection()

Vector_t Offset::getEndDirection ( ) const

Definition at line 122 of file Offset.cpp.

References _end_direction.

Referenced by operator<<(), operator==(), and updateGeometry().

◆ getEndPosition()

Vector_t Offset::getEndPosition ( ) const

Definition at line 114 of file Offset.cpp.

References _end_position.

Referenced by operator<<(), operator==(), and updateGeometry().

◆ getField() [1/2]

const EMField & Offset::getField ( ) const
overridevirtual

Not implemented - throws GeneralClassicException.

Implements Component.

Definition at line 93 of file Offset.cpp.

◆ getField() [2/2]

EMField & Offset::getField ( )
overridevirtual

Not implemented - throws GeneralClassicException.

Implements Component.

Definition at line 88 of file Offset.cpp.

◆ getGeometry() [1/2]

const Euclid3DGeometry & Offset::getGeometry ( ) const
overridevirtual

Get geometry.

Implements ElementBase.

Definition at line 138 of file Offset.cpp.

References geometry_m.

◆ getGeometry() [2/2]

Euclid3DGeometry & Offset::getGeometry ( )
overridevirtual

Get geometry.

Implements ElementBase.

Definition at line 134 of file Offset.cpp.

References geometry_m.

Referenced by operator==().

◆ getIsLocal()

bool Offset::getIsLocal ( ) const

Returns true if stored coordinates are in the local coordinate system of the last placed object

Definition at line 130 of file Offset.cpp.

References _is_local.

Referenced by operator<<(), and operator==().

◆ getTheta()

double Offset::getTheta ( Vector_t  vec1,
Vector_t  vec2 
)
static

Calculate the angle between vectors on the midplane

Returns theta in domain -pi, pi. A positive angle means a rotation anticlockwise from vec1 to vec2.

Throws an GeneralClassicException if vec1, vec2 are not in the midplane i.e. non-zero z.

Definition at line 147 of file Offset.cpp.

References abs(), atan2(), Physics::e, and Physics::pi.

Referenced by updateGeometry().

Here is the call graph for this function:

◆ globalCartesianOffset()

Offset Offset::globalCartesianOffset ( std::string  name,
Vector_t  end_position,
Vector_t  end_direction 
)
static

Factory method to make an offset in global cartesian coordinates

  • name name of the offset
  • end_position position of the end of the offset
  • end_direction direction of the end of the offset Call updateGeometry(Vector_t, Vector_t) using the end of the previous element before placement; Offset will convert to the local coordinate system.

Definition at line 295 of file Offset.cpp.

References lengthUnits_m, name, setEndDirection(), setEndPosition(), and setIsLocal().

Referenced by OpalOffset::OpalGlobalCartesianOffset::update().

Here is the call graph for this function:

◆ globalCylindricalOffset()

Offset Offset::globalCylindricalOffset ( std::string  name,
double  radius_out,
double  phi_out,
double  theta_out 
)
static

Factory method to make an offset in global cylindrical polar coordinates

  • name name of the offset
  • radius_out radius of the end of the offset
  • phi_out azimuthal angle of the end of the offset
  • theta_out angle relative to the tangent of the end of the offset Call updateGeometry(Vector_t, Vector_t) using the end of the previous element before placement; Offset will convert to the local coordinate system.

Definition at line 267 of file Offset.cpp.

References cos(), lengthUnits_m, name, setEndDirection(), setEndPosition(), setIsLocal(), and sin().

Referenced by OpalOffset::OpalGlobalCylindricalOffset::update().

Here is the call graph for this function:

◆ initialise()

void Offset::initialise ( PartBunchBase< double, 3 > *  bunch,
double &  startField,
double &  endField 
)
overridevirtual

Implements Component.

Definition at line 98 of file Offset.cpp.

References Component::RefPartBunch_m.

◆ isGeometryAllocated()

bool Offset::isGeometryAllocated ( ) const

Definition at line 194 of file Offset.cpp.

References geometry_m.

Referenced by operator==().

◆ localCartesianOffset()

Offset Offset::localCartesianOffset ( std::string  name,
Vector_t  end_position,
Vector_t  end_direction 
)
static

Factory method to make an offset in cartesian coordinates local to the end of the previous element

  • name name of the offset
  • end_position position of the end of the offset
  • end_direction direction of the end of the offset

Definition at line 283 of file Offset.cpp.

References lengthUnits_m, name, setEndDirection(), setEndPosition(), setIsLocal(), and updateGeometry().

Referenced by OpalOffset::OpalLocalCartesianOffset::update().

Here is the call graph for this function:

◆ localCylindricalOffset()

Offset Offset::localCylindricalOffset ( std::string  name,
double  theta_in,
double  theta_out,
double  displacement 
)
static

Factory method to make an offset in Cylindrical coordinates local to the end of the previous element

  • name name of the offset
  • theta_in angle between the previous element and the displacement vector
  • theta_out angle between the displacement vector and the next element
  • displacement length of the displacement vector in the theta_in direction

Definition at line 252 of file Offset.cpp.

References cos(), lengthUnits_m, name, setEndDirection(), setEndPosition(), setIsLocal(), sin(), and updateGeometry().

Referenced by OpalOffset::OpalLocalCylindricalOffset::update().

Here is the call graph for this function:

◆ operator=()

Offset & Offset::operator= ( const Offset rhs)

Assignment operator deep copies geometry and wrappedGeometry; all other stuff is copied as well

Definition at line 64 of file Offset.cpp.

References _end_direction, _end_position, _is_local, geometry_m, ElementBase::getAperture(), ElementBase::getName(), Euclid3DGeometry::getTotalTransform(), ElementBase::setAperture(), and ElementBase::setName().

Here is the call graph for this function:

◆ rotate()

Vector_t Offset::rotate ( Vector_t  vec,
double  theta 
)
static

Rotate vec anticlockwise by angle theta about z axis; return the rotated vector

Definition at line 158 of file Offset.cpp.

References Physics::c, cos(), and sin().

Referenced by updateGeometry().

Here is the call graph for this function:

◆ setEndDirection()

void Offset::setEndDirection ( Vector_t  direction)

◆ setEndPosition()

void Offset::setEndPosition ( Vector_t  position)

◆ setIsLocal()

void Offset::setIsLocal ( bool  isLocal)

Set to true if stored coordinates are in the local coordinate system of the last placed object

Definition at line 126 of file Offset.cpp.

References _is_local.

Referenced by globalCartesianOffset(), globalCylindricalOffset(), localCartesianOffset(), and localCylindricalOffset().

◆ updateGeometry() [1/2]

void Offset::updateGeometry ( )

Definition at line 166 of file Offset.cpp.

References _is_local, cos(), geometry_m, getEndDirection(), getEndPosition(), getTheta(), sin(), and sqrt().

Referenced by updateGeometry().

Here is the call graph for this function:

◆ updateGeometry() [2/2]

void Offset::updateGeometry ( Vector_t  startPosition,
Vector_t  startDirection 
)

Definition at line 183 of file Offset.cpp.

References _end_direction, _end_position, _is_local, getTheta(), rotate(), and updateGeometry().

Referenced by localCartesianOffset(), localCylindricalOffset(), and ParallelCyclotronTracker::visitOffset().

Here is the call graph for this function:

Member Data Documentation

◆ _end_direction

Vector_t Offset::_end_direction
private

Definition at line 209 of file Offset.h.

Referenced by getEndDirection(), operator=(), setEndDirection(), and updateGeometry().

◆ _end_position

Vector_t Offset::_end_position
private

Definition at line 208 of file Offset.h.

Referenced by getEndPosition(), operator=(), setEndPosition(), and updateGeometry().

◆ _is_local

bool Offset::_is_local
private

Definition at line 210 of file Offset.h.

Referenced by getIsLocal(), operator=(), setIsLocal(), and updateGeometry().

◆ float_tolerance

double Offset::float_tolerance = 1e-12
static

Definition at line 206 of file Offset.h.

Referenced by bends(), and operator==().

◆ geometry_m

Euclid3DGeometry* Offset::geometry_m = nullptr
private

◆ lengthUnits_m

const double Offset::lengthUnits_m = 1e3
staticprivate

The documentation for this class was generated from the following files: