Public Member Functions | List of all members
Geometry Class Reference

Geometry defining class. More...

#include <geometry.hpp>

Inheritance diagram for Geometry:
Mesh

Public Member Functions

 Geometry (geom_mode_e geom_mode, Int3D size, Vec3D origo, double h)
 Constructor for geometry class. More...
 
 Geometry (std::istream &is)
 Constructor for loading geometry from a stream is. More...
 
 ~Geometry ()
 Destructor for geometry. More...
 
uint32_t number_of_solids () const
 Return number of solids. More...
 
uint32_t number_of_boundaries () const
 Return number of boundaries. More...
 
void set_solid (uint32_t n, const Solid *s)
 Sets solid number n to s. More...
 
const Solidget_solid (uint32_t n) const
 Returns a const pointer to solid number n. More...
 
void set_boundary (uint32_t n, const Bound &b)
 Sets boundary condition b for solid number n. More...
 
Bound get_boundary (uint32_t n) const
 Returns boundary condition for solid number n. More...
 
std::vector< Boundget_boundaries () const
 Returns a vector of boundary conditions. More...
 
void set_bracket_count (uint32_t n)
 Set the solid bracketing count number. More...
 
uint32_t get_bracket_count (void) const
 Returns the solid bracketing count number. More...
 
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. More...
 
bool inside (uint32_t n, const Vec3D &x) const
 Returns true if point x is inside solid n. More...
 
double bracket_surface (uint32_t n, const Vec3D &xin, const Vec3D &xout, Vec3D &xsurf) const
 Find solid n surface location by bracketing. More...
 
Vec3D surface_normal (const Vec3D &x) const
 Find surface outward normal at location x. More...
 
bool built (void) const
 Is the solid mesh built? More...
 
void build_mesh (void)
 Builds (or rebuilds) the solid mesh from solid definitions. More...
 
const signed char & mesh (int32_t i) const
 Returns a const reference to solid mesh. More...
 
const signed char & mesh (int32_t i, int32_t j) const
 Returns a const reference to solid mesh. More...
 
const signed char & mesh (int32_t i, int32_t j, int32_t k) const
 Returns a const reference to solid mesh. More...
 
signed char & mesh (int32_t i)
 Returns a reference to solid mesh. More...
 
signed char & mesh (int32_t i, int32_t j)
 Returns a reference to solid mesh. More...
 
signed char & mesh (int32_t i, int32_t j, int32_t k)
 Returns a reference to solid mesh. More...
 
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. More...
 
void save (const std::string &filename) const
 Saves data to a new file filename. More...
 
void save (std::ostream &os) const
 Saves data to stream os. More...
 
void debug_print (std::ostream &os) const
 Print debugging information to stream os. 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

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.

Constructor & Destructor Documentation

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.

Member Function Documentation

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.

bool Geometry::built ( void  ) const
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.

const signed char& Geometry::mesh ( int32_t  i) const
inline

Returns a const reference to solid mesh.

const signed char& Geometry::mesh ( int32_t  i,
int32_t  j 
) const
inline

Returns a const reference to solid mesh.

const signed char& Geometry::mesh ( int32_t  i,
int32_t  j,
int32_t  k 
) const
inline

Returns a const reference to solid mesh.

signed char& Geometry::mesh ( int32_t  i)
inline

Returns a reference to solid mesh.

signed char& Geometry::mesh ( int32_t  i,
int32_t  j 
)
inline

Returns a reference to solid mesh.

signed char& Geometry::mesh ( int32_t  i,
int32_t  j,
int32_t  k 
)
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.

Vec3D Geometry::surface_normal ( const Vec3D x) const

Find surface outward normal at location x.

Returns zero vector on failure.


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