Geometry defining class. More...
#include <geometry.hpp>
Public Member Functions | |
Geometry (geom_mode_e geom_mode, Int3D size, Vec3D origo, double h) | |
Constructor for geometry class. | |
Geometry (std::istream &is) | |
Constructor for loading geometry from a stream is. | |
~Geometry () | |
Destructor for geometry. | |
uint32_t | number_of_solids () const |
Return number of solids. | |
uint32_t | number_of_boundaries () const |
Return number of boundaries. | |
void | set_solid (uint32_t n, const Solid *s) |
Sets solid number n to s. | |
const Solid * | get_solid (uint32_t n) const |
Returns a const pointer to solid number n. | |
void | set_boundary (uint32_t n, const Bound &b) |
Sets boundary condition b for solid number n. | |
Bound | get_boundary (uint32_t n) const |
Returns boundary condition for solid number n. | |
std::vector< Bound > | get_boundaries () const |
Returns a vector of boundary conditions. | |
void | set_bracket_count (uint32_t n) |
Set the solid bracketing count number. | |
uint32_t | get_bracket_count (void) const |
Returns the solid bracketing count number. | |
uint32_t | inside (const Vec3D &x) const |
Returns 0 if point x is vacuum or the number of solid of x is inside a defined solid. Returns a number from 1 to 6 if point x is outside the defined geometry. If the point is inside several defined solids, the solid with the highest solid number is returned. | |
bool | inside (uint32_t n, const Vec3D &x) const |
Returns true if point x is inside solid n. | |
double | bracket_surface (uint32_t n, const Vec3D &xin, const Vec3D &xout, Vec3D &xsurf) const |
Find solid n surface location by bracketing. | |
Vec3D | surface_normal (const Vec3D &x) const |
Find surface outward normal at location x. | |
bool | built (void) const |
Is the solid mesh built? | |
void | build_mesh (void) |
Builds (or rebuilds) the solid mesh from solid definitions. | |
const signed char & | mesh (int32_t i) const |
Returns a const reference to solid mesh. | |
const signed char & | mesh (int32_t i, int32_t j) const |
Returns a const reference to solid mesh. | |
const signed char & | mesh (int32_t i, int32_t j, int32_t k) const |
Returns a const reference to solid mesh. | |
signed char & | mesh (int32_t i) |
Returns a reference to solid mesh. | |
signed char & | mesh (int32_t i, int32_t j) |
Returns a reference to solid mesh. | |
signed char & | mesh (int32_t i, int32_t j, int32_t k) |
Returns a reference to solid mesh. | |
signed char | mesh_check (int32_t i, int32_t j, int32_t k) const |
Returns solid node number from solid mesh at i, j, k or number from 1 to 6 if point is outside mesh. | |
void | save (const std::string &filename) const |
Saves data to a new file filename. | |
void | save (std::ostream &os) const |
Saves data to stream os. | |
void | debug_print (std::ostream &os) const |
Print debugging information to stream os. | |
![]() | |
Mesh () | |
Default constructor for mesh definition. | |
Mesh (geom_mode_e geom_mode, Int3D size, Vec3D origo, double h) | |
Constructor for mesh definition. | |
Mesh (std::istream &is) | |
Constructoer for loading mesh from a stream is. | |
~Mesh () | |
Destructor. | |
void | reset (geom_mode_e geom_mode, Int3D size, Vec3D origo, double h) |
Reset mesh definition. | |
geom_mode_e | geom_mode (void) const |
Returns geometry mode. | |
int32_t | dim (void) const |
Returns number of dimensions in geometry. | |
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. | |
Vec3D | max (void) const |
Returns vector pointing to the last mesh point opposite of origo. | |
double | max (int i) const |
Returns i-th component of vector pointing to the last mesh point opposite of origo. | |
double | h (void) const |
Returns mesh cell size. | |
double | div_h (void) const |
Returns reciprocal of mesh cell size (1/h). | |
void | save (std::ostream &os) const |
Saves geometry data to stream os. | |
bool | operator== (const Mesh &m) const |
Equality. | |
bool | operator!= (const Mesh &m) const |
Non-equality. | |
void | debug_print (std::ostream &os) const |
Print debugging information to stream os. | |
Additional Inherited Members | |
![]() | |
geom_mode_e | _geom_mode |
Geometry mode | |
Int3D | _size |
Size of mesh. | |
Vec3D | _origo |
Location of mesh point (0,0,0) [m]. | |
Vec3D | _max |
Location of mesh point (size[0]-1,size[1]-1,size[2]-1) [m]. | |
double | _h |
Length of mesh step [m]. | |
double | _div_h |
Reciprocal of length of mesh step [1/m]. | |
Geometry defining class.
Geometry class holds the definitions of the geometry dimensionality, mesh size and electrode configuration. Also it contains a signed char array for information about the type of each node. This array is known as the solid mesh.
The integer numbers in the solid mesh have the following meanings: The solid number 0 is reserved for vacuum and solid numbers from 1 to 6 are reserved for Dirichlet type boundaries of the bounding box. Solid numbers from -1 to -6 are reserved for Neumann type boundaries of the bounding box. Negative solid numbers starting from -7 are used for marking electrode edges and the positive numbers starting from 7 are used to mark the interior points of the electrodes.
The mesh nodes are marked using the following logic: First nodes, which are inside electrodes are marked solid (>=7). If a point is inside several solids, the highest solid number is marked. Other points are left as vacuum nodes (0). As the next step the solid nodes are mapped to find nodes which have vacuum as closest neighbour along any of the axes (not diagonal). These nodes are marked as solid edges (<=-7). As the last step, the vacuum nodes at the simulation box boundary are marked either as Neumann (<0 and >-7) or Dirichlet (>0 and <7).
Starting from 1.0.3: A. Mark solids, B. Mark Neumann and Dirichlet boundaries, C. Mark edges taking in account that Neumann = Vacuum and Dirichlet != Vacuum.
Bounding box edges are numbered in order xmin, xmax, ymin, ymax, zmin, xmax.
Geometry::Geometry | ( | geom_mode_e | geom_mode, |
Int3D | size, | ||
Vec3D | origo, | ||
double | h | ||
) |
Constructor for geometry class.
Sets geometry mode, mesh cell size h, mesh size size and origo origo.
Geometry::Geometry | ( | std::istream & | is | ) |
Constructor for loading geometry from a stream is.
Geometry::~Geometry | ( | ) |
Destructor for geometry.
double Geometry::bracket_surface | ( | uint32_t | n, |
const Vec3D & | xin, | ||
const Vec3D & | xout, | ||
Vec3D & | xsurf | ||
) | const |
Find solid n surface location by bracketing.
Searches for the solid n surface location on the line between points xin and xout by bracketing. Point xin should be inside the solid and point xout should be outside the solid. Function saves the coordinates of the surface to xsurf and returns parametrical distance (value from 0 to 1) from xin.
void Geometry::build_mesh | ( | void | ) |
Builds (or rebuilds) the solid mesh from solid definitions.
|
inline |
Is the solid mesh built?
void Geometry::debug_print | ( | std::ostream & | os | ) | const |
Print debugging information to stream os.
std::vector<Bound> Geometry::get_boundaries | ( | ) | const |
Returns a vector of boundary conditions.
Bound Geometry::get_boundary | ( | uint32_t | n | ) | const |
Returns boundary condition for solid number n.
uint32_t Geometry::get_bracket_count | ( | void | ) | const |
Returns the solid bracketing count number.
const Solid* Geometry::get_solid | ( | uint32_t | n | ) | const |
Returns a const pointer to solid number n.
Solid number n should be >= 7.
uint32_t Geometry::inside | ( | const Vec3D & | x | ) | const |
Returns 0 if point x is vacuum or the number of solid of x is inside a defined solid. Returns a number from 1 to 6 if point x is outside the defined geometry. If the point is inside several defined solids, the solid with the highest solid number is returned.
bool Geometry::inside | ( | uint32_t | n, |
const Vec3D & | x | ||
) | const |
Returns true if point x is inside solid n.
|
inline |
Returns a const reference to solid mesh.
|
inline |
Returns a const reference to solid mesh.
|
inline |
Returns a const reference to solid mesh.
|
inline |
Returns a reference to solid mesh.
|
inline |
Returns a reference to solid mesh.
|
inline |
Returns a reference to solid mesh.
signed char Geometry::mesh_check | ( | int32_t | i, |
int32_t | j, | ||
int32_t | k | ||
) | const |
Returns solid node number from solid mesh at i, j, k or number from 1 to 6 if point is outside mesh.
uint32_t Geometry::number_of_boundaries | ( | ) | const |
Return number of boundaries.
Always returns at least n >= 6.
uint32_t Geometry::number_of_solids | ( | ) | const |
Return number of solids.
void Geometry::save | ( | const std::string & | filename | ) | const |
Saves data to a new file filename.
void Geometry::save | ( | std::ostream & | os | ) | const |
Saves data to stream os.
void Geometry::set_boundary | ( | uint32_t | n, |
const Bound & | b | ||
) |
Sets boundary condition b for solid number n.
Solid number n should be > 0 here. Boundary numbers from 1 to 6 are the boundary conditions for the bounding box. Numbers starting from 7 are the user defined solids. All boundaries of the simulation box (n <= 6) default to Neumann boundary condition with derivative value zero. All defined solids (n >= 7) default to Dirichlet boundary with potential zero.
In cylindrical geometry case the rmin boundary can be set to Dirichlet, which means that there is an infinitely thin wire with a fixed potential at the axis or to Neumann, which means that the natural boundary for cylindrical axis will be used.
void Geometry::set_bracket_count | ( | uint32_t | n | ) |
Set the solid bracketing count number.
The "exact" locations of the solid surfaces are determined by bracketing in class Geometry using function bracket_surface(). In a typical case the bracketing is started from two mesh nodes and the estimate for the location of the surface is halved at each bracketing. This function sets the number halvings n that are done before bracket_surface() returns the best estimate.
The bracketing count number defaults to 12, which corresponds to relative accuracy of 1/4096.
void Geometry::set_solid | ( | uint32_t | n, |
const Solid * | s | ||
) |
Sets solid number n to s.
Solids have to be defined in incresing order. Solid number n should be >= 7. This function can also be used to overwrite a previous solid definition. Pointer to solid s is saved to geometry structure. Solid will be deleted when geometry is deleted. The newly defined defined solids default to Dirichlet boundary with potential zero.
Find surface outward normal at location x.
Returns zero vector on failure.