From 3807c0e907d5ff818808a9bbea2f71293030202b Mon Sep 17 00:00:00 2001 From: Michael Ingold Date: Sun, 17 Aug 2025 19:24:21 -0400 Subject: [PATCH 01/10] Bump Meshes min --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index a0472333..b630efb5 100644 --- a/Project.toml +++ b/Project.toml @@ -25,7 +25,7 @@ Enzyme = "0.13.47" FastGaussQuadrature = "1" HCubature = "1.5" LinearAlgebra = "1" -Meshes = "0.52.12, 0.53, 0.54" +Meshes = "0.53, 0.54" QuadGK = "2.1.1" Unitful = "1.19" julia = "1.9" From e979b081b4d855942ebe732408fde441f3f93830 Mon Sep 17 00:00:00 2001 From: Michael Ingold Date: Sun, 17 Aug 2025 19:25:45 -0400 Subject: [PATCH 02/10] Use predicates --- src/integral.jl | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/integral.jl b/src/integral.jl index 51c8091f..c6840902 100644 --- a/src/integral.jl +++ b/src/integral.jl @@ -23,9 +23,7 @@ calculate Jacobians within the integration domain. function integral end # Default integration rule to use if unspecified -function _default_rule(geometry) - ifelse(Meshes.paramdim(geometry) == 1, GaussKronrod(), HAdaptiveCubature()) -end +_default_rule(geometry) = ifelse(Meshes.iscurve, GaussKronrod(), HAdaptiveCubature()) # If only f and geometry are specified, select default rule function integral( @@ -64,7 +62,7 @@ function _integral( _check_diff_method_support(geometry, diff_method) # Only supported for 1D geometries - if Meshes.paramdim(geometry) != 1 + if !Meshes.iscurve(geometry) msg = "GaussKronrod rules not supported in more than one parametric dimension." throw(ArgumentError(msg)) end From b1537ff6489f226bd7f563186e7c8bc3fe8e43e0 Mon Sep 17 00:00:00 2001 From: Michael Ingold Date: Sun, 17 Aug 2025 20:59:14 -0400 Subject: [PATCH 03/10] Fix _default_rule bug --- src/integral.jl | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/integral.jl b/src/integral.jl index c6840902..8eed8946 100644 --- a/src/integral.jl +++ b/src/integral.jl @@ -2,6 +2,9 @@ # Master Integral Function ################################################################################ +# Default integration rule when rule arg is unspecified +_default_rule(g) = ifelse(Meshes.iscurve(g), GaussKronrod(), HAdaptiveCubature()) + """ integral(f, geometry[, rule]; kwargs...) @@ -22,10 +25,6 @@ calculate Jacobians within the integration domain. """ function integral end -# Default integration rule to use if unspecified -_default_rule(geometry) = ifelse(Meshes.iscurve, GaussKronrod(), HAdaptiveCubature()) - -# If only f and geometry are specified, select default rule function integral( f, geometry::Geometry, From 5a4eb1f3761f4fed0cb392d8d32cdfdcd29510d9 Mon Sep 17 00:00:00 2001 From: Michael Ingold Date: Sun, 17 Aug 2025 21:08:09 -0400 Subject: [PATCH 04/10] Uses predicates --- src/integral_aliases.jl | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/integral_aliases.jl b/src/integral_aliases.jl index aca250f3..d44179b9 100644 --- a/src/integral_aliases.jl +++ b/src/integral_aliases.jl @@ -1,5 +1,5 @@ function _alias_error_msg(name, N) - "Performing a $name integral on a geometry with $N parametric dimensions not supported." + "$name integrals not supported on a geometry without exactly $N parametric dimensions." end ################################################################################ @@ -27,8 +27,8 @@ function lineintegral( rule::IntegrationRule = GaussKronrod(); kwargs... ) - if (N = Meshes.paramdim(geometry)) != 1 - throw(ArgumentError(_alias_error_msg("line", N))) + if !Meshes.iscurve(geometry) + throw(ArgumentError(_alias_error_msg("Line", 1))) end return integral(f, geometry, rule; kwargs...) @@ -59,8 +59,8 @@ function surfaceintegral( rule::IntegrationRule = HAdaptiveCubature(); kwargs... ) - if (N = Meshes.paramdim(geometry)) != 2 - throw(ArgumentError(_alias_error_msg("surface", N))) + if !Meshes.issurface(geometry) + throw(ArgumentError(_alias_error_msg("Surface", 2))) end return integral(f, geometry, rule; kwargs...) @@ -91,8 +91,8 @@ function volumeintegral( rule::IntegrationRule = HAdaptiveCubature(); kwargs... ) - if (N = Meshes.paramdim(geometry)) != 3 - throw(ArgumentError(_alias_error_msg("volume", N))) + if !Meshes.issolid(geometry) + throw(ArgumentError(_alias_error_msg("Volume", 3))) end return integral(f, geometry, rule; kwargs...) From 9f5213e716d26e7cec1a3432f68ea2dbe8ba6a55 Mon Sep 17 00:00:00 2001 From: Michael Ingold Date: Sun, 17 Aug 2025 21:11:22 -0400 Subject: [PATCH 05/10] Update docs Project.toml --- docs/Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Project.toml b/docs/Project.toml index aa17206f..8a11b5a1 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -8,6 +8,6 @@ Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d" [compat] BenchmarkTools = "1" Documenter = "1" -Meshes = "0.51.20, 0.52" +Meshes = "0.53, 0.54" Unitful = "1.19" julia = "1.9" From 1a439366452b7998ba8dcbf206c998f854cca148 Mon Sep 17 00:00:00 2001 From: Michael Ingold Date: Sun, 17 Aug 2025 21:12:26 -0400 Subject: [PATCH 06/10] Update test Project.toml --- test/Project.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/Project.toml b/test/Project.toml index c4d94210..aa11bfcb 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -12,12 +12,12 @@ TestItems = "1c621080-faea-4a02-84b6-bbd5e436b8fe" Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d" [compat] -Aqua = "0.7, 0.8" -CoordRefSystems = "0.15, 0.16, 0.17, 0.18" +Aqua = "0.8" +CoordRefSystems = "0.16, 0.17, 0.18" Enzyme = "0.13.47" ExplicitImports = "1.6.0" LinearAlgebra = "1" -Meshes = "0.51.20, 0.52, 0.53, 0.54" +Meshes = "0.53, 0.54" SpecialFunctions = "2" TestItemRunner = "1" TestItems = "1" From d9629c68580385532cfbb574374c2ca54ea77834 Mon Sep 17 00:00:00 2001 From: Michael Ingold Date: Sun, 17 Aug 2025 21:19:26 -0400 Subject: [PATCH 07/10] Update benchmark Project.toml --- benchmark/Project.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/benchmark/Project.toml b/benchmark/Project.toml index 6eec58b7..e775a676 100644 --- a/benchmark/Project.toml +++ b/benchmark/Project.toml @@ -7,8 +7,8 @@ Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d" [compat] BenchmarkTools = "1.5" -Enzyme = "0.13.19" +Enzyme = "0.13.47" LinearAlgebra = "1" -Meshes = "0.51.20, 0.52" +Meshes = "0.53, 0.54" Unitful = "1.19" julia = "1.9" From 45e24ab489c77f762cd7cc0d65912e153766beb0 Mon Sep 17 00:00:00 2001 From: Michael Ingold Date: Sun, 17 Aug 2025 21:53:58 -0400 Subject: [PATCH 08/10] Use SVector in benchmarks for vector-valued integrands --- benchmark/Project.toml | 2 ++ benchmark/benchmarks.jl | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/benchmark/Project.toml b/benchmark/Project.toml index e775a676..9e9d61bb 100644 --- a/benchmark/Project.toml +++ b/benchmark/Project.toml @@ -3,6 +3,7 @@ BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" Enzyme = "7da242da-08ed-463a-9acd-ee780be4f1d9" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" Meshes = "eacbb407-ea5a-433e-ab97-5258b1ca43fa" +StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d" [compat] @@ -10,5 +11,6 @@ BenchmarkTools = "1.5" Enzyme = "0.13.47" LinearAlgebra = "1" Meshes = "0.53, 0.54" +StaticArrays = "1" Unitful = "1.19" julia = "1.9" diff --git a/benchmark/benchmarks.jl b/benchmark/benchmarks.jl index 768d2ab6..0acc86a5 100644 --- a/benchmark/benchmarks.jl +++ b/benchmark/benchmarks.jl @@ -2,6 +2,7 @@ using BenchmarkTools using LinearAlgebra using Meshes using MeshIntegrals +using StaticArrays using Unitful import Enzyme @@ -11,9 +12,12 @@ const SUITE = BenchmarkGroup() # Integrals ############################################################################################ +# Like fill but returns an SVector to eliminate integrand function allocations +staticfill(val, N) = SVector(ntuple(Returns(val), N)...) + integrands = ( (name = "Scalar", f = p -> norm(to(p))), - (name = "Vector", f = p -> fill(norm(to(p)), 3)) + (name = "Vector", f = p -> staticfill(norm(to(p)), 3)) ) rules = ( (name = "GaussLegendre", rule = GaussLegendre(100)), From e9c8aa173a7618224eb640de2da3275af410ef52 Mon Sep 17 00:00:00 2001 From: Michael Ingold Date: Sun, 17 Aug 2025 22:24:51 -0400 Subject: [PATCH 09/10] Use SVector for allocation-free integrands in testing --- test/Project.toml | 2 ++ test/combinations.jl | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/test/Project.toml b/test/Project.toml index aa11bfcb..f6a8c27d 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -6,6 +6,7 @@ ExplicitImports = "7d51a73a-1435-4ff3-83d9-f097790105c7" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" Meshes = "eacbb407-ea5a-433e-ab97-5258b1ca43fa" SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b" +StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" TestItemRunner = "f8b46487-2199-4994-9208-9a1283c18c0a" TestItems = "1c621080-faea-4a02-84b6-bbd5e436b8fe" @@ -19,6 +20,7 @@ ExplicitImports = "1.6.0" LinearAlgebra = "1" Meshes = "0.53, 0.54" SpecialFunctions = "2" +StaticArrays = "1" TestItemRunner = "1" TestItems = "1" Unitful = "1.19" diff --git a/test/combinations.jl b/test/combinations.jl index b3ba3800..40f65d4d 100644 --- a/test/combinations.jl +++ b/test/combinations.jl @@ -18,9 +18,12 @@ This file includes tests for: import LinearAlgebra: norm using Meshes using MeshIntegrals: MeshIntegrals, GeometryOrDomain + import StaticArrays: SVector import Unitful: @u_str, Quantity, ustrip import Enzyme + staticfill(val, N) = SVector(ntuple(Returns(val), N)...) + # Used for testing callable objects as integrand functions struct Callable{F <: Function} f::F @@ -113,8 +116,8 @@ This file includes tests for: @test integral(f, testable.geometry, rule)≈sol rtol=rtol # Vector integrand - fv(p) = fill(testable.integrand(p), 3) - sol_v = fill(testable.solution, 3) + fv(p) = staticfill(testable.integrand(p), 3) + sol_v = staticfill(testable.solution, 3) @test integral(fv, testable.geometry, rule)≈sol_v rtol=rtol else f = testable.integrand From dea6e24469daec68cb70593b0f5a48fbd76000cc Mon Sep 17 00:00:00 2001 From: Michael Ingold Date: Mon, 18 Aug 2025 06:41:59 -0400 Subject: [PATCH 10/10] Update CHANGELOG.md --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 62268d89..7fb868c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,11 +8,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -## [0.17.0] - 2025-08-14 +## [0.17.0] - 2025-08-18 ### Changed -- Increased minimum dependency version for Meshes.jl to `v0.52.12` and CoordRefSystems.jl to `0.16` to natively support some new geometry types. +- Increased minimum dependency version for Meshes.jl to `v0.53` and CoordRefSystems.jl to `0.16` to support some new geometry types and make use of new helper functions. ### Removed