Working with voxel images

Meshing and remeshing


Retrieve the current mesh data.

The three arrays returned are:

  • t = array of tetrahedral connectivities, one row per element,
  • v = array of coordinates of the nodes, one row per vertex,
  • tmid = array of material identifiers, one per element.

Perform a meshing step.

If no mesh exists, the initial mesh is created; otherwise a coarsening sequence of coarsen surface -> smooth -> coarsen volume -> smooth is performed. The current element size (self.currentelementsize) is used. So don't forget to update the current elements size for the next iteration of the re-meshing algorithm.

After meshing the vertices, tetrahedra, and material identifiers, can be retrieved as self.v, self.t, and self.tmid.

coarsen(t::Array{Int, 2}, inputv::Array{Float64, 2}, tmid::Vector{Int}; bv::Vector{Bool} = Bool[], desired_ts::Number = 0.0, stretch::Number = 1.25, nblayer::Int = 1, surface_coarsening::Bool = false, preserve_thin::Bool = false, vertex_weight::Vector{Float64} = Float64[], reportprogress::F = n -> nothing) where {F<:Function}

Coarsen a T4 (tetrahedral) mesh.


  • t = array with vertex numbers, one per tetrahedron in each row
  • v = array of vertex coordinates, one per vertex in each row
  • tmid = tetrahedron material identifiers, one per tetrahedron in each row
  • Keyword arguments:
    • bv=array for all vertices in the input array v. Is the vertex on the boundary? True or false. The boundary vertices are in layer 1. The vertex layer numbers increase away from the boundary, and the bigger the vertex layer number the bigger the mesh size.
    • desired_ts=mesh size desired for vertices in layer 1, here mesh size is the length of an edge
    • stretch=the mesh size should increase by this much within one layer of elements, default is 1.25
    • nblayer=number of boundary layers where the mesh size should not increase, default is 1
    • surface_coarsening = is the coarsening intended for the interior or for the surface? default is false, which means the default is coarsening of the interior.
    • preserve_thin= when coarsening the surface, should features which are thin be unaffected by the coarsening? Here thin means consisting of only "surface" vertices.
    • vertex_weight= weight of vertices, one per vertex; weight <= 1.0 is ignored, but weight>1.0 is used to "stretch" edges connected to the vertex. In this way one may preserve certain edges by assigning larger weight to their vertices. Default is vertex_weight= [] (which means ignore the vertex weights)


t, v, tmid = new arrays for the coarsened grid