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
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...
 
bool have_solid_data (void) const
 Returns true if full solid data available. More...
 
uint32_t inside (const Vec3D &x) const
 Return if point is inside solids. 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 and near solid data from solid definitions. More...
 
const uint32_t & mesh (int32_t i) const
 Returns a const reference to solid mesh array. More...
 
const uint32_t & mesh (int32_t i, int32_t j) const
 Returns a const reference to solid mesh array. More...
 
const uint32_t & mesh (int32_t i, int32_t j, int32_t k) const
 Returns a const reference to solid mesh array. More...
 
uint32_t & mesh (int32_t i)
 Returns a reference to solid mesh array. More...
 
uint32_t & mesh (int32_t i, int32_t j)
 Returns a reference to solid mesh array. More...
 
uint32_t & mesh (int32_t i, int32_t j, int32_t k)
 Returns a reference to solid mesh array. More...
 
uint32_t mesh_check (int32_t i) const
 Returns number from solid mesh array. More...
 
uint32_t mesh_check (int32_t i, int32_t j) const
 Returns number from solid mesh array. More...
 
uint32_t mesh_check (int32_t i, int32_t j, int32_t k) const
 Returns number from solid mesh array. More...
 
bool is_near_solid (int32_t i, int32_t j, int32_t k) const
 Returns true if node is a potential near solid point. More...
 
const uint8_t * nearsolid_ptr (int32_t index) const
 Returns a const pointer to start of near-solid data for near-solid node index. More...
 
uint8_t solid_dist (uint32_t i, uint32_t j, uint32_t k, uint32_t dir) const
 Returns distance of solid boundary from point. More...
 
uint8_t solid_dist (uint32_t i, uint32_t dir) const
 Returns distance of solid boundary from point. More...
 
void build_surface (void)
 Build surface triangulation data. More...
 
bool surface_built (void) const
 Is the solid surface representation built? More...
 
uint32_t surface_inside (const Vec3D &x) const
 Finds if point is inside surface triangulation. More...
 
uint32_t surface_vertexc (void) const
 Return total surface vertex count. More...
 
uint32_t surface_trianglec (void) const
 Return total surface triangle count. More...
 
const Vec3Dsurface_vertex (int32_t a) const
 Return reference to surface vertex a. More...
 
Vec3D surface_triangle_normal (const Vec3D &x) const
 Return normal of surface triangle near point x. More...
 
Vec3D surface_triangle_normal (int32_t a) const
 Return normal of surface triangle a. More...
 
const VTrianglesurface_triangle (int32_t a) const
 Return reference to surface triangle a. More...
 
uint32_t surface_triangle_ptr (int32_t i, int32_t j, int32_t k) const
 Return index of first surface triangle at mesh cube (i,j,k). More...
 
int32_t surface_trianglec (int32_t i, int32_t j, int32_t k) const
 Return surface triangle count at mesh cube (i,j,k). More...
 
void save (const std::string &filename, bool save_solids=false) const
 Saves data to a new file filename. More...
 
void save (std::ostream &os, bool save_solids=false) 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...
 
uint32_t dim (void) const
 Returns number of dimensions in geometry. More...
 
Int3D size (void) const
 Returns size array of geometry. More...
 
uint32_t size (int i) const
 Returns size of solid mesh in direction i. More...
 
uint32_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...
 
Int3D closest_node (Vec3D x) const
 Returns node closest to location x. More...
 
Int3D mesh_number (Vec3D x) const
 Returns node, which contains x. More...
 
Vec3D coord_of_node (Int3D n) const
 Returns coordinates of node i. 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() [1/2]

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

Geometry::Geometry ( std::istream &  is)
explicit

Constructor for loading geometry from a stream is.

◆ ~Geometry()

Geometry::~Geometry ( )

Destructor for geometry.

Member Function Documentation

◆ bracket_surface()

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.

Uses solid data.

◆ build_mesh()

void Geometry::build_mesh ( void  )

Builds (or rebuilds) the solid mesh and near solid data from solid definitions.

◆ build_surface()

void Geometry::build_surface ( void  )

Build surface triangulation data.

◆ built()

bool Geometry::built ( void  ) const
inline

Is the solid mesh built?

◆ debug_print()

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

Print debugging information to stream os.

◆ get_boundaries()

std::vector<Bound> Geometry::get_boundaries ( ) const

Returns a vector of boundary conditions.

◆ get_boundary()

Bound Geometry::get_boundary ( uint32_t  n) const

Returns boundary condition for solid number n.

◆ get_solid()

const Solid * Geometry::get_solid ( uint32_t  n) const

Returns a const pointer to solid number n.

Solid number n should be >= 7.

◆ have_solid_data()

bool Geometry::have_solid_data ( void  ) const

Returns true if full solid data available.

Returns false if any defined solid does not include solid data.

◆ inside() [1/2]

uint32_t Geometry::inside ( const Vec3D x) const

Return if point is inside solids.

Returns 0 if point x is in 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.

Uses solid data.

◆ inside() [2/2]

bool Geometry::inside ( uint32_t  n,
const Vec3D x 
) const

Returns true if point x is inside solid n.

Uses solid data.

◆ is_near_solid()

bool Geometry::is_near_solid ( int32_t  i,
int32_t  j,
int32_t  k 
) const

Returns true if node is a potential near solid point.

Returns true if any of the neighbouring points is a solid point (Dirichlet with solid number >= 7). The state of node (i,j,k) is not checked.

◆ mesh() [1/6]

uint32_t& Geometry::mesh ( int32_t  i)
inline

Returns a reference to solid mesh array.

◆ mesh() [2/6]

const uint32_t& Geometry::mesh ( int32_t  i) const
inline

Returns a const reference to solid mesh array.

◆ mesh() [3/6]

uint32_t& Geometry::mesh ( int32_t  i,
int32_t  j 
)
inline

Returns a reference to solid mesh array.

◆ mesh() [4/6]

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

Returns a const reference to solid mesh array.

◆ mesh() [5/6]

uint32_t& Geometry::mesh ( int32_t  i,
int32_t  j,
int32_t  k 
)
inline

Returns a reference to solid mesh array.

◆ mesh() [6/6]

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

Returns a const reference to solid mesh array.

◆ mesh_check() [1/3]

uint32_t Geometry::mesh_check ( int32_t  i) const

Returns number from solid mesh array.

For 1D geometries. Returns number from solid mesh array at i or Dirichlet boundary number (1 or 2) if point is outside mesh.

◆ mesh_check() [2/3]

uint32_t Geometry::mesh_check ( int32_t  i,
int32_t  j 
) const

Returns number from solid mesh array.

For 2D geometries. Returns number from solid mesh array at (i,j) or Dirichlet boundary number (1-4) if point is outside mesh.

◆ mesh_check() [3/3]

uint32_t Geometry::mesh_check ( int32_t  i,
int32_t  j,
int32_t  k 
) const

Returns number from solid mesh array.

Returns number from solid mesh array at (i,j,k) or Dirichlet boundary number (1-6) if point is outside mesh.

◆ nearsolid_ptr()

const uint8_t* Geometry::nearsolid_ptr ( int32_t  index) const
inline

Returns a const pointer to start of near-solid data for near-solid node index.

The first byte contains the bit flags for the existance of neighbouring solids. From bit 0 to bit 5 the boolean flags are for directions: xmin, xmax, ymin, ymax, zmin, zmax. The next bytes contain the parametric distances of the solid surfaces from the node in each direction. Only the directions with set bit flag are saved to data. The distances are saved in the same order as the flags (from xmin to zmax). The distance information is an unsigned 8-bit integer (0 to 255), where 0 means distance 0.0 and 255 means 1.0.

◆ number_of_boundaries()

uint32_t Geometry::number_of_boundaries ( ) const

Return number of boundaries.

Always returns at least n >= 6.

◆ number_of_solids()

uint32_t Geometry::number_of_solids ( ) const

Return number of solids.

◆ save() [1/2]

void Geometry::save ( const std::string &  filename,
bool  save_solids = false 
) const

Saves data to a new file filename.

If save_solids is true, also the solid definitions are saved. Not all solid types are saveable. A warning is printed if trying to save such a solid.

◆ save() [2/2]

void Geometry::save ( std::ostream &  os,
bool  save_solids = false 
) const

Saves data to stream os.

If save_solids is true, also the solid definitions are saved. Not all solid types are saveable. A warning is printed if trying to save such a solid.

◆ set_boundary()

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.

◆ set_solid()

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 not be deleted when geometry is deleted. The newly defined defined solids default to Dirichlet boundary with potential zero.

◆ solid_dist() [1/2]

uint8_t Geometry::solid_dist ( uint32_t  i,
uint32_t  dir 
) const

Returns distance of solid boundary from point.

Same as solid_dist() above, just using one dimensional index for mesh.

◆ solid_dist() [2/2]

uint8_t Geometry::solid_dist ( uint32_t  i,
uint32_t  j,
uint32_t  k,
uint32_t  dir 
) const

Returns distance of solid boundary from point.

Returns the distance (0 to 255) of solid surface in direction dir from near solid point at (i, j, k). The direction dir is an integer from 0 to 5, with 0 meaning -x, 1 meaning +x, 2 meaning -y, 3 meaning +y, 4 meaning -z and 5 meaning +z. If the node at (i, j, k) is not a near solid node or if there is no solid nearby in the direction an error will be thrown.

◆ surface_built()

bool Geometry::surface_built ( void  ) const
inline

Is the solid surface representation built?

◆ surface_inside()

uint32_t Geometry::surface_inside ( const Vec3D x) const

Finds if point is inside surface triangulation.

Returns 0 if point x is in 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. Uses solid mesh and surface triangulation data.

The surface triangulation does not separate solids which are touching (no vacuum node in between). Therefore in these cases this function can not separate these solids with accuracy higher than one grid cell. The vacuum to solid separation always has the maximum resolution.

◆ surface_normal()

Vec3D Geometry::surface_normal ( const Vec3D x) const

Find surface outward normal at location x.

Returns zero vector on failure. Uses solid data. The location x should be within 1 mesh unit of a surface.

◆ surface_triangle()

const VTriangle& Geometry::surface_triangle ( int32_t  a) const
inline

Return reference to surface triangle a.

◆ surface_triangle_normal() [1/2]

Vec3D Geometry::surface_triangle_normal ( const Vec3D x) const

Return normal of surface triangle near point x.

Uses surface triangulation, returns NaN if surface not found.

◆ surface_triangle_normal() [2/2]

Vec3D Geometry::surface_triangle_normal ( int32_t  a) const

Return normal of surface triangle a.

◆ surface_triangle_ptr()

uint32_t Geometry::surface_triangle_ptr ( int32_t  i,
int32_t  j,
int32_t  k 
) const
inline

Return index of first surface triangle at mesh cube (i,j,k).

◆ surface_trianglec() [1/2]

int32_t Geometry::surface_trianglec ( int32_t  i,
int32_t  j,
int32_t  k 
) const

Return surface triangle count at mesh cube (i,j,k).

◆ surface_trianglec() [2/2]

uint32_t Geometry::surface_trianglec ( void  ) const
inline

Return total surface triangle count.

◆ surface_vertex()

const Vec3D& Geometry::surface_vertex ( int32_t  a) const
inline

Return reference to surface vertex a.

◆ surface_vertexc()

uint32_t Geometry::surface_vertexc ( void  ) const
inline

Return total surface vertex count.


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.