OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
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 getFieldstrengthPolar (const Vector_t &R_p, Vector_t &E_p, Vector_t &B_p) const
 
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

Enumerator
none 
dipole 

Definition at line 204 of file SectorMagneticFieldMap.h.

Constructor & Destructor Documentation

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 60 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::SectorMagneticFieldMap ( const SectorMagneticFieldMap field)

Copy constructor - makes a deep copy of the field map

Definition at line 97 of file SectorMagneticFieldMap.cpp.

References interpolator_m.

SectorMagneticFieldMap::~SectorMagneticFieldMap ( )

Destructor - delete allocated memory

Definition at line 108 of file SectorMagneticFieldMap.cpp.

Member Function Documentation

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 240 of file SectorMagneticFieldMap.cpp.

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

Here is the call graph for this function:

void SectorMagneticFieldMap::clearFieldCache ( )
static

Delete cached fields

Definition at line 249 of file SectorMagneticFieldMap.cpp.

References _fields.

void SectorMagneticFieldMap::freeMap ( )

Delete the field map interpolator and set pointer to NULL

Definition at line 161 of file SectorMagneticFieldMap.cpp.

References setInterpolator().

Here is the call graph for this function:

double SectorMagneticFieldMap::getDeltaPhi ( ) const

Get change in azimuthal angle between entrance and exit

Definition at line 286 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:

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 277 of file SectorMagneticFieldMap.cpp.

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().

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

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(), and sin().

Referenced by SBend3D::apply().

Here is the call graph for this function:

bool SectorMagneticFieldMap::getFieldstrengthPolar ( const Vector_t R_p,
Vector_t E_p,
Vector_t B_p 
) 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

Implements SectorField.

Definition at line 194 of file SectorMagneticFieldMap.cpp.

References SectorField::convertToPolar().

Here is the call graph for this function:

double SectorMagneticFieldMap::getFrequency ( ) const
inline

Magnetostatic field map - so returns 0.

Definition at line 187 of file SectorMagneticFieldMap.h.

void SectorMagneticFieldMap::getInfo ( Inform msg)

Print summary information about the field map to Inform

Definition at line 257 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:

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 112 of file SectorMagneticFieldMap.cpp.

References interpolator_m.

double SectorMagneticFieldMap::getPhiOffset ( ) const
inline

Get phi offset

Definition at line 193 of file SectorMagneticFieldMap.h.

References phiOffset_m.

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 146 of file SectorMagneticFieldMap.cpp.

References symmetry_m, and SymmetryToString().

Here is the call graph for this function:

SectorMagneticFieldMap& SectorMagneticFieldMap::operator= ( const SectorMagneticFieldMap field)
private
void SectorMagneticFieldMap::print ( std::ostream &  out)

Print summary information about the field map to out

Definition at line 267 of file SectorMagneticFieldMap.cpp.

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

Here is the call graph for this function:

void SectorMagneticFieldMap::readMap ( )

Read in the field map from the file

Definition at line 154 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:

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

Magnetostatic field map - so does nothing

Definition at line 190 of file SectorMagneticFieldMap.h.

void SectorMagneticFieldMap::setInterpolator ( interpolation::VectorMap interpolator)
void SectorMagneticFieldMap::setPhiOffset ( double  dphi)
inline

Set phi offset

Definition at line 196 of file SectorMagneticFieldMap.h.

References phiOffset_m.

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

Set the field map symmetry

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

Definition at line 150 of file SectorMagneticFieldMap.cpp.

References StringToSymmetry(), and symmetry_m.

Referenced by SectorMagneticFieldMap().

Here is the call graph for this function:

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

Definition at line 166 of file SectorMagneticFieldMap.cpp.

Referenced by setSymmetry().

void SectorMagneticFieldMap::swap ( )

Does nothing

Definition at line 283 of file SectorMagneticFieldMap.cpp.

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

Definition at line 180 of file SectorMagneticFieldMap.cpp.

Referenced by getSymmetry().

Friends And Related Function Documentation

friend class FieldMap
friend

Definition at line 201 of file SectorMagneticFieldMap.h.

friend class SectorMagneticFieldMapIO
friend

Definition at line 226 of file SectorMagneticFieldMap.h.

Member Data Documentation

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

Definition at line 225 of file SectorMagneticFieldMap.h.

Referenced by clearFieldCache(), and SectorMagneticFieldMap().

const std::string SectorMagneticFieldMap::filename_m
private

Definition at line 219 of file SectorMagneticFieldMap.h.

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

const double SectorMagneticFieldMap::fractionalBBPhiTolerance_m
staticprivate

Definition at line 224 of file SectorMagneticFieldMap.h.

interpolation::VectorMap* SectorMagneticFieldMap::interpolator_m
private
double SectorMagneticFieldMap::phiOffset_m
private

Definition at line 220 of file SectorMagneticFieldMap.h.

Referenced by getPhiOffset(), SectorMagneticFieldMap(), and setPhiOffset().

int SectorMagneticFieldMap::poly_order_m
private

Definition at line 221 of file SectorMagneticFieldMap.h.

Referenced by readMap().

int SectorMagneticFieldMap::smoothing_order_m
private

Definition at line 222 of file SectorMagneticFieldMap.h.

Referenced by readMap().

symmetry SectorMagneticFieldMap::symmetry_m
private
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: