diff --git a/previews/PR101/.documenter-siteinfo.json b/previews/PR101/.documenter-siteinfo.json index c460186..0ce06dd 100644 --- a/previews/PR101/.documenter-siteinfo.json +++ b/previews/PR101/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.9.4","generation_timestamp":"2024-10-08T01:39:20","documenter_version":"1.7.0"}} \ No newline at end of file +{"documenter":{"julia_version":"1.9.4","generation_timestamp":"2024-10-08T01:50:24","documenter_version":"1.7.0"}} \ No newline at end of file diff --git a/previews/PR101/api/index.html b/previews/PR101/api/index.html index 4bb8473..4c2bc92 100644 --- a/previews/PR101/api/index.html +++ b/previews/PR101/api/index.html @@ -1,2 +1,2 @@ -Public API · MeshIntegrals.jl

Public API

Integrals

MeshIntegrals.integralFunction
integral(f, geometry[, rule]; FP=Float64)

Numerically integrate a given function f(::Point) over the domain defined by a geometry using a particular numerical integration rule with floating point precision of type FP.

Arguments

  • f: an integrand function with a method f(::Meshes.Point)
  • geometry: some Meshes.Geometry that defines the integration domain
  • rule: optionally, the IntegrationRule used for integration (by default GaussKronrod() in 1D and HAdaptiveCubature() else)
  • FP: optionally, the floating point precision desired (Float64 by default)

Note that reducing FP below Float64 will incur some loss of precision. By contrast, increasing FP to e.g. BigFloat will typically increase precision (at the expense of longer runtimes).

source

Aliases

MeshIntegrals.lineintegralFunction
lineintegral(f, geometry[, rule]; FP=Float64)

Numerically integrate a given function f(::Point) along a line-like geometry using a particular numerical integration rule with floating point precision of type FP.

Rule types available:

  • GaussKronrod (default)
  • GaussLegendre
  • HAdaptiveCubature
source
MeshIntegrals.surfaceintegralFunction
surfaceintegral(f, geometry[, rule]; FP=Float64)

Numerically integrate a given function f(::Point) along a surface geometry using a particular numerical integration rule with floating point precision of type FP.

Algorithm types available:

  • GaussKronrod
  • GaussLegendre
  • HAdaptiveCubature (default)
source
MeshIntegrals.volumeintegralFunction
volumeintegral(f, geometry[, rule]; FP=Float64)

Numerically integrate a given function f(::Point) throughout a volumetric geometry using a particular numerical integration rule with floating point precision of type FP.

Algorithm types available:

  • GaussKronrod
  • GaussLegendre
  • HAdaptiveCubature (default)
source

Integration Rules

MeshIntegrals.GaussKronrodType
GaussKronrod(kwargs...)

The h-adaptive Gauss-Kronrod quadrature rule implemented by QuadGK.jl. All standard QuadGK.quadgk keyword arguments are supported. This rule works natively for one dimensional geometries; some two- and three-dimensional geometries are additionally supported using nested integral solvers with the specified kwarg settings.

source
MeshIntegrals.GaussLegendreType
GaussLegendre(n)

An n'th-order Gauss-Legendre quadrature rule. Nodes and weights are efficiently calculated using FastGaussQuadrature.jl.

So long as the integrand function can be well-approximated by a polynomial of order 2n-1, this method should yield results with 16-digit accuracy in O(n) time. If the function is know to have some periodic content, then n should (at a minimum) be greater than the expected number of periods over the geometry, e.g. length(geometry)/λ.

source
MeshIntegrals.HAdaptiveCubatureType
HAdaptiveCubature(kwargs...)

The h-adaptive cubature rule implemented by HCubature.jl. All standard HCubature.hcubature keyword arguments are supported.

source

Derivatives

MeshIntegrals.jacobianFunction
jacobian(geometry, ts; ε=1e-6)

Calculate the Jacobian of a geometry at some parametric point ts using a simple finite-difference approximation with step size ε.

Arguments

  • geometry: some Meshes.Geometry of N parametric dimensions
  • ts: a parametric point specified as a vector or tuple of length N
  • ε: step size to use for the finite-difference approximation
source
+Public API · MeshIntegrals.jl

Public API

Integrals

MeshIntegrals.integralFunction
integral(f, geometry[, rule]; FP=Float64)

Numerically integrate a given function f(::Point) over the domain defined by a geometry using a particular numerical integration rule with floating point precision of type FP.

Arguments

  • f: an integrand function with a method f(::Meshes.Point)
  • geometry: some Meshes.Geometry that defines the integration domain
  • rule: optionally, the IntegrationRule used for integration (by default GaussKronrod() in 1D and HAdaptiveCubature() else)
  • FP: optionally, the floating point precision desired (Float64 by default)

Note that reducing FP below Float64 will incur some loss of precision. By contrast, increasing FP to e.g. BigFloat will typically increase precision (at the expense of longer runtimes).

source

Aliases

MeshIntegrals.lineintegralFunction
lineintegral(f, geometry[, rule]; FP=Float64)

Numerically integrate a given function f(::Point) along a line-like geometry using a particular numerical integration rule with floating point precision of type FP.

Rule types available:

  • GaussKronrod (default)
  • GaussLegendre
  • HAdaptiveCubature
source
MeshIntegrals.surfaceintegralFunction
surfaceintegral(f, geometry[, rule]; FP=Float64)

Numerically integrate a given function f(::Point) along a surface geometry using a particular numerical integration rule with floating point precision of type FP.

Algorithm types available:

  • GaussKronrod
  • GaussLegendre
  • HAdaptiveCubature (default)
source
MeshIntegrals.volumeintegralFunction
volumeintegral(f, geometry[, rule]; FP=Float64)

Numerically integrate a given function f(::Point) throughout a volumetric geometry using a particular numerical integration rule with floating point precision of type FP.

Algorithm types available:

  • GaussKronrod
  • GaussLegendre
  • HAdaptiveCubature (default)
source

Integration Rules

MeshIntegrals.GaussKronrodType
GaussKronrod(kwargs...)

The h-adaptive Gauss-Kronrod quadrature rule implemented by QuadGK.jl. All standard QuadGK.quadgk keyword arguments are supported. This rule works natively for one dimensional geometries; some two- and three-dimensional geometries are additionally supported using nested integral solvers with the specified kwarg settings.

source
MeshIntegrals.GaussLegendreType
GaussLegendre(n)

An n'th-order Gauss-Legendre quadrature rule. Nodes and weights are efficiently calculated using FastGaussQuadrature.jl.

So long as the integrand function can be well-approximated by a polynomial of order 2n-1, this method should yield results with 16-digit accuracy in O(n) time. If the function is know to have some periodic content, then n should (at a minimum) be greater than the expected number of periods over the geometry, e.g. length(geometry)/λ.

source
MeshIntegrals.HAdaptiveCubatureType
HAdaptiveCubature(kwargs...)

The h-adaptive cubature rule implemented by HCubature.jl. All standard HCubature.hcubature keyword arguments are supported.

source

Derivatives

MeshIntegrals.jacobianFunction
jacobian(geometry, ts; ε=1e-6)

Calculate the Jacobian of a geometry at some parametric point ts using a simple finite-difference approximation with step size ε.

Arguments

  • geometry: some Meshes.Geometry of N parametric dimensions
  • ts: a parametric point specified as a vector or tuple of length N
  • ε: step size to use for the finite-difference approximation
source
diff --git a/previews/PR101/index.html b/previews/PR101/index.html index 7a6d1cf..4473e74 100644 --- a/previews/PR101/index.html +++ b/previews/PR101/index.html @@ -1,2 +1,2 @@ -About · MeshIntegrals.jl

MeshIntegrals.jl

Docs-stable Docs-dev License: MIT ColPrac

Build Status codecov Coveralls Aqua QA

MeshIntegrals.jl is a Julia library that leverages differential forms to implement fast and easy numerical integration of field equations over geometric domains.

+About · MeshIntegrals.jl

MeshIntegrals.jl

Docs-stable Docs-dev License: MIT ColPrac

Build Status codecov Coveralls Aqua QA

MeshIntegrals.jl is a Julia library that leverages differential forms to implement fast and easy numerical integration of field equations over geometric domains.

diff --git a/previews/PR101/supportmatrix/index.html b/previews/PR101/supportmatrix/index.html index ffce49d..6036b47 100644 --- a/previews/PR101/supportmatrix/index.html +++ b/previews/PR101/supportmatrix/index.html @@ -1,2 +1,2 @@ -Support Matrix · MeshIntegrals.jl

Support Matrix

While this library aims to support all possible integration rules and Meshes.jl geometry types, some combinations are ill-suited and some others are simplu not yet implemented. The following Support Matrix aims to capture the current development state of all geometry/rule combinations. Entries with a green check mark are fully supported and have passing unit tests that provide some confidence they produce accurate results.

In general, Gauss-Kronrod integration rules are recommended (and the default) for geometries with one parametric dimension, e.g.: Segment, BezierCurve, and Rope. Gauss-Kronrod rules can also be applied to some geometries with more dimensions by nesting multiple integration solves, but this is inefficient. These Gauss-Kronrod rules are supported (but not recommended) for surface-like geometries, but not for volume-like geometries. For geometries with more than one parametric dimension, e.g. surfaces and volumes, H-Adaptive Cubature integration rules are recommended (and the default).

SymbolSupport Level
Supported, passes unit tests
🎗️Planned to support in the future
🛑Not supported
Meshes.GeometryGauss-LegendreGauss-KronrodH-Adaptive Cubature
Ball in 𝔼{2}
Ball in 𝔼{3}🛑
BezierCurve
Box in 𝔼{1}
Box in 𝔼{2}
Box in 𝔼{3}🛑
Circle
Cone
ConeSurface
Cylinder🛑
CylinderSurface
Disk
Frustum🎗️🎗️🎗️
FrustumSurface
Line
ParaboloidSurface
Plane
Quadrangle
Ray
Ring
Rope
Segment
SimpleMesh🎗️🎗️🎗️
Sphere in 𝔼{2}
Sphere in 𝔼{3}
Tetrahedron in 𝔼{3}🎗️🎗️
Triangle
Torus
+Support Matrix · MeshIntegrals.jl

Support Matrix

While this library aims to support all possible integration rules and Meshes.jl geometry types, some combinations are ill-suited and some others are simplu not yet implemented. The following Support Matrix aims to capture the current development state of all geometry/rule combinations. Entries with a green check mark are fully supported and have passing unit tests that provide some confidence they produce accurate results.

In general, Gauss-Kronrod integration rules are recommended (and the default) for geometries with one parametric dimension, e.g.: Segment, BezierCurve, and Rope. Gauss-Kronrod rules can also be applied to some geometries with more dimensions by nesting multiple integration solves, but this is inefficient. These Gauss-Kronrod rules are supported (but not recommended) for surface-like geometries, but not for volume-like geometries. For geometries with more than one parametric dimension, e.g. surfaces and volumes, H-Adaptive Cubature integration rules are recommended (and the default).

SymbolSupport Level
Supported, passes unit tests
🎗️Planned to support in the future
🛑Not supported
Meshes.GeometryGauss-LegendreGauss-KronrodH-Adaptive Cubature
Ball in 𝔼{2}
Ball in 𝔼{3}🛑
BezierCurve
Box in 𝔼{1}
Box in 𝔼{2}
Box in 𝔼{3}🛑
Circle
Cone
ConeSurface
Cylinder🛑
CylinderSurface
Disk
Frustum🎗️🎗️🎗️
FrustumSurface
Line
ParaboloidSurface
Plane
Quadrangle
Ray
Ring
Rope
Segment
SimpleMesh🎗️🎗️🎗️
Sphere in 𝔼{2}
Sphere in 𝔼{3}
Tetrahedron in 𝔼{3}🎗️🎗️
Triangle
Torus
diff --git a/previews/PR101/triangle/index.html b/previews/PR101/triangle/index.html index 36c4cf1..38c7e5a 100644 --- a/previews/PR101/triangle/index.html +++ b/previews/PR101/triangle/index.html @@ -4,4 +4,4 @@ = 2A \int_0^1 \int_0^{1-v} f\left( \bar{r}(u,v) \right) \, \text{d}u \, \text{d}v\]

Since the integral domain is a right-triangle in the Barycentric domain, a nested application of Gauss-Kronrod quadrature rules is capable of computing the result, albeit inefficiently. However, many numerical integration methods that require rectangular bounds can not be directly applied.

In order to enable integration methods that operate over rectangular bounds, two coordinate system transformations are applied: the first maps from Barycentric coordinates $(u, v)$ to polar coordinates $(r, \phi)$, and the second is a non-linear map from polar coordinates to a new curvilinear basis $(R, \phi)$.

For the first transformation, let $u = r~\cos\phi$ and $v = r~\sin\phi$ where $\text{d}u~\text{d}v = r~\text{d}r~\text{d}\phi$. The Barycentric triangle's hypotenuse boundary line is described by the function $v(u) = 1 - u$. Substituting in the previous definitions leads to a new boundary line function in polar coordinate space $r(\phi) = 1 / (\sin\phi + \cos\phi)$.

\[\int_0^1 \int_0^{1-v} f\left( \bar{r}(u,v) \right) \, \text{d}u \, \text{d}v = \int_0^{\pi/2} \int_0^{1/(\sin\phi+\cos\phi)} f\left( \bar{r}(r,\phi) \right) \, r \, \text{d}r \, \text{d}\phi\]

These integral boundaries remain non-rectangular, so an additional transformation will be applied to a curvilinear $(R, \phi)$ space that normalizes all of the hypotenuse boundary line points to $R=1$. To achieve this, a function $R(r,\phi)$ is required such that $R(r_0, \phi) = 1$ where $r_0 = 1 / (\sin\phi + \cos\phi)$

To achieve this, let $R(r, \phi) = r~(\sin\phi + \cos\phi)$. Now, substituting some terms leads to

\[\int_0^{\pi/2} \int_0^{1/(\sin\phi+\cos\phi)} f\left( \bar{r}(r,\phi) \right) \, r \, \text{d}r \, \text{d}\phi = \int_0^{\pi/2} \int_0^{r_0} f\left( \bar{r}(r,\phi) \right) \, \left(\frac{R}{\sin\phi + \cos\phi}\right) \, \text{d}r \, \text{d}\phi\]

Since $\text{d}R/\text{d}r = \sin\phi + \cos\phi$, a change of integral domain leads to

\[\int_0^{\pi/2} \int_0^{r_0} f\left( \bar{r}(r,\phi) \right) \, \left(\frac{R}{\sin\phi + \cos\phi}\right) \, \text{d}r \, \text{d}\phi - = \int_0^{\pi/2} \int_0^1 f\left( \bar{r}(R,\phi) \right) \, \left(\frac{R}{\left(\sin\phi + \cos\phi\right)^2}\right) \, \text{d}R \, \text{d}\phi\]

The second term in this new integrand function serves as a correction factor that corrects for the impact of the non-linear domain transformation. Since all of the integration bounds are now constants, specialized integration methods can be defined for triangles that performs these domain transformations and then solve the new rectangular integration problem using a wider range of solver options.

+ = \int_0^{\pi/2} \int_0^1 f\left( \bar{r}(R,\phi) \right) \, \left(\frac{R}{\left(\sin\phi + \cos\phi\right)^2}\right) \, \text{d}R \, \text{d}\phi\]

The second term in this new integrand function serves as a correction factor that corrects for the impact of the non-linear domain transformation. Since all of the integration bounds are now constants, specialized integration methods can be defined for triangles that performs these domain transformations and then solve the new rectangular integration problem using a wider range of solver options.

diff --git a/previews/PR101/usage/index.html b/previews/PR101/usage/index.html index 2657c37..b672e0b 100644 --- a/previews/PR101/usage/index.html +++ b/previews/PR101/usage/index.html @@ -23,4 +23,4 @@ integral(f, unit_circle_bz, GaussKronrod()) # 0.017122 seconds (18.93 k allocations: 78.402 MiB) - # ans = 5.551055333711397 m^2 + # ans = 5.551055333711397 m^2