Public Member Functions
MeshVectorField Class Reference

Mesh based vector field. More...

#include <meshvectorfield.hpp>

Inheritance diagram for MeshVectorField:
VectorField Mesh

List of all members.

Public Member Functions

 MeshVectorField ()
 Default constructor.
 MeshVectorField (const Mesh &m, const bool fout[3])
 Constructor for vector field from m.
 MeshVectorField (geom_mode_e geom_mode, const bool fout[3], Int3D size, Vec3D origo, double h)
 Constructor for set geometry.
 MeshVectorField (geom_mode_e geom_mode, const bool fout[3], double xscale, double fscale, const std::string &filename)
 Constructor for vector field from ascii file.
 MeshVectorField (geom_mode_e geom_mode, const bool fout[3], Int3D size, Vec3D origo, double h, const MeshVectorField &fin)
 Conversion constructor.
 MeshVectorField (const MeshVectorField &f)
 Copy constructor.
 MeshVectorField (std::istream &is)
 Constructor for loading vector field from stream is.
virtual ~MeshVectorField ()
 Destructor.
void set_extrapolation (const field_extrpl_e extrpl[6])
 Set the behaviour of field interpolation outside mesh points (extrapolation).
void reset_transformation (void)
 Set transformation to unity.
void set_transformation (const Transformation &T)
 Set transformation as a copy of T.
void translate (const Vec3D &dx)
 Translate field.
void scale (const Vec3D &sx)
 Scale field.
void rotate_x (double a)
 Rotate solid around x-axis.
void rotate_y (double a)
 Rotate solid around y-axis.
void rotate_z (double a)
 Rotate solid around z-axis.
void clear ()
 Clears the field.
void reset (geom_mode_e geom_mode, const 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.
MeshVectorFieldoperator= (const MeshVectorField &f)
 Copy operator.
MeshVectorFieldoperator+= (const MeshVectorField &f)
 Accumulation operator.
MeshVectorFieldoperator*= (double x)
 Scaling operator for field values.
MeshVectorFieldoperator/= (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.
virtual const Vec3D operator() (Vec3D x) const
 Operator for getting linearly interpolated field value at x.
void save (const std::string &filename) const
 Saves data to a new file filename.
void save (std::ostream &os) const
 Saves vector field data to stream os.
void debug_print (std::ostream &os) const
 Print debugging information to stream os.

Detailed Description

Mesh based vector field.

The mesh based vector field is a vector field implementation storing vector data in a even, rectangular mesh. The IBSimu Package uses vector fields for electric and magnetic fields. 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.


Constructor & Destructor Documentation

Default constructor.

The field made with the default constructor sets geometry mode to MODE3D, mesh cell size h to 1, mesh size size to (0,0,0) and origo origo to (0,0,0). The field evaluator returns always zero.

MeshVectorField::MeshVectorField ( const Mesh m,
const bool  fout[3] 
)

Constructor for vector field from m.

Returns a new vector field with geometry parameters (including mesh size) set from m. The field is set to zero in all locations.

MeshVectorField::MeshVectorField ( geom_mode_e  geom_mode,
const 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.

MeshVectorField::MeshVectorField ( geom_mode_e  geom_mode,
const 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)

MeshVectorField::MeshVectorField ( geom_mode_e  geom_mode,
const bool  fout[3],
Int3D  size,
Vec3D  origo,
double  h,
const MeshVectorField fin 
)

Conversion constructor.

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 content is copied from another mesh based vector field fin.

Currently supports

1. Conversion from cylindrical (x,r,Bx,Br,Btheta) to 3d (x,y,z,Bx,By,Bz), where x -> z and r -> (x,y).

2. Conversion from 3d to 3d. Allows change of mesh density and size of field, change of extrapolation effect...

Conversion algorithm uses field evaluator ot the input field and therefore the extrapolation settings and the transformation in the field affect the created field.

Copy constructor.

MeshVectorField::MeshVectorField ( std::istream &  is)

Constructor for loading vector field from stream is.

virtual MeshVectorField::~MeshVectorField ( ) [virtual]

Destructor.


Member Function Documentation

Clears the field.

void MeshVectorField::debug_print ( std::ostream &  os) const

Print debugging information to stream os.

Reimplemented from Mesh.

void MeshVectorField::get_defined_components ( bool  fout[3]) const

Get which field components are defined.

void MeshVectorField::get_minmax ( double &  min,
double &  max 
) const

Search minimum and maximum vector length values of vector field.

const Vec3D MeshVectorField::operator() ( int32_t  i) const

Operator for getting elements of the field mesh.

const Vec3D MeshVectorField::operator() ( int32_t  i,
int32_t  j 
) const

Operator for getting elements of the field mesh.

const Vec3D MeshVectorField::operator() ( int32_t  i,
int32_t  j,
int32_t  k 
) const

Operator for getting elements of the field mesh.

virtual const Vec3D MeshVectorField::operator() ( Vec3D  x) const [virtual]

Operator for getting linearly interpolated field value at x.

Implements VectorField.

MeshVectorField& MeshVectorField::operator*= ( double  x)

Scaling operator for field values.

MeshVectorField& MeshVectorField::operator+= ( const MeshVectorField f)

Accumulation operator.

MeshVectorField& MeshVectorField::operator/= ( double  x)

Inverse scaling operator.

MeshVectorField& MeshVectorField::operator= ( const MeshVectorField f)

Copy operator.

void MeshVectorField::reset ( geom_mode_e  geom_mode,
const bool  fout[3],
Int3D  size,
Vec3D  origo,
double  h 
)

Resets the field geometry.

Sets the field mesh geometry according to the parameters, clears the field to zero in all locations and resets the transformation.

Set transformation to unity.

void MeshVectorField::rotate_x ( double  a)

Rotate solid around x-axis.

Rotate around x-axis for a radians.

void MeshVectorField::rotate_y ( double  a)

Rotate solid around y-axis.

Rotate around y-axis for a radians.

Rotate field in coordinate system around y-axis.

void MeshVectorField::rotate_z ( double  a)

Rotate solid around z-axis.

Rotate around z-axis for a radians.

void MeshVectorField::save ( const std::string &  filename) const

Saves data to a new file filename.

void MeshVectorField::save ( std::ostream &  os) const

Saves vector field data to stream os.

Reimplemented from Mesh.

void MeshVectorField::scale ( const Vec3D sx)

Scale field.

void MeshVectorField::set ( int32_t  i,
const Vec3D v 
)

Operator for setting element (i) of the field mesh.

void MeshVectorField::set ( int32_t  i,
int32_t  j,
const Vec3D v 
)

Operator for setting element (i,j) of the field mesh.

void MeshVectorField::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 MeshVectorField::set_extrapolation ( const 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), can return a zero field (FIELD_ZERO) or it can return a NaN (FIELD_NAN) outside the mesh

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.

Set transformation as a copy of T.

void MeshVectorField::translate ( const Vec3D dx)

Translate field.


The documentation for this class was generated from the following file: