Mesh#
Tetrahedral mesh representation for finite element simulation
This module provides the TetrahedralMesh class, which represents volumetric geometry using tetrahedral elements. The mesh stores vertex positions and element connectivity, and computes the deformation gradient for each element during simulation.
The deformation gradient \(\mathbf{F}\) maps from the reference (rest) configuration to the current (deformed) configuration:
where \(\mathbf{D}_s\) contains edge vectors in the current configuration and \(\mathbf{D}_m\) contains edge vectors in the rest configuration.
- class diffsim.mesh.TetrahedralMesh(vertices, tetrahedra, device='cpu')[source]#
Bases:
objectTetrahedral mesh for finite element simulation
This class represents a volumetric mesh using tetrahedral elements. Each tetrahedron is defined by four vertices, and the mesh computes quantities needed for FEM simulation such as the deformation gradient, element volumes, and shape matrices.
The mesh automatically computes and caches rest-state quantities when initialized:
\(\mathbf{D}_m\): Rest shape matrix for each element (3×3)
\(\mathbf{D}_m^{-1}\): Inverse rest shape matrix
\(V_0\): Rest volume for each element
- vertices#
Vertex positions \((N \times 3)\)
- Type:
- tetrahedra#
Element connectivity \((M \times 4)\) indices
- Type:
- Dm#
Rest shape matrices \((M \times 3 \times 3)\)
- Type:
- Dm_inv#
Inverse rest shape matrices \((M \times 3 \times 3)\)
- Type:
- rest_volume#
Rest volumes \((M,)\)
- Type:
- device#
Device where tensors are stored
- Type:
- __init__(vertices, tetrahedra, device='cpu')[source]#
Initialize tetrahedral mesh
- Parameters:
vertices – \((N, 3)\) array of vertex positions
tetrahedra – \((M, 4)\) array of tetrahedron indices
device – ‘cpu’ or ‘cuda’