Navigation

Main Page
Download
Support
Installation
Tutorial
Examples
Reference Manual
   Version 1.0.6dev
      Class Index
      File List
   Version 1.0.6
   Version 1.0.5new_solver
   Version 1.0.5dev
   Version 1.0.5b
   Version 1.0.4dev
   Version 1.0.4
Publications


Hosted by Get Ion Beam Simulator at SourceForge.net. Fast, secure and Free Open Source software downloads
MultiMeshVectorField Class Reference

Vector field based on multiple meshes. More...

#include <multimeshvectorfield.hpp>

Inheritance diagram for MultiMeshVectorField:
VectorField Field

Public Member Functions

 MultiMeshVectorField ()
 Default constructor. More...
 
 MultiMeshVectorField (const Mesh &m, const bool fout[3])
 Constructor for vector field from m. More...
 
 MultiMeshVectorField (geom_mode_e geom_mode, const bool fout[3], Int3D size, Vec3D origo, double h)
 Constructor for set geometry. More...
 
 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. More...
 
 MultiMeshVectorField (const MultiMeshVectorField &f)
 Copy constructor. More...
 
 MultiMeshVectorField (std::istream &s)
 Constructor for loading vector field from a file. More...
 
virtual ~MultiMeshVectorField ()
 Destructor. More...
 
void set_extrapolation (const field_extrpl_e extrpl[6])
 Set the behaviour of field interpolation outside mesh points (extrapolation). More...
 
void translate (Vec3D x)
 Translate field in coordinate system. More...
 
void scale (double s)
 Scale field in coordinate system. More...
 
void rotate_x (double a)
 Rotate field in coordinate system around x-axis for a radians. More...
 
void rotate_y (double a)
 Rotate field in coordinate system around y-axis for a radians. More...
 
void rotate_z (double a)
 Rotate field in coordinate system around z-axis for a radians. 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 add_mesh (const MeshVectorField &field)
 Add a new mesh field to the multiple mesh vector field. More...
 
void add_mesh (Int3D size, Vec3D origo, double h)
 Add a new mesh field to the multiple mesh vector field. More...
 
void add_mesh (double xscale, double fscale, const std::string &filename)
 Add a new mesh field from ascii file. 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...
 
MultiMeshVectorFieldoperator= (const MultiMeshVectorField &f)
 Copy operator. More...
 
const MeshVectorFieldoperator[] (int i) const
 Return const reference to subfield i. More...
 
MeshVectorFieldoperator[] (int i)
 Return reference to subfield i. More...
 
virtual const Vec3D operator() (const 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 &s) const
 Saves vector field data to stream. More...
 
void debug_print (std::ostream &os) const
 Print debugging information to os. More...
 
- Public Member Functions inherited from VectorField
virtual ~VectorField ()
 Virtual destructor. More...
 
void get_minmax (const Mesh &mesh, double &min, double &max) const
 Search minimum and maximum vector length values of vector field at mesh nodes. More...
 
void get_minmax (const Mesh &mesh, Vec3D &min, Vec3D &max) const
 Search minimum and maximum for each vector component at mesh nodes. More...
 
- Public Member Functions inherited from Field
virtual ~Field ()
 Virtual destructor. More...
 

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 (according to the extrapolation settings).

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

The MultiMeshVectorField can't be yet used with electric potential solvers. This functionality has been planned to be added in the future for possibility of having a higher mesh density in critical areas. Currently the MultiMeshVectorFields can only be used as magnetic fields.

Constructor & Destructor Documentation

◆ MultiMeshVectorField() [1/6]

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), origo origo to (0,0,0). The field evaluator returns always zero.

◆ MultiMeshVectorField() [2/6]

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() [3/6]

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() [4/6]

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() [5/6]

MultiMeshVectorField::MultiMeshVectorField ( const MultiMeshVectorField f)

Copy constructor.

◆ MultiMeshVectorField() [6/6]

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

Constructor for loading vector field from a file.

◆ ~MultiMeshVectorField()

MultiMeshVectorField::~MultiMeshVectorField ( )
virtual

Destructor.

Member Function Documentation

◆ add_mesh() [1/3]

void MultiMeshVectorField::add_mesh ( const MeshVectorField field)

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

The new field, which is an internal copy of the field given as a parameter to this function 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 to have the same defined field components and same geometry mode as the first field defined.

◆ add_mesh() [2/3]

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 defined. The size, origo and mesh step h can differ.

◆ add_mesh() [3/3]

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 defined. The size, origo and mesh step h can differ.

◆ clear()

void MultiMeshVectorField::clear ( void  )

Clears the field.

◆ debug_print()

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

Print debugging information to os.

◆ get_defined_components()

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

Get which field components are defined.

◆ get_minmax()

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

Search minimum and maximum vector length values of vector field.

◆ operator()()

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

Operator for getting linearly interpolated field value at x.

Implements VectorField.

◆ operator=()

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

Copy operator.

◆ operator[]() [1/2]

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

Return reference to subfield i.

◆ operator[]() [2/2]

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

Return const reference to subfield i.

◆ reset()

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.

◆ rotate_x()

void MultiMeshVectorField::rotate_x ( double  a)

Rotate field in coordinate system around x-axis for a radians.

◆ rotate_y()

void MultiMeshVectorField::rotate_y ( double  a)

Rotate field in coordinate system around y-axis for a radians.

◆ rotate_z()

void MultiMeshVectorField::rotate_z ( double  a)

Rotate field in coordinate system around z-axis for a radians.

◆ save() [1/2]

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

Saves data to a new file filename.

◆ save() [2/2]

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

Saves vector field data to stream.

◆ scale()

void MultiMeshVectorField::scale ( double  s)

Scale field in coordinate system.

◆ set_extrapolation()

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 FIELD_EXTRAPOLATE is the default behaviour.

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.

◆ translate()

void MultiMeshVectorField::translate ( Vec3D  x)

Translate field in coordinate system.


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


Reference manual for Ion Beam Simulator 1.0.6dev
Generated by Doxygen 1.9.1 on Thu Sep 11 2025 09:37:24.