- Notifications
You must be signed in to change notification settings - Fork1
Standalone package for mesh/SPDE/GMRF code from the INLA package
License
inlabru-org/fmesher
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Generate planar and spherical triangle meshes, compute finite elementcalculations for 1- and 2-dimensional flat and curved manifolds withassociated basis function spaces, methods for lines and polygons, andtransparent handling of coordinate reference systems and coordinatetransformation, includingsf andsp geometries. The corefmesherlibrary code was originally part of theINLApackage, and also distributed in theEUSTACE Horizon 2020project, andimplements parts of “Triangulations and Applications” byHjelle andDæhlen (2006). The expandedcrs/CRS support started as an add-on feature ofinlabru.
You can install the currentCRANversion version offmesher:
install.packages("fmesher")Installation usingpak
You can install the latest bugfix release of fmesher fromGitHub with:
# install.packages("pak")pak::pkg_install("inlabru-org/fmesher@stable")
You can install the development version of inlabru fromGitHub with
pak::pkg_install("inlabru-org/fmesher")
or track the development version builds viainlabru-org.r-universe.dev:
# Enable universe(s) by inlabru-orgpak::repo_add(inlabruorg="https://inlabru-org.r-universe.dev")pak::pkg_install("fmesher")
This will pick the r-universe version if it is more recent than the CRANversion.
To install and runfmesher in full debug mode (this is quite anexperience!), use
# install.packages("pkgbuild")source("https://raw.githubusercontent.com/inlabru-org/fmesher/devel/misc/build.R")fmesher_install(repo="inlabru-org/fmesher",debug=TRUE)
You can install the latest bugfix release of fmesher fromGitHub with:
# install.packages("remotes")remotes::install_github("inlabru-org/fmesher",ref="stable")
You can install the development version of fmesher fromGitHub with
remotes::install_github("inlabru-org/fmesher")
or track the development version builds viainlabru-org.r-universe.dev:
# Enable universe(s) by inlabru-orgoptions(repos= c(inlabruorg="https://inlabru-org.r-universe.dev", getOption("repos")))install.packages("fmesher")
https://inlabru-org.github.io/fmesher/
Refined constrained Delaunay triangulations can be constructed byfm_rcdt_2d() andfm_mesh_2d(). The_inla() versions of these willusually return the same meshes as the oldINLA methods,INLA::inla.mesh.create() andINLA::inla.mesh.2d().
suppressPackageStartupMessages(library(fmesher))suppressPackageStartupMessages(library(ggplot2))bnd<- fm_extensions(cbind(0,0),convex= c(1,1.5))(mesh<- fm_mesh_2d_inla(boundary=bnd,max.edge= c(0.2,0.5)))#> fm_mesh_2d object:#> Manifold: R2#> V / E / T: 304 / 877 / 574#> Euler char.: 1#> Constraints: Boundary: 32 boundary edges (1 group: 1), Interior: 54 interior edges (1 group: 1)#> Bounding box: (-1.498873, 1.498873) x (-1.498873, 1.498873)#> Basis d.o.f.: 304
ggplot()+ geom_fm(data=mesh)+ theme_minimal()
Mostly regular triangulations can be constructed by supplying a regularset of input points. Thefm_hexagon_lattice() function (developed byMan Ho Suen) generates points in a regular hexagonal lattice pattern,contained in a givensf polygon.
hex_points<- fm_hexagon_lattice(bnd=bnd[[1]],edge_len=0.2)(mesh_hex<- fm_mesh_2d_inla(loc=hex_points,boundary=bnd,max.edge= c(0.3,0.5)))#> fm_mesh_2d object:#> Manifold: R2#> V / E / T: 164 / 457 / 294#> Euler char.: 1#> Constraints: Boundary: 32 boundary edges (1 group: 1), Interior: 33 interior edges (1 group: 1)#> Bounding box: (-1.498873, 1.498873) x (-1.498873, 1.498873)#> Basis d.o.f.: 164
ggplot()+ geom_fm(data=mesh_hex)+ theme_minimal()
(mesh<- fm_mesh_1d(c(1,2,3,4,6),boundary= c("neumann","free"),degree=2))#> fm_mesh_1d object:#> Manifold: R1#> #{knots}: 5#> Interval: (1, 6)#> Boundary: (neumann, free)#> B-spline degree: 2#> Basis d.o.f.: 5
ggplot()+ geom_fm(data=mesh,xlim= c(0,7))
The package provides methodsfm_crs() andfm_CRS() for extractingCRS information fromsf andsp objects and automatically converts tothe desired output format. Thefm_transform() wrapper similarlyhandles a variety of objects, as well as special handling for convertingbetween spheres and globes of different radii, e.g. used to map betweenthe Earth and a unit radius sphere uses as a model of the Earth.
# longlat for a spherical version of the Earthprint(fm_proj4string(fm_crs("longlat_globe")))#> [1] "+proj=longlat +ellps=sphere +no_defs"# longlat for a sphere of radius 1mprint(fm_proj4string(fm_crs("longlat_norm")))#> [1] "+proj=longlat +R=1 +no_defs"# A sphere of radius 1mprint(fm_proj4string(fm_crs("sphere")))#> [1] "+proj=geocent +R=1 +units=m +no_defs"
About
Standalone package for mesh/SPDE/GMRF code from the INLA package
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors5
Uh oh!
There was an error while loading.Please reload this page.


