lapy.TetMesh¶
- class lapy.TetMesh(v, t)¶
Class representing a tetraheral mesh.
This is an efficient implementation of a tetrahedral mesh data structure with core functionality using sparse matrices internally (Scipy).
- Parameters:
- varray_like
List of lists of 3 float coordinates.
- tarray_like
List of lists of 4 int of indices (>=0) into
v
array. Ordering is important: so that t0, t1, t2 are oriented counterclockwise when looking from above, and t3 is on top of that triangle.
Methods
Get average edge lengths in tet mesh.
boundary_tria
([tetfunc])Get boundary triangle mesh of tetrahedra.
Create adjacency symmetric matrix.
Check if the vertex list has more vertices than what is used in tetra.
Check if tet mesh is oriented.
orient_
()Ensure that tet mesh is oriented.
read_gmsh
(filename)Load GMSH tetrahedron mesh.
read_vtk
(filename)Load VTK tetrahedron mesh.
Remove unused (free) vertices from v and t.
write_vtk
(filename)Save as VTK file.
Notes
The class has static class methods to read tetrahera meshes from GMSH and VTK files.
- boundary_tria(tetfunc=None)¶
Get boundary triangle mesh of tetrahedra.
It can have multiple connected components. Tria will have same vertices (including free vertices), so that the tria indices agree with the tet-mesh, in case we want to transfer information back, e.g. a FEM boundary condition, or to access a TetMesh vertex function with TriaMesh.t indices.
Warning
Note, that it seems to be returning non-oriented triangle meshes, may need some debugging, until then use tria.orient_() after this.
- construct_adj_sym()¶
Create adjacency symmetric matrix.
The adjacency matrix will be symmetric. Each inner edge will get the number of tetrahedra that contain this edge. Inner edges are usually 3 or larger, boundary, 2 or 1. Works on tetras only.
- Returns:
- adj
csc_matrix
Symmetric adjacency matrix as csc sparse matrix.
- adj
- has_free_vertices()¶
Check if the vertex list has more vertices than what is used in tetra.
(same implementation as in
TriaMesh
)- Returns:
bool
Whether vertex list has more vertices than tetra or not.
- is_oriented()¶
Check if tet mesh is oriented.
True if all tetrahedra are oriented so that v0,v1,v2 are oriented counterclockwise when looking from above, and v3 is on top of that triangle.
- Returns:
- oriented:
bool
True if
max(adj_directed)=1
.
- oriented:
- orient_()¶
Ensure that tet mesh is oriented.
Re-orient tetras so that v0,v1,v2 are oriented counterclockwise when looking from above, and v3 is on top of that triangle.
- Returns:
- onum
int
Number of re-oriented tetras.
- onum
- classmethod read_gmsh(filename)¶
Load GMSH tetrahedron mesh.
- classmethod read_vtk(filename)¶
Load VTK tetrahedron mesh.