Meshes

Overview

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

Meshes.MeshType
Mesh{Dim,T}

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

source
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(start, finish, dims=dims)

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

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 locations:

julia> CartesianGrid(100,100,50)

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

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

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

julia> CartesianGrid((-1.,),(1.,), dims=(100,))
source
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].

source

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.

source
Meshes.connectFunction
connect(indices, PL)

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

Example

Δ = connect((1,2,3), Triangle)
source
Meshes.materializeFunction
materialize(connec, points)

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

source

Topological structures

Meshes.FullStructureType
FullStructure(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.

source
Meshes.HalfEdgeStructureType
HalfEdgeStructure(halfedges, edgeonelem, edgeonvertex)

A data structure for orientable 2-manifolds based on half-edges.

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 vector of edgeonelem and a vector of edgeonvertex can be used to retrieve topolological relations in optimal time. In this case, edgeonvertex[i] returns the index of the half-edge in halfedges with head equal to i. Similarly, edgeonelem[i] returns the index of a half-edge in halfedges that is in the elem i.

Such data structure is usually constructed from another data structure such as ElementListStructure via convert methods:

he = convert(HalfEdgeStructure, structure)

See also TopologicalStructure.

References

source

Examples

using Meshes

# 3D Cartesian grid
grid = CartesianGrid(10, 10, 10)
10×10×10 CartesianGrid{3,Float64}
  minimum: Point(0.0, 0.0, 0.0)
  maximum: Point(10.0, 10.0, 10.0)
  spacing: (1.0, 1.0, 1.0)
using Plots

plot(grid)
# 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)
4-element Vector{Connectivity}:
 Quadrangle(1, 2, 6, 5)
 Triangle(2, 4, 6)
 Quadrangle(4, 3, 5, 6)
 Triangle(3, 1, 5)
# 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)
plot(mesh)