|
OPALX (Object Oriented Parallel Accelerator Library for Exascal) MINIorX
OPALX
|
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< double, 3 > &R_c, Vector_t< double, 3 > &E_c, Vector_t< double, 3 > &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< double, 3 > &R, Vector_t< double, 3 > &E, Vector_t< double, 3 > &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 |
| 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 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 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) |
| std::vector< std::vector< double > > | getCorners (double bbMinR, double bbMinPhi, double bbMaxR, double bbMaxPhi) |
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 |
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.
position coordinates are left in polar because it makes the interpolation easier
field coordinates are left in cartesian because it means we can avoid doing a coordinate transformation (tracking is done 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, dipole, filename_m, interpolator_m, interpolation::ThreeDGrid::minZ(), phiOffset_m, poly_order_m, readMap(), SectorField::SectorField(), SectorMagneticFieldMap(), setInterpolator(), setSymmetry(), smoothing_order_m, symmetry_m, and units_m.
Referenced by operator=(), SectorMagneticFieldMap(), and SectorMagneticFieldMap().
| SectorMagneticFieldMap::SectorMagneticFieldMap | ( | const SectorMagneticFieldMap & | field | ) |
Copy constructor - makes a deep copy of the field map
Definition at line 95 of file SectorMagneticFieldMap.cpp.
References filename_m, interpolator_m, phiOffset_m, SectorField::SectorField(), SectorMagneticFieldMap(), setInterpolator(), symmetry_m, and units_m.
| 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 |
|
staticinherited |
Convert a 3 vector from polar to cartesian coordinate system
| position | position in polar coordinates at which the value is valid |
| value | pointer 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.
|
staticinherited |
Convert a position from polar coordinates to cartesian
| position | position 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.
Referenced by getCorners().
|
staticinherited |
Convert a 3 vector from cartesian to polar coordinate system
| position | position in polar coordinates at which the value is valid |
| value | pointer 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.
|
staticinherited |
Convert a position from cartesian to polar coordinates
| position | position 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.
Referenced by SectorMagneticFieldMap::getFieldstrength(), and SectorMagneticFieldMap::IO::readLines().
| void SectorMagneticFieldMap::freeMap | ( | ) |
Delete the field map interpolator and set pointer to nullptr
Definition at line 160 of file SectorMagneticFieldMap.cpp.
References setInterpolator().
|
privateinherited |
Definition at line 162 of file SectorField.cpp.
References convertToCartesian().
Referenced by setPolarBoundingBox().
| double SectorMagneticFieldMap::getDeltaPhi | ( | ) | const |
Get change in azimuthal angle between entrance and exit
Definition at line 287 of file SectorMagneticFieldMap.cpp.
References interpolator_m, interpolation::ThreeDGrid::maxZ(), and interpolation::ThreeDGrid::minZ().
| bool SectorMagneticFieldMap::getFieldDerivative | ( | const Vector_t< double, 3 > & | R, |
| Vector_t< double, 3 > & | E, | ||
| Vector_t< double, 3 > & | B, | ||
| const DiffDirection & | dir ) const |
Not implemented - throws a LogicalError
Definition at line 278 of file SectorMagneticFieldMap.cpp.
|
inherited |
Fill inputs with the bounding box in Cartesian coordinates
| xIni | lower bound on field x-position (horizontal) |
| xFinal | upper bound on field x-position (horizontal) |
| yIni | lower bound on field y-position (vertical) |
| yFinal | upper bound on field y-position (vertical) |
| zIni | lower bound on field z-position (longitudinal) |
| zFinal | upper bound on field z-position (longitudinal) |
Definition at line 205 of file SectorField.cpp.
|
inherited |
Fill inputs with the bounding box in Polar coordinates
| zBegin | lower bound on field length in phi direction (units of distance) |
| zEnd | upper bound on field length in phi direction (units of distance) |
| rBegin | lower bound on field length in radial direction |
| rEnd | lower bound on field length in radial direction |
Definition at line 197 of file SectorField.cpp.
References polarBBMax_m, and polarBBMin_m.
|
inline |
Get the field map file name
Definition at line 149 of file SectorMagneticFieldMap.h.
References filename_m.
|
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(), SectorField::getPolarBoundingBoxMax(), SectorField::getPolarBoundingBoxMin(), interpolator_m, SectorField::isInBoundingBox(), and phiOffset_m.
|
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 SectorField::Filename_m, SectorField::getPolarBoundingBoxMax(), and SectorField::getPolarBoundingBoxMin().
Referenced by setInterpolator().
| VectorMap * SectorMagneticFieldMap::getInterpolator | ( | ) |
Get a pointer to the interpolator or nullptr if it is not set
Note SectorMagneticFieldMap still owns this memory.
Definition at line 111 of file SectorMagneticFieldMap.cpp.
References interpolator_m.
Referenced by SectorMagneticFieldMap::IO::readMap().
|
inline |
|
virtualinherited |
Get the maximum bounding box in polar coordinates
Definition at line 193 of file SectorField.cpp.
References polarBBMax_m.
Referenced by SectorMagneticFieldMap::getFieldstrength(), SectorMagneticFieldMap::getInfo(), and SectorMagneticFieldMap::print().
|
virtualinherited |
Get the minimum bounding box in polar coordinates
Definition at line 189 of file SectorField.cpp.
References polarBBMin_m.
Referenced by SectorMagneticFieldMap::applySymmetry(), SectorMagneticFieldMap::getFieldstrength(), SectorMagneticFieldMap::getInfo(), and SectorMagneticFieldMap::print().
| 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().
|
inlineinherited |
Return true if polar vector R_p is within polar bounding box
| R_p | polar coordinates (r, y, phi) |
Definition at line 224 of file SectorField.h.
References polarBBMax_m, and polarBBMin_m.
Referenced by SectorMagneticFieldMap::getFieldstrength().
|
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 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(), 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(), SectorMagneticFieldMap(), and SectorMagneticFieldMap().
|
inline |
|
protectedinherited |
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.
| bbMinR | minimum radius - must be positive |
| bbMinY | minimum y value |
| bbMinPhi | minimum phi value - must be greater than -2*pi |
| bbMaxR | maximum radius - must be greater than minimum radius |
| bbMaxY | maximum y value - must be greater than minimum y value |
| bbMaxPhi | maximum 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().
| 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 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.
References FieldMap.
Referenced by FieldMap.
|
friend |
Definition at line 226 of file SectorMagneticFieldMap.h.
References SectorMagneticFieldMapIO.
Referenced by SectorMagneticFieldMapIO.
|
staticprivate |
Definition at line 225 of file SectorMagneticFieldMap.h.
Referenced by clearFieldCache(), and SectorMagneticFieldMap().
|
protectedinherited |
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().
|
protectedinherited |
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().
|
protectedinherited |
Keep the filename
Definition at line 217 of file SectorField.h.
Referenced by SectorMagneticFieldMap::getInfo(), and SectorMagneticFieldMap::print().
|
private |
Definition at line 219 of file SectorMagneticFieldMap.h.
Referenced by getFieldMapFileName(), readMap(), SectorMagneticFieldMap(), 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(), SectorMagneticFieldMap(), and setInterpolator().
|
private |
Definition at line 220 of file SectorMagneticFieldMap.h.
Referenced by getFieldstrength(), getPhiOffset(), SectorMagneticFieldMap(), SectorMagneticFieldMap(), and setPhiOffset().
|
protectedinherited |
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().
|
protectedinherited |
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().
|
private |
Definition at line 221 of file SectorMagneticFieldMap.h.
Referenced by readMap(), and SectorMagneticFieldMap().
|
private |
Definition at line 222 of file SectorMagneticFieldMap.h.
Referenced by readMap(), and SectorMagneticFieldMap().
|
private |
Definition at line 217 of file SectorMagneticFieldMap.h.
Referenced by applySymmetry(), getSymmetry(), readMap(), SectorMagneticFieldMap(), SectorMagneticFieldMap(), and setSymmetry().
|
private |
Definition at line 218 of file SectorMagneticFieldMap.h.
Referenced by readMap(), SectorMagneticFieldMap(), and SectorMagneticFieldMap().