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
— Functiongenerate_mesh(mp::GeometryBasics.MultiPoint, buffer_width::Real,
interior_mesh_size::Real;
exterior_mesh_size::Real = 2 * interior_mesh_size,
element_order::Int = 1, save_path=nothing)
Generate a mesh for a spatial point cloud, with a buffer to counteract boundary effects from the SPDE discretization.
Input
mp
– MultiPoint objectbuffer_width
– Width of the buffer around the convex hullinterior_mesh_size
– Mesh size inside the convex hullexterior_mesh_size
– Mesh size outside the convex hullelement_order
– Order of the element basis functionssave_path
– Optional path to save the mesh
Output
A Ferrite.Grid
object
Algorithm
- Create the convex hull of the point cloud via LibGEOS
- Create the buffer around the convex hull
- Create a mesh for the buffered polygon using Gmsh
- Transfer the Gmsh information to Ferrite
generate_mesh(points, buffer_width::Real, interior_mesh_size::Real;
exterior_mesh_size::Real=2 * interior_mesh_size,
element_order::Int=1, save_path=nothing)
Generate a mesh from a list of points using Gmsh.
Input
points
– List of pointsbuffer_width
– Width of the buffer around the convex hullinterior_mesh_size
– Mesh size inside the convex hullexterior_mesh_size
– Mesh size outside the convex hullelement_order
– Order of the elementssave_path
– Path to save the mesh
Output
A Ferrite.Grid object
GaussianMarkovRandomFields.create_inflated_rectangle
— Functioncreate_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