OPAL (Object Oriented Parallel Accelerator Library)
2021.1.99
OPAL
|
handles field map grids with sector geometry More...
#include <SectorMagneticFieldMap.h>
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::VectorMap * | getInterpolator () |
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) |
SectorMagneticFieldMap & | operator= (const SectorMagneticFieldMap &field) |
Static Private Member Functions | |
static symmetry | StringToSymmetry (std::string name) |
static std::string | SymmetryToString (symmetry sym) |
Private Attributes | |
interpolation::VectorMap * | interpolator_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 |
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.
|
private |
Enumerator | |
---|---|
none | |
dipole |
Definition at line 204 of file SectorMagneticFieldMap.h.
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
file_name | name of the file to read in |
symmetry | parameter that controls mirror symmetry applied to the field map - either "Dipole" or "None" |
length_units | multiplier for lengths |
field_units | multiplier for fields |
polynomial_order | order of polynomial fit to the mesh points |
smoothing_order | order 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.
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().
SectorMagneticFieldMap::~SectorMagneticFieldMap | ( | ) |
Destructor - delete allocated memory
Definition at line 107 of file SectorMagneticFieldMap.cpp.
|
private |
Reflect R_temp about y if below bbmin
Definition at line 241 of file SectorMagneticFieldMap.cpp.
References dipole, SectorField::getPolarBoundingBoxMin(), and symmetry_m.
|
static |
void SectorMagneticFieldMap::freeMap | ( | ) |
Delete the field map interpolator and set pointer to NULL
Definition at line 160 of file SectorMagneticFieldMap.cpp.
References setInterpolator().
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().
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.
|
inline |
Get the field map file name
Definition at line 149 of file SectorMagneticFieldMap.h.
References filename_m.
Referenced by SBend3D::getFieldMapFileName().
|
virtual |
Return the field value in polar coordinates
R_p | position in cylindrical coordinates at which to evaluate the field. Should be an array of length 3 like (r, y, phi) |
E_p | reference 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_p | reference 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 |
R_p | array holding the cartesian 3-position at which the field is to be evaluated, (x, y, z) |
E_p | array 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_p | array of at 3 doubles, to which the field at point is written (bx, by, bz) |
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().
|
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 258 of file SectorMagneticFieldMap.cpp.
References endl(), SectorField::Filename_m, SectorField::getPolarBoundingBoxMax(), and SectorField::getPolarBoundingBoxMin().
Referenced by setInterpolator().
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.
|
inline |
std::string SectorMagneticFieldMap::getSymmetry | ( | ) | const |
Get a string corresponding to the field map symmetry
Definition at line 145 of file SectorMagneticFieldMap.cpp.
References symmetry_m, and SymmetryToString().
|
private |
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().
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().
|
private |
|
inline |
Magnetostatic field map - so does nothing
Definition at line 190 of file SectorMagneticFieldMap.h.
void SectorMagneticFieldMap::setInterpolator | ( | interpolation::VectorMap * | interpolator | ) |
Set the interpolator
interpolator | set the field map interpolator. Note SectorMagneticFieldMap now owns the memory pointed to by interpolator |
Definition at line 115 of file SectorMagneticFieldMap.cpp.
References getInfo(), interpolation::VectorMap::getMesh(), interpolation::VectorMap::getPointDimension(), interpolation::VectorMap::getValueDimension(), gmsg, interpolator_m, interpolation::ThreeDGrid::maxX(), interpolation::ThreeDGrid::maxY(), interpolation::ThreeDGrid::maxZ(), interpolation::ThreeDGrid::minX(), interpolation::ThreeDGrid::minY(), interpolation::ThreeDGrid::minZ(), and SectorField::setPolarBoundingBox().
Referenced by freeMap(), readMap(), and SectorMagneticFieldMap().
|
inline |
void SectorMagneticFieldMap::setSymmetry | ( | std::string | name | ) |
Set the field map symmetry
name | field map symmetry, either "None" or "Dipole" |
Definition at line 149 of file SectorMagneticFieldMap.cpp.
References name, StringToSymmetry(), and symmetry_m.
Referenced by SectorMagneticFieldMap().
|
staticprivate |
Definition at line 164 of file SectorMagneticFieldMap.cpp.
Referenced by setSymmetry().
void SectorMagneticFieldMap::swap | ( | ) |
Does nothing
Definition at line 284 of file SectorMagneticFieldMap.cpp.
|
staticprivate |
Definition at line 178 of file SectorMagneticFieldMap.cpp.
Referenced by getSymmetry().
|
friend |
Definition at line 201 of file SectorMagneticFieldMap.h.
|
friend |
Definition at line 226 of file SectorMagneticFieldMap.h.
|
staticprivate |
Definition at line 225 of file SectorMagneticFieldMap.h.
Referenced by clearFieldCache(), and SectorMagneticFieldMap().
|
private |
Definition at line 219 of file SectorMagneticFieldMap.h.
Referenced by getFieldMapFileName(), readMap(), and SectorMagneticFieldMap().
|
staticprivate |
Definition at line 224 of file SectorMagneticFieldMap.h.
|
private |
Definition at line 216 of file SectorMagneticFieldMap.h.
Referenced by getDeltaPhi(), getFieldstrength(), getInterpolator(), SectorMagneticFieldMap(), and setInterpolator().
|
private |
Definition at line 220 of file SectorMagneticFieldMap.h.
Referenced by getFieldstrength(), getPhiOffset(), SectorMagneticFieldMap(), and setPhiOffset().
|
private |
Definition at line 221 of file SectorMagneticFieldMap.h.
Referenced by readMap().
|
private |
Definition at line 222 of file SectorMagneticFieldMap.h.
Referenced by readMap().
|
private |
Definition at line 217 of file SectorMagneticFieldMap.h.
Referenced by applySymmetry(), getSymmetry(), readMap(), SectorMagneticFieldMap(), and setSymmetry().
|
private |
Definition at line 218 of file SectorMagneticFieldMap.h.
Referenced by readMap(), and SectorMagneticFieldMap().