#include <vectorfield.hpp>
Public Member Functions | |
VectorField () | |
Default constructor. | |
VectorField (const Geometry &g, bool fout[3]) | |
Constructor for geometry from g. | |
VectorField (geom_mode_e geom_mode, bool fout[3], Int3D size, Vec3D origo, double h) | |
Constructor for set geometry. | |
VectorField (geom_mode_e geom_mode, bool fout[3], double xscale, double fscale, const std::string &filename) | |
Constructor for vector field from ascii file. | |
VectorField (const VectorField &f) | |
Copy constructor. | |
~VectorField () | |
Destructor. | |
geom_mode_e | geom_mode (void) const |
Returns geometry mode. | |
Int3D | size (void) const |
Returns size array of geometry. | |
int32_t | size (int i) const |
Returns size of solid mesh in direction i. | |
int32_t | nodecount (void) const |
Returns number of nodes in the mesh. | |
Vec3D | origo (void) const |
Returns origo vector of geometry. | |
double | origo (int i) const |
Returns i-th component of vector origo. | |
double | h (void) const |
Returns mesh cell size. | |
double | div_h (void) const |
Returns inverse mesh cell size. | |
void | set_extrapolation (field_extrpl_e extrpl[6]) |
Set the behaviour of field interpolation outside mesh points (extrapolation). | |
void | translate (Vec3D x) |
Translate field in coordinate system. | |
void | scale (double s) |
Scale field in coordinate system. | |
void | rotate_x (int a) |
Rotate field in coordinate system around x-axis. | |
void | rotate_y (int a) |
Rotate field in coordinate system around y-axis. | |
void | rotate_z (int a) |
Rotate field in coordinate system around z-axis. | |
void | clear () |
Clears the field. | |
void | reset (geom_mode_e geom_mode, bool fout[3], Int3D size, Vec3D origo, double h) |
Resets the field geometry. | |
void | get_minmax (double &min, double &max) const |
Search minimum and maximum vector length values of vector field. | |
void | get_defined_components (bool fout[3]) const |
Get which field components are defined. | |
VectorField & | operator= (const VectorField &f) |
Copy operator. | |
VectorField & | operator+= (const VectorField &f) |
Accumulation operator. | |
VectorField & | operator *= (double x) |
Scaling operator for field values. | |
VectorField & | operator/= (double x) |
Inverse scaling operator. | |
const Vec3D | operator() (int32_t i) const |
Operator for getting elements of the field mesh. | |
const Vec3D | operator() (int32_t i, int32_t j) const |
Operator for getting elements of the field mesh. | |
const Vec3D | operator() (int32_t i, int32_t j, int32_t k) const |
Operator for getting elements of the field mesh. | |
void | set (int32_t i, const Vec3D &v) |
Operator for setting element (i) of the field mesh. | |
void | set (int32_t i, int32_t j, const Vec3D &v) |
Operator for setting element (i,j) of the field mesh. | |
void | set (int32_t i, int32_t j, int32_t k, const Vec3D &v) |
Operator for setting element (i,j,k) of the field mesh. | |
Vec3D | operator() (Vec3D x) const |
Operator for getting linearly interpolated field value at x. | |
void | debug_print (void) const |
Prints internal data to std::cout. |
VectorField is intended to be used as a container for vector field data. The IBSimu Package uses vector fields for storing magnetic field. The vector field class provides a subset of vector operations to copy, sum and scale vector fields. The class also includes operators for indexed access to mesh elements and interpolation functions for linearly interpolated smooth field data. The interpolation function uses linear extrapolation of field outside the defined mesh. This way it can be ensured that VectorField returns sensible values even close by to the edges of the geometry.
If the size of mesh is 1 in some direction, then the field is constant in that direction. Otherwise linear interpolation is used.
VectorField::VectorField | ( | ) |
Default constructor.
VectorField::VectorField | ( | const Geometry & | g, | |
bool | fout[3] | |||
) |
Constructor for geometry from g.
Returns a new vector field with geometry parameters (including mesh size) set from g. The field is set to zero in all locations.
VectorField::VectorField | ( | geom_mode_e | geom_mode, | |
bool | fout[3], | |||
Int3D | size, | |||
Vec3D | origo, | |||
double | h | |||
) |
Constructor for set geometry.
Returns a new vector field with geometry set according to parameters: geom_mode is the geometry mode, size is the size of the mesh, origo is the location of mesh point (0,0,0) and h is the mesh cell size. The vector field components marked true in array fout are to be defined in the vector field. Components marked false are always zero. The field is initially set to zero in all locations.
VectorField::VectorField | ( | geom_mode_e | geom_mode, | |
bool | fout[3], | |||
double | xscale, | |||
double | fscale, | |||
const std::string & | filename | |||
) |
Constructor for vector field from ascii file.
The vector field for geometry mode geom_mode is read in from file filename. The lines starting with # are skipped. After that the data is read in line-by-line with one data point per line. The data columns are separated by white space. The coordinate data are (x, y) in 2D, (x, r) in Cyl and (x, y, z) in 3D. The field data to be read are enabled by user with fout. The enabled field data components are read in after the coordinate data from the data line.
The data points are expected to appear in coordinate sorted order because the mesh step h is determined from the spatial difference of first two data points. Spatial coordinates are multiplied with xscale and field components with fscale while read in.
For magnetic fields the particle iterator assumes vector field in the following formats: In 2D: (x, y, Bz) In Cyl: (x, r, Bx, Br, Btheta) In 3D: (x, y, z, Bx, By, Bz)
VectorField::VectorField | ( | const VectorField & | f | ) |
Copy constructor.
VectorField::~VectorField | ( | ) |
Destructor.
void VectorField::clear | ( | ) |
Clears the field.
void VectorField::debug_print | ( | void | ) | const |
Prints internal data to std::cout.
double VectorField::div_h | ( | void | ) | const [inline] |
Returns inverse mesh cell size.
geom_mode_e VectorField::geom_mode | ( | void | ) | const [inline] |
Returns geometry mode.
void VectorField::get_defined_components | ( | bool | fout[3] | ) | const |
Get which field components are defined.
void VectorField::get_minmax | ( | double & | min, | |
double & | max | |||
) | const |
Search minimum and maximum vector length values of vector field.
double VectorField::h | ( | void | ) | const [inline] |
Returns mesh cell size.
int32_t VectorField::nodecount | ( | void | ) | const [inline] |
Returns number of nodes in the mesh.
VectorField& VectorField::operator *= | ( | double | x | ) |
Scaling operator for field values.
Operator for getting linearly interpolated field value at x.
const Vec3D VectorField::operator() | ( | int32_t | i, | |
int32_t | j, | |||
int32_t | k | |||
) | const |
Operator for getting elements of the field mesh.
const Vec3D VectorField::operator() | ( | int32_t | i, | |
int32_t | j | |||
) | const |
Operator for getting elements of the field mesh.
const Vec3D VectorField::operator() | ( | int32_t | i | ) | const |
Operator for getting elements of the field mesh.
VectorField& VectorField::operator+= | ( | const VectorField & | f | ) |
Accumulation operator.
VectorField& VectorField::operator/= | ( | double | x | ) |
Inverse scaling operator.
VectorField& VectorField::operator= | ( | const VectorField & | f | ) |
Copy operator.
double VectorField::origo | ( | int | i | ) | const [inline] |
Returns i-th component of vector origo.
Vec3D VectorField::origo | ( | void | ) | const [inline] |
Returns origo vector of geometry.
void VectorField::reset | ( | geom_mode_e | geom_mode, | |
bool | fout[3], | |||
Int3D | size, | |||
Vec3D | origo, | |||
double | h | |||
) |
Resets the field geometry.
Sets the field geometry according to the parameters and clears the field to zero in all locations.
void VectorField::rotate_x | ( | int | a | ) |
Rotate field in coordinate system around x-axis.
void VectorField::rotate_y | ( | int | a | ) |
Rotate field in coordinate system around y-axis.
void VectorField::rotate_z | ( | int | a | ) |
Rotate field in coordinate system around z-axis.
void VectorField::scale | ( | double | s | ) |
Scale field in coordinate system.
void VectorField::set | ( | int32_t | i, | |
int32_t | j, | |||
int32_t | k, | |||
const Vec3D & | v | |||
) |
Operator for setting element (i,j,k) of the field mesh.
void VectorField::set | ( | int32_t | i, | |
int32_t | j, | |||
const Vec3D & | v | |||
) |
Operator for setting element (i,j) of the field mesh.
void VectorField::set | ( | int32_t | i, | |
const Vec3D & | v | |||
) |
Operator for setting element (i) of the field mesh.
void VectorField::set_extrapolation | ( | field_extrpl_e | extrpl[6] | ) | [inline] |
Set the behaviour of field interpolation outside mesh points (extrapolation).
The interpolation function behaviour can be set separately for each boundary. This is done by setting the desired properties to the extrpl array. The interpolation function can use an extrapolation of the last two field values (FIELD_EXTRAPOLATE) or it can return the mirror of the field across the mesh boundary (FIELD_MIRROR) or it can return a zero field outside the mesh (FIELD_ZERO).
The use of FIELD_MIRROR in case of symmetric cases, where beam is traversing next to the geometry boundary, is necessary to get physical results.
Very far (double the size of the simulation box) the field evaluator will always return zero.
int32_t VectorField::size | ( | int | i | ) | const [inline] |
Returns size of solid mesh in direction i.
Int3D VectorField::size | ( | void | ) | const [inline] |
Returns size array of geometry.
void VectorField::translate | ( | Vec3D | x | ) |
Translate field in coordinate system.