Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Standalone package for mesh/SPDE/GMRF code from the INLA package

License

NotificationsYou must be signed in to change notification settings

inlabru-org/fmesher

Repository files navigation

CRAN statusinlabru-org r-universe statusR build statustest-coverageCodecov test coverage

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.

Installation

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)

Installation usingremotes

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")

Online documentation

https://inlabru-org.github.io/fmesher/

Examples

2D triangular meshes

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()

2D triangular mesh

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()

Quasi-regular 2D triangular mesh

1D B-spline function spaces

(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))

1D B-spline function space

Extended helper methods for CRS handling

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

Stars

Watchers

Forks

Packages

No packages published

Contributors5

Languages


[8]ページ先頭

©2009-2025 Movatter.jp