Public Member Functions | List of all members
MeshVectorField Class Reference

Mesh based vector field. More...

#include <meshvectorfield.hpp>

Inheritance diagram for MeshVectorField:
VectorField Mesh

Public Member Functions

 MeshVectorField ()
 Default constructor. More...
 
 MeshVectorField (const Mesh &m, const bool fout[3])
 Constructor for vector field from m. More...
 
 MeshVectorField (geom_mode_e geom_mode, const bool fout[3], Int3D size, Vec3D origo, double h)
 Constructor for set geometry. More...
 
 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. More...
 
 MeshVectorField (geom_mode_e geom_mode, const bool fout[3], Int3D size, Vec3D origo, double h, const MeshVectorField &fin)
 Conversion constructor. More...
 
 MeshVectorField (const MeshVectorField &f)
 Copy constructor. More...
 
 MeshVectorField (std::istream &is)
 Constructor for loading vector field from stream is. More...
 
virtual ~MeshVectorField ()
 Destructor. More...
 
void set_extrapolation (const field_extrpl_e extrpl[6])
 Set the behaviour of field interpolation outside mesh points (extrapolation). More...
 
void reset_transformation (void)
 Set transformation to unity. More...
 
void set_transformation (const Transformation &T)
 Set transformation as a copy of T. More...
 
void translate (const Vec3D &dx)
 Translate field. More...
 
void scale (const Vec3D &sx)
 Scale field. More...
 
void rotate_x (double a)
 Rotate solid around x-axis. More...
 
void rotate_y (double a)
 Rotate solid around y-axis. More...
 
void rotate_z (double a)
 Rotate solid around z-axis. More...
 
void clear ()
 Clears the field. More...
 
void reset (geom_mode_e geom_mode, const bool fout[3], Int3D size, Vec3D origo, double h)
 Resets the field geometry. More...
 
void get_minmax (double &min, double &max) const
 Search minimum and maximum vector length values of vector field. More...
 
void get_defined_components (bool fout[3]) const
 Get which field components are defined. More...
 
MeshVectorFieldoperator= (const MeshVectorField &f)
 Copy operator. More...
 
MeshVectorFieldoperator+= (const MeshVectorField &f)
 Accumulation operator. More...
 
MeshVectorFieldoperator*= (double x)
 Scaling operator for field values. More...
 
MeshVectorFieldoperator/= (double x)
 Inverse scaling operator. More...
 
const Vec3D operator() (int32_t i) const
 Operator for getting elements of the field mesh. More...
 
const Vec3D operator() (int32_t i, int32_t j) const
 Operator for getting elements of the field mesh. More...
 
const Vec3D operator() (int32_t i, int32_t j, int32_t k) const
 Operator for getting elements of the field mesh. More...
 
void set (int32_t i, const Vec3D &v)
 Operator for setting element (i) of the field mesh. More...
 
void set (int32_t i, int32_t j, const Vec3D &v)
 Operator for setting element (i,j) of the field mesh. More...
 
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. More...
 
virtual const Vec3D operator() (Vec3D x) const
 Operator for getting linearly interpolated field value at x. More...
 
void save (const std::string &filename) const
 Saves data to a new file filename. More...
 
void save (std::ostream &os) const
 Saves vector field data to stream os. More...
 
void debug_print (std::ostream &os) const
 Print debugging information to stream os. More...
 
- Public Member Functions inherited from VectorField
virtual ~VectorField ()
 Virtual destructor. More...
 
- Public Member Functions inherited from Mesh
 Mesh ()
 Default constructor for mesh definition. More...
 
 Mesh (geom_mode_e geom_mode, Int3D size, Vec3D origo, double h)
 Constructor for mesh definition. More...
 
 Mesh (std::istream &is)
 Constructoer for loading mesh from a stream is. More...
 
 ~Mesh ()
 Destructor. More...
 
void reset (geom_mode_e geom_mode, Int3D size, Vec3D origo, double h)
 Reset mesh definition. More...
 
geom_mode_e geom_mode (void) const
 Returns geometry mode. More...
 
int32_t dim (void) const
 Returns number of dimensions in geometry. More...
 
Int3D size (void) const
 Returns size array of geometry. More...
 
int32_t size (int i) const
 Returns size of solid mesh in direction i. More...
 
int32_t nodecount (void) const
 Returns number of nodes in the mesh. More...
 
Vec3D origo (void) const
 Returns origo vector of geometry. More...
 
double origo (int i) const
 Returns i-th component of vector origo. More...
 
Vec3D max (void) const
 Returns vector pointing to the last mesh point opposite of origo. More...
 
double max (int i) const
 Returns i-th component of vector pointing to the last mesh point opposite of origo. More...
 
double h (void) const
 Returns mesh cell size. More...
 
double div_h (void) const
 Returns reciprocal of mesh cell size (1/h). More...
 
void save (std::ostream &os) const
 Saves geometry data to stream os. More...
 
bool operator== (const Mesh &m) const
 Equality. More...
 
bool operator!= (const Mesh &m) const
 Non-equality. More...
 
void debug_print (std::ostream &os) const
 Print debugging information to stream os. More...
 

Additional Inherited Members

- Protected Attributes inherited from Mesh
geom_mode_e _geom_mode
 Geometry mode More...
 
Int3D _size
 Size of mesh. More...
 
Vec3D _origo
 Location of mesh point (0,0,0) [m]. More...
 
Vec3D _max
 Location of mesh point (size[0]-1,size[1]-1,size[2]-1) [m]. More...
 
double _h
 Length of mesh step [m]. More...
 
double _div_h
 Reciprocal of length of mesh step [1/m]. More...
 

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

MeshVectorField::MeshVectorField ( )

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.

MeshVectorField::MeshVectorField ( const MeshVectorField f)

Copy constructor.

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

Constructor for loading vector field from stream is.

virtual MeshVectorField::~MeshVectorField ( )
virtual

Destructor.

Member Function Documentation

void MeshVectorField::clear ( )

Clears the field.

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

Print debugging information to stream os.

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.

void MeshVectorField::reset_transformation ( void  )

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.

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.

void MeshVectorField::set_transformation ( const Transformation T)

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: