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
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).
Triangulate the buffered region with Gmsh, embedding the interior points as constrained vertices.
Transfer the Gmsh mesh into a
Ferrite.Grid(viaFerriteGmsh).
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.mshfile.
GaussianMarkovRandomFields.create_inflated_rectangle Function
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 rectangley0::Real: y-coordinate of the bottom-left corner of the rectangledx::Real: Width of the rectangledy::Real: Height of the rectangleboundary_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 rectangleexterior_mesh_size::Real: Mesh size in the exterior of the rectangleelement_order::Int: Order of the FEM elements
Returns
grid::Ferrite.Grid: the FEM discretization of the rectangleboundary_tags::Vector{Int}: the indices of the boundary nodes