Movatterモバイル変換


[0]ホーム

URL:


Type:Package
Title:Triangle Meshes and Related Geometry Tools
Version:0.6.1
Description:Generate planar and spherical triangle meshes, compute finite element calculations for 1-, 2-, and 3-dimensional flat and curved manifolds with associated basis function spaces, methods for lines and polygons, and transparent handling of coordinate reference systems and coordinate transformation, including 'sf' and 'sp' geometries. The core 'fmesher' library code was originally part of the 'INLA' package, and implements parts of "Triangulations and Applications" by Hjelle and Daehlen (2006) <doi:10.1007/3-540-33261-8>.
Depends:R (≥ 4.1.0), methods
Imports:dplyr, graphics, grDevices, lifecycle, Matrix, Rcpp, rlang,sf, splancs, stats, tibble, utils, withr
Suggests:geometry, ggplot2, knitr, patchwork, testthat (≥ 3.0.0),terra, tidyterra, rgl, rmarkdown, sp (≥ 1.6-1)
URL:https://inlabru-org.github.io/fmesher/,https://github.com/inlabru-org/fmesher
BugReports:https://github.com/inlabru-org/fmesher/issues
License:MPL-2.0
Copyright:2010-2025 Finn Lindgren, except src/predicates.cc byJonathan Richard Shewchuk, 1996
NeedsCompilation:yes
RoxygenNote:7.3.3
Encoding:UTF-8
Config/testthat/edition:3
Config/testthat/parallel:true
SystemRequirements:C++17
LinkingTo:Rcpp
VignetteBuilder:knitr
BuildVignettes:true
Collate:'RcppExports.R' 'deprecated.R' 'bary.R' 'basis.R' 'bbox.R''collect.R' 'components.R' 'print.R' 'crs.R' 'data-fmexample.R''diameter.R' 'evaluator.R' 'fem.R' 'fm.R' 'fmesher-package.R''fmesher.R' 'ggplot.R' 'integration.R' 'lattice_2d.R''lattice_Nd.R' 'list.R' 'local.R' 'manifold.R' 'mapping.R''matern.R' 'mesh.R' 'mesh_1d.R' 'mesh_2d.R' 'mesh_3d.R''mesh_assessment.R' 'nonconvex_hull.R' 'onload.R' 'plot.R''segm.R' 'sf_mesh.R' 'sf_utils.R' 'simplify.R' 'sp_mesh.R''split_lines.R' 'tensor.R' 'utils.R'
LazyData:true
Packaged:2025-12-11 23:30:01 UTC; flindgre
Author:Finn LindgrenORCID iD [aut, cre, cph] (Finn Lindgren wrote the main code), Seaton Andy [ctb] (Andy Seaton constributed features to the sf support), Suen Man Ho [ctb] (Man Ho Suen contributed features and code structure design for the integration methods), Fabian E. Bachl [ctb] (Fabian Bachl co-developed precursors of fm_pixels and fm_split_lines in inlabru)
Maintainer:Finn Lindgren <finn.lindgren@gmail.com>
Repository:CRAN
Date/Publication:2025-12-12 07:10:37 UTC

fmesher: Triangle Meshes and Related Geometry Tools

Description

Generate planar and spherical triangle meshes, compute finite element calculations for 1-, 2-, and 3-dimensional flat and curved manifolds with associated basis function spaces, methods for lines and polygons, and transparent handling of coordinate reference systems and coordinate transformation, including 'sf' and 'sp' geometries. The core 'fmesher' library code was originally part of the 'INLA' package, and implements parts of "Triangulations and Applications" by Hjelle and Daehlen (2006)doi:10.1007/3-540-33261-8.

Author(s)

Maintainer: Finn Lindgrenfinn.lindgren@gmail.com (ORCID) (Finn Lindgren wrote the main code) [copyright holder]

Other contributors:

See Also

Useful links:


Convert a 3D mesh to a 3D rgl triangulation

Description

Extracts a matrix of coordinates of triangles, suitable forpassing torgl::triangles3d().

Usage

as.triangles3d.fm_mesh_3d(obj, subset = NULL, ...)

Arguments

obj

Anfm_mesh_3d object

subset

Character string specifying which triangles to extract. Either"all" (default) or "boundary".

...

Currently unused

Value

A 3-column matrix of coordinates of triangles, suitable forpassing torgl::triangles3d().

Examples

# Protect against unavailable rgl device by only running interactivelyif (interactive() &&  requireNamespace("geometry", quietly = TRUE) &&  requireNamespace("rgl", quietly = TRUE)) {  (m <- fm_delaunay_3d(matrix(rnorm(30), 10, 3)))  rgl::open3d()  rgl::triangles3d(rgl::as.triangles3d(m, "boundary"), col = "blue")  rgl::axes3d()}

Call stack utility functions

Description

Helper functions for displaying call stack information

Usage

fm_caller_name(which = 0L, override = NULL)fm_call_stack(start = 0L, end = 0L, with_numbers = TRUE, ...)fm_try_callstack(expr)

Arguments

which

The number of frames to go back from the caller

override

character; Overrides the automated function name logic

start

The stack starting point

end

The stack end point

with_numbers

INclude call stack location numbers

...

Currently unused

expr

Anexpression to evaluate

Value

fm_caller_name returns a string with the the name of a callingfunction

fm_call_stack returns a character vector

fm_try_callstack If successful, returns (invisibly) the value fromthe evaluated expression, otherwise an error object with call stackinformation attached to the error message.

Functions

Examples

fun <- function() {  print(fm_caller_name())  nm <- fm_caller_name()  print(nm)}fun()

Create a coordinate reference system object

Description

Creates either a CRS object or an inla.CRS object, describing a coordinatereference system

Usage

fm_CRS(x, ..., units = NULL, oblique = NULL)## S3 method for class 'fm_CRS'is.na(x)## S3 method for class 'crs'fm_CRS(x, ..., units = NULL, oblique = NULL)## S3 method for class 'fm_crs'fm_CRS(x, ..., units = NULL, oblique = NULL)## S3 method for class 'Spatial'fm_CRS(x, ..., units = NULL, oblique = NULL)## S3 method for class 'fm_CRS'fm_CRS(x, ..., units = NULL, oblique = NULL)## S3 method for class 'SpatVector'fm_CRS(x, ..., units = NULL, oblique = NULL)## S3 method for class 'SpatRaster'fm_CRS(x, ..., units = NULL, oblique = NULL)## S3 method for class 'sf'fm_CRS(x, ..., units = NULL, oblique = NULL)## S3 method for class 'sfc'fm_CRS(x, ..., units = NULL, oblique = NULL)## S3 method for class 'sfg'fm_CRS(x, ..., units = NULL, oblique = NULL)## S3 method for class 'fm_mesh_2d'fm_CRS(x, ..., units = NULL, oblique = NULL)## S3 method for class 'fm_lattice'fm_CRS(x, ..., units = NULL, oblique = NULL)## S3 method for class 'fm_segm'fm_CRS(x, ..., units = NULL, oblique = NULL)## S3 method for class 'fm_collect'fm_CRS(x, ..., units = NULL, oblique = NULL)## S3 method for class 'matrix'fm_CRS(x, ..., units = NULL, oblique = NULL)## S3 method for class 'CRS'fm_CRS(x, ..., units = NULL, oblique = NULL)## Default S3 method:fm_CRS(  x,  oblique = NULL,  projargs = NULL,  doCheckCRSArgs = NULL,  args = NULL,  SRS_string = NULL,  ...,  units = NULL)## S3 method for class 'inla.CRS'is.na(x)## S3 method for class 'inla.CRS'fm_CRS(x, ..., units = NULL, oblique = NULL)

Arguments

x

Object to convert to CRS or to extract CRS information from.

...

Additional parameters, passed on to sub-methods.

units

character; if non-NULL,⁠fm_length_unit()<-⁠ is called to changethe length units of the crs object. IfNULL (default), the length unitsare not changed. (From version⁠0.3.0.9013⁠)

oblique

Vector of length at most 4 of rotation angles (in degrees)for an oblique projection, all values defaulting to zero. The valuesindicate (longitude, latitude, orientation, orbit), as explained in theDetails section forfm_crs().

projargs

Either 1) a projection argument string suitable as input tosp::CRS, or 2) an existingCRS object, or 3) a shortcutreference string to a predefined projection; runnames(fm_wkt_predef()) for valid predefined projections. (projargs is acompatibility parameter that can be used for the defaultfm_CRS() method)

doCheckCRSArgs

ignored.

args

An optional list of name/value pairs to add to and/or overridethe PROJ4 arguments inprojargs.name=value is converted to"+name=value", andname=NA is converted to"+name".

SRS_string

a WKT2 string defining the coordinate system;seesp::CRS. This takes precedence overprojargs.

Details

The first twoelements of theoblique vector are the (longitude, latitude)coordinates for the oblique centre point. The third value (orientation) is acounterclockwise rotation angle for an observer looking at the centre pointfrom outside the sphere. The fourth value is the quasi-longitude (orbitangle) for a rotation along the oblique observers equator.

Simple oblique:oblique=c(0, 45)

Polar:oblique=c(0, 90)

Quasi-transversal:oblique=c(0, 0, 90)

Satellite orbit viewpoint:oblique=c(lon0-time*v1, 0, orbitangle, orbit0+time*v2), wherelon0 is the longitude at which a satelliteorbit crosses the equator attime=0, when the satellite is at anangleorbit0 further along in its orbit. The orbital angle relativeto the equatorial plane isorbitangle, andv1 andv2are the angular velocities of the planet and the satellite, respectively.Note that "forward" from the satellite's point of view is "to the right" inthe projection.

Whenoblique[2] oroblique[3] are non-zero, the resultingprojection is only correct for perfect spheres.

Value

Either ansp::CRS object or aninla.CRS object,depending on if the coordinate reference system described by the parameterscan be expressed with a puresp::CRS object or not.

An S3inla.CRS object is a list, usually (but not necessarily)containing at least one element:

crs

The basicsp::CRSobject

Functions

Author(s)

Finn LindgrenFinn.Lindgren@gmail.com

See Also

fm_crs(),sp::CRS(),fm_crs_wkt,fm_crs_is_identical()

Examples

if (fm_safe_sp()) {  crs1 <- fm_CRS("longlat_globe")  crs2 <- fm_CRS("lambert_globe")  crs3 <- fm_CRS("mollweide_norm")  crs4 <- fm_CRS("hammer_globe")  crs5 <- fm_CRS("sphere")  crs6 <- fm_CRS("globe")}

Calculate the area inside segments

Description

Calculate the (signed) area insidefm_segm boundary objects.

Usage

fm_area(x, ...)## S3 method for class 'fm_segm'fm_area(x, ...)## S3 method for class 'fm_segm_list'fm_area(x, ...)

Arguments

x

Object for which to calculate the area

...

Currently unused


Convert objects tofm_collect

Description

Convert objects tofm_collect

Usage

fm_as_collect(x, ...)fm_as_collect_list(x, ...)## S3 method for class 'fm_collect'fm_as_collect(x, ...)

Arguments

x

Object to be converted

...

Arguments passed on to submethods

Value

Anfm_collect object

Functions

See Also

Other object creation and conversion:fm_as_fm(),fm_as_lattice_2d(),fm_as_lattice_Nd(),fm_as_mesh_1d(),fm_as_mesh_2d(),fm_as_mesh_3d(),fm_as_segm(),fm_as_sfc(),fm_as_tensor(),fm_collect(),fm_lattice_2d(),fm_lattice_Nd(),fm_mesh_1d(),fm_mesh_2d(),fm_segm(),fm_simplify(),fm_tensor()

Examples

fm_as_collect_list(list(fm_collect(list())))

Conversion between sparse matrix types

Description

Conversion between sparse matrix types

Usage

fm_as_dgCMatrix(x)fm_as_dgTMatrix(x, unique = TRUE, ...)fm_as_unpackedMatrix(x)fm_as_fmesher_sparse(x)## Default S3 method:fm_as_dgCMatrix(x)## S3 method for class 'fmesher_sparse'fm_as_dgCMatrix(x)## Default S3 method:fm_as_dgTMatrix(x, unique = TRUE, ...)## Default S3 method:fm_as_unpackedMatrix(x)## S3 method for class 'fmesher_sparse'fm_as_unpackedMatrix(x)## S3 method for class 'fmesher_sparse'fm_as_dgTMatrix(x, unique = TRUE, ...)

Arguments

x

Object to be converted

unique

logical; ifTRUE, ensures that the sparse tripletrepresentation has a single entry for each non-zero matrix element.

Value

fm_as_dgCMatrix returns aMatrix::dgCMatrix object.

fm_as_dgTMatrix returns aMatrix::dgTMatrix object.

fm_as_unpackedMatrix returns an object of virtual classMatrix::unpackedMatrix.

fm_as_fmesher_sparse returns anfmesher_sparse object.

Examples

library(Matrix)str(A <- fm_as_dgCMatrix(matrix(c(1, 2, 0, 0, 0, 3, 4, 0, 5), 3, 3)))str(fm_as_dgTMatrix(A))str(fm_as_unpackedMatrix(A))str(fm_as_fmesher_sparse(A))

Convert objects to fmesher objects

Description

Used for conversion from general objects(usuallyinla.mesh and other legacy INLA specific classes)tofmesher classes.

Usage

fm_as_fm(x, ...)## S3 method for class 'NULL'fm_as_fm(x, ...)## S3 method for class 'fm_mesh_1d'fm_as_fm(x, ...)## S3 method for class 'fm_mesh_2d'fm_as_fm(x, ...)## S3 method for class 'fm_mesh_3d'fm_as_fm(x, ...)## S3 method for class 'fm_tensor'fm_as_fm(x, ...)## S3 method for class 'fm_collect'fm_as_fm(x, ...)## S3 method for class 'fm_segm'fm_as_fm(x, ...)## S3 method for class 'fm_lattice_Nd'fm_as_fm(x, ...)## S3 method for class 'fm_lattice_2d'fm_as_fm(x, ...)## S3 method for class 'fm_bbox'fm_as_fm(x, ...)## S3 method for class 'crs'fm_as_fm(x, ...)## S3 method for class 'CRS'fm_as_fm(x, ...)## S3 method for class 'fm_crs'fm_as_fm(x, ...)## S3 method for class 'inla.CRS'fm_as_fm(x, ...)## S3 method for class 'inla.mesh.1d'fm_as_fm(x, ...)## S3 method for class 'inla.mesh'fm_as_fm(x, ...)## S3 method for class 'inla.mesh.segment'fm_as_fm(x, ...)## S3 method for class 'inla.mesh.lattice'fm_as_fm(x, ...)

Arguments

x

Object to be converted

...

Arguments forwarded to submethods

Value

An object of some⁠fm_*⁠ class

See Also

Other object creation and conversion:fm_as_collect(),fm_as_lattice_2d(),fm_as_lattice_Nd(),fm_as_mesh_1d(),fm_as_mesh_2d(),fm_as_mesh_3d(),fm_as_segm(),fm_as_sfc(),fm_as_tensor(),fm_collect(),fm_lattice_2d(),fm_lattice_Nd(),fm_mesh_1d(),fm_mesh_2d(),fm_segm(),fm_simplify(),fm_tensor()

Examples

fm_as_fm(NULL)

Convert objects tofm_lattice_2d

Description

Convert objects tofm_lattice_2d

Usage

fm_as_lattice_2d(...)fm_as_lattice_2d_list(x, ...)## S3 method for class 'fm_lattice_2d'fm_as_lattice_2d(x, ...)## S3 method for class 'inla.mesh.lattice'fm_as_lattice_2d(x, ...)

Arguments

...

Arguments passed on to submethods

x

Object to be converted

Value

Anfm_lattice_2d orfm_lattice_2d_list object

Functions

See Also

Other object creation and conversion:fm_as_collect(),fm_as_fm(),fm_as_lattice_Nd(),fm_as_mesh_1d(),fm_as_mesh_2d(),fm_as_mesh_3d(),fm_as_segm(),fm_as_sfc(),fm_as_tensor(),fm_collect(),fm_lattice_2d(),fm_lattice_Nd(),fm_mesh_1d(),fm_mesh_2d(),fm_segm(),fm_simplify(),fm_tensor()

Examples

str(fm_as_lattice_2d_list(list(fm_lattice_2d(), fm_lattice_2d())))

Convert objects tofm_lattice_Nd

Description

Convert objects tofm_lattice_Nd

Usage

fm_as_lattice_Nd(...)fm_as_lattice_Nd_list(x, ...)## S3 method for class 'fm_lattice_Nd'fm_as_lattice_Nd(x, ...)

Arguments

...

Arguments passed on to submethods

x

Object to be converted

Value

Anfm_lattice_Md orfm_lattice_Nd_list object

Functions

See Also

Other object creation and conversion:fm_as_collect(),fm_as_fm(),fm_as_lattice_2d(),fm_as_mesh_1d(),fm_as_mesh_2d(),fm_as_mesh_3d(),fm_as_segm(),fm_as_sfc(),fm_as_tensor(),fm_collect(),fm_lattice_2d(),fm_lattice_Nd(),fm_mesh_1d(),fm_mesh_2d(),fm_segm(),fm_simplify(),fm_tensor()

Examples

(fm_as_lattice_Nd_list(list(  fm_lattice_Nd(list(1:3, 1:2)),  fm_lattice_Nd(list(1:4)))))

Convert objects tofm_segm

Description

Convert objects tofm_segm

Usage

fm_as_mesh_1d(x, ...)fm_as_mesh_1d_list(x, ...)## S3 method for class 'fm_mesh_1d'fm_as_mesh_1d(x, ...)## S3 method for class 'inla.mesh.1d'fm_as_mesh_1d(x, ...)

Arguments

x

Object to be converted

...

Arguments passed on to submethods

Value

Anfm_mesh_1d orfm_mesh_1d_list object

Functions

See Also

Other object creation and conversion:fm_as_collect(),fm_as_fm(),fm_as_lattice_2d(),fm_as_lattice_Nd(),fm_as_mesh_2d(),fm_as_mesh_3d(),fm_as_segm(),fm_as_sfc(),fm_as_tensor(),fm_collect(),fm_lattice_2d(),fm_lattice_Nd(),fm_mesh_1d(),fm_mesh_2d(),fm_segm(),fm_simplify(),fm_tensor()

Examples

fm_as_mesh_1d_list(list(fm_mesh_1d(1:4)))

Convert objects tofm_mesh_2d

Description

Convert objects tofm_mesh_2d

Usage

fm_as_mesh_2d(x, ...)fm_as_mesh_2d_list(x, ...)## S3 method for class 'fm_mesh_2d'fm_as_mesh_2d(x, ...)## S3 method for class 'inla.mesh'fm_as_mesh_2d(x, ...)## S3 method for class 'fm_mesh_3d'fm_as_mesh_2d(x, ...)## S3 method for class 'sfg'fm_as_mesh_2d(x, ...)## S3 method for class 'sfc_MULTIPOLYGON'fm_as_mesh_2d(x, ...)## S3 method for class 'sfc_POLYGON'fm_as_mesh_2d(x, ...)## S3 method for class 'sf'fm_as_mesh_2d(x, ...)

Arguments

x

Object to be converted

...

Arguments passed on to submethods

Value

Anfm_mesh_2d orfm_mesh_2d_list object

Methods (by class)

Functions

See Also

Other object creation and conversion:fm_as_collect(),fm_as_fm(),fm_as_lattice_2d(),fm_as_lattice_Nd(),fm_as_mesh_1d(),fm_as_mesh_3d(),fm_as_segm(),fm_as_sfc(),fm_as_tensor(),fm_collect(),fm_lattice_2d(),fm_lattice_Nd(),fm_mesh_1d(),fm_mesh_2d(),fm_segm(),fm_simplify(),fm_tensor()

Examples

fm_as_mesh_2d_list(list(fm_mesh_2d(cbind(2, 1))))

Convert objects tofm_mesh_3d

Description

Convert objects tofm_mesh_3d

Usage

fm_as_mesh_3d(x, ...)fm_as_mesh_3d_list(x, ...)## S3 method for class 'fm_mesh_3d'fm_as_mesh_3d(x, ...)

Arguments

x

Object to be converted

...

Arguments passed on to submethods

Value

Anfm_mesh_3d orfm_mesh_3d_list object

Functions

See Also

Other object creation and conversion:fm_as_collect(),fm_as_fm(),fm_as_lattice_2d(),fm_as_lattice_Nd(),fm_as_mesh_1d(),fm_as_mesh_2d(),fm_as_segm(),fm_as_sfc(),fm_as_tensor(),fm_collect(),fm_lattice_2d(),fm_lattice_Nd(),fm_mesh_1d(),fm_mesh_2d(),fm_segm(),fm_simplify(),fm_tensor()

Examples

(m <- fm_mesh_3d(  matrix(c(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0), 4, 3, byrow = TRUE),  matrix(c(1, 2, 3, 4), 1, 4, byrow = TRUE)))fm_as_mesh_3d_list(list(m))

Convert objects tofm_segm

Description

Convert objects tofm_segm

Usage

fm_as_segm(x, ...)fm_as_segm_list(x, ...)## S3 method for class 'fm_segm'fm_as_segm(x, ...)## S3 method for class 'inla.mesh.segment'fm_as_segm(x, ...)## S3 method for class 'sfg'fm_as_segm(x, ...)## S3 method for class 'sfc_POINT'fm_as_segm(x, reverse = FALSE, grp = NULL, is.bnd = TRUE, ...)## S3 method for class 'sfc_LINESTRING'fm_as_segm(x, join = TRUE, grp = NULL, reverse = FALSE, ...)## S3 method for class 'sfc_MULTILINESTRING'fm_as_segm(x, join = TRUE, grp = NULL, reverse = FALSE, ...)## S3 method for class 'sfc_POLYGON'fm_as_segm(x, join = TRUE, grp = NULL, ...)## S3 method for class 'sfc_MULTIPOLYGON'fm_as_segm(x, join = TRUE, grp = NULL, ...)## S3 method for class 'sfc_GEOMETRY'fm_as_segm(x, grp = NULL, join = TRUE, ...)## S3 method for class 'sf'fm_as_segm(x, ...)## S3 method for class 'matrix'fm_as_segm(  x,  reverse = FALSE,  grp = NULL,  is.bnd = FALSE,  crs = NULL,  closed = FALSE,  ...)## S3 method for class 'SpatialPoints'fm_as_segm(x, reverse = FALSE, grp = NULL, is.bnd = TRUE, closed = FALSE, ...)## S3 method for class 'SpatialPointsDataFrame'fm_as_segm(x, ...)## S3 method for class 'Line'fm_as_segm(x, reverse = FALSE, grp = NULL, crs = NULL, ...)## S3 method for class 'Lines'fm_as_segm(x, join = TRUE, grp = NULL, crs = NULL, ...)## S3 method for class 'SpatialLines'fm_as_segm(x, join = TRUE, grp = NULL, ...)## S3 method for class 'SpatialLinesDataFrame'fm_as_segm(x, ...)## S3 method for class 'SpatialPolygons'fm_as_segm(x, join = TRUE, grp = NULL, ...)## S3 method for class 'SpatialPolygonsDataFrame'fm_as_segm(x, ...)## S3 method for class 'Polygons'fm_as_segm(x, join = TRUE, crs = NULL, grp = NULL, ...)## S3 method for class 'Polygon'fm_as_segm(x, crs = NULL, ...)

Arguments

x

Object to be converted.

...

Arguments passed on to submethods

reverse

logical; When TRUE, reverse the order of the input points.DefaultFALSE

grp

if non-null, should be an integer vector of grouping labels forone for each segment.DefaultNULL

is.bnd

logical; ifTRUE, set the boundary flag for the segments.DefaultTRUE

join

logical; ifTRUE, join input segments with common vertices.DefaultTRUE

crs

A crs object

closed

logical; whether to treat a point sequence as a closed polygon.Default:FALSE

Value

Anfm_segm orfm_segm_list object

Functions

See Also

c.fm_segm(),c.fm_segm_list(),[.fm_segm_list()

Other object creation and conversion:fm_as_collect(),fm_as_fm(),fm_as_lattice_2d(),fm_as_lattice_Nd(),fm_as_mesh_1d(),fm_as_mesh_2d(),fm_as_mesh_3d(),fm_as_sfc(),fm_as_tensor(),fm_collect(),fm_lattice_2d(),fm_lattice_Nd(),fm_mesh_1d(),fm_mesh_2d(),fm_segm(),fm_simplify(),fm_tensor()

Examples

fm_as_segm_list(list(  fm_segm(fmexample$mesh),  fm_segm(fmexample$mesh, boundary = FALSE)))(segm <- fm_segm(fmexample$mesh, boundary = FALSE))(segm_sfc <- fm_as_sfc(segm))(fm_as_segm(segm_sfc))

Conversion methods from mesh related objects to sfc

Description

Conversion methods from mesh related objects to sfc

Usage

fm_as_sfc(x, ...)## S3 method for class 'fm_mesh_2d'fm_as_sfc(x, ..., format = NULL, multi = FALSE)## S3 method for class 'fm_segm'fm_as_sfc(x, ..., multi = FALSE)## S3 method for class 'fm_segm_list'fm_as_sfc(x, ...)## S3 method for class 'sfc'fm_as_sfc(x, ...)## S3 method for class 'sf'fm_as_sfc(x, ...)

Arguments

x

An object to be coerced/transformed/converted into another class

...

Arguments passed on to other methods

format

One of "mesh", "int", "bnd", or "loc". Default"mesh".

multi

logical; ifTRUE, attempt to asfc_MULTIPOLYGON/LINESTRING/POINT/GEOMETRYCOLLECTION, otherwise a set ofsfc_POLYGON/LINESTRING/POINT. DefaultFALSE

Value

Methods (by class)

See Also

Other object creation and conversion:fm_as_collect(),fm_as_fm(),fm_as_lattice_2d(),fm_as_lattice_Nd(),fm_as_mesh_1d(),fm_as_mesh_2d(),fm_as_mesh_3d(),fm_as_segm(),fm_as_tensor(),fm_collect(),fm_lattice_2d(),fm_lattice_Nd(),fm_mesh_1d(),fm_mesh_2d(),fm_segm(),fm_simplify(),fm_tensor()

Examples

fm_as_sfc(fmexample$mesh)fm_as_sfc(fmexample$mesh, multi = TRUE)fm_as_sfc(fmexample$mesh, format = "loc")# Boundary edge conversion to polygons is supported from version 0.4.0.9002:fm_as_sfc(fmexample$mesh, format = "bnd")

Convert objects tofm_tensor

Description

Convert objects tofm_tensor

Usage

fm_as_tensor(x, ...)fm_as_tensor_list(x, ...)## S3 method for class 'fm_tensor'fm_as_tensor(x, ...)

Arguments

x

Object to be converted

...

Arguments passed on to submethods

Value

Anfm_tensor object

Functions

See Also

Other object creation and conversion:fm_as_collect(),fm_as_fm(),fm_as_lattice_2d(),fm_as_lattice_Nd(),fm_as_mesh_1d(),fm_as_mesh_2d(),fm_as_mesh_3d(),fm_as_segm(),fm_as_sfc(),fm_collect(),fm_lattice_2d(),fm_lattice_Nd(),fm_mesh_1d(),fm_mesh_2d(),fm_segm(),fm_simplify(),fm_tensor()

Examples

fm_as_tensor_list(list(fm_tensor(list())))

Interactive mesh building and diagnostics

Description

Assess the finite element approximation errors in a mesh for interactive Rsessions.

Usage

fm_assess(mesh, spatial.range, alpha = 2, dims = NULL)

Arguments

mesh

Anfm_mesh_2d object

spatial.range

numeric; the spatial range parameter to use for theassessment

alpha

numeric; A validfm_matern_precision()alpha parameter

dims

2-numeric; the grid size

Value

Ansf object with gridded mesh assessment information

Author(s)

Finn LindgrenFinn.Lindgren@gmail.com

See Also

fm_mesh_2d(),fm_rcdt_2d

Examples

bnd <- fm_segm(cbind(  c(0, 10, 10, 0, 0),  c(0, 0, 10, 10, 0)), is.bnd = TRUE)mesh <- fm_rcdt_2d_inla(boundary = bnd, max.edge = 1)out <- fm_assess(mesh, spatial.range = 3, alpha = 2)

Compute barycentric coordinates

Description

Identify knot intervals or triangles and compute barycentriccoordinates

Usage

fm_bary(...)## S3 method for class 'fm_bary'fm_bary(bary, ..., extra_class = NULL)## S3 method for class 'list'fm_bary(bary, ..., extra_class = NULL)## S3 method for class 'tbl_df'fm_bary(bary, ..., extra_class = NULL)## S3 method for class 'fm_mesh_1d'fm_bary(mesh, loc, method = c("linear", "nearest"), restricted = FALSE, ...)## S3 method for class 'fm_mesh_2d'fm_bary(mesh, loc, crs = NULL, ..., max_batch_size = NULL)## S3 method for class 'fm_mesh_3d'fm_bary(mesh, loc, ..., max_batch_size = NULL)## S3 method for class 'fm_lattice_2d'fm_bary(mesh, loc, crs = NULL, ...)## S3 method for class 'fm_lattice_Nd'fm_bary(mesh, loc, ...)

Arguments

...

Arguments forwarded to sub-methods.

bary

Anfm_bary object, or an object that can be converted tofm_bary.

extra_class

character; If non-NULL and not already in the classvector ofbary, add it to the front of the class vector.

mesh

fm_mesh_1d orfm_mesh_2d object

loc

Points for which to identify the containing interval/triangle, andcorresponding barycentric coordinates. May be a vector (for 1d) or a matrixof raw coordinates,sf, orsp point information (for 2d).

method

character; method for defining the barycentric coordinates,"linear" (default) or "nearest"

restricted

logical, used formethod="linear".IfFALSE (default), points outside the mesh interval will be givenbarycentric weights less than 0 and greater than 1, according to linearextrapolation. IfTRUE, the barycentric weights are clamped to the (0, 1)interval.

crs

Optional crs information forloc

max_batch_size

integer; maximum number of points to process in asingle batch. This speeds up calculations by avoiding repeated largeinternal memory allocations and data copies. The default,NULL, usesmax_batch_size = 2e5L, chosen based on empirical time measurements togive an approximately optimal runtime.

Value

Afm_bary object, atibble with columnsindex; either

andwhere, a matrix of barycentric coordinates.

Methods (by class)

See Also

fm_bary_simplex(),fm_bary_loc()

Examples

bary <- fm_bary(fm_mesh_1d(1:4), seq(0, 5, by = 0.5))barystr(fm_bary(fmexample$mesh, fmexample$loc_sf))m <- fm_mesh_3d(  rbind(    c(1, 0, 0),    c(0, 1, 0),    c(0, 0, 1),    c(0, 0, 0)  ),  matrix(c(1, 2, 3, 4), 1, 4))b <- fm_bary(m, matrix(c(1, 1, 1) / 4, 1, 3))str(fm_bary(fmexample$mesh, fmexample$loc_sf))

Extract Euclidean Sgeometry from Barycentric coordinates

Description

Extract the Euclidean coordinates for location identified by anfm_baryobject. This acts as the inverse offm_bary().

Usage

fm_bary_loc(mesh, bary = NULL, ..., format = NULL)## S3 method for class 'fm_mesh_2d'fm_bary_loc(mesh, bary = NULL, ..., format = NULL)## S3 method for class 'fm_mesh_3d'fm_bary_loc(mesh, bary = NULL, ..., format = NULL)## S3 method for class 'fm_mesh_1d'fm_bary_loc(mesh, bary = NULL, ..., format = NULL)## S3 method for class 'fm_lattice_2d'fm_bary_loc(mesh, bary = NULL, ..., format = NULL)## S3 method for class 'fm_lattice_Nd'fm_bary_loc(mesh, bary = NULL, ..., format = NULL)

Arguments

mesh

A mesh object, e.g.fm_mesh_2d orfm_mesh_1d.

bary

Anfm_bary object. IfNULL, return the mesh nodes is the meshclass supports it, otherwise gives an error.

...

Further arguments potentially used by sub-methods.

format

Optional format for the output. IfNULL, the output formatis determined by the default for the mesh object.

Value

Output format depends on the meshclass.

Methods (by class)

See Also

fm_bary(),fm_bary_simplex()

Examples

head(fm_bary_loc(fmexample$mesh))bary <- fm_bary(fmexample$mesh, fmexample$loc_sf)fm_bary_loc(fmexample$mesh, bary, format = "matrix")fm_bary_loc(fmexample$mesh, bary, format = "sf")(m <- fm_mesh_3d(  matrix(c(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0), 4, 3, byrow = TRUE),  matrix(c(1, 2, 3, 4), 1, 4, byrow = TRUE)))(bary <- fm_bary(m, rbind(  cbind(0.1, 0.2, 0.3),  cbind(-0.1, 0.2, 0.3))))fm_bary_loc(m, bary)mesh1 <- fm_mesh_1d(1:4)fm_bary_loc(mesh1)(bary1 <- fm_bary(mesh1, seq(0, 5, by = 0.5)))fm_bary_loc(mesh1, bary1)(bary1 <- fm_bary(mesh1, seq(0, 5, by = 0.5), restricted = TRUE))fm_bary_loc(mesh1, bary1)fm_basis(mesh1, bary1)(bary1 <- fm_bary(mesh1, bary1, method = "nearest"))fm_bary_loc(mesh1, bary1)fm_basis(mesh1, bary1)(bary1 <- fm_bary(mesh1, bary1, method = "linear"))fm_bary_loc(mesh1, bary1)fm_basis(mesh1, bary1)m <- fm_lattice_2d(x = 1:3, y = 1:4)head(fm_bary_loc(m))(bary <- fm_bary(m, cbind(1.5, 3.2)))fm_bary_loc(m, bary, format = "matrix")fm_bary_loc(m, bary, format = "sf")m <- fm_lattice_Nd(list(x = 1:3, y = 1:4, z = 1:2))head(fm_bary_loc(m))(bary <- fm_bary(m, cbind(1.5, 3.2, 1.5)))fm_bary_loc(m, bary)

Extract Simplex information for Barycentric coordinates

Description

Extract the simplex vertex information for a combination of a meshandfm_bary coordinates.

Usage

fm_bary_simplex(mesh, bary = NULL, ...)## S3 method for class 'fm_mesh_2d'fm_bary_simplex(mesh, bary = NULL, ...)## S3 method for class 'fm_mesh_3d'fm_bary_simplex(mesh, bary = NULL, ...)## S3 method for class 'fm_mesh_1d'fm_bary_simplex(mesh, bary = NULL, ...)## S3 method for class 'fm_lattice_2d'fm_bary_simplex(mesh, bary = NULL, ...)## S3 method for class 'fm_lattice_Nd'fm_bary_simplex(mesh, bary = NULL, ...)

Arguments

mesh

A mesh object, e.g.fm_mesh_2d orfm_mesh_1d.

bary

Anfm_bary object. If NULL, return the full simplexinformation for the mesh.

...

Further arguments potentially used by sub-methods.

Value

A matrix of vertex indices, one row per point inbary.

Methods (by class)

See Also

fm_bary(),fm_bary_loc()

Examples

bary <- fm_bary(fmexample$mesh, fmexample$loc_sf)fm_bary_simplex(fmexample$mesh, bary)(m <- fm_mesh_3d(  matrix(c(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0), 4, 3, byrow = TRUE),  matrix(c(1, 2, 3, 4), 1, 4, byrow = TRUE)))(bary <- fm_bary(m, rbind(  cbind(0.1, 0.2, 0.3),  cbind(-0.1, 0.2, 0.3))))fm_bary_simplex(m, bary)mesh1 <- fm_mesh_1d(1:4)(bary1 <- fm_bary(mesh1, seq(0, 5, by = 0.5)))(bary1 <- fm_bary(mesh1, seq(0, 5, by = 0.5), restricted = TRUE))fm_bary_simplex(mesh1, bary1)m <- fm_lattice_2d(x = 1:3, y = 1:4)bary <- fm_bary(m, cbind(1.5, 3.2))fm_bary_simplex(m, bary)m <- fm_lattice_Nd(list(x = 1:3, y = 1:4, z = 1:2))(bary <- fm_bary(m, cbind(1.5, 3.2, 1.5)))(fm_bary_simplex(m, bary))fm_bary_loc(m, bary)

Compute mapping matrix between mesh function space and points

Description

Computes the basis mapping matrix between a function space on amesh, and locations.

Usage

fm_basis(x, ..., full = FALSE)## Default S3 method:fm_basis(x, ..., full = FALSE)## S3 method for class 'fm_mesh_1d'fm_basis(x, loc, weights = NULL, derivatives = NULL, ..., full = FALSE)## S3 method for class 'fm_mesh_2d'fm_basis(x, loc, weights = NULL, derivatives = NULL, ..., full = FALSE)## S3 method for class 'fm_mesh_3d'fm_basis(x, loc, weights = NULL, ..., full = FALSE)## S3 method for class 'fm_lattice_2d'fm_basis(x, loc, weights = NULL, ..., full = FALSE)## S3 method for class 'fm_lattice_Nd'fm_basis(x, loc, weights = NULL, ..., full = FALSE)## S3 method for class 'fm_tensor'fm_basis(x, loc, weights = NULL, ..., full = FALSE)## S3 method for class 'fm_collect'fm_basis(x, loc, weights = NULL, ..., full = FALSE)## S3 method for class 'matrix'fm_basis(x, ok = NULL, weights = NULL, ..., full = FALSE)## S3 method for class 'Matrix'fm_basis(x, ok = NULL, weights = NULL, ..., full = FALSE)## S3 method for class 'list'fm_basis(x, weights = NULL, ..., full = FALSE)## S3 method for class 'fm_basis'fm_basis(x, ..., full = FALSE)## S3 method for class 'fm_evaluator'fm_basis(x, ..., full = FALSE)

Arguments

x

An function space object, or other supported object(matrix,Matrix,list)

...

Passed on to submethods

full

logical; ifTRUE, return afm_basis object, containing atleast a projection matrixA and logical vectorok indicating whichevaluations are valid. IfFALSE, return only the projection matrixA.Default isFALSE.

loc

A location/value information object (numeric,matrix,sf,fm_bary, etc, depending on the class ofx)

weights

Optional weight vector to apply (from the left, oneweight for each row of the basis matrix)

derivatives

If non-NULL and logical, include derivative matricesin the output. Forcesfull = TRUE.

ok

numerical of lengthNROW(x), indicating which rows ofx arevalid/successful basis evaluations. IfNULL, inferred asrep(TRUE, NROW(x)).

Value

AsparseMatrix object (iffull = FALSE), or afm_basis object(iffull = TRUE orisTRUE(derivatives)). Thefm_basis object containsat least the projection matrixA and logical vectorok; Ifx_jdenotes the latent basis coefficient for basis functionj, the field isdefined as⁠u(loc_i)=sum_j A_ij x_j⁠ for alli whereok[i] isTRUE,andu(loc_i)=0.0 whereok[i] isFALSE.

Methods (by class)

See Also

fm_raw_basis()

Examples

# Compute basis mapping matrixdim(fm_basis(fmexample$mesh, fmexample$loc))print(fm_basis(fmexample$mesh, fmexample$loc, full = TRUE))# From precomputed `fm_bary` information:bary <- fm_bary(fmexample$mesh, fmexample$loc)print(fm_basis(fmexample$mesh, bary, full = TRUE))

Internal helper functions for mesh field evaluation

Description

Methods called internally byfm_basis() methods.

Usage

fm_basis_mesh_2d(  mesh,  loc = NULL,  weights = NULL,  derivatives = NULL,  crs = NULL,  ...)fm_basis_mesh_1d(mesh, loc, weights = NULL, derivatives = NULL, ...)

Arguments

loc

A location/value information object (numeric,matrix,sf,fm_bary, etc, depending on the class ofx)

weights

Optional weight vector, one weight for each location

derivatives

logical; If true, also return matricesdA andd2Aforfm_mesh_1d objects, anddx,dy,dz forfm_mesh_2d.

...

Passed on to submethods

Value

Afm_basis object; a list of evaluator information objects,at least a matrixA and logical vectorok.

Examples

str(fm_basis_mesh_2d(fmexample$mesh, loc = fmexample$loc))

Bounding box class

Description

Simple class for handling bounding box information

Usage

fm_bbox(...)## S3 method for class 'list'fm_bbox(x, ...)## S3 method for class 'NULL'fm_bbox(...)## S3 method for class 'numeric'fm_bbox(x, ...)## S3 method for class 'matrix'fm_bbox(x, ...)## S3 method for class 'Matrix'fm_bbox(x, ...)## S3 method for class 'fm_bbox'fm_bbox(x, ...)## S3 method for class 'fm_mesh_1d'fm_bbox(x, ...)## S3 method for class 'fm_mesh_2d'fm_bbox(x, ...)## S3 method for class 'fm_mesh_3d'fm_bbox(x, ...)## S3 method for class 'fm_segm'fm_bbox(x, ...)## S3 method for class 'fm_lattice_2d'fm_bbox(x, ...)## S3 method for class 'fm_lattice_Nd'fm_bbox(x, ...)## S3 method for class 'fm_tensor'fm_bbox(x, ...)## S3 method for class 'fm_collect'fm_bbox(x, ...)## S3 method for class 'sf'fm_bbox(x, ...)## S3 method for class 'sfg'fm_bbox(x, ...)## S3 method for class 'sfc'fm_bbox(x, ...)## S3 method for class 'bbox'fm_bbox(x, ...)fm_as_bbox(x, ...)## S3 method for class 'fm_bbox'x[i]## S3 method for class 'fm_bbox'c(..., .join = FALSE)fm_as_bbox_list(x, ...)

Arguments

...

Passed on to sub-methods

x

fm_bbox object from which to extract element(s)

i

indices specifying elements to extract

.join

logical; ifTRUE, concatenate the bounding boxes into a singlemulti-dimensional bounding box. Default isFALSE.

Value

Forc.fm_bbox(), afm_bbox_list object if.join = FALSE (thedefault) or anfm_bbox object if.join = TRUE.

Methods (by class)

Methods (by generic)

Functions

Examples

fm_bbox(matrix(1:6, 3, 2))m <- c(A = fm_bbox(cbind(1, 2)), B = fm_bbox(cbind(3, 4)))str(m)str(m[2])m <- fm_as_bbox_list(list(  A = fm_bbox(cbind(1, 2)),  B = fm_bbox(cbind(3, 4))))str(fm_as_bbox_list(m))

Blockwise aggregation matrices

Description

Creates an aggregation matrix for blockwise aggregation, with optionalweighting.

Usage

fm_block(  block = NULL,  weights = NULL,  log_weights = NULL,  rescale = FALSE,  n_block = NULL)fm_block_eval(  block = NULL,  weights = NULL,  log_weights = NULL,  rescale = FALSE,  n_block = NULL,  values = NULL)fm_block_logsumexp_eval(  block = NULL,  weights = NULL,  log_weights = NULL,  rescale = FALSE,  n_block = NULL,  values = NULL,  log = TRUE)fm_block_weights(  block = NULL,  weights = NULL,  log_weights = NULL,  rescale = FALSE,  n_block = NULL)fm_block_log_weights(  block = NULL,  weights = NULL,  log_weights = NULL,  rescale = FALSE,  n_block = NULL)fm_block_log_shift(block = NULL, log_weights = NULL, n_block = NULL)fm_block_prep(  block = NULL,  log_weights = NULL,  weights = NULL,  n_block = NULL,  values = NULL,  n_values = NULL,  force_log = FALSE)

Arguments

block

integer vector; block information. IfNULL,rep(1L, block_len) is used, whereblock_len is determined by⁠length(log_weights)))⁠ or⁠length(weights)))⁠. A single scalar is alsorepeated to a vector of corresponding length to the weights.

Note: from version⁠0.2.0.9017⁠ to⁠0.4.0.9005⁠, 'character'input was converted to integer withas.integer(factor(block)). As thiscould lead to unintended ordering of the output, this is no longer allowed.

weights

Optional weight vector

log_weights

Optionallog(weights) vector. Overridesweights whennon-NULL.

rescale

logical; IfTRUE, normalise the weights bysum(weights)orsum(exp(log_weights)) within each block.Default:FALSE

n_block

integer; The number of conceptual blocks. Only needs to bespecified if it's larger thanmax(block), or to keep the output ofconsistent size for different inputs.

values

Vector to be blockwise aggregated

log

IfTRUE (default), return log-sum-exp. IfFALSE,return sum-exp.

n_values

When supplied, used instead oflength(values) to determinethe value vector input length.

force_log

WhenFALSE (default),passes eitherweights andlog_weights on, if provided, withlog_weightstaking precedence. IfTRUE, forces the computation oflog_weights,whether given in the input or not.

Value

A (sparse) matrix

Functions

Examples

block <- rep(1:2, 3:2)fm_block(block)fm_block(block, rescale = TRUE)fm_block(block, log_weights = -2:2, rescale = TRUE)fm_block_eval(  block,  weights = 1:5,  rescale = TRUE,  values = 11:15)fm_block_logsumexp_eval(  block,  weights = 1:5,  rescale = TRUE,  values = log(11:15),  log = FALSE)

Extract triangle centroids from anfm_mesh_2d

Description

Computes the centroids of the triangles of anfm_mesh_2d()object.

Usage

fm_centroids(x, format = NULL)

Arguments

x

Anfm_mesh_2d object.

format

character;"sf","df","sp"

Value

Ansf,data.frame, orSpatialPointsDataFrame object, with the vertexcoordinates, and a.triangle column with the triangle indices.

Author(s)

Finn LindgrenFinn.Lindgren@gmail.com

See Also

fm_vertices()

Examples

if (require("ggplot2", quietly = TRUE)) {  vrt <- fm_centroids(fmexample$mesh, format = "sf")  ggplot() +    geom_sf(data = fm_as_sfc(fmexample$mesh)) +    geom_sf(data = vrt, color = "red")}

Make a collection function space

Description

[Experimental]Collection function spaces. The interface and object storage modelis experimental and may change.

Usage

fm_collect(x, ...)

Arguments

x

list of function space objects, such asfm_mesh_2d(), all of thesame type.

...

Currently unused

Value

Afm_collect orfm_collect_list object.Elements offm_collect:

fun_spaces

fm_list of function space objects

manifold

character; manifold type summary, obtained from thefunction spaces.

See Also

Other object creation and conversion:fm_as_collect(),fm_as_fm(),fm_as_lattice_2d(),fm_as_lattice_Nd(),fm_as_mesh_1d(),fm_as_mesh_2d(),fm_as_mesh_3d(),fm_as_segm(),fm_as_sfc(),fm_as_tensor(),fm_lattice_2d(),fm_lattice_Nd(),fm_mesh_1d(),fm_mesh_2d(),fm_segm(),fm_simplify(),fm_tensor()

Examples

m <- fm_collect(list(  A = fmexample$mesh,  B = fmexample$mesh))m2 <- fm_as_collect(m)m3 <- fm_as_collect_list(list(m, m))c(fm_dof(m$fun_spaces[[1]]) + fm_dof(m$fun_spaces[[2]]), fm_dof(m))fm_basis(m, loc = tibble::tibble(  loc = fmexample$loc_sf,  index = c(1, 1, 2, 2, 1, 2, 2, 1, 1, 2)), full = TRUE)fm_basis(m, loc = tibble::tibble(  loc = rbind(c(0, 0), c(0.1, 0.1)),  index = c("B", "A")), full = TRUE)fm_evaluator(m, loc = tibble::tibble(loc = cbind(0, 0), index = 2))names(fm_fem(m))fm_diameter(m)

Compute connected mesh subsets

Description

Compute subsets of vertices and triangles/tetrahedrons in anfm_mesh_2d orfm_mesh_3d object that are connected by edges/triangles,and splitfm_segm objects into connected components.

Usage

fm_components(x, ...)## S3 method for class 'fm_mesh_2d'fm_components(x, ...)## S3 method for class 'fm_mesh_3d'fm_components(x, ...)## S3 method for class 'fm_segm'fm_components(x, ...)## S3 method for class 'fm_segm_list'fm_components(x, ...)

Arguments

x

An object to extract components from

...

Additional arguments passed to methods

Value

Forfm_mesh_2d andfm_mesh_3d, returns a list with elementsvertex andtriangle/tetra, vectors ofinteger labels for which connected component they belong, andinfo, adata.frame with columns

component

Connected component integer label.

nV

The number of vertices in the component.

nT

The number of triangles/tetrahedrons in the component.

area/volume

The surface area or volume associated with the component.Component labels are not comparable acrossdifferent meshes, but some ordering stability is guaranteed by initiatingeach component from the lowest numbered triangle whenever a new component isinitiated.

Forfm_segm, returns a list of segments, each with componenteither a single closed loop of segments, or an open segment chain.

Author(s)

Finn LindgrenFinn.Lindgren@gmail.com

See Also

fm_mesh_2d(),fm_rcdt_2d(),fm_mesh_3d(),fm_segm()

Examples

# Construct two simple meshes:loc <- matrix(c(0, 1, 0, 1), 2, 2)mesh1 <- fm_mesh_2d(loc = loc, max.edge = 0.1)bnd <- fm_nonconvex_hull(loc, 0.3)mesh2 <- fm_mesh_2d(boundary = bnd, max.edge = 0.1)# Compute connectivity information:conn1 <- fm_components(mesh1)conn2 <- fm_components(mesh2)# One component, simply connected meshconn1$info# Two disconnected componentsconn2$info# Extract the subset mesh for each component:# (Note: some information is lost, such as fixed segments,# and boundary edge labels.)mesh3_1 <- fm_rcdt_2d_inla(  loc = mesh2$loc,  tv = mesh2$graph$tv[conn2$triangle == 1, , drop = FALSE],  delaunay = FALSE)mesh3_2 <- fm_rcdt_2d_inla(  loc = mesh2$loc,  tv = mesh2$graph$tv[conn2$triangle == 2, , drop = FALSE],  delaunay = FALSE)if (require("ggplot2")) {  ggplot() +    geom_fm(data = mesh3_1, fill = "red", alpha = 0.5) +    geom_fm(data = mesh3_2, fill = "blue", alpha = 0.5)}(m <- fm_mesh_3d(  matrix(c(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0), 4, 3, byrow = TRUE),  matrix(c(1, 2, 3, 4), 1, 4, byrow = TRUE)))# Compute connectivity information:(conn <- fm_components(m))(segm <- c(  fm_segm(    matrix(c(0, 0, 1, 0, 1, 1, 0, 1), 4, 2, byrow = TRUE),    matrix(c(1, 2, 2, 3, 3, 4, 4, 1), 4, 2, byrow = TRUE)  ),  fm_segm(    matrix(c(0, 0, 1, 0, 1, 1, 0, 1), 4, 2, byrow = TRUE),    matrix(c(3, 4, 1, 2, 2, 3), 3, 2, byrow = TRUE),    is.bnd = FALSE  )))# Compute connectivity information:(conn <- lapply(segm, fm_components))(conn2 <- fm_components(segm))

Check which mesh triangles are inside a polygon

Description

Wrapper for thesf::st_contains() (previouslysp::over()) method to findtriangle centroids or vertices insidesf orsp polygon objects

Usage

fm_contains(x, y, ...)## S3 method for class 'Spatial'fm_contains(x, y, ...)## S3 method for class 'sf'fm_contains(x, y, ...)## S3 method for class 'sfc'fm_contains(x, y, ..., type = c("centroid", "vertex"))

Arguments

x

geometry (typically ansf orsp::SpatialPolygons object) for thequeries

y

anfm_mesh_2d() object

...

Passed on to other methods

type

the query type; either'centroid' (default, for trianglecentroids), or'vertex' (for mesh vertices)

Value

List of vectors of triangle indices (whentype is'centroid') orvertex indices (whentype is'vertex'). The list has one entry per rowof thesf object. Useunlist(fm_contains(...)) if the combined union isneeded.

Author(s)

Haakon Bakka,bakka@r-inla.org, and Finn LindgrenFinn.Lindgren@gmail.com

Examples

# Create a polygon and a meshobj <- sf::st_sfc(  sf::st_polygon(    list(rbind(      c(0, 0),      c(50, 0),      c(50, 50),      c(0, 50),      c(0, 0)    ))  ),  crs = fm_crs("longlat_globe"))mesh <- fm_rcdt_2d_inla(globe = 2, crs = fm_crs("sphere"))## 2 vertices found in the polygonfm_contains(obj, mesh, type = "vertex")## 3 triangles found in the polygonfm_contains(obj, mesh)## Multiple transformations can lead to slightly different results## due to edge cases:## 4 triangles found in the polygonfm_contains(  obj,  fm_transform(mesh, crs = fm_crs("mollweide_norm")))

(Blockwise) cross product of integration points

Description

Calculates the groupwise cross product of integration points in differentdimensions and multiplies their weights accordingly.If the object defining points in a particular dimension has noweights attached to it all weights are assumed to be 1.

Usage

fm_cprod(..., na.rm = NULL, .blockwise = FALSE)

Arguments

...

tibble,data.frame,sf, orSpatialPointsDataFrame objects,each one usually obtained by a call to anfm_int() method.

na.rm

logical; ifTRUE, the rows with weightNA from thenon-overlapping full_join will be removed; ifFALSE, set the undefinedweights toNA. IfNULL (default), act asTRUE, but warn if anyelements needed removing.

.blockwise

logical; ifFALSE, computes full tensor productintegration. IfTRUE, computes within-block tensor product integration(used internally byfm_int()). DefaultFALSE

Value

Adata.frame,sf, orSpatialPointsDataFrame ofmultidimensional integration points and their weights

Examples

if (require("ggplot2")) {  # Create integration points in dimension 'myDim' and 'myDiscreteDim'  ips1 <- fm_int(fm_mesh_1d(1:20),    rbind(c(0, 3), c(3, 8)),    name = "myDim"  )  ips2 <- fm_int(domain = c(1, 2, 4), name = "myDiscreteDim")  # Calculate the cross product  ips <- fm_cprod(ips1, ips2)  # Plot the integration points  ggplot(ips) +    geom_point(aes(myDim, myDiscreteDim, size = weight)) +    scale_size_area()}

Obtain coordinate reference system object

Description

Obtain ansf::crs orfm_crs object from a spatial object, orconvert crs information to construct a newsf::crs object.

Usage

fm_crs(x, ..., units = NULL, oblique = NULL)fm_crs_oblique(x)## S3 method for class 'fm_crs'st_crs(x, ...)## S3 method for class 'fm_crs'x$name## Default S3 method:fm_crs(x, ..., units = NULL, oblique = NULL)## S3 method for class 'crs'fm_crs(x, ..., units = NULL, oblique = NULL)## S3 method for class 'fm_crs'fm_crs(x, ..., units = NULL, oblique = NULL)## S3 method for class 'fm_CRS'fm_crs(x, ..., units = NULL, oblique = NULL)## S3 method for class 'character'fm_crs(x, ..., units = NULL, oblique = NULL)## S3 method for class 'Spatial'fm_crs(x, ..., units = NULL, oblique = NULL)## S3 method for class 'SpatVector'fm_crs(x, ..., units = NULL, oblique = NULL)## S3 method for class 'SpatRaster'fm_crs(x, ..., units = NULL, oblique = NULL)## S3 method for class 'sf'fm_crs(x, ..., units = NULL, oblique = NULL)## S3 method for class 'sfc'fm_crs(x, ..., units = NULL, oblique = NULL)## S3 method for class 'sfg'fm_crs(x, ..., units = NULL, oblique = NULL)## S3 method for class 'fm_mesh_2d'fm_crs(x, ..., units = NULL, oblique = NULL)## S3 method for class 'fm_mesh_1d'fm_crs(x, ..., units = NULL, oblique = NULL)## S3 method for class 'fm_mesh_3d'fm_crs(x, ..., units = NULL, oblique = NULL)## S3 method for class 'fm_tensor'fm_crs(x, ..., units = NULL, oblique = NULL, .multi = FALSE)## S3 method for class 'fm_collect'fm_crs(x, ..., units = NULL, oblique = NULL, .multi = FALSE)## S3 method for class 'fm_lattice_2d'fm_crs(x, ..., units = NULL, oblique = NULL)## S3 method for class 'fm_segm'fm_crs(x, ..., units = NULL, oblique = NULL)## S3 method for class 'fm_list'fm_crs(x, ..., units = NULL, oblique = NULL)## S3 method for class 'matrix'fm_crs(x, ..., units = NULL, oblique = NULL)## S3 method for class 'fm_list'fm_CRS(x, ..., units = NULL, oblique = NULL)fm_wkt_predef()## S3 method for class 'inla.CRS'fm_crs(x, ..., units = NULL, oblique = NULL)

Arguments

x

Object to convert tocrs or to extractcrs information from.Ifcharacter, a string suitable forsf::st_crs(x), or the name of apredefinedwkt string from “names(fm_wkt_predef())'.

...

Additional parameters. Not currently in use.

units

character; if non-NULL,⁠fm_length_unit()<-⁠ is called to changethe length units of the crs object. IfNULL (default), the length unitsare not changed. (From version⁠0.3.0.9013⁠)

oblique

Numeric vector of length at most 4 of rotation angles (indegrees) for an oblique projection, all values defaulting to zero. Thevalues indicate (longitude, latitude, orientation, orbit), as explained inthe Details section below. Whenoblique is non-NULL, used to override theobliqueness parameters of afm_crs object. WhenNA, remove obliquenessfrom the object, resulting in a return class ofsf::st_crs(). WhenNULL, pass though any oblique information in the object, returning anfm_crs() object if needed.

name

element name

.multi

logical; IfTRUE, return a list offm_crs objectsfor classes that support multiple spaces. DefaultFALSE

Details

The first twoelements of theoblique vector are the (longitude, latitude)coordinates for the oblique centre point. The third value (orientation) is acounter-clockwise rotation angle for an observer looking at the centre pointfrom outside the sphere. The fourth value is the quasi-longitude (orbitangle) for a rotation along the oblique observers equator.

Simple oblique:oblique=c(0, 45)

Polar:oblique=c(0, 90)

Quasi-transversal:oblique=c(0, 0, 90)

Satellite orbit viewpoint:oblique=c(lon0-time*v1, 0, orbitangle, orbit0+time*v2), wherelon0 is the longitude at which a satelliteorbit crosses the equator attime=0, when the satellite is at anangleorbit0 further along in its orbit. The orbital angle relativeto the equatorial plane isorbitangle, andv1 andv2are the angular velocities of the planet and the satellite, respectively.Note that "forward" from the satellite's point of view is "to the right" inthe projection.

Whenoblique[2] oroblique[3] are non-zero, the resultingprojection is only correct for perfect spheres.

Value

Either ansf::crs object or anfm_crs object,depending on if the coordinate reference system described by the parameterscan be expressed with a purecrs object or not.

Acrs object (sf::st_crs()) or afm_crs object.An S3fm_crs object is a list with elementscrs andoblique.

fm_wkt_predef returns a WKT2 string defining a projection

Methods (by class)

Methods (by generic)

Functions

Author(s)

Finn LindgrenFinn.Lindgren@gmail.com

See Also

sf::st_crs(),fm_crs_wkt

fm_crs_is_null

fm_crs<-(),fm_crs_oblique<-()

Examples

crs1 <- fm_crs("longlat_globe")crs2 <- fm_crs("lambert_globe")crs3 <- fm_crs("mollweide_norm")crs4 <- fm_crs("hammer_globe")crs5 <- fm_crs("sphere")crs6 <- fm_crs("globe")names(fm_wkt_predef())

Assignment operators for crs information objects

Description

Assigns new crs information.

Usage

fm_crs(x) <- valuefm_crs_oblique(x) <- value## S3 replacement method for class 'NULL'fm_crs(x) <- value## S3 replacement method for class 'NULL'fm_crs_oblique(x) <- value## S3 replacement method for class 'fm_segm'fm_crs(x) <- value## S3 replacement method for class 'fm_list'fm_crs(x) <- value## S3 replacement method for class 'fm_mesh_2d'fm_crs(x) <- value## S3 replacement method for class 'fm_collect'fm_crs(x) <- value## S3 replacement method for class 'fm_lattice_2d'fm_crs(x) <- value## S3 replacement method for class 'sf'fm_crs(x) <- value## S3 replacement method for class 'sfg'fm_crs(x) <- value## S3 replacement method for class 'sfc'fm_crs(x) <- value## S3 replacement method for class 'Spatial'fm_crs(x) <- value## S3 replacement method for class 'crs'fm_crs_oblique(x) <- value## S3 replacement method for class 'CRS'fm_crs_oblique(x) <- value## S3 replacement method for class 'fm_CRS'fm_crs_oblique(x) <- value## S3 replacement method for class 'fm_crs'fm_crs_oblique(x) <- value## S3 replacement method for class 'fm_segm'fm_crs_oblique(x) <- value## S3 replacement method for class 'fm_mesh_2d'fm_crs_oblique(x) <- value## S3 replacement method for class 'fm_collect'fm_crs_oblique(x) <- value## S3 replacement method for class 'fm_lattice_2d'fm_crs_oblique(x) <- value## S3 replacement method for class 'inla.CRS'fm_crs_oblique(x) <- value

Arguments

x

Object to assign crs information to

value

For⁠fm_crs<-()⁠, object supported byfm_crs(value).

For⁠fm_crs_oblique<-()⁠,NA or a numeric vector, see theobliqueargument forfm_crs(). For assignment,NULL is treated asNA.

Value

The modified object

Functions

See Also

fm_crs()

Examples

x <- fm_segm()fm_crs(x) <- fm_crs("+proj=longlat")fm_crs(x)$proj4string

Check if two CRS objects are identical

Description

Check if two CRS objects are identical

Usage

fm_crs_is_identical(crs0, crs1, crsonly = FALSE)

Arguments

crs0,crs1

Twosf::crs,sp::CRS,fm_crs orinla.CRS objects tobe compared.

crsonly

logical. IfTRUE and any ofcrs0 andcrs1 arefm_crsorinla.CRS objects, extract and compare only thesf::crs orsp::CRSaspects. Default:FALSE

Value

logical, indicating if the two crs objects are identical in thespecified sense (see thecrsonly argument)

See Also

fm_crs(),fm_CRS(),fm_crs_is_null()

Examples

crs0 <- crs1 <- fm_crs("longlat_globe")fm_crs_oblique(crs1) <- c(0, 90)print(c(  fm_crs_is_identical(crs0, crs0),  fm_crs_is_identical(crs0, crs1),  fm_crs_is_identical(crs0, crs1, crsonly = TRUE)))

Check if a crs is NULL or NA

Description

Methods of checking whether various kinds of CRS objects areNULL orNA.Logically equivalent to eitheris.na(fm_crs(x)) oris.na(fm_crs(x, oblique = NA)), but with a short-cut pre-check foris.null(x).

Usage

fm_crs_is_null(x, crsonly = FALSE)## S3 method for class 'fm_crs'is.na(x)

Arguments

x

An object supported byfm_crs(x)

crsonly

For crs objects with extended functionality, such asfm_crs() objects withoblique information,crsonly = TRUE only checksthe plain CRS part.

Value

logical

Functions

See Also

fm_crs(),fm_CRS(),fm_crs_is_identical()

Examples

fm_crs_is_null(NULL)fm_crs_is_null(27700)fm_crs_is_null(fm_crs())fm_crs_is_null(fm_crs(27700))fm_crs_is_null(fm_crs(oblique = c(1, 2, 3, 4)))fm_crs_is_null(fm_crs(oblique = c(1, 2, 3, 4)), crsonly = TRUE)fm_crs_is_null(fm_crs(27700, oblique = c(1, 2, 3, 4)))fm_crs_is_null(fm_crs(27700, oblique = c(1, 2, 3, 4)), crsonly = TRUE)

Plot CRS and fm_crs objects

Description

[Experimental] Plot the outline of acrsorfm_crs() projection, with optional graticules (transformed parallelsand meridians) and Tissot indicatrices.

Usage

fm_crs_plot(  x,  xlim = NULL,  ylim = NULL,  outline = TRUE,  graticule = c(15, 15, 45),  tissot = c(30, 30, 30),  asp = 1,  add = FALSE,  eps = 0.05,  ...)fm_crs_graticule(  x,  by = c(15, 15, 45),  add = FALSE,  do.plot = TRUE,  eps = 0.05,  ...)fm_crs_tissot(  x,  by = c(30, 30, 30),  add = FALSE,  do.plot = TRUE,  eps = 0.05,  diff.eps = 0.01,  ...)

Arguments

x

Acrs orfm_crs() object.

xlim

Optional x-axis limits.

ylim

Optional y-axis limits.

outline

Logical, ifTRUE, draw the outline of the projection.

graticule

Vector of length at most 3, to plot meridians with spacinggraticule[1] degrees and parallels with spacinggraticule[2]degrees.graticule[3] optionally specifies the spacing above andbelow the first and last parallel. Whengraticule[1]==0 no meridiansare drawn, and whengraticule[2]==0 no parallels are drawn. Usegraticule=NULL to skip drawing a graticule.

tissot

Vector of length at most 3, to plot Tissot's indicatrices withspacingtissot[1] degrees and parallels with spacingtissot[2]degrees.tissot[3] specifices a scaling factor. Usetissot=NULL to skip drawing a Tissot's indicatrices.

asp

The aspect ratio for the plot, default 1.

add

IfTRUE, add the projecton plot to an existing plot.

eps

Clipping tolerance for rudimentary boundary clipping

...

Additional arguments passed on to the internal calls toplot andlines.

by

The spacing between⁠(long, lat, long_at_poles)⁠graticules/indicatrices, see thegraticule andtissot arguments.

do.plot

logical; If TRUE, do plotting

diff.eps

Pre-scaling

Value

NULL, invisibly

Functions

Author(s)

Finn LindgrenFinn.Lindgren@gmail.com

See Also

fm_crs()

Examples

if (require("sf") && require("sp")) {  for (projtype in c(    "longlat_norm",    "lambert_norm",    "mollweide_norm",    "hammer_norm"  )) {    fm_crs_plot(fm_crs(projtype), main = projtype)  }}if (require("sf") && require("sp")) {  oblique <- c(0, 45, 45, 0)  for (projtype in c(    "longlat_norm",    "lambert_norm",    "mollweide_norm",    "hammer_norm"  )) {    fm_crs_plot(      fm_crs(projtype, oblique = oblique),      main = paste("oblique", projtype)    )  }}

Handling CRS/WKT

Description

Get and set CRS object or WKT string properties.

Usage

fm_wkt_is_geocent(wkt)fm_crs_is_geocent(crs)fm_wkt_get_ellipsoid_radius(wkt)fm_crs_get_ellipsoid_radius(crs)fm_ellipsoid_radius(x)## Default S3 method:fm_ellipsoid_radius(x)## S3 method for class 'character'fm_ellipsoid_radius(x)fm_wkt_set_ellipsoid_radius(wkt, radius)fm_ellipsoid_radius(x) <- value## S3 replacement method for class 'character'fm_ellipsoid_radius(x) <- value## S3 replacement method for class 'CRS'fm_ellipsoid_radius(x) <- value## S3 replacement method for class 'fm_CRS'fm_ellipsoid_radius(x) <- value## S3 replacement method for class 'crs'fm_ellipsoid_radius(x) <- value## S3 replacement method for class 'fm_crs'fm_ellipsoid_radius(x) <- valuefm_crs_set_ellipsoid_radius(crs, radius)fm_wkt_unit_params()fm_wkt_get_lengthunit(wkt)fm_wkt_set_lengthunit(wkt, unit, params = NULL)fm_crs_get_lengthunit(crs)fm_crs_set_lengthunit(crs, unit)fm_length_unit(x)## Default S3 method:fm_length_unit(x)## S3 method for class 'character'fm_length_unit(x)fm_length_unit(x) <- value## S3 replacement method for class 'character'fm_length_unit(x) <- value## S3 replacement method for class 'CRS'fm_length_unit(x) <- value## S3 replacement method for class 'fm_CRS'fm_length_unit(x) <- value## S3 replacement method for class 'crs'fm_length_unit(x) <- value## S3 replacement method for class 'fm_crs'fm_length_unit(x) <- valuefm_wkt(crs)fm_proj4string(crs)fm_wkt_tree_projection_type(wt)fm_wkt_projection_type(wkt)fm_crs_projection_type(crs)fm_crs_bounds(crs, warn.unknown = FALSE)## S3 replacement method for class 'inla.CRS'fm_ellipsoid_radius(x) <- value## S3 replacement method for class 'inla.CRS'fm_length_unit(x) <- value

Arguments

wkt

A WKT2 character string

crs

Ansf::crs,sp::CRS,fm_crs orinla.CRS object

x

crs object to extract value from or assign values in

radius

numeric; The new radius value

value

Value to assign

unit

character, name of a unit. Supported names are"metre", "kilometre", and the aliases "meter", "m", International metre","kilometer", and "km", as defined byfm_wkt_unit_params or theparams argument.

params

Length unit definitions, in the list format produced byfm_wkt_unit_params(), Default: NULL, which invokesfm_wkt_unit_params()

wt

A parsed wkt tree, seefm_wkt_as_wkt_tree()

warn.unknown

logical, defaultFALSE. Produce warning if the shapeof the projection bounds is unknown.

Value

Forfm_wkt_unit_params, alist of named unit definitions

Forfm_wkt_get_lengthunit, alist of length units used in the wkt string, excluding the ellipsoid radiusunit.

Forfm_wkt_set_lengthunit, aWKT2 string with altered length units.Note that the length unit for the ellipsoid radius is unchanged.

Forfm_crs_get_lengthunit, alist of length units used in the wkt string, excluding the ellipsoid radiusunit.

For⁠fm_length_unit<-⁠, a crs object withaltered length units.Note that the length unit for the ellipsoid radius is unchanged.

Functions

Author(s)

Finn LindgrenFinn.Lindgren@gmail.com

See Also

fm_crs()

Examples

c1 <- fm_crs("globe")fm_length_unit(c1)fm_length_unit(c1) <- "m"fm_length_unit(c1)

Detect manifold type

Description

Detect if a 2d object is on "R2", "S2", or "M2"

Usage

fm_detect_manifold(x)fm_crs_detect_manifold(x)## S3 method for class 'crs'fm_detect_manifold(x)## S3 method for class 'CRS'fm_detect_manifold(x)## S3 method for class 'numeric'fm_detect_manifold(x)## S3 method for class 'matrix'fm_detect_manifold(x)## S3 method for class 'fm_mesh_2d'fm_detect_manifold(x)

Arguments

x

Object to investigate

Value

A string containing the detected manifold classification

Functions

Examples

fm_detect_manifold(1:4)fm_detect_manifold(rbind(c(1, 0, 0), c(0, 1, 0), c(1, 1, 0)))fm_detect_manifold(rbind(c(1, 0, 0), c(0, 1, 0), c(0, 0, 1)))

Diameter bound for a geometric object

Description

Find an upper bound to the convex hull of a point set or function space

Usage

fm_diameter(x, ...)## S3 method for class 'matrix'fm_diameter(x, manifold = NULL, ...)## S3 method for class 'sf'fm_diameter(x, ...)## S3 method for class 'sfg'fm_diameter(x, ...)## S3 method for class 'sfc'fm_diameter(x, ...)## S3 method for class 'fm_lattice_2d'fm_diameter(x, ...)## S3 method for class 'fm_mesh_1d'fm_diameter(x, ...)## S3 method for class 'fm_mesh_2d'fm_diameter(x, ...)## S3 method for class 'fm_segm'fm_diameter(x, ...)## S3 method for class 'fm_mesh_3d'fm_diameter(x, ...)## S3 method for class 'fm_tensor'fm_diameter(x, ...)## S3 method for class 'fm_collect'fm_diameter(x, ...)## S3 method for class 'fm_list'fm_diameter(x, ...)

Arguments

x

A point set as ann\times d matrix, or anfm_mesh_2d/⁠1d⁠/sf related object.

...

Additional parameters passed on to the submethods.

manifold

Character string specifying the manifold type. Default formatrix input is to treat the point set with Euclidean\mathbb{R}^d metrics.Usemanifold="S2" for great circle distances on a sphere centred at theorigin.

Value

A scalar, upper bound for the diameter of the convex hull of thepoint set. For multi-domain spaces (e.g.fm_tensor() andfm_collect()), a vector of upper bounds for each domain is returned.

Author(s)

Finn LindgrenFinn.Lindgren@gmail.com

Examples

fm_diameter(matrix(c(0, 1, 1, 0, 0, 0, 1, 1), 4, 2))

Function spece degrees of freedom

Description

Obtain the degrees of freedom of a function space, i.e.the number of basis functions it uses.

Usage

fm_dof(x)## S3 method for class 'fm_mesh_1d'fm_dof(x)## S3 method for class 'fm_mesh_2d'fm_dof(x)## S3 method for class 'fm_mesh_3d'fm_dof(x)## S3 method for class 'fm_tensor'fm_dof(x)## S3 method for class 'fm_collect'fm_dof(x)## S3 method for class 'fm_lattice_2d'fm_dof(x)## S3 method for class 'fm_lattice_Nd'fm_dof(x)

Arguments

x

A function space object, such asfm_mesh_1d() orfm_mesh_2d()

Value

An integer

Examples

fm_dof(fmexample$mesh)

Methods for projecting to/from mesh objects

Description

Calculate evaluation information and/or evaluate a functiondefined on a mesh or function space.

Usage

fm_evaluate(...)## Default S3 method:fm_evaluate(mesh, field, ...)## S3 method for class 'fm_evaluator'fm_evaluate(projector, field, ...)## S3 method for class 'fm_basis'fm_evaluate(basis, field, ...)fm_evaluator(...)## Default S3 method:fm_evaluator(...)## S3 method for class 'fm_mesh_3d'fm_evaluator(mesh, loc = NULL, lattice = NULL, dims = NULL, ...)## S3 method for class 'fm_mesh_2d'fm_evaluator(mesh, loc = NULL, lattice = NULL, crs = NULL, ...)## S3 method for class 'fm_mesh_1d'fm_evaluator(mesh, loc = NULL, xlim = mesh$interval, dims = 100, ...)fm_evaluator_lattice(mesh, ...)## Default S3 method:fm_evaluator_lattice(mesh, dims = 100, ...)## S3 method for class 'fm_bbox'fm_evaluator_lattice(mesh, dims = 100, ...)## S3 method for class 'fm_mesh_2d'fm_evaluator_lattice(  mesh,  xlim = NULL,  ylim = NULL,  dims = c(100, 100),  projection = NULL,  crs = NULL,  ...)

Arguments

...

Additional arguments passed on to methods.

mesh

Anfm_mesh_1d,fm_mesh_2d, or other object supported by asub-method.

field

Basis function weights, one per mesh basis function, describingthe function to be evaluated at the projection locations

projector

Anfm_evaluator object.

basis

Anfm_basis object.

loc

Projection locations. Can be a matrix,SpatialPoints,SpatialPointsDataFrame,sf,sfc, orsfg object.

lattice

Anfm_lattice_2d() object.

dims

Lattice dimensions.

crs

An optional CRS or inla.CRS object associated withlocand/orlattice.

xlim

X-axis limits for a lattice. For R2 meshes, defaults to coveringthe domain.

ylim

Y-axis limits for a lattice. For R2 meshes, defaults to coveringthe domain.

projection

One ofc("default", "longlat", "longsinlat", "mollweide").

Value

A vector or matrix of the evaluated function

Anfm_evaluator object

Methods (by class)

Functions

Author(s)

Finn LindgrenFinn.Lindgren@gmail.com

See Also

fm_mesh_2d(),fm_mesh_1d(),fm_lattice_2d()

Examples

if (TRUE) {  n <- 20  loc <- matrix(runif(n * 2), n, 2)  mesh <- fm_rcdt_2d_inla(loc, refine = list(max.edge = 0.05))  proj <- fm_evaluator(mesh)  field <- cos(mesh$loc[, 1] * 2 * pi * 3) * sin(mesh$loc[, 2] * 2 * pi * 7)  image(proj$x, proj$y, fm_evaluate(proj, field))}# if (require("ggplot2") &&#  require("ggpolypath")) {#  ggplot() +#    gg(data = fm_as_sfc(mesh), col = field)# }

Compute finite element matrices

Description

Compute finite element mass and structure matrices

Usage

fm_fem(mesh, order = 2, ...)## S3 method for class 'fm_mesh_1d'fm_fem(mesh, order = 2, ...)## S3 method for class 'fm_mesh_2d'fm_fem(mesh, order = 2, aniso = NULL, ...)## S3 method for class 'fm_tensor'fm_fem(mesh, order = 2, ...)## S3 method for class 'fm_collect'fm_fem(mesh, order = 2, ...)## S3 method for class 'fm_mesh_3d'fm_fem(mesh, order = 2, ...)

Arguments

mesh

fm_mesh_1d(),fm_mesh_2d(), or other supported mesh classobject

order

integer; the maximum operator order

...

Currently unused

aniso

If non-NULL, alist(gamma, v). Calculates anisotropicstructure matrices (in addition to the regular) for\gamma andv for an anisotropic operator\nabla\cdot H \nabla, whereH=\gamma I + v v^\top. Currently(2023-08-05) the fields need to be given per vertex.

Value

fm_fem.fm_mesh_1d: A list with elementsc0,c1,g1,g2,etc.Whenmesh$degree == 2, alsog01,g02, andg12.

fm_fem.fm_mesh_2d: A list with elementsc0,c1,g1,va,ta, and more iforder > 1. Whenaniso is non-NULL, alsog1anisomatrices, etc.

fm_fem.fm_tensor: A list with elementscc,g1,g2.

fm_fem.fm_collect: A list with elementsc0,c1,g1,g2, etc, andcc (c0 for every model exceptfm_mesh_1d withdegree=2, for which it isc1). If the base type for the collectionprovidesva andta values, those are also returned.

fm_fem.fm_mesh_3d: A list with elementsc0,c1,g1,g2,va,ta, and more iforder > 2.

Examples

names(fm_fem(fm_mesh_1d(1:4), order = 3))names(fm_fem(fmexample$mesh, order = 3))

Generate text RGB color specifications.

Description

Generates a text RGB color specification matrix based on a color palette.

Usage

fm_generate_colors(  color,  color.axis = NULL,  color.n = 512,  color.palette = cm.colors,  color.truncate = FALSE,  alpha = NULL)

Arguments

color

character,matrix orvector

color.axis

The min/max limit values for the color mapping.

color.n

The number of colors to use in the color palette.

color.palette

A color palette function.

color.truncate

IfTRUE, truncate the colors at the color axislimits.

alpha

Transparency/opaqueness values.

Value

A list with character vectorcolors and numeric vectoralpha

Author(s)

Finn LindgrenFinn.Lindgren@gmail.com

Examples

fm_generate_colors(1:4, color.axis = c(1, 4))

SPDE, GMRF, and Matérn process methods

Description

[Experimental]Methods for SPDEs and GMRFs.

Usage

fm_matern_precision(x, alpha, rho, sigma)fm_matern_sample(x, alpha = 2, rho, sigma, n = 1, loc = NULL)fm_covariance(Q, A1 = NULL, A2 = NULL, partial = FALSE)fm_sample(n, Q, mu = 0, constr = NULL)

Arguments

x

A mesh object, e.g. fromfm_mesh_1d(),fm_mesh_2d(), orother object with supportingfm_fem() andfm_manifold_dim() methods.

alpha

The SPDE operator order. The resulting smoothness indexisnu = alpha - dim / 2. Supports integers 1, 2, 3, etc. that givenu > 0.

rho

The Matérn range parameter(scale parameterkappa = sqrt(8 * nu) / rho)

sigma

The nominal Matérn std.dev. parameter

n

The number of samples to generate

loc

locations to evaluate the random field, compatible withfm_evaluate(x, loc = loc, field = ...)

Q

A precision matrix

A1,A2

Matrices, typically obtained fromfm_basis() and/orfm_block().

partial

[Experimental] IfTRUE, compute thepartial inverse ofQ, i.e. the elements of the inverse corresponding tothe non-zero pattern ofQ. (Note: This can be done efficiently withthe Takahashi recursion method, but to avoid an RcppEigen dependency thisis currently disabled, and a slower method is used until the efficient methodis reimplemented.)

mu

Optional mean vector

constr

Optional list of constraint information, with elementsA ande. Should only be used for a small number of exact constraints.

Value

fm_matern_sample() returns a matrix, where each column is asampled field. Ifloc isNULL, thefm_dof(mesh) basis weights aregiven. Otherwise, the evaluated field at thenrow(loc) locationslocare given (from version⁠0.1.4.9001⁠)

Functions

Examples

library(Matrix)mesh <- fm_mesh_1d(-20:120, degree = 2)Q <- fm_matern_precision(mesh, alpha = 2, rho = 15, sigma = 1)x <- seq(0, 100, length.out = 601)A <- fm_basis(mesh, x)plot(x,  as.vector(Matrix::diag(fm_covariance(Q, A))),  type = "l",  ylab = "marginal variances")plot(x,  fm_evaluate(mesh, loc = x, field = fm_sample(1, Q)[, 1]),  type = "l",  ylab = "process sample")

Create hexagon lattice points

Description

[Experimental] from⁠0.3.0.9001⁠. Createhexagon lattice points within a boundary. By default, the hexagonal latticeis anchored at the coordinate system origin, so that grids with differentbut overlapping boundaries will have matching points.

Usage

fm_hexagon_lattice(  bnd,  edge_len = NULL,  buffer_n = 0.49,  align = "origin",  meta = FALSE)

Arguments

bnd

Boundary object (sf polygon or boundaryfm_segm object)

edge_len

Triangle edge length. Defaultdiff(fm_bbox(bnd)[[1]]) / 250.

buffer_n

Number of triangle height multiples for buffer inside theboundary object to the start of the lattice. Default 0.49.

align

Alignment of the hexagon lattice, either a length-2 numeric, orcharacter, asf/sfc/sfg object containing a single point), orcharacter, default"origin":

"origin"

align the lattice with the coordinate system origin

"bbox"

align the lattice with the midpoint of the bounding box ofbnd

"centroid"

align the lattice with the centroid of the boundary,sf::st_centroid(bnd)

meta

logical; ifTRUE, return a list with diagnostic informationfrom the lattice construction (including the points themselves inlattice)

Value

Ansfc object with points, ifmeta isFALSE (default), or ifmeta=TRUE, a list:

lattice

sfc with lattice points

edge_len

numeric with edge length

bnd_inner

sf object with the inner boundary used to filter pointsoutside of aedge_len * buffer_n distance from the boundary

grid_n

integer with the number of points in each direction prior tofiltering

align

numeric with the alignment coordinates of the hexagon lattice

Author(s)

Man Ho SuenM.H.Suen@sms.ed.ac.uk,Finn LindgrenFinn.Lindgren@gmail.com

See Also

fm_mesh_2d()

Examples

(m <- fm_mesh_2d(  fm_hexagon_lattice(    fmexample$boundary_sf[[1]],    edge_len = 0.1 * 5  ),  max.edge = c(0.2, 1) * 5,  boundary = fmexample$boundary_sf))(m2 <- fm_mesh_2d(  fm_hexagon_lattice(    fmexample$boundary_sf[[1]],    edge_len = 0.1 * 5,    align = "centroid"  ),  max.edge = c(0.2, 1) * 5,  boundary = fmexample$boundary_sf))if (require("ggplot2", quietly = TRUE) &&  require("patchwork", quietly = TRUE)) {  ((ggplot() +    geom_fm(data = m) +    geom_point(aes(0, 0), col = "red")) |    (ggplot() +      geom_fm(data = m2) +      geom_point(aes(0, 0), col = "red") +      geom_sf(data = sf::st_centroid(fmexample$boundary_sf[[1]]))    )  )}

Create hexagon lattice points

Description

Create hexagon lattice points within a boundary

Usage

fm_hexagon_lattice_orig(bnd, x_bin = 250, edge_len_n = 1)

Arguments

bnd

Boundary object

x_bin

Number of bins in x axis

edge_len_n

Number of edge length of mesh from the boundary to createhexagon mesh using x_bin

Value

A list with lattice points, edge length, and inner boundary

Author(s)

Man Ho SuenM.H.Suen@sms.ed.ac.uk


Multi-domain integration

Description

Construct integration points on tensor product spaces

Usage

fm_int(domain, samplers = NULL, ...)## S3 method for class 'list'fm_int(domain, samplers = NULL, ..., extra = NULL)## S3 method for class 'numeric'fm_int(domain, samplers = NULL, name = "x", ...)## S3 method for class 'character'fm_int(domain, samplers = NULL, name = "x", ...)## S3 method for class 'factor'fm_int(domain, samplers = NULL, name = "x", ...)## S3 method for class 'SpatRaster'fm_int(domain, samplers = NULL, name = "x", ...)## S3 method for class 'fm_lattice_2d'fm_int(domain, samplers = NULL, name = "x", ...)## S3 method for class 'fm_mesh_1d'fm_int(  domain,  samplers = NULL,  name = "x",  int.args = NULL,  format = NULL,  ...)## S3 method for class 'fm_mesh_2d'fm_int(  domain,  samplers = NULL,  name = NULL,  int.args = NULL,  format = NULL,  ...)

Arguments

domain

Functional space specification; single domain or a named listof domains

samplers

For single domainfm_int methods, an object specifying oneor more subsets of the domain, and optional weighting in aweightvariable. Forfm_int.list, a list of sampling definitions, where dataframe elements may contain information for multiple domains, in which caseeach row represent a separate tensor product integration subspace.

...

Additional arguments passed on to other methods

extra

Optional character vector with names of variables other than theintegration domains to be included from the samplers. IfNULL (default),all additional variables are included.

name

For single-domain methods, the variable name to use for theintegration points. Default 'x'

int.args

List of arguments passed to line and integration methods.

  • method: "stable" (to aggregate integration weights onto mesh nodes)or "direct" (to construct a within triangle/segment integration schemewithout aggregating onto mesh nodes)

  • nsub1,nsub2: integers controlling the number of internal integrationpoints before aggregation. Points per triangle:(nsub2+1)^2.Points per knot segment:nsub1

format

character; determines the output format, as either "sf"(default forfm_mesh_2d when the sampler isNULL),"numeric" (default forfm_mesh_1d), "bary", or "sp".WhenNULL, determined by the domain and sampler types.

Value

Atibble,sf, orSpatialPointsDataFrame of 1Dand 2D integration points, including aweight column, a.block column,and a matrix column.block_origin.The.block column is used to identify the integrationblocks defined by the samplers. The.block_origin collects the originalsubdomain block information for tensor product blocks.

Methods (by class)

Examples

# Integration on the interval (2, 3.5) with Simpson's ruleips <- fm_int(fm_mesh_1d(0:4), samplers = cbind(2, 3.5))plot(ips$x, ips$weight)# Create integration points for the two intervals [0,3] and [5,10]ips <- fm_int(  fm_mesh_1d(0:10),  rbind(c(0, 3), c(5, 10)))plot(ips$x, ips$weight)# Convert a 1D mesh into integration pointsmesh <- fm_mesh_1d(seq(0, 10, by = 1))ips <- fm_int(mesh, name = "time")plot(ips$time, ips$weight)if (require("ggplot2", quietly = TRUE)) {  #' Integrate on a 2D mesh with polygon boundary subset  ips <- fm_int(fmexample$mesh, fmexample$boundary_sf[[1]])  ggplot() +    geom_sf(data = fm_as_sfc(fmexample$mesh, multi = TRUE), alpha = 0.5) +    geom_sf(data = fmexample$boundary_sf[[1]], fill = "red", alpha = 0.5) +    geom_sf(data = ips, aes(size = weight)) +    scale_size_area()}# Individual sampling points:(ips <- fm_int(0:10, c(0, 3, 5, 6, 10)))# Sampling blocks:(ips <- fm_int(0:10, list(c(0, 3), c(5, 6, 10))))# Continuous integration on intervalsips <- fm_int(  fm_mesh_1d(0:10, boundary = "cyclic"),  rbind(c(0, 3), c(5, 10)))plot(ips$x, ips$weight)

Subset integration on a mesh

Description

Integration methods for spatial samplers onfm_mesh_2d meshes.

Usage

fm_int_mesh_2d(samplers, domain, name = NULL, int.args = NULL, ...)fm_int_mesh_2d_NULL(samplers, domain, name = NULL, int.args = NULL, ...)## S3 method for class 'sf'fm_int_mesh_2d(samplers, domain, name = NULL, int.args = NULL, ...)## S3 method for class 'sfc_POINT'fm_int_mesh_2d(  samplers,  domain,  name = NULL,  int.args = NULL,  .weight = rep(1, NROW(samplers)),  ...)## S3 method for class 'sfc_MULTIPOINT'fm_int_mesh_2d(  samplers,  domain,  name = NULL,  int.args = NULL,  .weight = rep(1, NROW(samplers)),  ...)## S3 method for class 'sfc_LINESTRING'fm_int_mesh_2d(  samplers,  domain,  name = NULL,  int.args = NULL,  .weight = rep(1, NROW(samplers)),  ...)## S3 method for class 'sfc_MULTILINESTRING'fm_int_mesh_2d(  samplers,  domain,  name = NULL,  int.args = NULL,  .weight = rep(1, NROW(samplers)),  ...)## S3 method for class 'sfc_POLYGON'fm_int_mesh_2d(  samplers,  domain,  name = NULL,  int.args = NULL,  .weight = rep(1, NROW(samplers)),  ...)## S3 method for class 'sfc_MULTIPOLYGON'fm_int_mesh_2d(  samplers,  domain,  name = NULL,  int.args = NULL,  .weight = rep(1, NROW(samplers)),  ...)## S3 method for class 'sfc_GEOMETRY'fm_int_mesh_2d(  samplers,  domain,  name = NULL,  int.args = NULL,  .weight = rep(1, NROW(samplers)),  ...)## S3 method for class 'Spatial'fm_int_mesh_2d(  samplers,  domain,  name = NULL,  int.args = NULL,  format = NULL,  ...)## S3 method for class 'fm_segm'fm_int_mesh_2d(  samplers,  domain,  name = NULL,  int.args = NULL,  format = NULL,  ...)

Arguments

samplers

For single domainfm_int methods, an object specifying oneor more subsets of the domain, and optional weighting in aweightvariable. Forfm_int.list, a list of sampling definitions, where dataframe elements may contain information for multiple domains, in which caseeach row represent a separate tensor product integration subspace.

domain

Functional space specification; single domain or a named listof domains

name

For single-domain methods, the variable name to use for theintegration points. Default 'x'

int.args

List of arguments passed to line and integration methods.

  • method: "stable" (to aggregate integration weights onto mesh nodes)or "direct" (to construct a within triangle/segment integration schemewithout aggregating onto mesh nodes)

  • nsub1,nsub2: integers controlling the number of internal integrationpoints before aggregation. Points per triangle:(nsub2+1)^2.Points per knot segment:nsub1

...

Additional arguments passed on to other methods

format

character; determines the output format, as either "sf"(default forfm_mesh_2d when the sampler isNULL),"numeric" (default forfm_mesh_1d), "bary", or "sp".WhenNULL, determined by the domain and sampler types.

Value

Alist,sf, orSpatial object withpoint coordinate information and additional columnsweight and.block

Methods (by class)

Functions

Examples

str(fm_int_mesh_2d(samplers = NULL, domain = fmexample$mesh))

Integration scheme for mesh triangle interiors

Description

Integration scheme for mesh triangle interiors

Usage

fm_int_mesh_2d_core(mesh, tri_subset = NULL, nsub = NULL)

Arguments

mesh

Mesh on which to integrate

tri_subset

Optional triangle index vector for integration on a subsetof the mesh triangles (DefaultNULL)

nsub

number of subdivision points along each triangle edge, giving(nsub + 1)^2 proto-integration points used to computethe vertex weights(defaultnsub=9, giving 100 integration points for each triangle)

Value

tibble with columnsloc andweight withintegration points for the mesh

Author(s)

Finn LindgrenFinn.Lindgren@gmail.com

Examples

str(fm_int_mesh_2d_core(fmexample$mesh))

Multi-domain sampler integration

Description

Combine integration over different domains

Usage

fm_int_multi_sampler(domain, samplers, ..., extra = NULL)

Arguments

domain

A list of named domains

samplers

A named list of samplers

...

Passed on to eachfm_int() call.

extra

Optional character vector with names of variables other than theintegration domains to be included from the samplers. IfNULL (default),all additional variables are included.

Value

An object with integration points and weights

Examples

fm_int_multi_sampler(  domain = list(x = fm_mesh_1d(1:4), y = 11:12),  samplers = tibble::tibble(    x = rbind(c(1, 3), c(2, 4)),    y = c(12, 11)  ))

Query if points are inside a mesh

Description

Queries whether each input point is within a mesh or not.

Usage

fm_is_within(x, y, ...)

Arguments

x

A set of points/locations of a class supported byfm_basis(y, loc = x, ..., full = TRUE)

y

Anfm_mesh_2d or other class supported byfm_basis(y, loc = x, ..., full = TRUE)

...

Passed on tofm_basis()

Value

A logical vector

Examples

all(fm_is_within(fmexample$loc, fmexample$mesh))

Make a lattice object

Description

Construct a lattice grid forfm_mesh_2d()

Usage

fm_lattice_2d(...)## Default S3 method:fm_lattice_2d(  x = seq(0, 1, length.out = 2),  y = seq(0, 1, length.out = 2),  z = NULL,  dims = if (is.matrix(x)) {     dim(x) } else {     c(length(x), length(y)) },  units = NULL,  crs = NULL,  ...)

Arguments

...

Passed on to submethods

x

vector or grid matrix of x-values. Vector values are sorted beforeuse. Matrix input is assumed to be a grid of x-values with the sameordering convention ofas.vector(x) asrep(x, times = dims[2]) forvector input.

y

vector of grid matrix of y-values. Vector values are sorted beforeuse. Matrix input is assumed to be a grid of y-values with the sameordering convention ofas.vector(y) asrep(y, each = dims[1]) forvector input.

z

if x is a matrix, a grid matrix of z-values, with the same orderingasx andy. Ifx is a vector,z is ignored.

dims

the size of the grid, length 2 vector

units

One ofc("default", "longlat", "longsinlat", "mollweide")or NULL (equivalent to"default").

crs

An optionalfm_crs,sf::st_crs, orsp::CRS object,denoting the CRS info for the x-y grid.

Value

Anfm_lattice_2d object with elements

dims

integer vector

x

x-values for original vector input

y

y-values for original vector input

loc

matrix of⁠(x, y)⁠ values or⁠(x, y, z)⁠ values. May be altered byfm_transform()

segm

fm_segm object

crs

fm_crs object forloc, orNULL

crs0

fm_crs object for⁠(x,y)⁠, orNULL

Author(s)

Finn LindgrenFinn.Lindgren@gmail.com

See Also

fm_mesh_2d()

Other object creation and conversion:fm_as_collect(),fm_as_fm(),fm_as_lattice_2d(),fm_as_lattice_Nd(),fm_as_mesh_1d(),fm_as_mesh_2d(),fm_as_mesh_3d(),fm_as_segm(),fm_as_sfc(),fm_as_tensor(),fm_collect(),fm_lattice_Nd(),fm_mesh_1d(),fm_mesh_2d(),fm_segm(),fm_simplify(),fm_tensor()

Examples

lattice <- fm_lattice_2d(  seq(0, 1, length.out = 17),  seq(0, 1, length.out = 10))## Use the lattice "as-is", without refinement:mesh <- fm_rcdt_2d_inla(lattice = lattice, boundary = lattice$segm)mesh <- fm_rcdt_2d_inla(lattice = lattice, extend = FALSE)## Refine the triangulation, with limits on triangle angles and edges:mesh <- fm_rcdt_2d(  lattice = lattice,  refine = list(max.edge = 0.08),  extend = FALSE)## Add an extension around the lattice, but maintain the lattice edges:mesh <- fm_rcdt_2d(  lattice = lattice,  refine = list(max.edge = 0.08),  interior = lattice$segm)## Only add extension:mesh <- fm_rcdt_2d(lattice = lattice, refine = list(max.edge = 0.08))

Lattice grids for N dimensions

Description

Construct an N-dimensional lattice grid

Usage

fm_lattice_Nd(x = NULL, ...)## S3 method for class 'matrix'fm_lattice_Nd(x = NULL, dims = NULL, values = NULL, ...)## S3 method for class 'data.frame'fm_lattice_Nd(x = NULL, ...)## S3 method for class 'list'fm_lattice_Nd(x = NULL, dims = NULL, ...)## S3 method for class 'fm_bbox'fm_lattice_Nd(x = NULL, dims = NULL, ...)## S3 method for class ''NULL''fm_lattice_Nd(x = NULL, ..., dims = NULL)

Arguments

x

list,data.frame,matrix,fm_bbox orNULL. If a list ofvectors,as.matrix(expand.grid(x)) is used to create a full gridcoordinates.data.frame andmatrix input is assumed to follow the sameordering convention as the output ofexpand.grid(). of length N ofvectors or grid matrices of coordinate values. List vector values aresorted before use.

...

Passed on to submethods

dims

numeric; the size of the grid of dimensionlength(dims)

values

list of grid axis values

Value

Anfm_lattice_Nd object with elements

dims

integer vector

values

the grid coordinate axis values

loc

matrix of constructed grid coordinates

Methods (by class)

Author(s)

Finn LindgrenFinn.Lindgren@gmail.com

See Also

fm_mesh_3d()

Other object creation and conversion:fm_as_collect(),fm_as_fm(),fm_as_lattice_2d(),fm_as_lattice_Nd(),fm_as_mesh_1d(),fm_as_mesh_2d(),fm_as_mesh_3d(),fm_as_segm(),fm_as_sfc(),fm_as_tensor(),fm_collect(),fm_lattice_2d(),fm_mesh_1d(),fm_mesh_2d(),fm_segm(),fm_simplify(),fm_tensor()

Examples

(lattice <- fm_lattice_Nd(  list(    seq(0, 1, length.out = 3),    seq(0, 1, length.out = 4),    seq(0, 1, length.out = 2)  )))if (requireNamespace("geometry", quietly = TRUE)) {  (mesh <- fm_delaunay_3d(lattice$loc))}

Handle lists of fmesher objects

Description

Methods for constructing and manipulatingfm_list objects.

Usage

fm_list(x, ..., .class_stub = NULL)fm_as_list(x, ..., .class_stub = NULL)## S3 method for class 'fm_list'c(...)## S3 method for class 'fm_list'x[i]

Arguments

x

fm_list object from which to extract element(s)

...

Arguments passed to each individual conversion call.

.class_stub

character; class stub name of class to convert each listelement to. IfNULL, usesfm_as_fm and auto-detects if the resultinglist has consistent class, and then adds that to the class list. Ifnon-null, usespaste0("fm_as_", .class_stub) for conversion, and verifiesthat the resulting list has elements consistent with that class.

i

indices specifying elements to extract

Value

Anfm_list object, potentially with⁠fm_{class_stub}_list⁠added.

Methods (by generic)

Functions

Examples

fm_as_list(list(fmexample$mesh, fm_segm_join(fmexample$boundary_fm)))

Query the mesh manifold type

Description

Extract a manifold definition string, or a logical for matchingmanifold type

Usage

fm_manifold(x, type = NULL)fm_manifold_get(x)## Default S3 method:fm_manifold_get(x)## S3 method for class 'character'fm_manifold_get(x)## S3 method for class 'fm_lattice_2d'fm_manifold_get(x)## S3 method for class 'fm_lattice_Nd'fm_manifold_get(x)fm_manifold_type(x)fm_manifold_dim(x)

Arguments

x

An object withmanifold information, or a character string

type

character; ifNULL (the default), returns the manifolddefinition string by callingfm_manifold_get(x).Ifcharacter, returnsTRUE if the manifold type ofx matches at leastone of the character vector elements.

Value

fm_manifold(): Either logical (matching manifold type yes/no),or character (the stored manifold, whenis.null(type) isTRUE)

fm_manifold_get():character orNULL

fm_manifold_type(): character or NULL; "M" (curved manifold),"R" (flat space), "S" (generalised spherical space), "T"(general tensor product space), or "G" (metric graph)

fm_manifold_dim(): integer or NULL

Functions

Examples

fm_manifold_get(fmexample$mesh)fm_manifold(fmexample$mesh)fm_manifold(fmexample$mesh, "R2")fm_manifold_type(fmexample$mesh)fm_manifold_dim(fmexample$mesh)

Make a 1D mesh object

Description

Create afm_mesh_1d object.

Usage

fm_mesh_1d(  loc,  interval = range(loc),  boundary = NULL,  degree = 1,  free.clamped = FALSE,  ...)

Arguments

loc

B-spline knot locations.

interval

Interval domain endpoints.

boundary

Boundary condition specification. Valid conditions arec('neumann', 'dirichlet', 'free', 'cyclic'). Two separate values canbe specified, one applied to each endpoint.

degree

The B-spline basis degree. Supported values are 0, 1, and 2.

free.clamped

IfTRUE, for'free' boundaries, clamp thebasis functions to the interval endpoints.

...

Additional options, currently unused.

Value

Anfm_mesh_1d object

Author(s)

Finn LindgrenFinn.Lindgren@gmail.com

See Also

Other object creation and conversion:fm_as_collect(),fm_as_fm(),fm_as_lattice_2d(),fm_as_lattice_Nd(),fm_as_mesh_1d(),fm_as_mesh_2d(),fm_as_mesh_3d(),fm_as_segm(),fm_as_sfc(),fm_as_tensor(),fm_collect(),fm_lattice_2d(),fm_lattice_Nd(),fm_mesh_2d(),fm_segm(),fm_simplify(),fm_tensor()

Examples

if (require("ggplot2")) {  m1 <- fm_mesh_1d(c(1, 2, 3, 5, 8, 10),    boundary = c("neumann", "free")  )  weights <- c(2, 3, 6, 3, 4, 7)  ggplot() +    geom_fm(data = m1, xlim = c(0.5, 11), weights = weights)  m2 <- fm_mesh_1d(c(1, 2, 3, 5, 8, 10),    boundary = c("neumann", "free"),    degree = 2  )  ggplot() +    geom_fm(data = m2, xlim = c(0.5, 11), weights = weights)  # The knot interpretation is different for degree=2 and degree=1 meshes:  ggplot() +    geom_fm(data = m1, xlim = c(0.5, 11), weights = weights) +    geom_fm(data = m2, xlim = c(0.5, 11), weights = weights)  # The `mid` values are the representative basis function midpoints,  # and can be used to connect degree=2 and degree=1 mesh interpretations:  m1b <- fm_mesh_1d(m2$mid,    boundary = c("neumann", "free"),    degree = 1  )  ggplot() +    geom_fm(data = m2, xlim = c(0.5, 11), weights = weights) +    geom_fm(data = m1b, xlim = c(0.5, 11), weights = weights)}

Make a 2D mesh object

Description

Make a 2D mesh object

Usage

fm_mesh_2d(...)fm_mesh_2d_inla(  loc = NULL,  loc.domain = NULL,  offset = NULL,  n = NULL,  boundary = NULL,  interior = NULL,  max.edge = NULL,  min.angle = NULL,  cutoff = 1e-12,  max.n.strict = NULL,  max.n = NULL,  plot.delay = NULL,  crs = NULL,  ...)

Arguments

...

Currently passed on tofm_mesh_2d_inla

loc

Matrix of point locations to be used as initial triangulationnodes. Can alternatively be asf,sfc,SpatialPoints orSpatialPointsDataFrame object.

loc.domain

Matrix of point locations used to determine the domainextent. Can alternatively be aSpatialPoints orSpatialPointsDataFrame object.

offset

The automatic extension distance. One or two values, for aninner and an optional outer extension. If negative, interpreted as a factorrelative to the approximate data diameter (default=-0.10???)

n

The number of initial nodes in the automatic extensions(default=16)

boundary

one or more (as list) offm_segm() objects, or objectssupported byfm_as_segm()

interior

one object supported byfm_as_segm(), or (from version⁠0.2.0.9016⁠) a list of such objects. If a list, the objects are joinedinto a single object.

max.edge

The largest allowed triangle edge length. One or twovalues.

min.angle

The smallest allowed triangle angle. One or two values.(Default=21)

cutoff

The minimum allowed distance between points. Point at most asfar apart as this are replaced by a single vertex prior to the meshrefinement step.

max.n.strict

The maximum number of vertices allowed, overridingmin.angle andmax.edge (default=-1, meaning no limit). One ortwo values, where the second value gives the number of additional verticesallowed for the extension.

max.n

The maximum number of vertices allowed, overridingmax.edge only (default=-1, meaning no limit). One or two values,where the second value gives the number of additional vertices allowed forthe extension.

plot.delay

If logicalTRUE or a negative numeric value,activates displaying theresult after each step of the multi-step domain extension algorithm.

crs

An optionalfm_crs(),sf::crs orsp::CRS object

Value

Anfm_mesh_2d object.

Functions

INLA compatibility

For mesh and curve creation, thefm_rcdt_2d_inla(),fm_mesh_2d_inla(),andfm_nonconvex_hull_inla() methods will keep the interface syntax used byINLA::inla.mesh.create(),INLA::inla.mesh.2d(), andINLA::inla.nonconvex.hull() functions, respectively, whereas thefm_rcdt_2d(),fm_mesh_2d(), andfm_nonconvex_hull() interfaces may bedifferent, and potentially change in the future.

Author(s)

Finn LindgrenFinn.Lindgren@gmail.com

See Also

fm_rcdt_2d(),fm_mesh_2d(),fm_delaunay_2d(),fm_nonconvex_hull(),fm_extensions(),fm_refine()

Other object creation and conversion:fm_as_collect(),fm_as_fm(),fm_as_lattice_2d(),fm_as_lattice_Nd(),fm_as_mesh_1d(),fm_as_mesh_2d(),fm_as_mesh_3d(),fm_as_segm(),fm_as_sfc(),fm_as_tensor(),fm_collect(),fm_lattice_2d(),fm_lattice_Nd(),fm_mesh_1d(),fm_segm(),fm_simplify(),fm_tensor()

Examples

fm_mesh_2d_inla(boundary = fm_extensions(cbind(2, 1), convex = 1, 2))

Special coordinate mappings forfm_mesh_2d projections.

Description

Calculates coordinate mappings for sphericalfm_mesh_2d projections.This is an internal function not intended for general use.

Usage

fm_mesh_2d_map(loc, projection = NULL, inverse = TRUE)fm_mesh_2d_map_lim(loc = NULL, projection = NULL)

Arguments

loc

Coordinates to be mapped.

projection

The projection type. One ofNULL,"default", "longlat", "longsinlat", or "mollweide".

inverse

IfTRUE,loc are map coordinates andcoordinates in the spherical domain are calculated. IfFALSE,locare coordinates in the spherical domain and the forward map projection iscalculated. Default:TRUE

Value

Forfm_mesh_2d_map_lim, a list:

xlim

X axis limits in the map domain

ylim

Y axis limits in the map domain

No attempt ismade to find minimal limits for partial spherical domains.

Functions

Author(s)

Finn LindgrenFinn.Lindgren@gmail.com

See Also

fm_evaluator()

Examples

(loc <- fm_mesh_2d_map(cbind(20, 10), "longlat"))fm_mesh_2d_map(loc, "longlat", inverse = FALSE)

Construct a 3D tetrahedralisation

Description

Constructs a 3D tetrahedralisation object.

Usage

fm_mesh_3d(loc = NULL, tv = NULL, ...)fm_delaunay_3d(loc, ...)

Arguments

loc

Input coordinates that should be part of the mesh. Can be amatrix,sf,sfc,SpatialPoints, or other object supported byfm_unify_coords().

tv

Tetrahedron indices, as a N-by-4 index vector intoloc

...

Currently unused.

Value

Anfm_mesh_3d object

Functions

Examples

(m <- fm_mesh_3d(  matrix(c(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0), 4, 3, byrow = TRUE),  matrix(c(1, 2, 3, 4), 1, 4, byrow = TRUE)))(m <- fm_delaunay_3d(matrix(rnorm(30), 10, 3)))

Construct the intersection mesh of a mesh and a polygon

Description

[Experimental] (from version⁠0.5.0.9006⁠)

Usage

fm_mesh_intersection(mesh, poly)

Arguments

mesh

fm_mesh_2d object to be intersected

poly

fm_segm object with a closed polygon to intersect with themesh, or a polygon object that can be converted withfm_as_segm()

Value

Anfm_mesh_2d object

Author(s)

Finn LindgrenFinn.Lindgren@gmail.com

Examples

segm <- fm_segm(  rbind(c(-4, -4), c(4, -3), c(0, 4)),  is.bnd = TRUE)(m <- fm_mesh_intersection(fmexample$mesh, segm))plot(fmexample$mesh)lines(segm, col = 4)plot(m, edge.color = 2, add = TRUE)# Non-overlapping additionsegm2 <- fm_segm(c(  segm,  fm_segm(    rbind(c(-4, 0), c(-3, 0), c(-2, 2)),    is.bnd = TRUE  )))(m2 <- fm_mesh_intersection(fm_subdivide(fmexample$mesh, 2), segm2))m2_int <- fm_int(m2)plot(m2, edge.color = 2)lines(segm2, col = 4)plot(fmexample$mesh, edge.color = 1, add = TRUE)plot(m2_int$geometry, pch = 20, cex = sqrt(m2_int$weight) * 4, add = TRUE)# Add a hole and restrict to inner part of the original mesh# To avoid issues with intersecting boundary segments, compute# two separate intersection calculations in sequence.# To allow this to be done as a single step, would need to first# cross-intersect the boundary segments.inner_bnd <- fm_segm(fmexample$mesh, boundary = FALSE)fm_is_bnd(inner_bnd) <- TRUEsegm3 <- fm_segm(c(  segm2,  fm_segm(    rbind(c(-1.5, 0), c(1, -0.5), c(0, -1.5)),    is.bnd = TRUE  )))(m3 <- fm_mesh_intersection(  fm_mesh_intersection(    fm_subdivide(fmexample$mesh, 2),    inner_bnd  ),  segm3))m3_int <- fm_int(m3)plot(fmexample$mesh)plot(m3, edge.color = 2, add = TRUE)lines(segm3, col = 4)plot(m3_int$geometry, pch = 20, cex = sqrt(m3_int$weight) * 4, add = TRUE)# Spherical mesh(m_s2 <- fm_rcdt_2d(globe = 4))segm4 <- fm_segm(  rbind(    c(1, 0, 0.1) / sqrt(1.01),    c(0, 1, 0),    c(-1, -1, 1) / sqrt(3)  ),  is.bnd = TRUE)(m4 <- fm_mesh_intersection(fm_subdivide(m_s2, 1), segm4))m4_int <- fm_int(m4)plot(m_s2)plot(m4, edge.color = 2, add = TRUE)plot(m4_int$geometry, pch = 20, cex = sqrt(m4_int$weight) * 8, add = TRUE)

Compute an extension of a spatial object

Description

Constructs a potentially nonconvex extension of a spatial object byperforming dilation byconvex + concave followed byerosion byconcave. This is equivalent to dilation byconvex followedby closing (dilation + erosion) byconcave.

Usage

fm_nonconvex_hull(x, ..., format = "sf", method = "fm")fm_extensions(  x,  convex = -0.15,  concave = convex,  ...,  format = "sf",  method = "fm")fm_nonconvex_hull_fm(  x,  convex = -0.15,  concave = convex,  resolution = 40,  eps = NULL,  eps_rel = NULL,  crs = fm_crs(x),  ...)fm_nonconvex_hull_sf(  x,  convex = -0.15,  concave = convex,  preserveTopology = TRUE,  dTolerance = NULL,  crs = fm_crs(x),  ...)## S3 method for class 'sfc'fm_nonconvex_hull(x, ..., format = "sf", method = "fm")## S3 method for class 'matrix'fm_nonconvex_hull(x, ..., format = "sf", method = "fm")## S3 method for class 'sf'fm_nonconvex_hull(x, ..., format = "sf", method = "fm")## S3 method for class 'Spatial'fm_nonconvex_hull(x, ..., format = "sf", method = "fm")## S3 method for class 'sfg'fm_nonconvex_hull(x, ..., format = "sf", method = "fm")## S3 method for class 'fm_segm'fm_nonconvex_hull(x, ..., format = "sf", method = "fm")## S3 method for class 'fm_segm_list'fm_nonconvex_hull(x, ..., format = "sf", method = "fm")

Arguments

x

A spatial object

...

Arguments passed on to thefm_nonconvex_hull() sub-methods

format

character specifying the output format; "sf" (default) or "fm"

method

character specifying the construction method; "fm" (default)or "sf"

convex

numeric vector; How much to extend

concave

numeric vector; The minimum allowed reentrant curvature.Default equal toconvex

resolution

integer; The internal computation resolution. A warningwill be issued when this needs to be increased for higher accuracy, withthe required resolution stated. Formethod="fm" only.

eps,eps_rel

The polygonal curve simplification tolerances used forsimplifying the resulting boundary curve. Seefm_simplify_helper() fordetails. Formethod="fm" only.

crs

Optional crs object for the resulting polygon. Default isfm_crs(x)

preserveTopology

logical; argument tosf::st_simplify()(formethod="sf" only)

dTolerance

If not zero, controls thedTolerance argument tosf::st_simplify(). The default ispmin(convex, concave) / 40, chosen togive approximately 4 or more subsegments per circular quadrant.(formethod="sf" only)

Details

Morphological dilation byconvex, followed by closing byconcave, with minimum concave curvature radiusconcave. Ifthe dilated set has no gaps of width between

2 \textrm{convex}(\sqrt{1+2\textrm{concave}/\textrm{convex}} - 1)

and2\textrm{concave}, then the minimum convex curvatureradius isconvex.

The implementation is based on the identity

\textrm{dilation}(a) \&\textrm{closing}(b) = \textrm{dilation}(a+b) \& \textrm{erosion}(b)

where all operationsare with respect to disks with the specified radii.

Whenconvex,concave, ordTolerance are negative,fm_diameter * abs(...) is used instead.

Value

fm_nonconvex_hull() returns an extended object as ansfc polygonobject (ifformat = "sf") or anfm_segm object (if 'format = "fm")

fm_extensions() returns a list ofsfc objects.

Functions

INLA compatibility

For mesh and curve creation, thefm_rcdt_2d_inla(),fm_mesh_2d_inla(),andfm_nonconvex_hull_inla() methods will keep the interface syntax used byINLA::inla.mesh.create(),INLA::inla.mesh.2d(), andINLA::inla.nonconvex.hull() functions, respectively, whereas thefm_rcdt_2d(),fm_mesh_2d(), andfm_nonconvex_hull() interfaces may bedifferent, and potentially change in the future.

References

Gonzalez and Woods (1992), Digital Image Processing

See Also

fm_nonconvex_hull_inla()

Examples

inp <- matrix(rnorm(20), 10, 2)out <- fm_nonconvex_hull(inp, convex = 1, method = "sf")plot(out)points(inp, pch = 20)out <- fm_nonconvex_hull(inp, convex = 1, method = "fm", format = "fm")lines(out, col = 2, add = TRUE)if (TRUE) {  inp <- sf::st_as_sf(as.data.frame(matrix(1:6, 3, 2)), coords = 1:2)  bnd <- fm_extensions(inp, convex = c(0.75, 2))  plot(fm_mesh_2d(boundary = bnd, max.edge = c(0.25, 1)), asp = 1)}

Non-convex hull computation

Description

[Deprecated]Legacy method forINLA::inla.nonconvex.hull().Usefm_nonconvex_hull() withmethod = "fm" instead, witheitherformat = "fm" (for compatibility with codeexpectingfm_segm output) orformat = "sf".

Usage

fm_nonconvex_hull_inla(  x,  convex = -0.15,  concave = convex,  resolution = 40,  eps = NULL,  eps_rel = NULL,  crs = NULL,  ...)fm_nonconvex_hull_inla_basic(  x,  convex = -0.15,  resolution = 40,  eps = NULL,  crs = fm_crs(x))

Arguments

x

A spatial object

convex

numeric vector; How much to extend

concave

numeric vector; The minimum allowed reentrant curvature.Default equal toconvex

resolution

integer; The internal computation resolution. A warningwill be issued when this needs to be increased for higher accuracy, withthe required resolution stated. Formethod="fm" only.

eps,eps_rel

The polygonal curve simplification tolerances used forsimplifying the resulting boundary curve. Seefm_simplify_helper() fordetails. Formethod="fm" only.

crs

Optional crs object for the resulting polygon. Default isfm_crs(x)

...

Unused.

Value

fm_nonconvex_hull_inla() returns anfm_segmobject, for compatibility withinla.nonconvex.hull().

Functions

INLA compatibility

For mesh and curve creation, thefm_rcdt_2d_inla(),fm_mesh_2d_inla(),andfm_nonconvex_hull_inla() methods will keep the interface syntax used byINLA::inla.mesh.create(),INLA::inla.mesh.2d(), andINLA::inla.nonconvex.hull() functions, respectively, whereas thefm_rcdt_2d(),fm_mesh_2d(), andfm_nonconvex_hull() interfaces may bedifferent, and potentially change in the future.

See Also

fm_nonconvex_hull()

Other nonconvex inla legacy support:fm_segm_contour_helper(),fm_simplify_helper()

Examples

# New preferred method for "fm_segm" output:fm_nonconvex_hull(cbind(0, 0), convex = 1, format = "fm")# Deprecated:suppressWarnings(  fm_nonconvex_hull_inla(cbind(0, 0), convex = 1))

Generate lattice points covering a mesh

Description

Generateterra,sf, orsp lattice locations

Usage

fm_pixels(  mesh,  dims = c(150, 150),  xlim = NULL,  ylim = NULL,  mask = TRUE,  format = "sf",  minimal = TRUE)

Arguments

mesh

Anfm_mesh_2d object

dims

A length 2 integer vector giving the dimensions ofthe target lattice.

xlim,ylim

Length 2 numeric vectors of x- and y- axis limits.Defaults taken from the range of the mesh or mask; seeminimal.

mask

If logical and TRUE, remove pixels that are outside the mesh.Ifmask is ansf orSpatial object, only return pixels covered by thisobject.

format

character; "sf", "terra" or "sp"

minimal

logical; ifTRUE (default), the default range is determinedby the minimum of the ranges of the mesh and mask, otherwise only the mesh.

Value

sf,SpatRaster, orSpatialPixelsDataFrame covering the mesh ormask.

Author(s)

Finn LindgrenFinn.Lindgren@gmail.com

Examples

if (require("ggplot2", quietly = TRUE)) {  dims <- c(50, 50)  pxl <- fm_pixels(    fmexample$mesh,    dims = dims,    mask = fmexample$boundary_sf[[1]],    minimal = TRUE  )  pxl$val <- rnorm(NROW(pxl)) +    fm_evaluate(fmexample$mesh, pxl, field = 2 * fmexample$mesh$loc[, 1])  ggplot() +    geom_tile(      data = pxl,      aes(geometry = geometry, fill = val),      stat = "sf_coordinates"    ) +    geom_sf(data = fm_as_sfc(fmexample$mesh), alpha = 0.2)}if (require("ggplot2", quietly = TRUE) &&  require("terra", quietly = TRUE) &&  require("tidyterra", quietly = TRUE)) {  pxl <- fm_pixels(fmexample$mesh,    dims = c(50, 50), mask = fmexample$boundary_sf[[1]],    format = "terra"  )  pxl$val <- rnorm(NROW(pxl) * NCOL(pxl))  pxl <-    terra::mask(      pxl,      mask = pxl$.mask,      maskvalues = c(FALSE, NA),      updatevalue = NA    )  ggplot() +    geom_spatraster(data = pxl, aes(fill = val)) +    geom_sf(data = fm_as_sfc(fmexample$mesh), alpha = 0.2)}

Sparse partial inverse

Description

Compute sparse partial matrix inverse. As of⁠0.2.0.9010⁠, an Rimplementation of the Takahashi recursion method, unless a special build ofthefmesher package is used.

Usage

fm_qinv(A)

Arguments

A

A sparse symmetric positive definite matrix

Value

A sparse symmetric matrix, with the elements of the inverse ofAfor the non-zero pattern ofA plus potential Cholesky in-fill locations.

Examples

A <- Matrix::Matrix(  c(2, -1, 0, 0, -1, 2, -1, 0, 0, -1, 2, -1, 0, 0, -1, 2),  4,  4)# Partial inverse:(S <- fm_qinv(A))# Full inverse (not guaranteed to be symmetric):(S2 <- solve(A))# Matrix symmetry:c(sum((S - Matrix::t(S))^2), sum((S2 - Matrix::t(S2))^2))# Accuracy (not that S2 is non-symmetric, and S may be more accurate):sum((S - S2)[S != 0]^2)

Basis functions for mesh manifolds

Description

Calculate basis functions onfm_mesh_1d() orfm_mesh_2d(),without necessarily matching the default function space of the given meshobject.

Usage

fm_raw_basis(  mesh,  type = "b.spline",  n = 3,  degree = 2,  knot.placement = "uniform.area",  rot.inv = TRUE,  boundary = "free",  free.clamped = TRUE,  ...)

Arguments

mesh

Anfm_mesh_1d() orfm_mesh_2d() object.

type

b.spline (default) for B-spline basis functions,sph.harm for spherical harmonics (available only for meshes on thesphere)

n

For B-splines, the number of basis functions in each direction (for1d meshesn must be a scalar, and for planar 2d meshes a 2-vector).For spherical harmonics,n is the maximal harmonic order.

degree

Degree of B-spline polynomials. Seefm_mesh_1d().

knot.placement

For B-splines on the sphere, controls the latitudinalplacements of knots."uniform.area" (default) gives uniform spacinginsin(latitude),"uniform.latitude" gives uniform spacing inlatitudes.

rot.inv

For spherical harmonics on a sphere,rot.inv=TRUEgives the rotationally invariant subset of basis functions.

boundary

Boundary specification, default is free boundaries. Seefm_mesh_1d() for more information.

free.clamped

IfTRUE andboundary is"free", theboundary basis functions are clamped to 0/1 at the interval boundary byrepeating the boundary knots. Seefm_mesh_1d() for more information.

...

Unused

Value

A matrix with evaluated basis function

Author(s)

Finn LindgrenFinn.Lindgren@gmail.com

See Also

fm_mesh_1d(),fm_mesh_2d(),fm_basis()

Examples

loc <- rbind(c(0, 0), c(1, 0), c(1, 1), c(0, 1))mesh <- fm_mesh_2d(loc, max.edge = 0.15)basis <- fm_raw_basis(mesh, n = c(4, 5))proj <- fm_evaluator(mesh, dims = c(10, 10))image(proj$x, proj$y, fm_evaluate(proj, basis[, 7]), asp = 1)if (interactive() && require("rgl")) {  plot_rgl(mesh, col = basis[, 7], draw.edges = FALSE, draw.vertices = FALSE)}

Refined Constrained Delaunay Triangulation

Description

Computes a refined constrained Delaunay triangulation on R2 or S2.

Usage

fm_rcdt_2d(...)fm_rcdt_2d_inla(  loc = NULL,  tv = NULL,  boundary = NULL,  interior = NULL,  extend = (missing(tv) || is.null(tv)),  refine = FALSE,  lattice = NULL,  globe = NULL,  cutoff = 1e-12,  quality.spec = NULL,  crs = NULL,  delaunay = TRUE,  ...)fm_delaunay_2d(loc, crs = NULL, ...)

Arguments

...

Currently passed on tofm_mesh_2d_inla or converted tofmesher_rcdt() options.

loc

Input coordinates that should be part of the mesh. Can be amatrix,sf,sfc,SpatialPoints, or other object supported byfm_unify_coords().

tv

Initial triangulation, as a N-by-3 index vector intoloc

boundary,interior

Objects supported byfm_as_segm().Ifboundary isnumeric,fm_nonconvex_hull(loc, convex = boundary) isused.

extend

logical orlist specifying whether to extend thedata region, with parameters

list("n")

the number of edgesin the extended boundary (default=16)

list("offset")

the extensiondistance. If negative, interpreted as a factor relative to the approximatedata diameter (default=-0.10)

Setting toFALSE is only useful incombinationlattice orboundary.

refine

logical orlist specifying whether to refine thetriangulation, with parameters

list("min.angle")

theminimum allowed interior angle in any triangle. The algorithm is guaranteedto converge formin.angle at most 21 (default=21)

list("max.edge")

the maximum allowed edge length in any triangle. Ifnegative, interpreted as a relative factor in an ad hoc formula depending onthe data density (default=Inf)

list("max.n.strict")

themaximum number of vertices allowed, overridingmin.angle andmax.edge (default=-1, meaning no limit)

list("max.n")

themaximum number of vertices allowed, overridingmax.edge only(default=-1, meaning no limit)

lattice

Anfm_lattice_2d object, generated byfm_lattice_2d(), specifying points on a regular lattice.

globe

If non-NULL, an integer specifying the level of subdivisionfor global mesh points, used withfmesher_globe_points()

cutoff

The minimum allowed distance between points. Point at most asfar apart as this are replaced by a single vertex prior to the meshrefinement step.

quality.spec

List of vectors of per vertexmax.edge targetspecification for each location inloc,boundary/interior(segm), andlattice. Only used if refining the mesh.

crs

Optional crs object

delaunay

logical; IfFALSE,refine isFALSE, and a ready-mademesh is provided, only creates the mesh data structure. DefaultTRUE, forensuring a Delaunay triangulation.

Value

Anfm_mesh_2d object

Functions

INLA compatibility

For mesh and curve creation, thefm_rcdt_2d_inla(),fm_mesh_2d_inla(),andfm_nonconvex_hull_inla() methods will keep the interface syntax used byINLA::inla.mesh.create(),INLA::inla.mesh.2d(), andINLA::inla.nonconvex.hull() functions, respectively, whereas thefm_rcdt_2d(),fm_mesh_2d(), andfm_nonconvex_hull() interfaces may bedifferent, and potentially change in the future.

Examples

(m <- fm_rcdt_2d_inla(  boundary = fm_nonconvex_hull(cbind(0, 0), convex = 5)))fm_delaunay_2d(matrix(rnorm(30), 15, 2))

Refine a 2d mesh

Description

Refine an existing mesh

Usage

fm_refine(mesh, refine = list(max.edge = 1))

Arguments

mesh

Anfm_mesh_2d() object

refine

A list of refinement options passed on tofm_rcdt_2d_inla

Value

A refinedfm_mesh_2d object

Author(s)

Finn LindgrenFinn.Lindgren@gmail.com

Examples

fm_dof(fmexample$mesh)fm_dof(fm_refine(fmexample$mesh, refine = list(max.edge = 1)))

Row-wise Kronecker products

Description

Takes two Matrices and computes the row-wise Kronecker product. Optionallyapplies row-wise weights and/or applies an additional 0/1 row-wise Kroneckermatrix product.

Usage

fm_row_kron(M1, M2, repl = NULL, n.repl = NULL, weights = NULL)

Arguments

M1

A matrix that can be transformed into a sparse Matrix.

M2

A matrix that can be transformed into a sparse Matrix.

repl

An optional index vector. For each entry, specifies whichreplicate the row belongs to, in the sense used inINLA::inla.spde.make.A

n.repl

The maximum replicate index, in the sense used inINLA::inla.spde.make.A().

weights

Optional scaling weights to be applied row-wise to theresulting matrix.

Value

AMatrix::sparseMatrix object.

Author(s)

Finn LindgrenFinn.Lindgren@gmail.com

Examples

fm_row_kron(rbind(c(1, 1, 0), c(0, 1, 1)), rbind(c(1, 2), c(3, 4)))

Check for potentialsp version compatibility issues

Description

Loads the sp package withrequireNamespace("sp", quietly = TRUE), andchecks and optionally sets thesp evolution status flag ifrgdal isunavailable.This function is only needed for backwards compatibility withsp versionsbefore2.0-0.

Usage

fm_safe_sp(quietly = FALSE, force = FALSE, minimum_version = "1.4-5")

Arguments

quietly

logical; ifTRUE, prints diagnostic messages. DefaultFALSE

force

logical; Ifrgdal is unavailableand evolution status is less that2L, returnFALSE ifforce isFALSE.Ifforce isTRUE, returnTRUE if the package configuration is safe,potentially after forcing the evolution status to2L.DefaultFALSE

minimum_version

character; the minimum required sp version.Default 1.4-5 (should always match the requirement in the packageDESCRIPTION)

Value

Returns (invisibly)FALSE if a potential issue is detected, andgive a message ifquietly isFALSE. Otherwise returnsTRUE

Examples

if (fm_safe_sp()) {  # Run sp dependent calculations}

Make a spatial segment object

Description

Make a spatial segment object

Usage

fm_segm(...)## Default S3 method:fm_segm(loc = NULL, idx = NULL, grp = NULL, is.bnd = TRUE, crs = NULL, ...)## S3 method for class 'fm_segm'fm_segm(..., grp = NULL, grp.default = 0L, is.bnd = NULL)## S3 method for class 'fm_segm_list'fm_segm(x, grp = NULL, grp.default = 0L, ...)fm_segm_join(x, grp = NULL, grp.default = 0L, is.bnd = NULL)fm_segm_split(x, grp = NULL, grp.default = 0L)## S3 method for class 'inla.mesh.segment'fm_segm(..., grp.default = 0)## S3 method for class 'fm_mesh_2d'fm_segm(x, boundary = TRUE, grp = NULL, ...)fm_is_bnd(x)fm_is_bnd(x) <- value

Arguments

...

Passed on to submethods

loc

Matrix of point locations, orSpatialPoints, orsf/sfc pointobject.

idx

Segment index sequence vector or index pair matrix. The indicesrefer to the rows ofloc. Ifloc==NULL, the indices will beinterpreted as indices into the point specification supplied tofm_rcdt_2d(). Ifis.bnd==TRUE, defaults to linkingall the points inloc, asc(1:nrow(loc),1L), otherwise1:nrow(loc).

grp

When joining segments, use these group labels for segmentsinstead of the original group labels.

is.bnd

TRUE if the segments are boundary segments, otherwiseFALSE.

crs

An optionalfm_crs(),sf::st_crs() orsp::CRS() object

grp.default

Ifgrp.default isNULL, use these group labels forsegments with NULL group.

x

Mesh to extract segments from

boundary

logical; ifTRUE, extract the boundary segments,otherwise interior constrain segments.

value

logical

Value

Anfm_segm orfm_segm_list object

Methods (by class)

Functions

See Also

Other object creation and conversion:fm_as_collect(),fm_as_fm(),fm_as_lattice_2d(),fm_as_lattice_Nd(),fm_as_mesh_1d(),fm_as_mesh_2d(),fm_as_mesh_3d(),fm_as_segm(),fm_as_sfc(),fm_as_tensor(),fm_collect(),fm_lattice_2d(),fm_lattice_Nd(),fm_mesh_1d(),fm_mesh_2d(),fm_simplify(),fm_tensor()

Examples

fm_segm(rbind(c(0, 0), c(1, 0), c(1, 1), c(0, 1)), is.bnd = FALSE)fm_segm(rbind(c(0, 0), c(1, 0), c(1, 1), c(0, 1)), is.bnd = TRUE)fm_segm_join(fmexample$boundary_fm)fm_segm(fmexample$mesh, boundary = TRUE)fm_segm(fmexample$mesh, boundary = FALSE)

Contour segment

Description

Helper from legacyINLA::inla.contour.segment()

Usage

fm_segm_contour_helper(  x = seq(0, 1, length.out = nrow(z)),  y = seq(0, 1, length.out = ncol(z)),  z,  nlevels = 10,  levels = NULL,  groups = NULL,  positive = TRUE,  eps = NULL,  eps_rel = NULL,  crs = NULL)

Arguments

x,y,z

Thex andy coordinates of the grid, and thez values

nlevels

Number of contour levels

levels

The contour levels. IfNULL,pretty(range(z, na.rm = TRUE), nlevels) is used.

groups

The group values for each contour level.IfNULL,seq_len(length(levels)) is used.

positive

Logical; ifTRUE, the contour lines are made to beCCW around positive excursions

eps,eps_rel

Polygonal curve simplification tolerances

crs

A coordinate reference system

Value

Anfm_segm object

See Also

Other nonconvex inla legacy support:fm_nonconvex_hull_inla(),fm_simplify_helper()

Examples

fm_segm_contour_helper(z = matrix(1:16, 4, 4))

Methods for fm_segm lists

Description

fm_segm lists can be combined intofm_segm_list list objects.

Usage

## S3 method for class 'fm_segm'c(...)## S3 method for class 'fm_segm_list'c(...)## S3 method for class 'fm_segm_list'x[i]

Arguments

...

Objects to be combined.

x

fm_segm_list object from which to extract element(s)

i

indices specifying elements to extract

Value

Afm_segm_list object

Methods (by generic)

Functions

See Also

fm_as_segm_list()

Examples

m <- c(A = fm_segm(1:2), B = fm_segm(3:4))str(m)str(m[2])

Recursive curve simplification.

Description

[Experimental]Simplifies polygonal curve segments by joining nearlyco-linear segments.

Uses a variation of the binary splitting Ramer-Douglas-Peucker algorithm,with an ellipse of half-widtheps ellipse instead of a rectangle, motivatedby prediction ellipse for Brownian bridge.

Usage

fm_simplify(x, eps = NULL, eps_rel = NULL, ...)

Arguments

x

Anfm_segm() object.

eps

Absolute straightness tolerance. DefaultNULL, no constraint.

eps_rel

Relative straightness tolerance. DefaultNULL, noconstraint.

...

Currently unused.

Details

Variation of Ramer-Douglas-Peucker.Uses width epsilon ellipse instead of rectangle,motivated by prediction ellipse for Brownian bridge.

Value

The simplifiedfm_segm() object.

Author(s)

Finn LindgrenFinn.Lindgren@gmail.com

References

Ramer, Urs (1972). "An iterative procedure for the polygonal approximation ofplane curves".Computer Graphics and Image Processing.1 (3): 244–256.doi:10.1016/S0146-664X(72)80017-0

Douglas, David; Peucker, Thomas (1973). "Algorithms for the reduction ofthe number of points required to represent a digitized line or itscaricature".The Canadian Cartographer.10 (2): 112–122.doi:10.3138/FM57-6770-U75U-7727

See Also

Other object creation and conversion:fm_as_collect(),fm_as_fm(),fm_as_lattice_2d(),fm_as_lattice_Nd(),fm_as_mesh_1d(),fm_as_mesh_2d(),fm_as_mesh_3d(),fm_as_segm(),fm_as_sfc(),fm_as_tensor(),fm_collect(),fm_lattice_2d(),fm_lattice_Nd(),fm_mesh_1d(),fm_mesh_2d(),fm_segm(),fm_tensor()

Examples

theta <- seq(0, 2 * pi, length.out = 1000)(segm <- fm_segm(cbind(cos(theta), sin(theta)),  idx = seq_along(theta)))(segm1 <- fm_simplify(segm, eps_rel = 0.1))(segm2 <- fm_simplify(segm, eps_rel = 0.2))plot(segm)lines(segm1, col = 2)lines(segm2, col = 3)(segm <- fm_segm(cbind(theta, sin(theta * 4)),  idx = seq_along(theta)))(segm1 <- fm_simplify(segm, eps_rel = 0.1))(segm2 <- fm_simplify(segm, eps_rel = 0.2))plot(segm)lines(segm1, col = 2)lines(segm2, col = 3)

Recursive curve simplification.

Description

Helper from legacyINLA::inla.simplify.curve()

Attempts to simplify a polygonal curve by joining nearly colinear segments.

Uses a variation of the binary splitting Ramer-Douglas-Peucker algorithm,with an ellipse of half-widtheps ellipse instead of a rectangle, motivatedby prediction ellipse for Brownian bridge.

Usage

fm_simplify_helper(loc, idx, eps = NULL, eps_rel = NULL)

Arguments

loc

Coordinate matrix.

idx

Index vector intoloc specifying a polygonal curve.

eps

Absolute straightness tolerance. DefaultNULL, no constraint.

eps_rel

Relative straightness tolerance. DefaultNULL, noconstraint.

Details

Variation of Ramer-Douglas-Peucker.Uses width epsilon ellipse instead of rectangle,motivated by prediction ellipse for Brownian bridge.

Value

An index vector intoloc specifying the simplified polygonalcurve.

Author(s)

Finn LindgrenFinn.Lindgren@gmail.com

See Also

Other nonconvex inla legacy support:fm_nonconvex_hull_inla(),fm_segm_contour_helper()

Examples

theta <- seq(0, 2 * pi, length.out = 1000)loc <- cbind(cos(theta), sin(theta))idx <- fm_simplify_helper(loc = loc, idx = 1:nrow(loc), eps = 0.01)print(c(nrow(loc), length(idx)))plot(loc, type = "l")lines(loc[idx, ], col = "red")

fm_sizes

Description

[Experimental]Compute effective sizes of faces/cells and vertices in a mesh

Usage

fm_sizes(...)## S3 method for class 'fm_mesh_2d'fm_sizes(mesh, ...)## S3 method for class 'fm_mesh_3d'fm_sizes(mesh, ...)

Arguments

...

Passed on to submethods

mesh

object of a supported mesh class

Value

Alist with elementsface andvertex for 2D meshes, orcellandvertex for 3D meshes. The elements are vectors of effective sizes ofthe faces/cells and vertices, respectively.

Examples

str(fm_sizes(fmexample$mesh))

Split lines at triangle edges

Description

Compute intersections between line segments and triangle edges,and filter out segment of length zero.

Usage

fm_split_lines(mesh, ...)## S3 method for class 'fm_mesh_2d'fm_split_lines(mesh, segm, ...)

Arguments

mesh

Anfm_mesh_2d object

...

Unused.

segm

Anfm_segm() object with segments to be split

Value

Anfm_segm() object with the same crs as the mesh,with an added fieldorigin, that for each new segment gives theoriginator index into to originalsegm object for each new line segment.

Author(s)

Finn LindgrenFinn.Lindgren@gmail.com

Examples

mesh <- fm_mesh_2d(  boundary = fm_segm(    rbind(c(0, 0), c(1, 0), c(1, 1), c(0, 1)),    is.bnd = TRUE  ))splitter <- fm_segm(rbind(c(0.8, 0.2), c(0.2, 0.8)))segm_split <- fm_split_lines(mesh, splitter)plot(mesh)lines(splitter)points(segm_split$loc)

Store points in different formats

Description

Convert a matrix of points into different formats.

Usage

fm_store_points(loc, crs = NULL, info = NULL, format = NULL)

Arguments

loc

a coordinate matrix

crs

CRS information to associate with the coordinates

info

An optional data.frame of additional data

format

character;"sf","df","sp"

Value

Ansf,data.frame, orSpatialPointsDataFrame object, withoptional added information.

Examples

fm_store_points(fmexample$loc, format = "sf")

Split triangles of a mesh into subtriangles

Description

[Experimental]Splits each mesh triangle into(n + 1)^2 subtriangles.The current version drops any edge constraint information from the mesh.

Usage

fm_subdivide(mesh, n = 1, delaunay = FALSE)

Arguments

mesh

anfm_mesh_2d object

n

number of added points along each edge. Default is 1.

delaunay

logical; ifTRUE, the subdivided mesh is forced into aDelaunay triangle structure. IfFALSE (default), the triangles aresubdivided uniformly instead.

Value

A refinedfm_mesh_2d object, with addedbary information(anfm_bary() object), that can be used for interpolating functions fromthe original mesh to the new mesh (from version⁠0.5.0.9002⁠).

Author(s)

Finn LindgrenFinn.Lindgren@gmail.com

Examples

mesh <- fm_rcdt_2d_inla(  loc = rbind(c(0, 0), c(1, 0), c(0, 1)),  tv = rbind(c(1, 2, 3)))mesh_sub <- fm_subdivide(mesh, 3)meshmesh_sub# Difference should be zero for flat triangle meshes:sum((mesh_sub$loc - fm_basis(mesh, mesh_sub$bary) %*% mesh$loc)^2)plot(mesh_sub, edge.color = 2)plot(fm_subdivide(fmexample$mesh, 3), edge.color = 2)plot(fmexample$mesh, add = TRUE, edge.color = 1)

Extract a subset of a mesh

Description

[Experimental] (from version⁠0.5.0.9003⁠)Constructs a new mesh based on a subset of the triangles of an existing mesh.The current version drops any edge constraint information from the mesh.

Usage

fm_subset(mesh, t_sub)

Arguments

mesh

an mesh to subset

t_sub

triangle or tetrahedron indices.

Value

A subset mesh.

Author(s)

Finn LindgrenFinn.Lindgren@gmail.com

Examples

mesh_sub <- fm_subset(fmexample$mesh, 1:100)mesh_subplot(mesh_sub)if (requireNamespace("geometry", quietly = TRUE)) {  print(m <- fm_delaunay_3d(matrix(rnorm(30), 10, 3)))  print(fm_subset(m, seq_len(min(5, nrow(m$graph$tv)))))}

Make a tensor product function space

Description

[Experimental]Tensor product function spaces. The interface and object storage modelis experimental and may change.

Usage

fm_tensor(x, ...)

Arguments

x

list of function space objects, such asfm_mesh_2d().

...

Currently unused

Value

Afm_tensor orfm_tensor_list object. Elements offm_tensor:

fun_spaces

fm_list of function space objects

manifold

character; manifold type summary. Regular subset of Rd "Rd",if all function spaces have type "R",torus connected "Td" if all function spaces have type "S", and otherwise "Md"In all cases,d is the sum of the manifold dimensions of the functionspaces.

See Also

Other object creation and conversion:fm_as_collect(),fm_as_fm(),fm_as_lattice_2d(),fm_as_lattice_Nd(),fm_as_mesh_1d(),fm_as_mesh_2d(),fm_as_mesh_3d(),fm_as_segm(),fm_as_sfc(),fm_as_tensor(),fm_collect(),fm_lattice_2d(),fm_lattice_Nd(),fm_mesh_1d(),fm_mesh_2d(),fm_segm(),fm_simplify()

Examples

m <- fm_tensor(list(  space = fmexample$mesh,  time = fm_mesh_1d(1:5)))m2 <- fm_as_tensor(m)m3 <- fm_as_tensor_list(list(m, m))c(fm_dof(m$fun_spaces$space) * fm_dof(m$fun_spaces$time), fm_dof(m))str(fm_evaluator(m, loc = list(space = cbind(0, 0), time = 2.5)))str(fm_basis(m, loc = list(space = cbind(0, 0), time = 2.5)))str(fm_fem(m))

Object coordinate transformation

Description

Handle transformation of various inla objects according to coordinatereference systems ofcrs (fromsf::st_crs()),fm_crs,sp::CRS,fm_CRS, orINLA::inla.CRS class.

Usage

fm_transform(x, crs, ...)## Default S3 method:fm_transform(x, crs, ..., crs0 = NULL)## S3 method for class 'NULL'fm_transform(x, crs, ...)## S3 method for class 'matrix'fm_transform(x, crs, ..., passthrough = FALSE, crs0 = NULL)## S3 method for class 'sf'fm_transform(x, crs, ..., passthrough = FALSE)## S3 method for class 'sfc'fm_transform(x, crs, ..., passthrough = FALSE)## S3 method for class 'sfg'fm_transform(x, crs, ..., passthrough = FALSE)## S3 method for class 'Spatial'fm_transform(x, crs, ..., passthrough = FALSE)## S3 method for class 'fm_mesh_2d'fm_transform(x, crs = fm_crs(x), ..., passthrough = FALSE, crs0 = fm_crs(x))## S3 method for class 'fm_collect'fm_transform(x, crs = fm_crs(x), ..., passthrough = FALSE, crs0 = NULL)## S3 method for class 'fm_lattice_2d'fm_transform(x, crs = fm_crs(x), ..., passthrough = FALSE, crs0 = fm_crs(x))## S3 method for class 'fm_segm'fm_transform(x, crs = fm_crs(x), ..., passthrough = FALSE, crs0 = fm_crs(x))## S3 method for class 'fm_list'fm_transform(x, crs, ...)

Arguments

x

The object that should be transformed from it's current CRS to a new CRS

crs

The target crs object

...

Potential additional arguments

crs0

The source crs object for spatial classes without crs information

passthrough

Default is FALSE.Setting to TRUE allows objects with no CRS information to be passedthrough without transformation. Use with care!

Value

A transformed object, normally of the same class asthe input object.

See Also

fm_CRS()

Examples

fm_transform(  rbind(c(0, 0), c(0, 90), c(0, 91)),  crs = fm_crs("sphere"),  crs0 = fm_crs("longlat_norm"))

Unify coordinates to 3-column matrix

Description

Convert coordinate information to a 3-column matrix.This is mainly an internal function, and the interface may change.

Usage

fm_unify_coords(x, crs = NULL)## S3 method for class 'NULL'fm_unify_coords(x, crs = NULL)## Default S3 method:fm_unify_coords(x, crs = NULL)## S3 method for class 'Spatial'fm_unify_coords(x, crs = NULL)## S3 method for class 'sf'fm_unify_coords(x, crs = NULL)## S3 method for class 'sfc'fm_unify_coords(x, crs = NULL)

Arguments

x

A object with coordinate information

crs

A optional crs object to convert the coordinates to

Value

A coordinate matrix

Examples

fm_unify_coords(fmexample$loc_sf)

Project integration points to mesh vertices

Description

Compute information for assigning points to the vertices of the coveringtriangle

Usage

fm_vertex_projection(points, mesh)

Arguments

points

ASpatialPointsDataFrame,sf,tibble, orlist object

mesh

Anfm_mesh_2d object

Value

SpatialPointsDataFrame,sf,tibble, orlist of meshvertices with projected data attached

Examples

head(fm_vertex_projection(list(loc = fmexample$loc), fmexample$mesh))head(fm_vertex_projection(fmexample$loc_sf, fmexample$mesh))

Extract vertex locations from anfm_mesh_2d

Description

Extracts the vertices of anfm_mesh_2d object.

Usage

fm_vertices(x, format = NULL)

Arguments

x

Anfm_mesh_2d object.

format

character;"sf","df","sp"

Value

Ansf,data.frame, orSpatialPointsDataFrame object, with the vertexcoordinates, and a.vertex column with the vertex indices.

Author(s)

Finn LindgrenFinn.Lindgren@gmail.com

See Also

fm_centroids()

Examples

if (require("ggplot2", quietly = TRUE)) {  vrt <- fm_vertices(fmexample$mesh, format = "sf")  ggplot() +    geom_sf(data = fm_as_sfc(fmexample$mesh)) +    geom_sf(data = vrt, color = "red")}

Internal WKT handling

Description

Conversion between WKT and a tree representation

Usage

fm_wkt_as_wkt_tree(x, ...)fm_wkt_tree_as_wkt(x, pretty = FALSE, ...)fm_wkt_tree_get_item(x, item, duplicate = 1)fm_wkt_tree_set_item(x, item_tree, duplicate = 1)

Arguments

x

A WKT2 string, or awkt_tree list structure

...

Unused

pretty

logical; If TRUE, use pretty formatting. Default: FALSE

item

character vector with item labels identifying a parameter itementry.

duplicate

For items that have more than one match,duplicateindicates the index number of the desired version. Default: 1

item_tree

An item tree identifying a parameter item entry

Value

A hierarchical list, describing WKT information as a tree

fm_wkt_tree_as_wkt character; the WKT corresponding to the tree.

fm_wkt_tree_get_item returns the value of an item found in thetree

fm_wkt_tree_set_item returns the modified tree

Examples

str(fm_wkt_as_wkt_tree(fm_crs("longlat_norm")$wkt))

Add or remove Z/M information

Description

[Experimental]Add and/or remove Z and/or M information from simple feature geometries.

Usage

fm_zm(x, ...)## S3 method for class 'sf'fm_zm(x, ...)## S3 method for class 'sfc'fm_zm(x, ..., add = NULL, remove = NULL, target = NULL)## S3 method for class 'list'fm_zm(x, ..., add = NULL, remove = NULL, target = NULL)## S3 method for class 'sfg'fm_zm(x, ..., add = NULL, remove = NULL, target = NULL)## S3 method for class 'numeric'fm_zm(x, ..., add = NULL, remove = NULL, target = NULL, input = NULL)## S3 method for class 'matrix'fm_zm(x, ..., add = NULL, remove = NULL, target = NULL, input = NULL)fm_zm_input(x, ...)## S3 method for class 'sf'fm_zm_input(x, ...)## S3 method for class 'sfc'fm_zm_input(x, ...)## S3 method for class 'list'fm_zm_input(x, ...)## S3 method for class 'sfg'fm_zm_input(x, ...)## S3 method for class 'numeric'fm_zm_input(x, ..., input = NULL)## S3 method for class 'matrix'fm_zm_input(x, ..., input = NULL)fm_zm_target(input, add = NULL, remove = NULL, target = NULL)

Arguments

x

An object to modify

...

Further arguments passed to methods

add

character; one ofNULL,"Z","M", or"ZM". Specifieswhich dimensions to add.

remove

character; one ofNULL,"Z","M", or"ZM". Specifieswhich dimensions to remove.

target

character; one of"XY","XYZ","XYM", or"XYZM".Specifies the target dimension format. If provided, overridesadd andremove. When bothadd andremove areNULL, the default target isthe smallest format that can hold all the inputs without loss ofinformation.

input

character or character vector; one ofNULL,"XY","XYZ","XYM", or"XYZM".Specifies the input dimension format. IfNULL (default), the input formatis inferred from the number of columns inx (for matrices/numerics) orfrom the geometry type (forsfc objects).

Value

An object of the same class asx, with modified Z/M dimensions.

Functions

Author(s)

Finn LindgrenFinn.Lindgren@gmail.com

See Also

sf::st_zm() that supports a subset of these operations.

Examples

fm_zm(fmexample$loc_sf, add = "Z")fm_zm_input(fmexample$loc_sf)fm_zm_target(c("XY", "XYZ"))fm_zm_target("XY", add = "Z")fm_zm_target(c("XY", "XYZM"), remove = "M")

Deprecated functions in fmesher

Description

These functions still attempt to do their job, but will be removed in afuture version.

Usage

fm_mesh_components(...)fm_int_object(...)fm_sp2segment(...)

Arguments

...

Usually passed on to other methods

Functions

Author(s)

Finn LindgrenFinn.Lindgren@gmail.com


Print objects

Description

Print objects

Usage

## S3 method for class 'fm_segm'print(x, ..., digits = NULL, verbose = TRUE, newline = TRUE)## S3 method for class 'fm_segm_list'print(x, ..., digits = NULL, verbose = FALSE, newline = TRUE)## S3 method for class 'fm_list'print(x, ..., digits = NULL, verbose = FALSE, newline = TRUE)## S3 method for class 'fm_mesh_2d'print(x, ..., digits = NULL, verbose = FALSE)## S3 method for class 'fm_mesh_3d'print(x, ..., digits = NULL, verbose = FALSE)## S3 method for class 'fm_mesh_1d'print(x, ..., digits = NULL, verbose = FALSE)## S3 method for class 'fm_bbox'print(x, ..., digits = NULL, verbose = TRUE, newline = TRUE)## S3 method for class 'fm_tensor'print(x, ..., digits = NULL, verbose = FALSE)## S3 method for class 'fm_collect'print(x, ..., digits = NULL, verbose = FALSE)## S3 method for class 'fm_lattice_2d'print(x, ..., digits = NULL, verbose = FALSE)## S3 method for class 'fm_lattice_Nd'print(x, ..., digits = NULL, verbose = FALSE)## S3 method for class 'fm_crs'print(x, ...)## S3 method for class 'fm_CRS'print(x, ...)

Arguments

x

an object used to select a method.

...

further arguments passed to or from other methods.

digits

a positive integer indicating how many significant digits areto be used for numeric and complex x. The default, NULL, usesgetOption("digits").

verbose

logical

newline

logical; ifTRUE (default), end the printing with⁠\n⁠

Value

The input objectx

Examples

fm_bbox(matrix(1:6, 3, 2))print(fm_bbox(matrix(1:6, 3, 2)), verbose = FALSE)print(fmexample$mesh)print(fmexample$boundary_fm)print(fm_mesh_1d(c(1, 2, 3, 5, 7), degree = 2))

Barycentric coordinate computation

Description

Locate points and compute triangular barycentric coordinates

Usage

fmesher_bary(mesh_loc, mesh_tv, loc, options)

Arguments

mesh_loc

numeric matrix; mesh vertex coordinates

mesh_tv

3-column integer matrix with 0-based vertex indices for each triangle

loc

numeric matrix; coordinates of points to locate in the mesh

options

list of triangulation options

Value

A list with vectorindex (triangle index) and matrixwhere(3-column barycentric matrix)

Examples

m <- fmesher_rcdt(list(cet_margin = 1), matrix(0, 1, 2))b <- fmesher_bary(m$s,                  m$tv,                  matrix(c(0.5, 0.5), 1, 2),                  list())

Barycentric coordinate computation

Description

Locate points and compute triangular barycentric coordinates

Usage

fmesher_bary3d(mesh_loc, mesh_tv, loc, options)

Arguments

mesh_loc

numeric matrix; mesh vertex coordinates

mesh_tv

3-column integer matrix with 0-based vertex indices for each triangle

loc

numeric matrix; coordinates of points to locate in the mesh

options

list of triangulation options

Value

A list with vectorindex (tetra index) and matrixwhere(4-column barycentric matrix)

Examples

m <- fmesher_mesh3d(list(cet_margin = 1),                    matrix(rnorm(15), 5, 3),                    matrix(c(0,1,2,3), 1, 4))b <- fmesher_bary3d(m$loc,                    m$tv,                    matrix(c(0.5, 0.5, 0.5), 1, 3),                    list())

Finite element matrix computation

Description

Construct finite element structure matrices

Usage

fmesher_fem(mesh_loc, mesh_tv, fem_order_max, aniso, options)

Arguments

mesh_loc

numeric matrix; mesh vertex coordinates

mesh_tv

3-column integer matrix with 0-based vertex indices for each triangle

fem_order_max

integer; the highest operator order to compute

aniso

If non-NULL, alist(gamma, v). Calculates anisotropic structurematrices (in addition to the regular) for\gamma andv foran anisotropic operator\nabla\cdot H \nabla, whereH=\gamma I + v v^\top.Currently (2023-08-05) the fields need to be given per vertex.

options

list of triangulation options (sphere_tolerance)

Value

A list of matrices

Examples

m <- fmesher_rcdt(list(cet_margin = 1), matrix(0, 1, 2))b <- fmesher_fem(m$s, m$tv, fem_order_max = 2, aniso = NULL, options = list())

Globe points

Description

Create points on a globe

Usage

fmesher_globe_points(globe)

Arguments

globe

integer; the number of edge subdivision segments, 1 or higher.

Value

A matrix of points on a unit radius globe

Examples

fmesher_globe_points(1)

3D tetrahedralisation storage

Description

(...)

Usage

fmesher_mesh3d(options, loc, tv)

Arguments

options

list of triangulation options

loc

numeric matrix; initial points to include

tv

4-column integer matrix with 0-based vertex indices for each triangle

Value

A list of information objects for a generated tetrahedralisation

Examples

m <- fmesher_mesh3d(list(),                    matrix(c(1,0,0,0,1,0,0,0,1,0,0,0), 4, 3, byrow=TRUE),                    matrix(c(0,1,2,3), 1, 4, byrow=TRUE))

Compute sparse matrix inverse

Description

Requires RcppEigen which is not compiled in by default. Enable withPKG_CPPFLAGS=-DFMESHER_WITH_EIGEN insrc/Makevars and addRcppEigento theDESCRIPTIONLinkingTo field.

Usage

fmesher_qinv(AA)

Arguments

AA

A sparse matrix


Refined Constrained Delaunay Triangulation

Description

(...)

Usage

fmesher_rcdt(  options,  loc,  tv = NULL,  boundary = NULL,  interior = NULL,  boundary_grp = NULL,  interior_grp = NULL)

Arguments

options

list of triangulation options

loc

numeric matrix; initial points to include

tv

3-column integer matrix with 0-based vertex indices for each triangle

boundary

2-column integer matrix with 0-based vertex indices for eachboundary edge constraint

interior

2-column integer matrix with 0-based vertex indices for eachinterior edge constraint

boundary_grp

integer vector with group labels

interior_grp

integer vector with group labels

Value

A list of information objects for a generated triangulation

Examples

m <- fmesher_rcdt(list(cet_margin = 1), matrix(0, 1, 2))

Rotationally invariant spherical B-splines

Description

Compute rotationally invariant spherical B-splines on the unit sphere

Usage

fmesher_spherical_bsplines1(loc, n, degree, uniform)fmesher_spherical_bsplines(loc, n, degree, uniform)

Arguments

loc

numeric vector/matrix; coordinates of points to locate in the mesh,only the z-coordinates are used (sin(latitude))

n

The number of basis functions

degree

The polynomial basis degree

uniform

logical; IfTRUE, the knots are spaced uniformly by latitude,ifFALSE, the knots are spaced uniformly bysin(latitude)

Value

A matrix of evaluated b-spline basis functions

Examples

m <- fm_rcdt_2d(globe = 1)fmesher_spherical_bsplines(m$loc, n = 3, degree = 2, uniform = FALSE)fmesher_spherical_bsplines1(m$loc[, 3], n = 3, degree = 2, uniform = FALSE)

Spherical harmonics

Description

Compute spherical harmonics on the unit sphere

Usage

fmesher_spherical_harmonics(loc, max_order, rot_inv)

Arguments

loc

numeric matrix; coordinates of points to locate in the mesh

max_order

integer; the maximum basis order

rot_inv

logical; IfTRUE, only evaluate rotationallyinvariant basis functions

Value

A matrix of evaluated spherical harmonic basis functions

Examples

m <- fm_rcdt_2d(globe = 1)fmesher_spherical_harmonics(m$loc, max_order = 2, TRUE)fmesher_spherical_harmonics(m$loc, max_order = 2, FALSE)

Split lines at triangle edges

Description

Split a sequence of line segments at triangle edges

Usage

fmesher_split_lines(mesh_loc, mesh_tv, loc, idx, options)

Arguments

mesh_loc

numeric matrix; mesh vertex coordinates

mesh_tv

3-column integer matrix with 0-based vertex indices for each triangle

loc

numeric coordinate matrix

idx

2-column integer matrix

options

list of triangulation options (sphere_tolerance)

Value

A list of line splitting information objects

See Also

fm_split_lines()

Examples

mesh <- fm_mesh_2d(  boundary = fm_segm(rbind(c(0,0), c(1,0), c(1,1), c(0, 1)), is.bnd = TRUE))splitter <- fm_segm(rbind(c(0.8, 0.2), c(0.2, 0.8)))segm_split <- fm_split_lines(mesh, splitter)

Subdivide triangles

Description

Subdivide a mesh with congruent and anti-congruent subtriangles

Usage

fmesher_subdivide(  mesh_loc,  mesh_tv,  mesh_boundary,  mesh_interior,  subdivisions,  options)

Arguments

mesh_loc

numeric matrix; mesh vertex coordinates

mesh_tv

3-column integer matrix with 0-based vertex indices for each triangle

mesh_boundary

2-column integer matrix with 0-based vertex indices forboundary constraints, currently ignored

mesh_interior

2-column integer matrix with 0-based vertex indices forinterior constraints, currently ignored

subdivisions

integer; number of new points along each edge.

options

list of triangulation options (sphere_tolerance)

Value

A list of newloc andtv information, andbary_index andbary_where containing the fm_bary information for the new points.Can be e.g. used to construct an interpolation mapping matrix from the oldto new mesh.

See Also

fm_subdivide()

Examples

mesh <- fm_mesh_2d(  boundary = fm_segm(rbind(c(0,0), c(1,0), c(1,1), c(0, 1)), is.bnd = TRUE))new_mesh <- fm_subdivide(mesh, n = 3)plot(new_mesh, edge.color = 2)plot(mesh, add = TRUE, edge.color = 1)

Example mesh data

Description

This is an example data set used forfmesher package examples.

Usage

fmexample

Format

The data is a list containing these elements:

loc:

Amatrix of points.

loc_sf:

Ansfc version ofloc.

boundary_fm:

Afm_segm_list of twofm_segm objects used inthe mesh construction.

boundary_sf:

Ansfc list version ofboundary.

mesh:

Anfm_mesh_2d() object.

Source

Generated bydata-raw/fmexample.R.

See Also

fmexample_sp()

Examples

if (require(ggplot2, quietly = TRUE)) {  ggplot() +    geom_sf(data = fm_as_sfc(fmexample$mesh)) +    geom_sf(data = fmexample$boundary_sf[[1]], fill = "red", alpha = 0.5)}

Add sp data to fmexample

Description

Addsloc_sp andboundary_sp tofmexample for useinsp related code examples and tests.

Usage

fmexample_sp()

Value

Returns a copy offmexample withloc_sp (SpatialPoints) andboundary_sp (SpatialPolygons) added.

Examples

if (fm_safe_sp()) {  fmexample_sp()}

ggplot2 geomes for fmesher related objects

Description

[Experimental]

geom_fm is a generic function for generating geomes from various kinds offmesher objects, e.g.fm_segm andfm_mesh_2d.The function invokes particular methods which dependon theclass of thedata argument.Requires theggplot2 package.

Note:geom_fm is not yet a "proper"ggplot2 geom method; the interfacemay therefore change in the future.

Usage

geom_fm(mapping = NULL, data = NULL, ...)## S3 method for class 'fm_mesh_2d'geom_fm(  mapping = NULL,  data = NULL,  ...,  mappings = NULL,  defs = NULL,  crs = NULL)## S3 method for class 'fm_segm'geom_fm(mapping = NULL, data = NULL, ..., crs = NULL)## S3 method for class 'fm_mesh_1d'geom_fm(  mapping = NULL,  data = NULL,  ...,  mappings = NULL,  defs = NULL,  xlim = NULL,  basis = TRUE,  knots = TRUE,  derivatives = FALSE,  weights = NULL)

Arguments

mapping

ggplot2::aes() mapping information.

data

an object for which to generate a geom.

...

Arguments passed on to the geom method.

mappings,defs

optional lists ofaes mappings and non-aes settings.Forfm_mesh_2d, the non-triangle parts ofthe mesh, named "int" for interior constraint edges, "bnd" for boundaryedges, and "loc" for the vertices. Forfm_mesh_1d, the elements are"knots" and "fun".

crs

Optional crs to transform the object to before plotting.

xlim

numeric 2-vector; specifies the interval for which to computefunctions. Default isdata$interval

basis

logical; ifTRUE (default), show the spline basis functions

knots

logical; ifTRUE (default), show the spline knot locations

derivatives

logical; ifTRUE (not default), draw first orderderivatives instead of function values

weights

numeric vector; if provided, draw weighted basis functions andthe resulting weighted sum.

Value

A combination ofggplot2 geoms.

Methods (by class)

Examples

ggplot() +  geom_fm(data = fmexample$mesh)m <- fm_mesh_2d(  cbind(10, 20),  boundary = fm_extensions(cbind(10, 20), c(25, 65)),  max.edge = c(4, 10),  crs = fm_crs("+proj=longlat"))ggplot() +  geom_fm(data = m)ggplot() +  geom_fm(data = m, defs = list(loc = list()))ggplot() +  geom_fm(data = m, crs = fm_crs("epsg:27700"))# Compute a mesh vertex based function on a different gridpx <- fm_pixels(  fm_transform(m, fm_crs("mollweide_globe")),  dims = c(50, 50) # Speed up the example by lowering the resolution)px$fun <- fm_evaluate(m,  loc = px,  field = sin(m$loc[, 1] / 5) * sin(m$loc[, 2] / 5))ggplot() +  geom_tile(aes(geometry = geometry, fill = fun),    data = px,    stat = "sf_coordinates"  ) +  geom_fm(    data = m, alpha = 0.2, linewidth = 0.05,    crs = fm_crs("mollweide_globe")  )m1 <- fm_segm(rbind(c(1, 2), c(4, 3), c(2, 4)), is.bnd = TRUE)m2 <- fm_segm(rbind(c(2, 2), c(3, 4), c(2, 3)), is.bnd = FALSE)ggplot() +  geom_fm(data = m1) +  geom_fm(data = m2)m <- fm_mesh_1d(  c(1, 2, 3, 5, 7),  boundary = c("dirichlet", "neumann"),  degree = 2)ggplot() +  geom_fm(data = m)

Unit test helpers

Description

Local helper functions for package unit tests

Usage

local_fm_testthat_assign(x, values, envir = parent.frame())local_fm_testthat_tolerances(  tolerances = c(1e-04, 0.01, 0.1),  envir = parent.frame())local_fm_testthat_setup(envir = parent.frame())

Arguments

x

character; Name of variable to assign to

values

the object to assign tox

envir

environment for exit handlers

tolerances

numeric vector of length 3;⁠[lowtol, midtol, hitol]⁠

Value

None

Functions

Examples

outer_fun <- function() {  fun <- function(envir = parent.frame()) {    local_fm_testthat_assign("local_var_name", 1:4, envir = envir)  }  fun()  local_var_name}exists("local_var_name")outer_fun()exists("local_var_name")

Construct integration scheme objects

Description

Constructor method for integration scheme objects, allowingdefault construction of.block information. Primarily meant for internaluse, but can be used to manually create data of the same structure asfm_int() output.

Usage

new_fm_int(  object,  blocks = FALSE,  weight = NULL,  name = NULL,  override = FALSE)

Arguments

object

An object representing integration points; either adata.frame-like object, or a vector/list of coordinates or other locationreference objects.

blocks

logical; ifTRUE, set per-element.block indices.IfFALSE (default), set a common block,1L.

weight

Optional weight variable; ifNULL, all weights are set to 1.

name

character; name of the integration domain.

override

logical; Ifname is non-NULL andoverride=TRUE for sfobject, the currentsf_column is renamed toname.

Value

A tibble or sf/tibble object. May acquire additional classattributes in the future.

See Also

fm_int()

Examples

new_fm_int(1:4, blocks = TRUE, weight = c(1, 2, 1, 3), name = "z")

Draw a triangulation mesh object

Description

Plots anfm_mesh_2d() object using standard graphics.

Usage

## S3 method for class 'fm_mesh_2d'lines(x, ..., add = TRUE)## S3 method for class 'fm_mesh_2d'plot(  x,  col = "white",  t.sub = seq_len(nrow(x$graph$tv)),  add = FALSE,  lwd = 1,  xlim = range(x$loc[, 1]),  ylim = range(x$loc[, 2]),  main = NULL,  size = 1,  draw.vertices = FALSE,  vertex.color = "black",  draw.edges = TRUE,  edge.color = rgb(0.3, 0.3, 0.3),  draw.segments = draw.edges,  rgl = deprecated(),  visibility = "front",  asp = 1,  axes = FALSE,  xlab = "",  ylab = "",  ...)

Arguments

x

Anfm_mesh_2d() object.

...

Further graphics parameters, interpreted by the respectiveplotting systems.

add

IfTRUE, adds to the current plot instead of starting anew one.

col

Color specification. A single named color, a vector of scalarvalues, or a matrix of RGB values. Requiresrgl=TRUE.

t.sub

Optional triangle index subset to be drawn.

lwd

Line width for triangle edges.

xlim

X-axis limits.

ylim

Y-axis limits.

main

Deprecated.

size

argumentcex for vertex points.

draw.vertices

IfTRUE, draw triangle vertices.

vertex.color

Color specification for all vertices.

draw.edges

IfTRUE, draw triangle edges.

edge.color

Color specification for all edges.

draw.segments

IfTRUE, draw boundary and interior constraintedges more prominently.

rgl

Deprecated

visibility

If "front" only display mesh faces with normal pointingtowards the camera.

asp

Aspect ratio for new plots. Default 1.

axes

logical; whether axes should be drawn on the plot.Default FALSE.

xlab,ylab

character; labels for the axes.

Value

None

Author(s)

Finn LindgrenFinn.Lindgren@gmail.com

See Also

plot.fm_segm(),plot_rgl.fm_mesh_2d()

Examples

mesh <- fm_rcdt_2d(globe = 10)plot(mesh)mesh <- fm_mesh_2d(cbind(0, 1), offset = c(1, 1.5), max.edge = 0.5)plot(mesh)

Drawfm_segm objects.

Description

Draws afm_segm() object with generic orrglgraphics.

Usage

## S3 method for class 'fm_segm'plot(x, ..., add = FALSE)## S3 method for class 'fm_segm'lines(  x,  loc = NULL,  col = NULL,  colors = c("black", "blue", "red", "green"),  add = TRUE,  xlim = NULL,  ylim = NULL,  asp = 1,  axes = FALSE,  xlab = "",  ylab = "",  visibility = "front",  rgl = deprecated(),  ...)## S3 method for class 'fm_segm_list'plot(x, ...)## S3 method for class 'fm_segm_list'lines(x, ...)

Arguments

x

Anfm_segm() object.

...

Additional parameters, passed on to graphics methods.

add

IfTRUE, add to the current plot, otherwise start a newplot.

loc

Point locations to be used ifx$loc isNULL.

col

Segment color specification.

colors

Colors to cycle through ifcol isNULL.

xlim,ylim

X and Y axis limits for a new plot.

asp

Aspect ratio for new plots. Default 1.

axes

logical; whether axes should be drawn on the plot.Default FALSE.

xlab,ylab

character; labels for the axes.

visibility

If "front" only display mesh faces with normal pointingtowards the camera.

rgl

[Deprecated] since⁠0.5.0.9000⁠in favour of theplot_rgl() andlines_rgl() methods.IfTRUE, usergl for plotting.

Value

None

Author(s)

Finn LindgrenFinn.Lindgren@gmail.com

See Also

fm_segm(),plot.fm_mesh_2d

Examples

plot(fm_segm(fmexample$mesh, boundary = TRUE))lines(fm_segm(fmexample$mesh, boundary = FALSE), col = 2)

Low level triangulation mesh plotting

Description

Plots a triangulation mesh usingrgl.

Usage

plot_rgl(x, ...)lines_rgl(x, ..., add = TRUE)## S3 method for class 'fm_segm'lines_rgl(  x,  loc = NULL,  col = NULL,  colors = c("black", "blue", "red", "green"),  ...,  add = TRUE)## S3 method for class 'fm_mesh_2d'plot_rgl(  x,  col = "white",  color.axis = NULL,  color.n = 512,  color.palette = cm.colors,  color.truncate = FALSE,  alpha = NULL,  lwd = 1,  specular = "black",  draw.vertices = TRUE,  draw.edges = TRUE,  draw.faces = TRUE,  draw.segments = draw.edges,  size = 2,  edge.color = rgb(0.3, 0.3, 0.3),  t.sub = seq_len(nrow(x$graph$tv)),  visibility = "",  S = deprecated(),  add = FALSE,  ...)## S3 method for class 'fm_segm'plot_rgl(x, ..., add = FALSE)## S3 method for class 'fm_segm_list'plot_rgl(x, ...)## S3 method for class 'fm_segm_list'lines_rgl(x, ...)

Arguments

x

Afm_mesh_2d() object

...

Additional parameters passed to and from other methods.

add

IfTRUE, adds to the current plot instead of starting anew one.

loc

Point locations to be used ifx$loc isNULL.

col

Segment color specification.

colors

Colors to cycle through ifcol isNULL.

color.axis

The min/max limit values for the color mapping.

color.n

The number of colors to use in the color palette.

color.palette

A color palette function.

color.truncate

IfTRUE, truncate the colors at the color axislimits.

alpha

Transparency/opaqueness values. Seergl.material.

lwd

Line width for edges. Seergl.material.

specular

Specular color. Seergl.material.

draw.vertices

IfTRUE, draw triangle vertices.

draw.edges

IfTRUE, draw triangle edges.

draw.faces

IfTRUE, draw triangles.

draw.segments

IfTRUE, draw boundary and interior constraintedges more prominently.

size

Size for vertex points.

edge.color

Edge color specification.

t.sub

Optional triangle index subset to be drawn.

visibility

If "front" only display mesh faces with normal pointingtowards the camera.

S

Deprecated.

Value

An rgl device identifier, invisibly.

Author(s)

Finn LindgrenFinn.Lindgren@gmail.com

See Also

plot.fm_mesh_2d()

Examples

if (interactive() && requireNamespace("rgl")) {  mesh <- fm_rcdt_2d(globe = 10)  plot_rgl(mesh, col = mesh$loc[, 1])}

Print method forfm_basis

Description

Prints information for anfm_basis object.

Usage

## S3 method for class 'fm_basis'print(x, ..., prefix = "")

Arguments

x

fm_basis() object

...

Unused

prefix

a prefix to be used for each line. Default is an empty string.

Value

invisible(x)

See Also

fm_basis()

Examples

print(fm_basis(fmexample$mesh, fmexample$loc, full = TRUE))

Print method forfm_evaluator()

Description

Prints information for anfm_evaluator object.

Usage

## S3 method for class 'fm_evaluator'print(x, ...)

Arguments

x

fm_evaluator() object

...

Unused

Value

invisible(x)

See Also

fm_evaluator()

Examples

print(fm_evaluator(fmexample$mesh, fmexample$loc))

[8]ページ先頭

©2009-2025 Movatter.jp