Computes the finite element mass (C) and stiffness (G) matrices from a triangular mesh, plus the projection matrix (A) that maps mesh vertices to observation locations.
Arguments
- mesh
A
tulpa_meshobject.- obs_coords
Observation coordinates (N x 2 matrix). If NULL, the projection matrix A is the identity (observations at mesh nodes).
- barrier
Optional logical vector of length
n_triangles. Triangles markedTRUEare treated as physical barriers (coastlines, rivers): their stiffness contributions are zeroed so the spatial field cannot smooth across them. Based on Bakka et al. (2019).- parallel
Logical. If
TRUE, uses parallel FEM assembly via RcppParallel (thread-local triplet accumulation). Beneficial for meshes with >50K triangles. DefaultFALSE.- lumped
Logical. If
TRUE, returns a diagonal lumped mass matrix C0 (vertex areas) in addition to the consistent mass matrix C. The lumped mass inverse is trivial and needed for the SPDE Q-builder. DefaultFALSE.
Value
A list with sparse matrices (dgCMatrix class from Matrix package):
C: consistent mass matrix (n_vertices x n_vertices)G: stiffness matrix (n_vertices x n_vertices)A: projection matrix (n_obs x n_vertices)n_mesh: number of mesh verticesC0: (only iflumped = TRUE) diagonal lumped mass matrixva: (only iflumped = TRUE) vertex areas (numeric vector)ta: (only iflumped = TRUE) triangle areas (numeric vector)