OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
Classes | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
SectorMagneticFieldMap Class Reference

handles field map grids with sector geometry More...

#include <SectorMagneticFieldMap.h>

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

Classes

class  IO
 handles reading sector field maps More...
 

Public Member Functions

 SectorMagneticFieldMap (std::string file_name, std::string symmetry, double length_units, double field_units, int polynomial_order, int smoothing_order)
 
 SectorMagneticFieldMap (const SectorMagneticFieldMap &field)
 
 ~SectorMagneticFieldMap ()
 
bool getFieldstrength (const Vector_t &R_c, Vector_t &E_c, Vector_t &B_c) const
 
interpolation::VectorMapgetInterpolator ()
 
void setInterpolator (interpolation::VectorMap *interpolator)
 
std::string getFieldMapFileName () const
 
std::string getSymmetry () const
 
void setSymmetry (std::string name)
 
bool getFieldDerivative (const Vector_t &R, Vector_t &E, Vector_t &B, const DiffDirection &dir) const
 
void swap ()
 
void getInfo (Inform *msg)
 
void print (std::ostream &out)
 
void readMap ()
 
void freeMap ()
 
double getFrequency () const
 
void setFrequency (double)
 
double getPhiOffset () const
 
void setPhiOffset (double dphi)
 
double getDeltaPhi () const
 
- Public Member Functions inherited from SectorField
 SectorField (const std::string &file_name)
 
virtual ~SectorField ()
 
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 clearFieldCache ()
 
- Static Public Member Functions inherited from SectorField
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)
 

Private Types

enum  symmetry { none , dipole }
 

Private Member Functions

bool applySymmetry (double *R_temp) const
 
void Rotate (double *value, double angle)
 
SectorMagneticFieldMapoperator= (const SectorMagneticFieldMap &field)
 

Static Private Member Functions

static symmetry StringToSymmetry (std::string name)
 
static std::string SymmetryToString (symmetry sym)
 

Private Attributes

interpolation::VectorMapinterpolator_m
 
symmetry symmetry_m
 
std::vector< double > units_m
 
const std::string filename_m
 
double phiOffset_m
 
int poly_order_m
 
int smoothing_order_m
 

Static Private Attributes

static const double fractionalBBPhiTolerance_m
 
static std::map< std::string, SectorMagneticFieldMap * > _fields
 

Friends

class FieldMap
 
class SectorMagneticFieldMapIO
 

Additional Inherited Members

- Protected Member Functions inherited from SectorField
void setPolarBoundingBox (double bbMinR, double bbMinY, double bbMinPhi, double bbMaxR, double bbMaxY, double bbMaxPhi, double bbTolR, double bbTolY, double bbTolPhi)
 
- Protected Attributes inherited from SectorField
std::vector< double > bbMin_m
 
std::vector< double > bbMax_m
 
std::vector< double > polarBBMin_m
 
std::vector< double > polarBBMax_m
 
std::string Filename_m
 

Detailed Description

handles field map grids with sector geometry

SectorMagneticFieldMap provides an interface to the 3D interpolator routines for 3D field maps in a sector geometry. Interpolation is done from points in (r, y, phi) geometry off of a 3D field map stored in cartesian coordinates.

A constructor is provided which calls the SectorMagneticFieldMapIO class to generate the field map, and it is expected that this will be the usual way to generate the map.

The SectorMagneticFieldMap class caches field maps by file name to avoid multiple loads of the same field map. This cache should be cleared after running (otherwise we have a memory leak).

Note that the coordinate system used for tracking by Ring (z is up) is a bit different to that implemented in SectorField (y is up). I perform a coordinate transformation in the getFieldstrength function to facilitate this. Note that OpalBeamline has y is up...

SectorMagneticFieldMap enforces that field is hard against the start edge with no gap. SectorMagneticFieldMap auto-detects any field phi offset and removes each time it does a field lookup (just an add operation, so fast). If a phi offset is desired, user must zero-pad field map.

Definition at line 75 of file SectorMagneticFieldMap.h.

Member Enumeration Documentation

◆ symmetry

Enumerator
none 
dipole 

Definition at line 204 of file SectorMagneticFieldMap.h.

Constructor & Destructor Documentation

◆ SectorMagneticFieldMap() [1/2]

SectorMagneticFieldMap::SectorMagneticFieldMap ( std::string  file_name,
std::string  symmetry,
double  length_units,
double  field_units,
int  polynomial_order,
int  smoothing_order 
)

Generate the field map by calling SectorMagneticFieldMap::IO

Parameters
file_namename of the file to read in
symmetryparameter that controls mirror symmetry applied to the field map - either "Dipole" or "None"
length_unitsmultiplier for lengths
field_unitsmultiplier for fields
polynomial_orderorder of polynomial fit to the mesh points
smoothing_orderorder of smoothing (should be >= polynomial_order)

Definition at line 59 of file SectorMagneticFieldMap.cpp.

References _fields, filename_m, interpolation::VectorMap::getMesh(), interpolator_m, interpolation::ThreeDGrid::minZ(), phiOffset_m, readMap(), setInterpolator(), setSymmetry(), symmetry_m, and units_m.

Here is the call graph for this function:

◆ SectorMagneticFieldMap() [2/2]

SectorMagneticFieldMap::SectorMagneticFieldMap ( const SectorMagneticFieldMap field)

Copy constructor - makes a deep copy of the field map

Definition at line 95 of file SectorMagneticFieldMap.cpp.

References interpolator_m, and setInterpolator().

Here is the call graph for this function:

◆ ~SectorMagneticFieldMap()

SectorMagneticFieldMap::~SectorMagneticFieldMap ( )

Destructor - delete allocated memory

Definition at line 107 of file SectorMagneticFieldMap.cpp.

Member Function Documentation

◆ applySymmetry()

bool SectorMagneticFieldMap::applySymmetry ( double *  R_temp) const
private

Reflect R_temp about y if below bbmin

Returns
true if symmetry transformation was applied

Definition at line 241 of file SectorMagneticFieldMap.cpp.

References dipole, SectorField::getPolarBoundingBoxMin(), and symmetry_m.

Here is the call graph for this function:

◆ clearFieldCache()

void SectorMagneticFieldMap::clearFieldCache ( )
static

Delete cached fields

Definition at line 250 of file SectorMagneticFieldMap.cpp.

References _fields.

◆ freeMap()

void SectorMagneticFieldMap::freeMap ( )

Delete the field map interpolator and set pointer to NULL

Definition at line 160 of file SectorMagneticFieldMap.cpp.

References setInterpolator().

Here is the call graph for this function:

◆ getDeltaPhi()

double SectorMagneticFieldMap::getDeltaPhi ( ) const

Get change in azimuthal angle between entrance and exit

Definition at line 287 of file SectorMagneticFieldMap.cpp.

References interpolation::VectorMap::getMesh(), interpolator_m, interpolation::ThreeDGrid::maxZ(), and interpolation::ThreeDGrid::minZ().

Referenced by SBend3D::setFieldMapFileName().

Here is the call graph for this function:

◆ getFieldDerivative()

bool SectorMagneticFieldMap::getFieldDerivative ( const Vector_t R,
Vector_t E,
Vector_t B,
const DiffDirection dir 
) const

Not implemented - throws a LogicalError

Definition at line 278 of file SectorMagneticFieldMap.cpp.

◆ getFieldMapFileName()

std::string SectorMagneticFieldMap::getFieldMapFileName ( ) const
inline

Get the field map file name

Definition at line 149 of file SectorMagneticFieldMap.h.

References filename_m.

Referenced by SBend3D::getFieldMapFileName().

◆ getFieldstrength()

bool SectorMagneticFieldMap::getFieldstrength ( const Vector_t R_c,
Vector_t E_c,
Vector_t B_c 
) const
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 3 like (r, y, phi)
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
false if R_p is inside the bounding box Get the field value in cartesian coordinates
Parameters
R_parray holding the cartesian 3-position at which the field is to be evaluated, (x, y, z)
E_parray of at 3 doubles, to which the field at point is written (ex, ey, ez) - note this field is magnetostatic so always return 0 here.
B_parray of at 3 doubles, to which the field at point is written (bx, by, bz)
Returns
false if R_c is inside the bounding box

Implements SectorField.

Definition at line 208 of file SectorMagneticFieldMap.cpp.

References SectorField::convertToPolar(), cos(), interpolation::VectorMap::function(), SectorField::getPolarBoundingBoxMax(), SectorField::getPolarBoundingBoxMin(), interpolator_m, SectorField::isInBoundingBox(), phiOffset_m, and sin().

Referenced by SBend3D::apply().

Here is the call graph for this function:

◆ getFrequency()

double SectorMagneticFieldMap::getFrequency ( ) const
inline

Magnetostatic field map - so returns 0.

Definition at line 187 of file SectorMagneticFieldMap.h.

◆ getInfo()

void SectorMagneticFieldMap::getInfo ( Inform msg)

Print summary information about the field map to Inform

Definition at line 258 of file SectorMagneticFieldMap.cpp.

References endl(), SectorField::Filename_m, SectorField::getPolarBoundingBoxMax(), and SectorField::getPolarBoundingBoxMin().

Referenced by setInterpolator().

Here is the call graph for this function:

◆ getInterpolator()

VectorMap * SectorMagneticFieldMap::getInterpolator ( )

Get a pointer to the interpolator or NULL if it is not set

Note SectorMagneticFieldMap still owns this memory.

Definition at line 111 of file SectorMagneticFieldMap.cpp.

References interpolator_m.

◆ getPhiOffset()

double SectorMagneticFieldMap::getPhiOffset ( ) const
inline

Get phi offset

Definition at line 193 of file SectorMagneticFieldMap.h.

References phiOffset_m.

◆ getSymmetry()

std::string SectorMagneticFieldMap::getSymmetry ( ) const

Get a string corresponding to the field map symmetry

Returns
field map symmetry, either "None" or "Dipole"

Definition at line 145 of file SectorMagneticFieldMap.cpp.

References symmetry_m, and SymmetryToString().

Here is the call graph for this function:

◆ operator=()

SectorMagneticFieldMap& SectorMagneticFieldMap::operator= ( const SectorMagneticFieldMap field)
private

◆ print()

void SectorMagneticFieldMap::print ( std::ostream &  out)

Print summary information about the field map to out

Definition at line 268 of file SectorMagneticFieldMap.cpp.

References endl(), SectorField::Filename_m, SectorField::getPolarBoundingBoxMax(), and SectorField::getPolarBoundingBoxMin().

Here is the call graph for this function:

◆ readMap()

void SectorMagneticFieldMap::readMap ( )

Read in the field map from the file

Definition at line 153 of file SectorMagneticFieldMap.cpp.

References filename_m, poly_order_m, SectorMagneticFieldMap::IO::readMap(), setInterpolator(), smoothing_order_m, symmetry_m, and units_m.

Referenced by SectorMagneticFieldMap().

Here is the call graph for this function:

◆ Rotate()

void SectorMagneticFieldMap::Rotate ( double *  value,
double  angle 
)
private

◆ setFrequency()

void SectorMagneticFieldMap::setFrequency ( double  )
inline

Magnetostatic field map - so does nothing

Definition at line 190 of file SectorMagneticFieldMap.h.

◆ setInterpolator()

void SectorMagneticFieldMap::setInterpolator ( interpolation::VectorMap interpolator)

◆ setPhiOffset()

void SectorMagneticFieldMap::setPhiOffset ( double  dphi)
inline

Set phi offset

Definition at line 196 of file SectorMagneticFieldMap.h.

References phiOffset_m.

◆ setSymmetry()

void SectorMagneticFieldMap::setSymmetry ( std::string  name)

Set the field map symmetry

Parameters
namefield map symmetry, either "None" or "Dipole"

Definition at line 149 of file SectorMagneticFieldMap.cpp.

References name, StringToSymmetry(), and symmetry_m.

Referenced by SectorMagneticFieldMap().

Here is the call graph for this function:

◆ StringToSymmetry()

SectorMagneticFieldMap::symmetry SectorMagneticFieldMap::StringToSymmetry ( std::string  name)
staticprivate

Definition at line 164 of file SectorMagneticFieldMap.cpp.

References dipole, and none.

Referenced by setSymmetry().

◆ swap()

void SectorMagneticFieldMap::swap ( )

Does nothing

Definition at line 284 of file SectorMagneticFieldMap.cpp.

◆ SymmetryToString()

std::string SectorMagneticFieldMap::SymmetryToString ( SectorMagneticFieldMap::symmetry  sym)
staticprivate

Definition at line 178 of file SectorMagneticFieldMap.cpp.

References dipole, and none.

Referenced by getSymmetry().

Friends And Related Function Documentation

◆ FieldMap

friend class FieldMap
friend

Definition at line 201 of file SectorMagneticFieldMap.h.

◆ SectorMagneticFieldMapIO

friend class SectorMagneticFieldMapIO
friend

Definition at line 226 of file SectorMagneticFieldMap.h.

Member Data Documentation

◆ _fields

std::map< std::string, SectorMagneticFieldMap * > SectorMagneticFieldMap::_fields
staticprivate

Definition at line 225 of file SectorMagneticFieldMap.h.

Referenced by clearFieldCache(), and SectorMagneticFieldMap().

◆ filename_m

const std::string SectorMagneticFieldMap::filename_m
private

Definition at line 219 of file SectorMagneticFieldMap.h.

Referenced by getFieldMapFileName(), readMap(), and SectorMagneticFieldMap().

◆ fractionalBBPhiTolerance_m

const double SectorMagneticFieldMap::fractionalBBPhiTolerance_m
staticprivate

Definition at line 224 of file SectorMagneticFieldMap.h.

◆ interpolator_m

interpolation::VectorMap* SectorMagneticFieldMap::interpolator_m
private

◆ phiOffset_m

double SectorMagneticFieldMap::phiOffset_m
private

◆ poly_order_m

int SectorMagneticFieldMap::poly_order_m
private

Definition at line 221 of file SectorMagneticFieldMap.h.

Referenced by readMap().

◆ smoothing_order_m

int SectorMagneticFieldMap::smoothing_order_m
private

Definition at line 222 of file SectorMagneticFieldMap.h.

Referenced by readMap().

◆ symmetry_m

symmetry SectorMagneticFieldMap::symmetry_m
private

◆ units_m

std::vector<double> SectorMagneticFieldMap::units_m
private

Definition at line 218 of file SectorMagneticFieldMap.h.

Referenced by readMap(), and SectorMagneticFieldMap().


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