Public Member Functions | List of all members
MultiMeshVectorField Class Reference

Vector field based on multiple meshes. More...

#include <multimeshvectorfield.hpp>

Inheritance diagram for MultiMeshVectorField:
VectorField

Public Member Functions

 MultiMeshVectorField ()
 Default constructor.
 
 MultiMeshVectorField (const Mesh &m, const bool fout[3])
 Constructor for vector field from m.
 
 MultiMeshVectorField (geom_mode_e geom_mode, const bool fout[3], Int3D size, Vec3D origo, double h)
 Constructor for set geometry.
 
 MultiMeshVectorField (geom_mode_e geom_mode, const bool fout[3], double xscale, double fscale, const std::string &filename)
 Constructor for vector field from ascii file.
 
 MultiMeshVectorField (const MultiMeshVectorField &f)
 Copy constructor.
 
 MultiMeshVectorField (std::istream &s)
 Constructor for loading vector field from a file.
 
virtual ~MultiMeshVectorField ()
 Destructor.
 
void set_extrapolation (const 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, const bool fout[3], Int3D size, Vec3D origo, double h)
 Resets the field geometry.
 
void add_mesh (Int3D size, Vec3D origo, double h)
 Add a new mesh field to the multiple mesh vector field.
 
void add_mesh (double xscale, double fscale, const std::string &filename)
 Add a new mesh field from ascii file.
 
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.
 
MultiMeshVectorFieldoperator= (const MultiMeshVectorField &f)
 Copy operator.
 
const MeshVectorFieldoperator[] (int i) const
 Return const reference to subfield i.
 
MeshVectorFieldoperator[] (int i)
 Return reference to subfield i.
 
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 &s) const
 Saves vector field data to stream.
 
void debug_print (std::ostream &os) const
 Print debugging information to os.
 
- Public Member Functions inherited from VectorField
virtual ~VectorField ()
 Virtual destructor.
 

Detailed Description

Vector field based on multiple meshes.

The MultiMeshVectorField is a vector field implementation storing vector data in multiple rectangular meshes. This makes it possible to have higher precision in some areas and lower precision in other areas of the simulation. The multiple mesh vector field has several underlying mesh based vector fields in a certain order. When the field value is queried at a location, the underlying fields are queries in the defined order until a field covering the point of query is found. Is the point is outside all of the underlying fields, the last (largest and coarsest) field is used to extrapolate the field value.

The first (largest and coarsest) field of the multiple mesh vector field is defined first either with a constructor or using reset() function. The detailed meshes are then added with add_mesh().

Constructor & Destructor Documentation

MultiMeshVectorField::MultiMeshVectorField ( )

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.

MultiMeshVectorField::MultiMeshVectorField ( 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.

MultiMeshVectorField::MultiMeshVectorField ( 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.

MultiMeshVectorField::MultiMeshVectorField ( 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)

MultiMeshVectorField::MultiMeshVectorField ( const MultiMeshVectorField f)

Copy constructor.

MultiMeshVectorField::MultiMeshVectorField ( std::istream &  s)

Constructor for loading vector field from a file.

virtual MultiMeshVectorField::~MultiMeshVectorField ( )
virtual

Destructor.

Member Function Documentation

void MultiMeshVectorField::add_mesh ( Int3D  size,
Vec3D  origo,
double  h 
)

Add a new mesh field to the multiple mesh vector field.

The new field is appended to the list of fields. The field defined last is checked first by the evaluator when searching for field value at a point. The new field has same defined field components and same geometry mode as the first field definded. The size, origo and mesh step h can differ.

void MultiMeshVectorField::add_mesh ( double  xscale,
double  fscale,
const std::string &  filename 
)

Add a new mesh field from ascii file.

The new field is appended to the list of fields. The field defined last is checked first by the evaluator when searching for field value at a point. The new field has same defined field components and same geometry mode as the first field definded. The size, origo and mesh step h can differ.

void MultiMeshVectorField::clear ( )

Clears the field.

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

Print debugging information to os.

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

Get which field components are defined.

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

Search minimum and maximum vector length values of vector field.

virtual const Vec3D MultiMeshVectorField::operator() ( Vec3D  x) const
virtual

Operator for getting linearly interpolated field value at x.

Implements VectorField.

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

Copy operator.

const MeshVectorField& MultiMeshVectorField::operator[] ( int  i) const
inline

Return const reference to subfield i.

MeshVectorField& MultiMeshVectorField::operator[] ( int  i)
inline

Return reference to subfield i.

void MultiMeshVectorField::reset ( geom_mode_e  geom_mode,
const 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. Only the coarsest field will be defined using these parameters.

void MultiMeshVectorField::rotate_x ( int  a)

Rotate field in coordinate system around x-axis.

void MultiMeshVectorField::rotate_y ( int  a)

Rotate field in coordinate system around y-axis.

void MultiMeshVectorField::rotate_z ( int  a)

Rotate field in coordinate system around z-axis.

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

Saves data to a new file filename.

void MultiMeshVectorField::save ( std::ostream &  s) const

Saves vector field data to stream.

void MultiMeshVectorField::scale ( double  s)

Scale field in coordinate system.

void MultiMeshVectorField::set_extrapolation ( const field_extrpl_e  extrpl[6])

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 MultiMeshVectorField::translate ( Vec3D  x)

Translate field in coordinate system.


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