Skip to content

Meshes

Finite element method discretizations of SPDEs require a mesh. GaussianMarkovRandomFields provides some utility functions to create meshes for common use cases.

For a hands-on example meshing a 2D point cloud, check out the tutorial Spatial Modelling with SPDEs.

GaussianMarkovRandomFields.generate_mesh Function
julia
generate_mesh(points; element_order::Int=1, save_path=nothing)

Generate a Ferrite.Grid from a list of points using Gmsh.

points is an AbstractVector of point-like objects (tuples, vectors, or anything iterable yielding 1 or 2 real numbers), or an AbstractMatrix where each row is a point. The spatial dimension is inferred from the length of the first point.

For 2D point clouds the algorithm is: 2. Build the convex hull and an inflated buffer polygon (LibGEOS).

  1. Triangulate the buffered region with Gmsh, embedding the interior points as constrained vertices.

  2. Transfer the Gmsh mesh into a Ferrite.Grid (via FerriteGmsh).

For 1D point clouds the analogous bracketed line segment is meshed.

Keyword arguments

  • element_order: order of the FEM elements (default: 1).

  • save_path: optional path to save the Gmsh .msh file.

source
GaussianMarkovRandomFields.create_inflated_rectangle Function
julia
create_inflated_rectangle(x0, y0, dx, dy, boundary_width, interior_mesh_size,
exterior_mesh_size = 2 * interior_mesh_size; element_order = 1)

Create a triangular FEM discretization of a rectangle with an inflated boundary. Useful for FEM discretizations of SPDEs, where the domain is often artificially inflated to avoid undesirable boundary effects. Mesh has physical groups "Domain", "Interior", "Interior boundary" and possibly "Exterior boundary".

Arguments

  • x0::Real: x-coordinate of the bottom-left corner of the rectangle

  • y0::Real: y-coordinate of the bottom-left corner of the rectangle

  • dx::Real: Width of the rectangle

  • dy::Real: Height of the rectangle

  • boundary_width::Real: Width of the inflated boundary. If 0.0, mesh will not be inflated at all.

  • interior_mesh_size::Real: Mesh size in the interior of the rectangle

  • exterior_mesh_size::Real: Mesh size in the exterior of the rectangle

  • element_order::Int: Order of the FEM elements

Returns

  • grid::Ferrite.Grid: the FEM discretization of the rectangle

  • boundary_tags::Vector{Int}: the indices of the boundary nodes

source