OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
SectorField Class Referenceabstract

#include <SectorField.h>

Inheritance diagram for SectorField:
Inheritance graph
[legend]

Public Member Functions

 SectorField (const std::string &file_name)
 
virtual ~SectorField ()
 
virtual bool getFieldstrength (const Vector_t &R_c, Vector_t &E_c, Vector_t &B_c) const =0
 
virtual std::vector< double > getPolarBoundingBoxMin () const
 
virtual std::vector< double > getPolarBoundingBoxMax () const
 
void getFieldDimensions (double &zBegin, double &zEnd, double &rBegin, double &rEnd) const
 
void getFieldDimensions (double &xIni, double &xFinal, double &yIni, double &yFinal, double &zIni, double &zFinal) const
 
bool isInBoundingBox (const double R_p[]) const
 

Static Public Member Functions

static void convertToPolar (double *position)
 
static void convertToPolar (const double *position_polar, double *value)
 
static void convertToCartesian (double *position)
 
static void convertToCartesian (const double *position_polar, double *value)
 

Protected Member Functions

void setPolarBoundingBox (double bbMinR, double bbMinY, double bbMinPhi, double bbMaxR, double bbMaxY, double bbMaxPhi, double bbTolR, double bbTolY, double bbTolPhi)
 

Protected Attributes

std::vector< double > bbMin_m
 
std::vector< double > bbMax_m
 
std::vector< double > polarBBMin_m
 
std::vector< double > polarBBMax_m
 
std::string Filename_m
 

Private Member Functions

std::vector< std::vector< double > > getCorners (double bbMinR, double bbMinPhi, double bbMaxR, double bbMaxPhi)
 

Detailed Description

SectorField is an abstraction type for a sector field map i.e. a field map with a bent geometry as in a ring. Functions are provided for converting from cartesian coordinate systems to ring coordinate systems and vice versa and field calculation functions are defined for the field in cartesian coordinates and additionally ring coordinates.

The sector field map holds two bounding boxes - the standard rectangular bounding box in cartesian coordinates and additionally a sector bounding box in polar coordinates. The bounding box should always be given in polar coordinates - SectorField will do the conversion to cartesian coordinates (note this is a lossy procedure)

Ring coordinates are typically given as three vectors going like (radius, y, angle) also denoted by (r, y, phi). The ring coordinate system is defined with (x, y, z) = (0, 0, 0) the centre of the ring; y is the same in ring and cartesian coordinate systems. Positive phi is anticlockwise in the (x, z) plane.

Definition at line 55 of file SectorField.h.

Constructor & Destructor Documentation

◆ SectorField()

SectorField::SectorField ( const std::string &  file_name)

Make an empty sector field; set bounding box to max double

Definition at line 41 of file SectorField.cpp.

References bbMax_m, bbMin_m, polarBBMax_m, and polarBBMin_m.

◆ ~SectorField()

SectorField::~SectorField ( )
virtual

Destructor (does nothing)

Definition at line 52 of file SectorField.cpp.

Member Function Documentation

◆ convertToCartesian() [1/2]

void SectorField::convertToCartesian ( const double *  position_polar,
double *  value 
)
static

Convert a 3 vector from polar to cartesian coordinate system

Parameters
positionposition in polar coordinates at which the value is valid
valuepointer to an allocated block of at least 3 doubles. The function will apply a rotation to the existing data to render it from polar coordinates (a_r, a_y, a_phi) to polar coordinates (a_x, a_y, a_z) appropriate for the specified position.

Definition at line 77 of file SectorField.cpp.

References cos(), and sin().

Here is the call graph for this function:

◆ convertToCartesian() [2/2]

void SectorField::convertToCartesian ( double *  position)
static

Convert a position from polar coordinates to cartesian

Parameters
positionposition in polar coordinates to convert to cartesian polar coordinates. Input should be an allocated block of at least 3 doubles containing values (r, y, phi). This is over written with 3 double containing values (x, y, z).

Definition at line 70 of file SectorField.cpp.

References cos(), and sin().

Referenced by getCorners().

Here is the call graph for this function:

◆ convertToPolar() [1/2]

void SectorField::convertToPolar ( const double *  position_polar,
double *  value 
)
static

Convert a 3 vector from cartesian to polar coordinate system

Parameters
positionposition in polar coordinates at which the value is valid
valuepointer to an allocated block of at least 3 doubles. The function will apply a rotation to the existing data to render it from cartesian coordinates (a_x, a_y, a_z) to polar coordinates (a_r, a_y, a_phi) appropriate for the specified position.

Definition at line 61 of file SectorField.cpp.

References cos(), and sin().

Here is the call graph for this function:

◆ convertToPolar() [2/2]

void SectorField::convertToPolar ( double *  position)
static

Convert a position from cartesian to polar coordinates

Parameters
positionposition in cartesian coordinates to convert to cylindrical polar coordinates. Input should be an allocated block of at least 3 doubles containing values (x, y, z). This is over written with 3 double containing values (r, y, phi).

Definition at line 54 of file SectorField.cpp.

References atan2(), and sqrt().

Referenced by SectorMagneticFieldMap::getFieldstrength(), and SectorMagneticFieldMap::IO::readLines().

Here is the call graph for this function:

◆ getCorners()

std::vector< std::vector< double > > SectorField::getCorners ( double  bbMinR,
double  bbMinPhi,
double  bbMaxR,
double  bbMaxPhi 
)
private

Definition at line 162 of file SectorField.cpp.

References convertToCartesian().

Referenced by setPolarBoundingBox().

Here is the call graph for this function:

◆ getFieldDimensions() [1/2]

void SectorField::getFieldDimensions ( double &  xIni,
double &  xFinal,
double &  yIni,
double &  yFinal,
double &  zIni,
double &  zFinal 
) const

Fill inputs with the bounding box in Cartesian coordinates

Parameters
xInilower bound on field x-position (horizontal)
xFinalupper bound on field x-position (horizontal)
yInilower bound on field y-position (vertical)
yFinalupper bound on field y-position (vertical)
zInilower bound on field z-position (longitudinal)
zFinalupper bound on field z-position (longitudinal)

Definition at line 205 of file SectorField.cpp.

References bbMax_m, and bbMin_m.

◆ getFieldDimensions() [2/2]

void SectorField::getFieldDimensions ( double &  zBegin,
double &  zEnd,
double &  rBegin,
double &  rEnd 
) const

Fill inputs with the bounding box in Polar coordinates

Parameters
zBeginlower bound on field length in phi direction (units of distance)
zEndupper bound on field length in phi direction (units of distance)
rBeginlower bound on field length in radial direction
rEndlower bound on field length in radial direction

Definition at line 197 of file SectorField.cpp.

References polarBBMax_m, and polarBBMin_m.

◆ getFieldstrength()

virtual bool SectorField::getFieldstrength ( const Vector_t R_c,
Vector_t E_c,
Vector_t B_c 
) const
pure virtual

Return the field value in polar coordinates

Parameters
R_pposition in cylindrical coordinates at which to evaluate the field. Should be an array of length 4 like (r, y, phi, t)
E_preference to an allocated 3-vector. The function will fill the block with the value of the field in cylindrical polar coordinates, (e_r, e_y, e_phi) Overwrites any existing data
B_preference to an allocated 3-vector. The function will fill the block with the value of the field in cylindrical polar coordinates, (b_r, b_y, b_phi) Overwrites any existing data
Returns
true if any field value is non-zero Return the field value in cartesian coordinates
Parameters
R_cposition in cartesian coordinates at which to evaluate the field. Should be an array of length 4 like (x, y, z, t)
E_preference to an allocated 3-vector. The function will fill the block with the value of the field in cartesian coordinates, (e_x, e_y, e_z) Overwrites any existing data
B_preference to an allocated 3-vector. The function will fill the block with the value of the field in cartesian coordinates, (b_x, b_y, b_z) Overwrites any existing data
Returns
true if any field value is non-zero

Implemented in SectorMagneticFieldMap.

◆ getPolarBoundingBoxMax()

std::vector< double > SectorField::getPolarBoundingBoxMax ( ) const
virtual

Get the maximum bounding box in polar coordinates

Returns
bounding box maximum as a 3-vector like (r_max, y_max, phi_max)

Definition at line 193 of file SectorField.cpp.

References polarBBMax_m.

Referenced by SectorMagneticFieldMap::getFieldstrength(), SectorMagneticFieldMap::getInfo(), SectorMagneticFieldMap::print(), and SBend3D::setFieldMapFileName().

◆ getPolarBoundingBoxMin()

std::vector< double > SectorField::getPolarBoundingBoxMin ( ) const
virtual

Get the minimum bounding box in polar coordinates

Returns
bounding box minimum as a 3-vector like (r_min, y_min, phi_min)

Definition at line 189 of file SectorField.cpp.

References polarBBMin_m.

Referenced by SectorMagneticFieldMap::applySymmetry(), SectorMagneticFieldMap::getFieldstrength(), SectorMagneticFieldMap::getInfo(), SectorMagneticFieldMap::print(), and SBend3D::setFieldMapFileName().

◆ isInBoundingBox()

bool SectorField::isInBoundingBox ( const double  R_p[]) const
inline

Return true if polar vector R_p is within polar bounding box

Parameters
R_ppolar coordinates (r, y, phi)

Definition at line 224 of file SectorField.h.

References polarBBMax_m, and polarBBMin_m.

Referenced by SectorMagneticFieldMap::getFieldstrength().

◆ setPolarBoundingBox()

void SectorField::setPolarBoundingBox ( double  bbMinR,
double  bbMinY,
double  bbMinPhi,
double  bbMaxR,
double  bbMaxY,
double  bbMaxPhi,
double  bbTolR,
double  bbTolY,
double  bbTolPhi 
)
protected

Set the bounding boxes from polar coordinates

Sets the bounding boxes, both polar and cartesian, based on a set of minimum and maximum polar coordinates. Note that MinPhi->MaxPhi are allowed in the domain -2pi to 2pi. If the difference is >= 2pi, then this will describe the full ring.

Parameters
bbMinRminimum radius - must be positive
bbMinYminimum y value
bbMinPhiminimum phi value - must be greater than -2*pi
bbMaxRmaximum radius - must be greater than minimum radius
bbMaxYmaximum y value - must be greater than minimum y value
bbMaxPhimaximum phi value - must be greater than minimum phi and less than 2*pi

Definition at line 86 of file SectorField.cpp.

References bbMax_m, bbMin_m, begin(), end(), getCorners(), polarBBMax_m, and polarBBMin_m.

Referenced by SectorMagneticFieldMap::setInterpolator().

Here is the call graph for this function:

Member Data Documentation

◆ bbMax_m

std::vector<double> SectorField::bbMax_m
protected

bounding box maximum as a 3-vector like (x_max, y_max, z_max)

Definition at line 211 of file SectorField.h.

Referenced by getFieldDimensions(), SectorField(), and setPolarBoundingBox().

◆ bbMin_m

std::vector<double> SectorField::bbMin_m
protected

bounding box minimum as a 3-vector like (x_min, y_min, z_min)

Definition at line 209 of file SectorField.h.

Referenced by getFieldDimensions(), SectorField(), and setPolarBoundingBox().

◆ Filename_m

std::string SectorField::Filename_m
protected

Keep the filename

Definition at line 217 of file SectorField.h.

Referenced by SectorMagneticFieldMap::getInfo(), and SectorMagneticFieldMap::print().

◆ polarBBMax_m

std::vector<double> SectorField::polarBBMax_m
protected

bounding box maximum as a 3-vector like (r_max, y_max, phi_max)

Definition at line 215 of file SectorField.h.

Referenced by getFieldDimensions(), getPolarBoundingBoxMax(), isInBoundingBox(), SectorField(), and setPolarBoundingBox().

◆ polarBBMin_m

std::vector<double> SectorField::polarBBMin_m
protected

bounding box minimum as a 3-vector like (r_min, y_min, phi_min)

Definition at line 213 of file SectorField.h.

Referenced by getFieldDimensions(), getPolarBoundingBoxMin(), isInBoundingBox(), SectorField(), and setPolarBoundingBox().


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