DistMesh.jl
DistMesh.jl implements simplex refinement on signed distance functions, or anything that has a sign, distance, and called like a function. The algorithm was first presented in 2004 by Per-Olof Persson, and was initially a port of the corresponding Matlab Code.
What is Simplex Refinement?
In layman's terms, a simplex is either a triangle in the 2D case, or a tetrahedra in the 3D case.
When simulating, you other want a few things from a mesh of simplices: - Accurate approximation of boundaries and features - Adaptive mesh sizes to improve accuracy - Near-Regular Simplicies
DistMesh is designed to address the above.
Algorithm Overview
The basic processes is as follows:
Comparison to other refinements
DistMesh generally has a very low memory footprint, and can refine without additional memory allocation. Similarly, since the global state of simplex qualities is accounted for in each refinement iteration, this leads to very high quality meshes.
Aside from the above, since DistMesh works on signed distance functions it can handle complex and varied input data that are not in the form of surface meshes (Piecewise Linear Complicies).
Difference from the MatLab implementation
Given the same parameters, the Julia implementation of DistMesh will generally perform 4-60 times faster than the MatLab implementation. Delaunay Triangulation in MatLab uses QHull, whereas DistMesh.jl uses TetGen.
How do I get a Signed Distance Function?
Here are some libraries that turn gridded and level set data into an approximate signed distance function:
- Interpolations.jl
- AdaptiveDistanceFields.jl
DistMesh.DistMeshQuality
DistMesh.DistMeshResult
DistMesh.DistMeshSetup
DistMesh.DistMeshStatistics
DistMesh.HUniform
DistMesh.dihedral_angles
DistMesh.distmesh
DistMesh.hilbertsort!
DistMesh.min_dihedral_angles
DistMesh.retriangulate!
DistMesh.tet_to_edges!
DistMesh.tets_to_tris!
DistMesh.triqual
DistMesh.volume_edge_extrema
DistMesh.volume_edge_ratio
DistMesh.volume_edge_stats
DistMesh.DistMeshQuality
— TypeDistMeshQuality
Use Tetrahedral quality analysis to control the meshing process
iso (default: 0): Value of which to extract the iso surface, inside negative
deltat (default: 0.1): the fraction of edge displacement to apply each iteration
DistMesh.DistMeshResult
— TypeDistMeshResult
A struct returned from the distmesh
function that includes point, simplex, and interation statistics.
DistMesh.DistMeshSetup
— TypeDistMeshSetup
Takes Keyword arguments as follows:
iso (default: 0): Value of which to extract the isosurface, inside surface is negative
deltat (default: 0.1): the fraction of edge displacement to apply each iteration
sort (default:false): If true and no fixed points, sort points using a hilbert sort.
sort_interval (default:20) Use hilbert sort after the specified retriangulations
distribution (default: :regular) Initial point distribution, either :regular or :packed.
DistMesh.DistMeshStatistics
— TypeDistMeshStatistics
Statistics about the convergence between iterations
DistMesh.HUniform
— TypeUniform edge length function.
DistMesh.dihedral_angles
— MethodCompute dihedral angles within a tetrahedra
radians
DistMesh.distmesh
— Methoddistmesh
3D Mesh Generator using Signed Distance Functions.
Arguments:
fdist: Distance function
fh: Edge length function
h: Smallest edge length
Returns:
p: Node positions
t: Triangle indices
Example: Unit ball
d(p) = sqrt(sum(p.^2))-1
p,t = distmeshnd(d,huniform,0.2)
DistMesh.hilbertsort!
— FunctionHilbert Sorting. If carry
is specified, this array will be permuted in line with the specified array.
DistMesh.min_dihedral_angles
— MethodCompute the minimum dihedral angle within a tetrahedra
radians
DistMesh.retriangulate!
— Methodretriangulate!
Given a point set, generate a delaunay triangulation, and other requirements. This includes: - Spatial sorting of points - Delaunay triangulation - Filtering of invalid tetrahedra outside the boundary
DistMesh.tet_to_edges!
— MethodDecompose tets to edges, using a pre-allocated array and set.
Set ensures uniqueness, and result will be sorted.
DistMesh.tets_to_tris!
— Methodconvert tets to tris, returned sorted and unique
DistMesh.triqual
— MethodDetermine the quality of a triangle given 3 points.
Points must be 3D.
DistMesh.volume_edge_extrema
— Methodreturns the extrema elements (min, max) of the sampled qualities
DistMesh.volume_edge_ratio
— MethodComputes the volume and edge-length ratio from four given points
DistMesh.volume_edge_stats
— Methodreturns the (min, avg, max) of the sampled qualities