# 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.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.

Example

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
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(elements)

A data structure for orientable 2-manifolds based on half-edges constructed from a list of polygon elements.

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

See also TopologicalStructure.

References

Notes

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.

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)