Meshes

Meshes can be constructed directly (e.g. CartesianGrid) or based on other constructs such as connectivity lists and topological structures (e.g. SimpleMesh).

Overview

Meshes.MeshType
Mesh{Dim,T}

A mesh embedded in a Dim-dimensional space with coordinates of type T.

Meshes.CartesianGridType
CartesianGrid(dims, origin, spacing)

A Cartesian grid with dimensions dims, lower left corner at origin and cell spacing spacing. The three arguments must have the same length.

CartesianGrid(dims, origin, spacing, offset)

A Cartesian grid with dimensions dims, with lower left corner of element offset at origin and cell spacing spacing.

CartesianGrid(start, finish, dims=dims)

Alternatively, construct a Cartesian grid from a start point (lower left) to a finish point (upper right).

CartesianGrid(start, finish, spacing)

Alternatively, construct a Cartesian grid from a start point to a finish point using a given spacing.

CartesianGrid(dims)
CartesianGrid(dim1, dim2, ...)

Finally, a Cartesian grid can be constructed by only passing the dimensions dims as a tuple, or by passing each dimension dim1, dim2, ... separately. In this case, the origin and spacing default to (0,0,...) and (1,1,...).

Examples

Create a 3D grid with 100x100x50 hexahedrons:

julia> CartesianGrid(100,100,50)

Create a 2D grid with 100x100 quadrangles and origin at (10.,20.) units:

julia> CartesianGrid((100,100),(10.,20.),(1.,1.))

Create a 1D grid from -1 to 1 with 100 segments:

julia> CartesianGrid((-1.,),(1.,), dims=(100,))
# 3D Cartesian grid
grid = CartesianGrid(10, 10, 10)

viz(grid, showfacets = true)
Meshes.SimpleMeshType
SimpleMesh(points, connec)

A simple mesh with points and connectivities connec. The i-th face of the mesh is lazily built based on the connectivity list connec[i].

SimpleMesh(points, topology)

Alternatively, construct a simple mesh with points and a topological data structure (e.g. HalfEdgeTopology).

See also Topology.

Notes

  • Connectivities must be given with coherent orientation, i.e. all faces must be counter-clockwise (CCW) or clockwise (CW).
# global vector of 2D points
points = Point2[(0,0),(1,0),(0,1),(1,1),(0.25,0.5),(0.75,0.5)]

# connect the points into N-gon
connec = connect.([(1,2,6,5),(2,4,6),(4,3,5,6),(3,1,5)], Ngon)

# 2D mesh made of N-gon elements
mesh = SimpleMesh(points, connec)

viz(mesh, showfacets = true)

Connectivities

Meshes.ConnectivityType
Connectivity{PL,N}

A connectivity list of N indices representing a Polytope of type PL. Indices are taken from a global vector of Point.

Connectivity objects are constructed with the connect function.

Meshes.connectFunction
connect(indices, [PL])

Connect a list of indices from a global vector of Point into a Polytope of type PL.

The type PL can be a Ngon in which case the length of the indices is used to identify the actual N-gon type (e.g. Triangle).

Finally, the type PL can be ommitted. In this case, the indices are assumed to be connected as a Ngon or as a Segment.

Examples

Connect indices into a Triangle:

connect((1,2,3), Triangle)

Connect indices into N-gons, a Triangle and a Quadrangle:

connect.([(1,2,3), (2,3,4,5)], Ngon)

Connect indices into N-gon or segment:

connect((1,2)) # Segment
connect((1,2,3)) # Triangle
connect((1,2,3,4)) # Quadrangle
Meshes.materializeFunction
materialize(connec, points)

Materialize a face using the connec list and a global vector of points.

Topology

Meshes.FullTopologyType
FullTopology(connectivities)

A data structure that stores all connectivities of a mesh.

Notes

This data structure is sometimes referred to as the "soup of geometries". It does not support topological relations and is therefore incompatible with algorithms that rely on neighborhood search. It is still useful for mesh visualization and IO operations.

Meshes.GridTopologyType
GridTopology(dims)

A data structure for grid topologies with dims elements.

Meshes.HalfEdgeTopologyType
HalfEdgeTopology(elements)
HalfEdgeTopology(halfedges)

A data structure for orientable 2-manifolds based on half-edges constructed from a vector of connectivity elements or from a vector of pairs of halfedges.

Examples

Construct half-edge topology from a list of top-faces:

elements = connect.([(1,2,3),(3,2,4,5)])
topology = HalfEdgeTopology(elements)

See also Topology.

References

Notes

  • Two types of half-edges exist (Kettner 1999). This implementation is the most common type that splits the incident elements.

  • A vector of halfedges together with a dictionary of half4elem and a dictionary of half4vert can be used to retrieve topolological relations in optimal time. In this case, half4vert[i] returns the index of the half-edge in halfedges with head equal to i. Similarly, half4elem[i] returns the index of a half-edge in halfedges that is in the element i. Additionally, a dictionary edge4pair returns the index of the edge (i.e. two halves) for a given pair of vertices.

Relations

Meshes.TopologicalRelationType
TopologicalRelation

A topological relation between faces of a Mesh implemented for a given Topology.

An object implementing this trait is a functor that can be evaluated at an integer index representing the face.

Examples

# create boundary relation mapping
# 2-faces to 0-faces (i.e. vertices)
∂ = Boundary{2,0}(topology)

# list of vertices for first face
∂(1)

References

Meshes.BoundaryType
Boundary{P,Q}(topology)

The boundary relation from rank P to smaller rank Q for a given topology.

Meshes.CoboundaryType
Coboundary{P,Q}(topology)

The co-boundary relation from rank P to greater rank Q for a given topology.

Meshes.AdjacencyType
Adjacency{P}(topology)

The adjacency relation of rank P for a given topology.

Examples

# global vector of 2D points
points = Point2[(0,0),(1,0),(0,1),(1,1),(0.25,0.5),(0.75,0.5)]

# connect the points into N-gon
connec = connect.([(1,2,6,5),(2,4,6),(4,3,5,6),(3,1,5)], Ngon)

# 2D mesh made of N-gon elements
mesh = SimpleMesh(points, connec)
4 SimpleMesh{2,Float64}
  6 vertices
    └─Point(0.0, 0.0)
    └─Point(1.0, 0.0)
    └─Point(0.0, 1.0)
    └─Point(1.0, 1.0)
    └─Point(0.25, 0.5)
    └─Point(0.75, 0.5)
  4 elements
    └─Quadrangle(1, 2, 6, 5)
    └─Triangle(2, 4, 6)
    └─Quadrangle(4, 3, 5, 6)
    └─Triangle(3, 1, 5)
# convert topology to half-edge topology
topo = convert(HalfEdgeTopology, topology(mesh))

# boundary relation from faces (dim=2) to edges (dim=1)
∂₂₁ = Boundary{2,1}(topo)

# show boundary of first n-gon
∂₂₁(1)
4-element Vector{Int64}:
 1
 3
 5
 6
# co-boundary relation from edges (dim=1) to faces(dim=2)
𝒞₁₂ = Coboundary{1,2}(topo)

# show n-gons that share edge 3
𝒞₁₂(3)
2-element Vector{Int64}:
 2
 1