diff --git a/previews/PR122/.documenter-siteinfo.json b/previews/PR122/.documenter-siteinfo.json index 520faabd..baacc85a 100644 --- a/previews/PR122/.documenter-siteinfo.json +++ b/previews/PR122/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.9.4","generation_timestamp":"2024-10-27T17:44:57","documenter_version":"1.7.0"}} \ No newline at end of file +{"documenter":{"julia_version":"1.9.4","generation_timestamp":"2024-10-27T18:29:59","documenter_version":"1.7.0"}} \ No newline at end of file diff --git a/previews/PR122/api/index.html b/previews/PR122/api/index.html index 8b57bc98..f2f2a1e0 100644 --- a/previews/PR122/api/index.html +++ b/previews/PR122/api/index.html @@ -1,3 +1,3 @@ -Public API · MeshIntegrals.jl

Public API

Integrals

MeshIntegrals.integralFunction
integral(f, geometry[, rule]; diff_method=FiniteDifference(), 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)
  • diff_method: optionally, use a particular DifferentiationMethod for

calculating differential elements

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

Specializations

MeshIntegrals.integralMethod
integral(f, curve::BezierCurve, rule = GaussKronrod();
-         diff_method=FiniteDifference(), FP=Float64, alg=Meshes.Horner())

Like integral but integrates along the domain defined a curve. By default this uses Horner's method to improve performance when parameterizing the curve at the expense of a small loss of precision. Additional accuracy can be obtained by specifying the use of DeCasteljau's algorithm instead with alg=Meshes.DeCasteljau() but can come at a steep cost in memory allocations, especially for curves with a large number of control points.

source
MeshIntegrals.integralMethod
integral(f, triangle::Triangle, ::GaussKronrod; FP=Float64)

Like integral but integrates over the surface of a triangle using nested Gauss-Kronrod quadrature rules along each barycentric dimension of the triangle.

source
MeshIntegrals.integralMethod
integral(f, triangle::Triangle, ::GaussLegendre; FP=Float64)

Like integral but integrates over the surface of a triangle by transforming the triangle into a polar-barycentric coordinate system and using a Gauss-Legendre quadrature rule along each barycentric dimension of the triangle.

source
MeshIntegrals.integralMethod
integral(f, triangle::Triangle, ::GaussKronrod; FP=Float64)

Like integral but integrates over the surface of a triangle by transforming the triangle into a polar-barycentric coordinate system and using an h-adaptive cubature rule.

source

Aliases

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

Derivatives

MeshIntegrals.differentialMethod
differential(geometry, ts, diff_method=FiniteDifference())

Calculate the differential element (length, area, volume, etc) of the parametric function for geometry at arguments ts.

source
MeshIntegrals.jacobianFunction
jacobian(geometry, ts, diff_method=FiniteDifference())

Calculate the Jacobian of a geometry's parametric function at some point ts using a particular differentiation method diff_method.

Arguments

  • geometry: some Meshes.Geometry of N parametric dimensions
  • ts: a parametric point specified as a vector or tuple of length N
  • diff_method: the desired DifferentiationMethod
source
+Public API · MeshIntegrals.jl

Public API

Integrals

MeshIntegrals.integralFunction
integral(f, geometry[, rule]; diff_method=FiniteDifference(), 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)
  • diff_method: optionally, use a particular DifferentiationMethod for

calculating differential elements

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

Specializations

MeshIntegrals.integralMethod
integral(f, curve::BezierCurve, rule = GaussKronrod();
+         diff_method=FiniteDifference(), FP=Float64, alg=Meshes.Horner())

Like integral but integrates along the domain defined a curve. By default this uses Horner's method to improve performance when parameterizing the curve at the expense of a small loss of precision. Additional accuracy can be obtained by specifying the use of DeCasteljau's algorithm instead with alg=Meshes.DeCasteljau() but can come at a steep cost in memory allocations, especially for curves with a large number of control points.

source
MeshIntegrals.integralMethod
integral(f, triangle::Triangle, ::GaussKronrod; FP=Float64)

Like integral but integrates over the surface of a triangle using nested Gauss-Kronrod quadrature rules along each barycentric dimension of the triangle.

source
MeshIntegrals.integralMethod
integral(f, triangle::Triangle, ::GaussLegendre; FP=Float64)

Like integral but integrates over the surface of a triangle by transforming the triangle into a polar-barycentric coordinate system and using a Gauss-Legendre quadrature rule along each barycentric dimension of the triangle.

source
MeshIntegrals.integralMethod
integral(f, triangle::Triangle, ::GaussKronrod; FP=Float64)

Like integral but integrates over the surface of a triangle by transforming the triangle into a polar-barycentric coordinate system and using an h-adaptive cubature rule.

source

Aliases

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

Derivatives

MeshIntegrals.differentialMethod
differential(geometry, ts, diff_method=FiniteDifference())

Calculate the differential element (length, area, volume, etc) of the parametric function for geometry at arguments ts.

source
MeshIntegrals.jacobianFunction
jacobian(geometry, ts, diff_method=FiniteDifference())

Calculate the Jacobian of a geometry's parametric function at some point ts using a particular differentiation method diff_method.

Arguments

  • geometry: some Meshes.Geometry of N parametric dimensions
  • ts: a parametric point specified as a vector or tuple of length N
  • diff_method: the desired DifferentiationMethod
source
diff --git a/previews/PR122/index.html b/previews/PR122/index.html index a230c155..717de380 100644 --- a/previews/PR122/index.html +++ b/previews/PR122/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/PR122/supportmatrix/index.html b/previews/PR122/supportmatrix/index.html index 79093715..49c16ac0 100644 --- a/previews/PR122/supportmatrix/index.html +++ b/previews/PR122/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 simply 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
Ellipsoid
Frustum🎗️🎗️🎗️
FrustumSurface
Hexahedron
Line
ParaboloidSurface
ParametrizedCurve
Plane
Polyarea🎗️🎗️🎗️
Pyramid🎗️🎗️🎗️
Quadrangle
Ray
Ring
Rope
Segment
SimpleMesh🎗️🎗️🎗️
Sphere in 𝔼{2}
Sphere in 𝔼{3}
Tetrahedron in 𝔼{3}🎗️🎗️
Triangle
Torus
Wedge🎗️🎗️🎗️
+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 simply 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
Ellipsoid
Frustum🎗️🎗️🎗️
FrustumSurface
Hexahedron
Line
ParaboloidSurface
ParametrizedCurve
Plane
Polyarea🎗️🎗️🎗️
Pyramid🎗️🎗️🎗️
Quadrangle
Ray
Ring
Rope
Segment
SimpleMesh🎗️🎗️🎗️
Sphere in 𝔼{2}
Sphere in 𝔼{3}
Tetrahedron in 𝔼{3}🎗️🎗️
Triangle
Torus
Wedge🎗️🎗️🎗️
diff --git a/previews/PR122/triangle/index.html b/previews/PR122/triangle/index.html index ce874848..92e724fd 100644 --- a/previews/PR122/triangle/index.html +++ b/previews/PR122/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/PR122/usage/index.html b/previews/PR122/usage/index.html index 29a2b508..1f8f5be6 100644 --- a/previews/PR122/usage/index.html +++ b/previews/PR122/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