From 7929de475d42ba66c22c01827b02c3a0314a65f0 Mon Sep 17 00:00:00 2001 From: Michael Ingold Date: Tue, 12 Aug 2025 21:04:19 -0400 Subject: [PATCH 01/11] Remove support for GK in more than one dimension --- src/integral.jl | 24 +++++++----------------- src/integration_rules.jl | 7 +++---- src/utils.jl | 10 ---------- 3 files changed, 10 insertions(+), 31 deletions(-) diff --git a/src/integral.jl b/src/integral.jl index 94faebc5..12820348 100644 --- a/src/integral.jl +++ b/src/integral.jl @@ -63,24 +63,14 @@ function _integral( ) where {DM <: DifferentiationMethod, T <: AbstractFloat} _check_diff_method_support(geometry, diff_method) - # Implementation depends on number of parametric dimensions over which to integrate - N = Meshes.paramdim(geometry) - if N == 1 - integrand(t) = f(geometry(t)) * differential(geometry, (t,), diff_method) - return QuadGK.quadgk(integrand, zero(FP), one(FP); rule.kwargs...)[1] - elseif N == 2 - # Issue deprecation warning - Base.depwarn("Use `HAdaptiveCubature` instead of \ - `GaussKronrod` for surfaces.", :integral) - - # Nested integration - integrand2D(u, v) = f(geometry(u, v)) * differential(geometry, (u, v), diff_method) - βˆ«β‚(v) = QuadGK.quadgk(u -> integrand2D(u, v), zero(FP), one(FP); rule.kwargs...)[1] - return QuadGK.quadgk(v -> βˆ«β‚(v), zero(FP), one(FP); rule.kwargs...)[1] - else - _error_unsupported_combination("geometry with more than two parametric dimensions", - "GaussKronrod") + # Only supported for 1D geometries + if Meshes.paramdim(geometry) != 1 + msg = "GaussKronrod rules only supported in one parametric dimension." + throw(ArgumentError(msg)) end + + integrand(t) = f(geometry(t)) * differential(geometry, (t,), diff_method) + return QuadGK.quadgk(integrand, zero(FP), one(FP); rule.kwargs...)[1] end # GaussLegendre diff --git a/src/integration_rules.jl b/src/integration_rules.jl index 5d5fcc8c..5ba3433e 100644 --- a/src/integration_rules.jl +++ b/src/integration_rules.jl @@ -12,10 +12,9 @@ abstract type IntegrationRule end GaussKronrod(kwargs...) The h-adaptive Gauss-Kronrod quadrature rule implemented by -[QuadGK.jl](https://github.com/JuliaMath/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. +[QuadGK.jl](https://github.com/JuliaMath/QuadGK.jl) which can be used for any +single-dimensional geometry. All standard `QuadGK.quadgk` keyword arguments are +supported. """ struct GaussKronrod <: IntegrationRule kwargs::Base.Pairs diff --git a/src/utils.jl b/src/utils.jl index 94af3d2f..76677a21 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -1,13 +1,3 @@ -################################################################################ -# Misc. Internal Tools -################################################################################ - -# Common error message structure -function _error_unsupported_combination(geometry, rule) - msg = "Integrating a $geometry using a $rule rule not supported." - throw(ArgumentError(msg)) -end - ################################################################################ # DifferentiationMethod ################################################################################ From 6c53e9b540fe71dc292e12723549c23417342cce Mon Sep 17 00:00:00 2001 From: Michael Ingold Date: Tue, 12 Aug 2025 21:06:11 -0400 Subject: [PATCH 02/11] Bump version to 17-dev --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index e4b2af06..7fc131a9 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "MeshIntegrals" uuid = "dadec2fd-bbe0-4da4-9dbe-476c782c8e47" -version = "0.16.4" +version = "0.17.0-DEV" [deps] CliffordNumbers = "3998ac73-6bd4-4031-8035-f167dd3ed523" From a1ae9b5a84193116f5de1e56cfa4ddfd62b82c5b Mon Sep 17 00:00:00 2001 From: Michael Ingold Date: Tue, 12 Aug 2025 21:12:48 -0400 Subject: [PATCH 03/11] Update docs and changelog --- CHANGELOG.md | 4 ++++ docs/src/support.md | 47 +++++++++++++++++---------------------------- 2 files changed, 22 insertions(+), 29 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f3b05f1..30417caa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Removed + +- Removed previously-deprecated support for use of `GaussKronrod` rules on geometries with more than one parametric dimension. + ## [0.16.4] - 2025-08-10 diff --git a/docs/src/support.md b/docs/src/support.md index d6b57b9a..b58bf5f7 100644 --- a/docs/src/support.md +++ b/docs/src/support.md @@ -2,24 +2,13 @@ This library aims to enable users to calculate the value of integrals over all [**Meshes.jl**](https://github.com/JuliaGeometry/Meshes.jl) geometry types using -a number of numerical integration rules and techniques. However, some combinations -of geometry types and integration rules are ill-suited (and a few are simply not -yet implemented). - -## General Recommendations +a number of numerical integration rules and techniques. In general, `GaussKronrod` integration rules are recommended (and the default) for geometries with one parametric dimension. For geometries with more than one parametric dimension, e.g. surfaces and volumes, `HAdaptiveCubature` rules are recommended (and the default). -While it is currently possible to apply nested `GaussKronrod` rules to numerically -integrate surfaces, this produces results that are strictly inferior to using an -equivalent `HAdaptiveCubature` rule, so support for this usage has been deprecated. -In version 16.x of MeshIntegrals.jl, using a `GaussKronrod` rule for a surface -will work but will yield a deprecation warning. Beginning with a future version -17.0, this combination will simply be unsupported and throw an error. - ## The Support Matrix The following Support Matrix captures the current state of support for all geometry/rule @@ -28,46 +17,46 @@ designed to check for accuracy. | `Meshes.Geometry/Domain` | `GaussKronrod` | `GaussLegendre` | `HAdaptiveCubature` | |----------|----------------|---------------|---------------------| -| `Ball` in `𝔼{2}` | ⚠️ | βœ… | βœ… | +| `Ball` in `𝔼{2}` | πŸ›‘ | βœ… | βœ… | | `Ball` in `𝔼{3}` | πŸ›‘ | βœ… | βœ… | | `BezierCurve` | βœ… | βœ… | βœ… | | `Box` in `𝔼{1}` | βœ… | βœ… | βœ… | -| `Box` in `𝔼{2}` | ⚠️ | βœ… | βœ… | +| `Box` in `𝔼{2}` | πŸ›‘ | βœ… | βœ… | | `Box` in `𝔼{β‰₯3}` | πŸ›‘ | βœ… | βœ… | | `CartesianGrid` | βœ… | βœ… | βœ… | | `Circle` | βœ… | βœ… | βœ… | | `Cone` | πŸ›‘ | βœ… | βœ… | -| `ConeSurface` | ⚠️ | βœ… | βœ… | +| `ConeSurface` | πŸ›‘ | βœ… | βœ… | | `Cylinder` | πŸ›‘ | βœ… | βœ… | -| `CylinderSurface` | ⚠️ | βœ… | βœ… | -| `Disk` | ⚠️ | βœ… | βœ… | +| `CylinderSurface` | πŸ›‘ | βœ… | βœ… | +| `Disk` | πŸ›‘ | βœ… | βœ… | | `Ellipsoid` | βœ… | βœ… | βœ… | -| `Frustum` | ⚠️ | βœ… | βœ… | -| `FrustumSurface` | ⚠️ | βœ… | βœ… | +| `Frustum` | πŸ›‘ | βœ… | βœ… | +| `FrustumSurface` | πŸ›‘ | βœ… | βœ… | | `Hexahedron` | βœ… | βœ… | βœ… | | `Line` | βœ… | βœ… | βœ… | -| `ParaboloidSurface` | ⚠️ | βœ… | βœ… | +| `ParaboloidSurface` | πŸ›‘ | βœ… | βœ… | | `ParametrizedCurve` | βœ… | βœ… | βœ… | | `Plane` | βœ… | βœ… | βœ… | -| `PolyArea` | ⚠️ | βœ… | βœ… | -| `Pyramid` | ⚠️ | βœ… | βœ… | -| `Quadrangle` | ⚠️ | βœ… | βœ… | +| `PolyArea` | πŸ›‘ | βœ… | βœ… | +| `Pyramid` | πŸ›‘ | βœ… | βœ… | +| `Quadrangle` | πŸ›‘ | βœ… | βœ… | | `Ray` | βœ… | βœ… | βœ… | | `RegularGrid` | βœ… | βœ… | βœ… | | `Ring` | βœ… | βœ… | βœ… | | `Rope` | βœ… | βœ… | βœ… | | `Segment` | βœ… | βœ… | βœ… | -| `SimpleMesh` | ⚠️ | βœ… | βœ… | +| `SimpleMesh` | πŸ›‘ | βœ… | βœ… | | `Sphere` in `𝔼{2}` | βœ… | βœ… | βœ… | -| `Sphere` in `𝔼{3}` | ⚠️ | βœ… | βœ… | +| `Sphere` in `𝔼{3}` | πŸ›‘ | βœ… | βœ… | | `StructuredGrid` | βœ… | βœ… | βœ… | -| `Tetrahedron` | ⚠️ | βœ… | βœ… | +| `Tetrahedron` | πŸ›‘ | βœ… | βœ… | | `Triangle` | βœ… | βœ… | βœ… | -| `Torus` | ⚠️ | βœ… | βœ… | -| `Wedge` | ⚠️ | βœ… | βœ… | +| `Torus` | πŸ›‘ | βœ… | βœ… | +| `Wedge` | πŸ›‘ | βœ… | βœ… | | Symbol | Support Level | |--------|---------| | βœ… | Supported | -| ⚠️ | Deprecated | +| πŸ›‘ | Deprecated | | πŸ›‘ | Not supported | From 902423731132a6a6f2057e9ec635658469c4f1e3 Mon Sep 17 00:00:00 2001 From: Michael Ingold Date: Tue, 12 Aug 2025 21:14:40 -0400 Subject: [PATCH 04/11] Update support status for surfaces --- test/combinations.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/combinations.jl b/test/combinations.jl index 361b959e..e6b369d4 100644 --- a/test/combinations.jl +++ b/test/combinations.jl @@ -63,7 +63,7 @@ This file includes tests for: elseif N == 2 # surface aliases = Bool.((0, 1, 0)) - rules = Bool.((1, 1, 1)) + rules = Bool.((0, 1, 1)) return SupportStatus(aliases..., rules..., autoenzyme) elseif N == 3 # volume From 827b621f149e27a118ca7100fe1f721e9ea764c1 Mon Sep 17 00:00:00 2001 From: Michael Ingold Date: Tue, 12 Aug 2025 21:16:21 -0400 Subject: [PATCH 05/11] Remove unused deprecated status entry from legend --- docs/src/support.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/src/support.md b/docs/src/support.md index b58bf5f7..6d9b2d91 100644 --- a/docs/src/support.md +++ b/docs/src/support.md @@ -58,5 +58,4 @@ designed to check for accuracy. | Symbol | Support Level | |--------|---------| | βœ… | Supported | -| πŸ›‘ | Deprecated | | πŸ›‘ | Not supported | From 1ed86b4253dc43392df8301d8a857652855ee593 Mon Sep 17 00:00:00 2001 From: Michael Ingold Date: Tue, 12 Aug 2025 21:22:03 -0400 Subject: [PATCH 06/11] Tweak error check --- test/combinations.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/combinations.jl b/test/combinations.jl index e6b369d4..f6721f16 100644 --- a/test/combinations.jl +++ b/test/combinations.jl @@ -92,7 +92,7 @@ This file includes tests for: if getfield(supports, nameof(alias)) @test alias(testable.integrand, testable.geometry)β‰ˆtestable.solution rtol=rtol else - @test_throws "not supported" alias(testable.integrand, testable.geometry) + @test_throws "supported" alias(testable.integrand, testable.geometry) end end # for From b857086e8615edd0532c78059b7ec6f941db6e38 Mon Sep 17 00:00:00 2001 From: Michael Ingold Date: Tue, 12 Aug 2025 21:49:02 -0400 Subject: [PATCH 07/11] Tweak other error checks --- test/combinations.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/combinations.jl b/test/combinations.jl index f6721f16..0913fb4f 100644 --- a/test/combinations.jl +++ b/test/combinations.jl @@ -119,7 +119,7 @@ This file includes tests for: else f = testable.integrand geometry = testable.geometry - @test_throws "not supported" integral(f, geometry, rule) + @test_throws "supported" integral(f, geometry, rule) end end # for @@ -137,7 +137,7 @@ This file includes tests for: if supported @test integral(f, geometry; diff_method = method)β‰ˆsol rtol=rtol else - @test_throws "not supported" integral(f, geometry; diff_method = method) + @test_throws "supported" integral(f, geometry; diff_method = method) end end # for end # function From 82086f7f6dffdfc8c5d09c62863105a4a5c25792 Mon Sep 17 00:00:00 2001 From: Michael Ingold Date: Tue, 12 Aug 2025 22:55:45 -0400 Subject: [PATCH 08/11] Update benchmarks to skip unsupported GK usages --- benchmark/benchmarks.jl | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/benchmark/benchmarks.jl b/benchmark/benchmarks.jl index 14896a03..768d2ab6 100644 --- a/benchmark/benchmarks.jl +++ b/benchmark/benchmarks.jl @@ -21,12 +21,19 @@ rules = ( (name = "HAdaptiveCubature", rule = HAdaptiveCubature()) ) geometries = ( - (name = "Segment", item = Segment(Point(0, 0, 0), Point(1, 1, 1))), - (name = "Sphere", item = Sphere(Point(0, 0, 0), 1.0)) + (name = "Segment", item = Segment(Point(0, 0, 0), Point(1, 1, 1))), # 1D + (name = "Sphere", item = Sphere(Point(0, 0), 1.0)), # 2D + (name = "Sphere", item = Sphere(Point(0, 0, 0), 1.0)) # 3D ) SUITE["Integrals"] = let s = BenchmarkGroup() for (int, rule, geometry) in Iterators.product(integrands, rules, geometries) + # Skip unsupported applications of GaussKronrod + if (Meshes.paramdim(geometry.item) > 1) && (rule.rule == GaussKronrod()) + continue + end + + # Construct benchmark and add it to test suite n1 = geometry.name n2 = "$(int.name) $(rule.name)" s[n1][n2] = @benchmarkable integral($int.f, $geometry.item, $rule.rule) From 3471772c84e124ccbfc77839047888bad87979e5 Mon Sep 17 00:00:00 2001 From: Michael Ingold Date: Wed, 13 Aug 2025 20:06:44 -0400 Subject: [PATCH 09/11] Update outdated entries --- docs/src/support.md | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/docs/src/support.md b/docs/src/support.md index 6d9b2d91..4ad5b3fd 100644 --- a/docs/src/support.md +++ b/docs/src/support.md @@ -23,35 +23,37 @@ designed to check for accuracy. | `Box` in `𝔼{1}` | βœ… | βœ… | βœ… | | `Box` in `𝔼{2}` | πŸ›‘ | βœ… | βœ… | | `Box` in `𝔼{β‰₯3}` | πŸ›‘ | βœ… | βœ… | -| `CartesianGrid` | βœ… | βœ… | βœ… | +| `CartesianGrid` in `𝔼{1}` | βœ… | βœ… | βœ… | +| `CartesianGrid` in `𝔼{β‰₯2}` | πŸ›‘ | βœ… | βœ… | | `Circle` | βœ… | βœ… | βœ… | | `Cone` | πŸ›‘ | βœ… | βœ… | | `ConeSurface` | πŸ›‘ | βœ… | βœ… | | `Cylinder` | πŸ›‘ | βœ… | βœ… | | `CylinderSurface` | πŸ›‘ | βœ… | βœ… | | `Disk` | πŸ›‘ | βœ… | βœ… | -| `Ellipsoid` | βœ… | βœ… | βœ… | +| `Ellipsoid` | πŸ›‘ | βœ… | βœ… | | `Frustum` | πŸ›‘ | βœ… | βœ… | | `FrustumSurface` | πŸ›‘ | βœ… | βœ… | -| `Hexahedron` | βœ… | βœ… | βœ… | +| `Hexahedron` | πŸ›‘ | βœ… | βœ… | | `Line` | βœ… | βœ… | βœ… | | `ParaboloidSurface` | πŸ›‘ | βœ… | βœ… | | `ParametrizedCurve` | βœ… | βœ… | βœ… | -| `Plane` | βœ… | βœ… | βœ… | +| `Plane` | πŸ›‘ | βœ… | βœ… | | `PolyArea` | πŸ›‘ | βœ… | βœ… | | `Pyramid` | πŸ›‘ | βœ… | βœ… | | `Quadrangle` | πŸ›‘ | βœ… | βœ… | | `Ray` | βœ… | βœ… | βœ… | -| `RegularGrid` | βœ… | βœ… | βœ… | +| `RegularGrid` in `𝔼{1}` | βœ… | βœ… | βœ… | +| `RegularGrid` in `𝔼{β‰₯2}` | πŸ›‘ | βœ… | βœ… | | `Ring` | βœ… | βœ… | βœ… | | `Rope` | βœ… | βœ… | βœ… | | `Segment` | βœ… | βœ… | βœ… | | `SimpleMesh` | πŸ›‘ | βœ… | βœ… | -| `Sphere` in `𝔼{2}` | βœ… | βœ… | βœ… | -| `Sphere` in `𝔼{3}` | πŸ›‘ | βœ… | βœ… | -| `StructuredGrid` | βœ… | βœ… | βœ… | +| `Sphere` | πŸ›‘ | βœ… | βœ… | +| `StructuredGrid` in `𝔼{1}` | βœ… | βœ… | βœ… | +| `StructuredGrid` in `𝔼{β‰₯2}` | πŸ›‘ | βœ… | βœ… | | `Tetrahedron` | πŸ›‘ | βœ… | βœ… | -| `Triangle` | βœ… | βœ… | βœ… | +| `Triangle` | πŸ›‘ | βœ… | βœ… | | `Torus` | πŸ›‘ | βœ… | βœ… | | `Wedge` | πŸ›‘ | βœ… | βœ… | From 2b488b9727dae0e0e88108aa450dbfcfbccf0a43 Mon Sep 17 00:00:00 2001 From: Michael Ingold Date: Wed, 13 Aug 2025 20:12:07 -0400 Subject: [PATCH 10/11] Use helper function for alias error message generation --- src/integral_aliases.jl | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/integral_aliases.jl b/src/integral_aliases.jl index 811699ac..aca250f3 100644 --- a/src/integral_aliases.jl +++ b/src/integral_aliases.jl @@ -1,3 +1,7 @@ +function _alias_error_msg(name, N) + "Performing a $name integral on a geometry with $N parametric dimensions not supported." +end + ################################################################################ # Line Integral ################################################################################ @@ -24,8 +28,7 @@ function lineintegral( kwargs... ) if (N = Meshes.paramdim(geometry)) != 1 - throw(ArgumentError("Performing a line integral on a geometry \ - with $N parametric dimensions not supported.")) + throw(ArgumentError(_alias_error_msg("line", N))) end return integral(f, geometry, rule; kwargs...) @@ -57,8 +60,7 @@ function surfaceintegral( kwargs... ) if (N = Meshes.paramdim(geometry)) != 2 - throw(ArgumentError("Performing a surface integral on a geometry \ - with $N parametric dimensions not supported.")) + throw(ArgumentError(_alias_error_msg("surface", N))) end return integral(f, geometry, rule; kwargs...) @@ -90,8 +92,7 @@ function volumeintegral( kwargs... ) if (N = Meshes.paramdim(geometry)) != 3 - throw(ArgumentError("Performing a volume integral on a geometry \ - with $N parametric dimensions not supported.")) + throw(ArgumentError(_alias_error_msg("volume", N))) end return integral(f, geometry, rule; kwargs...) From 3428093b73a79d0dc7c5743ec25923914e091972 Mon Sep 17 00:00:00 2001 From: Michael Ingold Date: Wed, 13 Aug 2025 20:13:18 -0400 Subject: [PATCH 11/11] Revert error message --- src/integral.jl | 2 +- test/combinations.jl | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/integral.jl b/src/integral.jl index 12820348..51c8091f 100644 --- a/src/integral.jl +++ b/src/integral.jl @@ -65,7 +65,7 @@ function _integral( # Only supported for 1D geometries if Meshes.paramdim(geometry) != 1 - msg = "GaussKronrod rules only supported in one parametric dimension." + msg = "GaussKronrod rules not supported in more than one parametric dimension." throw(ArgumentError(msg)) end diff --git a/test/combinations.jl b/test/combinations.jl index 0913fb4f..e6b369d4 100644 --- a/test/combinations.jl +++ b/test/combinations.jl @@ -92,7 +92,7 @@ This file includes tests for: if getfield(supports, nameof(alias)) @test alias(testable.integrand, testable.geometry)β‰ˆtestable.solution rtol=rtol else - @test_throws "supported" alias(testable.integrand, testable.geometry) + @test_throws "not supported" alias(testable.integrand, testable.geometry) end end # for @@ -119,7 +119,7 @@ This file includes tests for: else f = testable.integrand geometry = testable.geometry - @test_throws "supported" integral(f, geometry, rule) + @test_throws "not supported" integral(f, geometry, rule) end end # for @@ -137,7 +137,7 @@ This file includes tests for: if supported @test integral(f, geometry; diff_method = method)β‰ˆsol rtol=rtol else - @test_throws "supported" integral(f, geometry; diff_method = method) + @test_throws "not supported" integral(f, geometry; diff_method = method) end end # for end # function