|
OPALX (Object Oriented Parallel Accelerator Library for Exascale) 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) | |
| Generate the field map by calling SectorMagneticFieldMap::IO. More... | |
| SectorMagneticFieldMap (const SectorMagneticFieldMap &field) | |
| Copy constructor - makes a deep copy of the field map. More... | |
| ~SectorMagneticFieldMap () | |
| Destructor - delete allocated memory. More... | |
| bool | getFieldstrength (const Vector_t< double, 3 > &R_c, Vector_t< double, 3 > &E_c, Vector_t< double, 3 > &B_c) const |
| Return the field value in polar coordinates. More... | |
| interpolation::VectorMap * | getInterpolator () |
| Get a pointer to the interpolator or nullptr if it is not set. More... | |
| void | setInterpolator (interpolation::VectorMap *interpolator) |
| Set the interpolator. More... | |
| std::string | getFieldMapFileName () const |
| Get the field map file name. More... | |
| std::string | getSymmetry () const |
| Get a string corresponding to the field map symmetry. More... | |
| void | setSymmetry (std::string name) |
| Set the field map symmetry. More... | |
| bool | 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. More... | |
| void | swap () |
| Does nothing. More... | |
| void | getInfo (Inform *msg) |
| Print summary information about the field map to Inform. More... | |
| void | print (std::ostream &out) |
| Print summary information about the field map to out. More... | |
| void | readMap () |
| Read in the field map from the file. More... | |
| void | freeMap () |
| Delete the field map interpolator and set pointer to nullptr. More... | |
| double | getFrequency () const |
| Magnetostatic field map - so returns 0. More... | |
| void | setFrequency (double) |
| Magnetostatic field map - so does nothing. More... | |
| double | getPhiOffset () const |
| Get phi offset. More... | |
| void | setPhiOffset (double dphi) |
| Set phi offset. More... | |
| double | getDeltaPhi () const |
| Get change in azimuthal angle between entrance and exit. More... | |
| virtual std::vector< double > | getPolarBoundingBoxMin () const |
| Get the minimum bounding box in polar coordinates. More... | |
| virtual std::vector< double > | getPolarBoundingBoxMax () const |
| Get the maximum bounding box in polar coordinates. More... | |
| void | getFieldDimensions (double &zBegin, double &zEnd, double &rBegin, double &rEnd) const |
| Fill inputs with the bounding box in Polar coordinates. More... | |
| void | getFieldDimensions (double &xIni, double &xFinal, double &yIni, double &yFinal, double &zIni, double &zFinal) const |
| Fill inputs with the bounding box in Cartesian coordinates. More... | |
| bool | isInBoundingBox (const double R_p[]) const |
| Return true if polar vector R_p is within polar bounding box. More... | |
Static Public Member Functions | |
| static void | clearFieldCache () |
| Delete cached fields. More... | |
| static void | convertToPolar (double *position) |
| Convert a position from cartesian to polar coordinates. More... | |
| static void | convertToPolar (const double *position_polar, double *value) |
| Convert a 3 vector from cartesian to polar coordinate system. More... | |
| static void | convertToCartesian (double *position) |
| Convert a position from polar coordinates to cartesian. More... | |
| static void | convertToCartesian (const double *position_polar, double *value) |
| Convert a 3 vector from polar to cartesian coordinate system. More... | |
Protected Member Functions | |
| void | setPolarBoundingBox (double bbMinR, double bbMinY, double bbMinPhi, double bbMaxR, double bbMaxY, double bbMaxPhi, double bbTolR, double bbTolY, double bbTolPhi) |
| Set the bounding boxes from polar coordinates. More... | |
Protected Attributes | |
| std::vector< double > | bbMin_m |
| bounding box minimum as a 3-vector like (x_min, y_min, z_min) More... | |
| std::vector< double > | bbMax_m |
| bounding box maximum as a 3-vector like (x_max, y_max, z_max) More... | |
| std::vector< double > | polarBBMin_m |
| bounding box minimum as a 3-vector like (r_min, y_min, phi_min) More... | |
| std::vector< double > | polarBBMax_m |
| bounding box maximum as a 3-vector like (r_max, y_max, phi_max) More... | |
| std::string | Filename_m |
| Keep the filename. More... | |
Private Types | |
| enum | symmetry { none , dipole } |
Private Member Functions | |
| bool | applySymmetry (double *R_temp) const |
| Reflect R_temp about y if below bbmin. More... | |
| 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.
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(), SectorMagneticFieldMap(), setInterpolator(), setSymmetry(), symmetry_m, and units_m.
Referenced by 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 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 |
Delete cached fields.
Definition at line 250 of file SectorMagneticFieldMap.cpp.
References _fields.
|
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 SectorField::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 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 SectorField::convertToCartesian().
Referenced by SectorField::setPolarBoundingBox().

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

| 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.
References SectorField::bbMax_m, and SectorField::bbMin_m.
|
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 SectorField::polarBBMax_m, and SectorField::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(), interpolation::VectorMap::function(), 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 endl(), 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.
|
inline |
|
virtualinherited |
Get the maximum bounding box in polar coordinates.
Definition at line 193 of file SectorField.cpp.
References SectorField::polarBBMax_m.
Referenced by getFieldstrength(), getInfo(), and print().
|
virtualinherited |
Get the minimum bounding box in polar coordinates.
Definition at line 189 of file SectorField.cpp.
References SectorField::polarBBMin_m.
Referenced by applySymmetry(), getFieldstrength(), getInfo(), and 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 SectorField::polarBBMax_m, and SectorField::polarBBMin_m.
Referenced by 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 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 |
|
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 SectorField::bbMax_m, SectorField::bbMin_m, begin(), end(), SectorField::getCorners(), SectorField::polarBBMax_m, and SectorField::polarBBMin_m.
Referenced by 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.
|
friend |
Definition at line 226 of file SectorMagneticFieldMap.h.
|
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 SectorField::getFieldDimensions(), SectorField::SectorField(), and SectorField::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 SectorField::getFieldDimensions(), SectorField::SectorField(), and SectorField::setPolarBoundingBox().
|
protectedinherited |
Keep the filename.
Definition at line 217 of file SectorField.h.
|
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().
|
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 SectorField::getFieldDimensions(), SectorField::getPolarBoundingBoxMax(), SectorField::isInBoundingBox(), SectorField::SectorField(), and SectorField::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 SectorField::getFieldDimensions(), SectorField::getPolarBoundingBoxMin(), SectorField::isInBoundingBox(), SectorField::SectorField(), and SectorField::setPolarBoundingBox().
|
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().