OOFEM 3.0
Loading...
Searching...
No Matches
VoxelGrid Class Reference

A class to represent a 3D grid of voxels. More...

#include <VoxelGrid.h>

Public Member Functions

 VoxelGrid (std::array< double, 3 > steps, std::array< int, 3 > sizes)
 Constructor for VoxelGrid.
std::array< int, 3 > sizes ()
 Get the number of steps in each dimension.
std::array< double, 3 > steps ()
 Get the step sizes in each dimension.
int get_index (int i, int j, int k)
 Get the 1D index of a voxel in the grid.
std::tuple< int, int, int > get_indices (int i)
 Get the 3D indices of a voxel from its 1D index.
std::tuple< int, int, int > get_indices_from_point (std::array< double, 3 > point)
 Get the 3D indices of a voxel from a point in space.
std::array< double, 3 > get_vector_3d (int i)
 Get the 3D vector of a voxel (origin) from its 1D index.
std::array< int, 8 > giveVoxelNodeIds (int index)
void activateNodes (int index, double timeActivated)
VoxelcreateVoxel (int index, double timeActivated)
 Create a Vovel at given index and at given time.
Voxelactivate (int index, double timeActivated, double vofIncrement)
 Activate a voxel at a given index in a given time and store the corresponding vof value.
bool is_active (int index)
 Check if a voxel at a given index is active.
bool is_active_node (int index)
 Check if a node at a given index is active.
int active_elements ()
 Get the number of active elements (voxels) in the grid.
int active_nodes ()
 Get the number of active nodes in the grid.
int size ()
 Get the size of the grid.
Voxelget_voxel (int index)
 Get the voxel at a given index.
VoxelNodeget_node (int index)
 Get the node at a given index.
std::unordered_map< int, Voxel > & giveVoxels ()
 Get the map of nodes in the grid.
std::unordered_map< int, VoxelNode > & giveNodes ()
 Get the map of nodes in the grid.
Model get_model (int index)
 Get the triangulated model of a voxel at a given index.
void writeVTK (std::string filename)

Private Attributes

std::unordered_map< int, Voxelm_voxels
std::unordered_map< int, VoxelNodem_nodes
std::array< double, 3 > m_steps
std::array< int, 3 > m_sizes

Detailed Description

A class to represent a 3D grid of voxels.

Definition at line 64 of file VoxelGrid.h.

Constructor & Destructor Documentation

◆ VoxelGrid()

VoxelGrid::VoxelGrid ( std::array< double, 3 > steps,
std::array< int, 3 > sizes )
inline

Constructor for VoxelGrid.

Parameters
stepsThe step sizes in each dimension.
sizesThe sizes of the grid in each dimension.

Definition at line 72 of file VoxelGrid.h.

References m_sizes, m_steps, sizes(), and steps().

Member Function Documentation

◆ activate()

Voxel & VoxelGrid::activate ( int index,
double timeActivated,
double vofIncrement )
inline

Activate a voxel at a given index in a given time and store the corresponding vof value.

Parameters
indexThe index of the voxel.
timeActivatedThe time the voxel was activated.
vofIncrementThe volume of fluid increment (new material volume [0-1]) in the voxel.

Definition at line 217 of file VoxelGrid.h.

References createVoxel(), get_index(), get_indices(), m_sizes, and m_voxels.

◆ activateNodes()

void VoxelGrid::activateNodes ( int index,
double timeActivated )
inline

Definition at line 164 of file VoxelGrid.h.

References get_vector_3d(), giveVoxelNodeIds(), is_active_node(), and m_nodes.

Referenced by createVoxel().

◆ active_elements()

int VoxelGrid::active_elements ( )
inline

Get the number of active elements (voxels) in the grid.

Returns
The number of active elements.

Definition at line 314 of file VoxelGrid.h.

References m_voxels.

◆ active_nodes()

int VoxelGrid::active_nodes ( )
inline

Get the number of active nodes in the grid.

Returns
The number of active nodes.

Definition at line 323 of file VoxelGrid.h.

References m_nodes.

◆ createVoxel()

Voxel & VoxelGrid::createVoxel ( int index,
double timeActivated )
inline

Create a Vovel at given index and at given time.

Parameters
indexThe index of the voxel to activate.
timeActivatedThe time the voxel was activated.

Definition at line 186 of file VoxelGrid.h.

References activateNodes(), giveVoxelNodeIds(), is_active(), m_nodes, and m_voxels.

Referenced by activate().

◆ get_index()

int VoxelGrid::get_index ( int i,
int j,
int k )
inline

Get the 1D index of a voxel in the grid.

Parameters
iThe x-coordinate of the voxel.
jThe y-coordinate of the voxel.
kThe z-coordinate of the voxel.
Returns
The 1D index of the voxel.

Definition at line 102 of file VoxelGrid.h.

References m_sizes.

Referenced by activate(), and giveVoxelNodeIds().

◆ get_indices()

std::tuple< int, int, int > VoxelGrid::get_indices ( int i)
inline

Get the 3D indices of a voxel from its 1D index.

Parameters
iThe 1D index of the voxel.
Returns
A tuple containing the x, y, and z indices of the voxel.

Definition at line 112 of file VoxelGrid.h.

References m_sizes.

Referenced by activate(), get_vector_3d(), and giveVoxelNodeIds().

◆ get_indices_from_point()

std::tuple< int, int, int > VoxelGrid::get_indices_from_point ( std::array< double, 3 > point)
inline

Get the 3D indices of a voxel from a point in space.

Parameters
pointAn array containing the x, y, and z coordinates of the point.
Returns
A tuple containing the x, y, and z indices of the voxel.

Definition at line 126 of file VoxelGrid.h.

References m_steps.

◆ get_model()

Model VoxelGrid::get_model ( int index)
inline

Get the triangulated model of a voxel at a given index.

Parameters
indexThe index of the voxel.
Returns
The model of the voxel at the given index.

Definition at line 380 of file VoxelGrid.h.

References get_vector_3d(), m_steps, and modelfrompolygons().

Referenced by Printer::handleG1Command().

◆ get_node()

VoxelNode & VoxelGrid::get_node ( int index)
inline

Get the node at a given index.

Parameters
indexThe index of the node.
Returns
The node at the given index.

Definition at line 352 of file VoxelGrid.h.

References m_nodes.

◆ get_vector_3d()

std::array< double, 3 > VoxelGrid::get_vector_3d ( int i)
inline

Get the 3D vector of a voxel (origin) from its 1D index.

Parameters
iThe 1D index of the voxel.
Returns
An array containing the x, y, and z coordinates of the voxel.

Definition at line 140 of file VoxelGrid.h.

References get_indices(), and m_steps.

Referenced by activateNodes(), get_model(), and writeVTK().

◆ get_voxel()

Voxel & VoxelGrid::get_voxel ( int index)
inline

Get the voxel at a given index.

Parameters
indexThe index of the voxel.
Returns
The voxel at the given index.

Definition at line 342 of file VoxelGrid.h.

References m_voxels.

◆ giveNodes()

std::unordered_map< int, VoxelNode > & VoxelGrid::giveNodes ( )
inline

Get the map of nodes in the grid.

Returns
The map of nodes in the grid.

Definition at line 370 of file VoxelGrid.h.

References m_nodes.

◆ giveVoxelNodeIds()

std::array< int, 8 > VoxelGrid::giveVoxelNodeIds ( int index)
inline

Definition at line 146 of file VoxelGrid.h.

References get_index(), and get_indices().

Referenced by activateNodes(), and createVoxel().

◆ giveVoxels()

std::unordered_map< int, Voxel > & VoxelGrid::giveVoxels ( )
inline

Get the map of nodes in the grid.

Returns
The map of nodes in the grid.

Definition at line 361 of file VoxelGrid.h.

References m_voxels.

◆ is_active()

bool VoxelGrid::is_active ( int index)
inline

Check if a voxel at a given index is active.

Parameters
indexThe index of the voxel.
Returns
True if the voxel is active, false otherwise.

Definition at line 295 of file VoxelGrid.h.

References m_voxels.

Referenced by createVoxel().

◆ is_active_node()

bool VoxelGrid::is_active_node ( int index)
inline

Check if a node at a given index is active.

Parameters
indexThe index of the node.
Returns
True if the node is active, false otherwise.

Definition at line 305 of file VoxelGrid.h.

References m_nodes.

Referenced by activateNodes().

◆ size()

int VoxelGrid::size ( )
inline

Get the size of the grid.

Returns
The size of the grid.

Definition at line 332 of file VoxelGrid.h.

References m_sizes.

◆ sizes()

std::array< int, 3 > VoxelGrid::sizes ( )
inline

Get the number of steps in each dimension.

Returns
The number of steps in each dimension.

Definition at line 81 of file VoxelGrid.h.

References m_sizes.

Referenced by VoxelGrid().

◆ steps()

std::array< double, 3 > VoxelGrid::steps ( )
inline

Get the step sizes in each dimension.

Returns
The step sizes in each dimension.

Definition at line 90 of file VoxelGrid.h.

References m_steps.

Referenced by VoxelGrid().

◆ writeVTK()

void VoxelGrid::writeVTK ( std::string filename)
inline

Definition at line 410 of file VoxelGrid.h.

References get_vector_3d(), m_steps, and m_voxels.

Member Data Documentation

◆ m_nodes

std::unordered_map<int, VoxelNode> VoxelGrid::m_nodes
private

The map of nodes in the grid.

Definition at line 461 of file VoxelGrid.h.

Referenced by activateNodes(), active_nodes(), createVoxel(), get_node(), giveNodes(), and is_active_node().

◆ m_sizes

std::array<int, 3> VoxelGrid::m_sizes
private

The sizes of the grid in each dimension.

Definition at line 464 of file VoxelGrid.h.

Referenced by activate(), get_index(), get_indices(), size(), sizes(), and VoxelGrid().

◆ m_steps

std::array<double, 3> VoxelGrid::m_steps
private

The step sizes in each dimension.

Definition at line 463 of file VoxelGrid.h.

Referenced by get_indices_from_point(), get_model(), get_vector_3d(), steps(), VoxelGrid(), and writeVTK().

◆ m_voxels

std::unordered_map<int, Voxel> VoxelGrid::m_voxels
private

The map of voxels in the grid.

Definition at line 460 of file VoxelGrid.h.

Referenced by activate(), active_elements(), createVoxel(), get_voxel(), giveVoxels(), is_active(), and writeVTK().


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

This page is part of the OOFEM-3.0 documentation. Copyright Copyright (C) 1994-2025 Borek Patzak Bořek Patzák
Project e-mail: oofem@fsv.cvut.cz
Generated at for OOFEM by doxygen 1.15.0 written by Dimitri van Heesch, © 1997-2011