From 01f14dece018551747f368cf998470f22d2c7bf2 Mon Sep 17 00:00:00 2001 From: Michael Ingold Date: Fri, 4 Oct 2024 20:46:23 -0400 Subject: [PATCH 01/19] Implement new Tetrahedron tests --- test/auto_tests.jl | 2 -- test/combinations.jl | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/test/auto_tests.jl b/test/auto_tests.jl index a1f699a7..4c4b9e73 100644 --- a/test/auto_tests.jl +++ b/test/auto_tests.jl @@ -86,7 +86,6 @@ end parab(T) = ParaboloidSurface(origin3d(T), T(2.5), T(4.15)) sphere2d(T) = Sphere(origin2d(T), T(2.5)) sphere3d(T) = Sphere(origin3d(T), T(2.5)) - tetra(T) = Tetrahedron(pt_n(T), pt_w(T), pt_e(T), pt_n(T) + ẑ(T)) triangle(T) = Ngon(pt_e(T), pt_n(T), pt_w(T)) torus(T) = Torus(origin3d(T), ẑ(T), T(3.5), T(1.25)) @@ -101,7 +100,6 @@ end SupportItem("ParaboloidSurface{$T}", T, parab(T), 1, 0, 1, 0, 1, 1, 1), SupportItem("Sphere{2,$T}", T, sphere2d(T), 1, 1, 0, 0, 1, 1, 1), SupportItem("Sphere{3,$T}", T, sphere3d(T), 1, 0, 1, 0, 1, 1, 1), - SupportItem("Tetrahedron", T, tetra(T), 1, 0, 0, 1, 0, 1, 0), SupportItem("Triangle{$T}", T, triangle(T), 1, 0, 1, 0, 1, 1, 1), SupportItem("Torus{$T}", T, torus(T), 1, 0, 1, 0, 1, 1, 1) ] diff --git a/test/combinations.jl b/test/combinations.jl index a334846e..273a0bf5 100644 --- a/test/combinations.jl +++ b/test/combinations.jl @@ -449,3 +449,28 @@ end @test_throws "not supported" surfaceintegral(f, segment) @test_throws "not supported" volumeintegral(f, segment) end + +@testitem "Meshes.Tetrahedron" setup=[Setup] begin + pt_n = Point(0, 1, 0) + pt_w = Point(-1, 0, 0) + pt_e = Point(1, 0, 0) + ẑ = Vec(0, 0, 1) + tetrahedron = Tetrahedron(pt_n, pt_w, pt_e, pt_n + ẑ) + + # Scalar integrand + sol = Meshes.measure(tetrahedron) + @test_throws "not supported" integral(f, tetrahedron, GaussLegendre(100)) + @test integral(f, tetrahedron, GaussKronrod()) ≈ sol + @test_throws "not supported" integral(f, tetrahedron, HAdaptiveCubature()) + + # Vector integrand + vsol = fill(sol, 3) + @test_throws "not supported" integral(fv, tetrahedron, GaussLegendre(100)) ≈ vsol + @test integral(fv, tetrahedron, GaussKronrod()) ≈ vsol + @test_throws "not supported" integral(fv, tetrahedron, HAdaptiveCubature()) ≈ vsol + + # Integral aliases + @test_throws "not supported" lineintegral(f, tetrahedron) + @test_throws "not supported" surfaceintegral(f, tetrahedron) + @test volumeintegral(f, tetrahedron) ≈ sol +end From a5781c3386e397d182fb2deb97d6c0e74ce0007d Mon Sep 17 00:00:00 2001 From: Michael Ingold Date: Fri, 4 Oct 2024 20:50:46 -0400 Subject: [PATCH 02/19] Bugfix --- test/combinations.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/combinations.jl b/test/combinations.jl index 273a0bf5..159b6a0e 100644 --- a/test/combinations.jl +++ b/test/combinations.jl @@ -457,6 +457,8 @@ end ẑ = Vec(0, 0, 1) tetrahedron = Tetrahedron(pt_n, pt_w, pt_e, pt_n + ẑ) + f = p -> one(Float64) + # Scalar integrand sol = Meshes.measure(tetrahedron) @test_throws "not supported" integral(f, tetrahedron, GaussLegendre(100)) From af8eb2aac636eb1f82dadeb0ca87313d151bed1e Mon Sep 17 00:00:00 2001 From: Michael Ingold Date: Fri, 4 Oct 2024 21:22:22 -0400 Subject: [PATCH 03/19] Fix tests --- test/combinations.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/combinations.jl b/test/combinations.jl index 159b6a0e..de2e6b64 100644 --- a/test/combinations.jl +++ b/test/combinations.jl @@ -458,6 +458,7 @@ end tetrahedron = Tetrahedron(pt_n, pt_w, pt_e, pt_n + ẑ) f = p -> one(Float64) + fv(p) = fill(f(p), 3) # Scalar integrand sol = Meshes.measure(tetrahedron) @@ -474,5 +475,5 @@ end # Integral aliases @test_throws "not supported" lineintegral(f, tetrahedron) @test_throws "not supported" surfaceintegral(f, tetrahedron) - @test volumeintegral(f, tetrahedron) ≈ sol + @test volumeintegral(f, tetrahedron, GaussKronrod()) ≈ sol end From b16b08f90ddbd9ef7ea2448afddfa3a14d9760ea Mon Sep 17 00:00:00 2001 From: Michael Ingold Date: Fri, 4 Oct 2024 22:09:38 -0400 Subject: [PATCH 04/19] Apply suggestions from code review [skip ci] Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- test/combinations.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/combinations.jl b/test/combinations.jl index de2e6b64..70ec0202 100644 --- a/test/combinations.jl +++ b/test/combinations.jl @@ -458,7 +458,7 @@ end tetrahedron = Tetrahedron(pt_n, pt_w, pt_e, pt_n + ẑ) f = p -> one(Float64) - fv(p) = fill(f(p), 3) + fv(p) = fill(f(p), 3) # Scalar integrand sol = Meshes.measure(tetrahedron) @@ -468,9 +468,9 @@ end # Vector integrand vsol = fill(sol, 3) - @test_throws "not supported" integral(fv, tetrahedron, GaussLegendre(100)) ≈ vsol + @test_throws "not supported" integral(fv, tetrahedron, GaussLegendre(100))≈vsol @test integral(fv, tetrahedron, GaussKronrod()) ≈ vsol - @test_throws "not supported" integral(fv, tetrahedron, HAdaptiveCubature()) ≈ vsol + @test_throws "not supported" integral(fv, tetrahedron, HAdaptiveCubature())≈vsol # Integral aliases @test_throws "not supported" lineintegral(f, tetrahedron) From d40c54a118e6cfaf2d8f03b17ccdd88cb4f71df7 Mon Sep 17 00:00:00 2001 From: Michael Ingold Date: Fri, 4 Oct 2024 22:20:04 -0400 Subject: [PATCH 05/19] Implement new Triangle tests --- test/auto_tests.jl | 5 ----- test/combinations.jl | 27 +++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/test/auto_tests.jl b/test/auto_tests.jl index 4c4b9e73..c38acbe9 100644 --- a/test/auto_tests.jl +++ b/test/auto_tests.jl @@ -70,9 +70,6 @@ end origin2d(T) = Point(T(0), T(0)) ẑ(T) = Vec(T(0), T(0), T(1)) plane_xy(T) = Plane(origin3d(T), ẑ(T)) - - # Points on xy-plane at unit distance on axes - pt_n(T) = Point(T(0), T(1), T(0)) pt_w(T) = Point(T(-1), T(0), T(0)) pt_e(T) = Point(T(1), T(0), T(0)) @@ -86,7 +83,6 @@ end parab(T) = ParaboloidSurface(origin3d(T), T(2.5), T(4.15)) sphere2d(T) = Sphere(origin2d(T), T(2.5)) sphere3d(T) = Sphere(origin3d(T), T(2.5)) - triangle(T) = Ngon(pt_e(T), pt_n(T), pt_w(T)) torus(T) = Torus(origin3d(T), ẑ(T), T(3.5), T(1.25)) SUPPORT_MATRIX(T) = [ @@ -100,7 +96,6 @@ end SupportItem("ParaboloidSurface{$T}", T, parab(T), 1, 0, 1, 0, 1, 1, 1), SupportItem("Sphere{2,$T}", T, sphere2d(T), 1, 1, 0, 0, 1, 1, 1), SupportItem("Sphere{3,$T}", T, sphere3d(T), 1, 0, 1, 0, 1, 1, 1), - SupportItem("Triangle{$T}", T, triangle(T), 1, 0, 1, 0, 1, 1, 1), SupportItem("Torus{$T}", T, torus(T), 1, 0, 1, 0, 1, 1, 1) ] diff --git a/test/combinations.jl b/test/combinations.jl index 70ec0202..bfa7d0b3 100644 --- a/test/combinations.jl +++ b/test/combinations.jl @@ -477,3 +477,30 @@ end @test_throws "not supported" surfaceintegral(f, tetrahedron) @test volumeintegral(f, tetrahedron, GaussKronrod()) ≈ sol end + +@testitem "Meshes.Triangle" setup=[Setup] begin + pt_n = Point(0, 1, 0) + pt_w = Point(-1, 0, 0) + pt_e = Point(1, 0, 0) + triangle = Ngon(pt_e, pt_n, pt_w) + + f = p -> one(Float64) + fv(p) = fill(f(p), 3) + + # Scalar integrand + sol = Meshes.measure(triangle) + @test integral(f, triangle, GaussLegendre(100)) ≈ sol + @test integral(f, triangle, GaussKronrod()) ≈ sol + @test integral(f, triangle, HAdaptiveCubature()) ≈ sol + + # Vector integrand + vsol = fill(sol, 3) + @test integral(fv, triangle, GaussLegendre(100)) ≈ vsol + @test integral(fv, triangle, GaussKronrod()) ≈ vsol + @test integral(fv, triangle, HAdaptiveCubature()) ≈ vsol + + # Integral aliases + @test_throws "not supported" lineintegral(f, triangle) + @test surfaceintegral(f, triangle) ≈ sol + @test_throws "not supported" volumeintegral(f, triangle) +end From c09865de96bc313cee33b0129c42a1fc9a95c025 Mon Sep 17 00:00:00 2001 From: Michael Ingold Date: Fri, 4 Oct 2024 22:51:08 -0400 Subject: [PATCH 06/19] Implement new tests for Cylinder and CylinderSurface --- test/auto_tests.jl | 6 ----- test/combinations.jl | 52 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 6 deletions(-) diff --git a/test/auto_tests.jl b/test/auto_tests.jl index c38acbe9..4686e860 100644 --- a/test/auto_tests.jl +++ b/test/auto_tests.jl @@ -70,15 +70,11 @@ end origin2d(T) = Point(T(0), T(0)) ẑ(T) = Vec(T(0), T(0), T(1)) plane_xy(T) = Plane(origin3d(T), ẑ(T)) - pt_w(T) = Point(T(-1), T(0), T(0)) - pt_e(T) = Point(T(1), T(0), T(0)) # Test Geometries ball2d(T) = Ball(origin2d(T), T(2.0)) ball3d(T) = Ball(origin3d(T), T(2.0)) circle(T) = Circle(plane_xy(T), T(2.5)) - cyl(T) = Cylinder(pt_e(T), pt_w(T), T(2.5)) - cylsurf(T) = CylinderSurface(pt_e(T), pt_w(T), T(2.5)) disk(T) = Disk(plane_xy(T), T(2.5)) parab(T) = ParaboloidSurface(origin3d(T), T(2.5), T(4.15)) sphere2d(T) = Sphere(origin2d(T), T(2.5)) @@ -90,8 +86,6 @@ end SupportItem("Ball{2,$T}", T, ball2d(T), 1, 0, 1, 0, 1, 1, 1), SupportItem("Ball{3,$T}", T, ball3d(T), 1, 0, 0, 1, 1, 0, 1), SupportItem("Circle{$T}", T, circle(T), 1, 1, 0, 0, 1, 1, 1), - SupportItem("Cylinder{$T}", T, cyl(T), 1, 0, 0, 1, 1, 0, 1), - SupportItem("CylinderSurface{$T}", T, cylsurf(T), 1, 0, 1, 0, 1, 1, 1), SupportItem("Disk{$T}", T, disk(T), 1, 0, 1, 0, 1, 1, 1), SupportItem("ParaboloidSurface{$T}", T, parab(T), 1, 0, 1, 0, 1, 1, 1), SupportItem("Sphere{2,$T}", T, sphere2d(T), 1, 1, 0, 0, 1, 1, 1), diff --git a/test/combinations.jl b/test/combinations.jl index bfa7d0b3..98dc7041 100644 --- a/test/combinations.jl +++ b/test/combinations.jl @@ -196,6 +196,58 @@ end @test_throws "not supported" volumeintegral(f, cone) end +@testitem "Meshes.Cylinder" setup=[Setup] begin + pt_w = Point(-1, 0, 0) + pt_e = Point(1, 0, 0) + cyl = Cylinder(pt_e, pt_w, 2.5) + + f = p -> one(Float64) + fv(p) = fill(f(p), 3) + + # Scalar integrand + sol = Meshes.measure(cyl) + @test integral(f, cyl, GaussLegendre(100)) ≈ sol + @test_throws "not supported" integral(f, cyl, GaussKronrod()) + @test integral(f, cyl, HAdaptiveCubature()) ≈ sol + + # Vector integrand + vsol = fill(sol, 3) + @test integral(fv, cyl, GaussLegendre(100)) ≈ vsol + @test_throws "not supported" integral(fv, cyl, GaussKronrod()) + @test integral(fv, cyl, HAdaptiveCubature()) ≈ vsol + + # Integral aliases + @test_throws "not supported" lineintegral(f, cyl) + @test_throws "not supported" surfaceintegral(f, cyl) + @test volumeintegral(f, cyl) ≈ sol +end + +@testitem "Meshes.CylinderSurface" setup=[Setup] begin + pt_w = Point(-1, 0, 0) + pt_e = Point(1, 0, 0) + cyl = CylinderSurface(pt_e, pt_w, 2.5) + + f = p -> one(Float64) + fv(p) = fill(f(p), 3) + + # Scalar integrand + sol = Meshes.measure(cyl) + @test integral(f, cyl, GaussLegendre(100)) ≈ sol + @test integral(f, cyl, GaussKronrod()) ≈ sol + @test integral(f, cyl, HAdaptiveCubature()) ≈ sol + + # Vector integrand + vsol = fill(sol, 3) + @test integral(fv, cyl, GaussLegendre(100)) ≈ vsol + @test integral(fv, cyl, GaussKronrod()) ≈ vsol + @test integral(fv, cyl, HAdaptiveCubature()) ≈ vsol + + # Integral aliases + @test_throws "not supported" lineintegral(f, cyl) + @test surfaceintegral(f, cyl) ≈ sol + @test_throws "not supported" volumeintegral(f, cyl) +end + @testitem "Meshes.FrustumSurface" setup=[Setup] begin # Create a frustum whose radius halves at the top, # i.e. the bottom half of a cone by height From 4d3d8c33416e31349adeb67b22b33025e5606f68 Mon Sep 17 00:00:00 2001 From: Michael Ingold Date: Fri, 4 Oct 2024 23:05:40 -0400 Subject: [PATCH 07/19] Implement new tests for Torus --- test/auto_tests.jl | 2 -- test/combinations.jl | 26 ++++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/test/auto_tests.jl b/test/auto_tests.jl index 4686e860..c833842c 100644 --- a/test/auto_tests.jl +++ b/test/auto_tests.jl @@ -79,7 +79,6 @@ end parab(T) = ParaboloidSurface(origin3d(T), T(2.5), T(4.15)) sphere2d(T) = Sphere(origin2d(T), T(2.5)) sphere3d(T) = Sphere(origin3d(T), T(2.5)) - torus(T) = Torus(origin3d(T), ẑ(T), T(3.5), T(1.25)) SUPPORT_MATRIX(T) = [ # Name, T type, example, integral,line,surface,volume, GaussLegendre,GaussKronrod,HAdaptiveCubature @@ -90,7 +89,6 @@ end SupportItem("ParaboloidSurface{$T}", T, parab(T), 1, 0, 1, 0, 1, 1, 1), SupportItem("Sphere{2,$T}", T, sphere2d(T), 1, 1, 0, 0, 1, 1, 1), SupportItem("Sphere{3,$T}", T, sphere3d(T), 1, 0, 1, 0, 1, 1, 1), - SupportItem("Torus{$T}", T, torus(T), 1, 0, 1, 0, 1, 1, 1) ] @testset "Float64 Geometries" verbose=true begin diff --git a/test/combinations.jl b/test/combinations.jl index 98dc7041..c09c08dd 100644 --- a/test/combinations.jl +++ b/test/combinations.jl @@ -530,6 +530,32 @@ end @test volumeintegral(f, tetrahedron, GaussKronrod()) ≈ sol end +@testitem "Meshes.Torus" setup=[Setup] begin + origin = Point(0, 0, 0) + ẑ = Vec(0, 0, 1) + torus = Torus(origin, ẑ, 3.5, 1.25) + + f = p -> one(Float64) + fv(p) = fill(f(p), 3) + + # Scalar integrand + sol = Meshes.measure(torus) + @test integral(f, torus, GaussLegendre(100)) ≈ sol + @test integral(f, torus, GaussKronrod()) ≈ sol + @test integral(f, torus, HAdaptiveCubature()) ≈ sol + + # Vector integrand + vsol = fill(sol, 3) + @test integral(fv, torus, GaussLegendre(100)) ≈ vsol + @test integral(fv, torus, GaussKronrod()) ≈ vsol + @test integral(fv, torus, HAdaptiveCubature()) ≈ vsol + + # Integral aliases + @test_throws "not supported" lineintegral(f, torus) + @test surfaceintegral(f, torus) ≈ sol + @test_throws "not supported" volumeintegral(f, torus) +end + @testitem "Meshes.Triangle" setup=[Setup] begin pt_n = Point(0, 1, 0) pt_w = Point(-1, 0, 0) From a8b664a93875c259016d0cec3fa60115c326f191 Mon Sep 17 00:00:00 2001 From: Michael Ingold Date: Fri, 4 Oct 2024 23:41:48 -0400 Subject: [PATCH 08/19] Format suggestion Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- test/auto_tests.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/auto_tests.jl b/test/auto_tests.jl index c833842c..9889daea 100644 --- a/test/auto_tests.jl +++ b/test/auto_tests.jl @@ -88,7 +88,7 @@ end SupportItem("Disk{$T}", T, disk(T), 1, 0, 1, 0, 1, 1, 1), SupportItem("ParaboloidSurface{$T}", T, parab(T), 1, 0, 1, 0, 1, 1, 1), SupportItem("Sphere{2,$T}", T, sphere2d(T), 1, 1, 0, 0, 1, 1, 1), - SupportItem("Sphere{3,$T}", T, sphere3d(T), 1, 0, 1, 0, 1, 1, 1), + SupportItem("Sphere{3,$T}", T, sphere3d(T), 1, 0, 1, 0, 1, 1, 1) ] @testset "Float64 Geometries" verbose=true begin From eb551478116a350f8912088bec5f5d1878f28f66 Mon Sep 17 00:00:00 2001 From: Michael Ingold Date: Sat, 5 Oct 2024 00:38:00 -0400 Subject: [PATCH 09/19] Implement new tests for ParaboloidSurface --- test/auto_tests.jl | 2 -- test/combinations.jl | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/test/auto_tests.jl b/test/auto_tests.jl index c833842c..8317c07e 100644 --- a/test/auto_tests.jl +++ b/test/auto_tests.jl @@ -76,7 +76,6 @@ end ball3d(T) = Ball(origin3d(T), T(2.0)) circle(T) = Circle(plane_xy(T), T(2.5)) disk(T) = Disk(plane_xy(T), T(2.5)) - parab(T) = ParaboloidSurface(origin3d(T), T(2.5), T(4.15)) sphere2d(T) = Sphere(origin2d(T), T(2.5)) sphere3d(T) = Sphere(origin3d(T), T(2.5)) @@ -86,7 +85,6 @@ end SupportItem("Ball{3,$T}", T, ball3d(T), 1, 0, 0, 1, 1, 0, 1), SupportItem("Circle{$T}", T, circle(T), 1, 1, 0, 0, 1, 1, 1), SupportItem("Disk{$T}", T, disk(T), 1, 0, 1, 0, 1, 1, 1), - SupportItem("ParaboloidSurface{$T}", T, parab(T), 1, 0, 1, 0, 1, 1, 1), SupportItem("Sphere{2,$T}", T, sphere2d(T), 1, 1, 0, 0, 1, 1, 1), SupportItem("Sphere{3,$T}", T, sphere3d(T), 1, 0, 1, 0, 1, 1, 1), ] diff --git a/test/combinations.jl b/test/combinations.jl index c09c08dd..78544b5c 100644 --- a/test/combinations.jl +++ b/test/combinations.jl @@ -317,6 +317,31 @@ end @test_throws "not supported" volumeintegral(f, line) end +@testitem "Meshes.ParaboloidSurface" setup=[Setup] begin + origin = Point(0, 0, 0) + parab = ParaboloidSurface(origin, 2.5, 4.15) + + f = p -> one(Float64) + fv(p) = fill(f(p), 3) + + # Scalar integrand + sol = Meshes.measure(parab) + @test integral(f, parab, GaussLegendre(100)) ≈ sol + @test integral(f, parab, GaussKronrod()) ≈ sol + @test integral(f, parab, HAdaptiveCubature()) ≈ sol + + # Vector integrand + vsol = fill(sol, 3) + @test integral(fv, parab, GaussLegendre(100)) ≈ vsol + @test integral(fv, parab, GaussKronrod()) ≈ vsol + @test integral(fv, parab, HAdaptiveCubature()) ≈ vsol + + # Integral aliases + @test_throws "not supported" lineintegral(f, parab) + @test surfaceintegral(f, parab) ≈ sol + @test_throws "not supported" volumeintegral(f, parab) +end + @testitem "Meshes.Plane" setup=[Setup] begin p = Point(0.0u"m", 0.0u"m", 0.0u"m") v = Vec(0.0u"m", 0.0u"m", 1.0u"m") From 888a13d461d145b4ed3be12f73c5b614f375319e Mon Sep 17 00:00:00 2001 From: Michael Ingold Date: Sat, 5 Oct 2024 14:18:42 -0400 Subject: [PATCH 10/19] Implement new tests for Ball in 2D --- test/auto_tests.jl | 2 -- test/combinations.jl | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/test/auto_tests.jl b/test/auto_tests.jl index 2c22c94c..9b2fd544 100644 --- a/test/auto_tests.jl +++ b/test/auto_tests.jl @@ -72,7 +72,6 @@ end plane_xy(T) = Plane(origin3d(T), ẑ(T)) # Test Geometries - ball2d(T) = Ball(origin2d(T), T(2.0)) ball3d(T) = Ball(origin3d(T), T(2.0)) circle(T) = Circle(plane_xy(T), T(2.5)) disk(T) = Disk(plane_xy(T), T(2.5)) @@ -81,7 +80,6 @@ end SUPPORT_MATRIX(T) = [ # Name, T type, example, integral,line,surface,volume, GaussLegendre,GaussKronrod,HAdaptiveCubature - SupportItem("Ball{2,$T}", T, ball2d(T), 1, 0, 1, 0, 1, 1, 1), SupportItem("Ball{3,$T}", T, ball3d(T), 1, 0, 0, 1, 1, 0, 1), SupportItem("Circle{$T}", T, circle(T), 1, 1, 0, 0, 1, 1, 1), SupportItem("Disk{$T}", T, disk(T), 1, 0, 1, 0, 1, 1, 1), diff --git a/test/combinations.jl b/test/combinations.jl index 78544b5c..248823e6 100644 --- a/test/combinations.jl +++ b/test/combinations.jl @@ -2,6 +2,31 @@ # - All supported combinations of integral(f, ::Geometry, ::IntegrationAlgorithm) produce accurate results # - Invalid applications of integral aliases (e.g. lineintegral) produce a descriptive error +@testitem "Meshes.Ball 2D" setup=[Setup] begin + origin = Point(0, 0) + ball = Ball(origin, 2.8) + + f = p -> one(Float64) + fv(p) = fill(f(p), 3) + + # Scalar integrand + sol = Meshes.measure(ball) + @test integral(f, ball, GaussLegendre(100)) ≈ sol + @test integral(f, ball, GaussKronrod()) ≈ sol + @test integral(f, ball, HAdaptiveCubature()) ≈ sol + + # Vector integrand + vsol = fill(sol, 3) + @test integral(fv, ball, GaussLegendre(100)) ≈ vsol + @test integral(fv, ball, GaussKronrod()) ≈ vsol + @test integral(fv, ball, HAdaptiveCubature()) ≈ vsol + + # Integral aliases + @test_throws "not supported" lineintegral(f, ball) + @test surfaceintegral(f, ball) ≈ sol + @test_throws "not supported" volumeintegral(f, ball) +end + @testitem "Meshes.BezierCurve" setup=[Setup] begin curve = BezierCurve( [Point(t * u"m", sin(t) * u"m", 0.0u"m") for t in range(-pi, pi, length = 361)] From 736426463bfaa23bc68a51cf2226be9f30f1902f Mon Sep 17 00:00:00 2001 From: Michael Ingold Date: Sat, 5 Oct 2024 14:21:05 -0400 Subject: [PATCH 11/19] Implement new tests for Ball in 3D --- test/auto_tests.jl | 2 -- test/combinations.jl | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/test/auto_tests.jl b/test/auto_tests.jl index 9b2fd544..43051522 100644 --- a/test/auto_tests.jl +++ b/test/auto_tests.jl @@ -72,7 +72,6 @@ end plane_xy(T) = Plane(origin3d(T), ẑ(T)) # Test Geometries - ball3d(T) = Ball(origin3d(T), T(2.0)) circle(T) = Circle(plane_xy(T), T(2.5)) disk(T) = Disk(plane_xy(T), T(2.5)) sphere2d(T) = Sphere(origin2d(T), T(2.5)) @@ -80,7 +79,6 @@ end SUPPORT_MATRIX(T) = [ # Name, T type, example, integral,line,surface,volume, GaussLegendre,GaussKronrod,HAdaptiveCubature - SupportItem("Ball{3,$T}", T, ball3d(T), 1, 0, 0, 1, 1, 0, 1), SupportItem("Circle{$T}", T, circle(T), 1, 1, 0, 0, 1, 1, 1), SupportItem("Disk{$T}", T, disk(T), 1, 0, 1, 0, 1, 1, 1), SupportItem("Sphere{2,$T}", T, sphere2d(T), 1, 1, 0, 0, 1, 1, 1), diff --git a/test/combinations.jl b/test/combinations.jl index 248823e6..6cbcaa25 100644 --- a/test/combinations.jl +++ b/test/combinations.jl @@ -27,6 +27,31 @@ @test_throws "not supported" volumeintegral(f, ball) end +@testitem "Meshes.Ball 3D" setup=[Setup] begin + origin = Point(0, 0, 0) + ball = Ball(origin, 2.8) + + f = p -> one(Float64) + fv(p) = fill(f(p), 3) + + # Scalar integrand + sol = Meshes.measure(ball) + @test integral(f, ball, GaussLegendre(100)) ≈ sol + @test_throws "not supported" integral(f, ball, GaussKronrod()) ≈ sol + @test integral(f, ball, HAdaptiveCubature()) ≈ sol + + # Vector integrand + vsol = fill(sol, 3) + @test integral(fv, ball, GaussLegendre(100)) ≈ vsol + @test_throws "not supported" integral(fv, ball, GaussKronrod()) ≈ vsol + @test integral(fv, ball, HAdaptiveCubature()) ≈ vsol + + # Integral aliases + @test_throws "not supported" lineintegral(f, ball) + @test_throws "not supported" surfaceintegral(f, ball) + @test volumeintegral(f, ball) ≈ sol +end + @testitem "Meshes.BezierCurve" setup=[Setup] begin curve = BezierCurve( [Point(t * u"m", sin(t) * u"m", 0.0u"m") for t in range(-pi, pi, length = 361)] From c031f3c6ce9c0db8fad33aec58a2295811fdcadf Mon Sep 17 00:00:00 2001 From: Michael Ingold Date: Sat, 5 Oct 2024 14:25:36 -0400 Subject: [PATCH 12/19] Implement new tests for Sphere in 3D --- test/auto_tests.jl | 2 -- test/combinations.jl | 67 ++++++++++++++++++++++++++++++-------------- 2 files changed, 46 insertions(+), 23 deletions(-) diff --git a/test/auto_tests.jl b/test/auto_tests.jl index 43051522..dc36a98f 100644 --- a/test/auto_tests.jl +++ b/test/auto_tests.jl @@ -75,14 +75,12 @@ end circle(T) = Circle(plane_xy(T), T(2.5)) disk(T) = Disk(plane_xy(T), T(2.5)) sphere2d(T) = Sphere(origin2d(T), T(2.5)) - sphere3d(T) = Sphere(origin3d(T), T(2.5)) SUPPORT_MATRIX(T) = [ # Name, T type, example, integral,line,surface,volume, GaussLegendre,GaussKronrod,HAdaptiveCubature SupportItem("Circle{$T}", T, circle(T), 1, 1, 0, 0, 1, 1, 1), SupportItem("Disk{$T}", T, disk(T), 1, 0, 1, 0, 1, 1, 1), SupportItem("Sphere{2,$T}", T, sphere2d(T), 1, 1, 0, 0, 1, 1, 1), - SupportItem("Sphere{3,$T}", T, sphere3d(T), 1, 0, 1, 0, 1, 1, 1) ] @testset "Float64 Geometries" verbose=true begin diff --git a/test/combinations.jl b/test/combinations.jl index 6cbcaa25..b20e3bfa 100644 --- a/test/combinations.jl +++ b/test/combinations.jl @@ -27,7 +27,27 @@ @test_throws "not supported" volumeintegral(f, ball) end -@testitem "Meshes.Ball 3D" setup=[Setup] begin + + +@testitem "Meshes.BezierCurve" setup=[Setup] begin + curve = BezierCurve( + [Point(t * u"m", sin(t) * u"m", 0.0u"m") for t in range(-pi, pi, length = 361)] + ) + + function f(p::P) where {P <: Meshes.Point} + ux = ustrip(p.coords.x) + (1 / sqrt(1 + cos(ux)^2)) * u"Ω/m" + end + fv(p) = fill(f(p), 3) + + # Scalar integrand + sol = 2π * u"Ω" + @test integral(f, curve, GaussLegendre(100))≈sol rtol=0.5e-2 + @test integral(f, curve, GaussKronrod())≈sol rtol=0.5e-2 + @test integral(f, curve, HAdaptiveCubature())≈sol rtol=0.5e-2 + + # Vector integrand + vsol = fill(sol, 3)@testitem "Meshes.Ball 3D" setup=[Setup] begin origin = Point(0, 0, 0) ball = Ball(origin, 2.8) @@ -51,26 +71,6 @@ end @test_throws "not supported" surfaceintegral(f, ball) @test volumeintegral(f, ball) ≈ sol end - -@testitem "Meshes.BezierCurve" setup=[Setup] begin - curve = BezierCurve( - [Point(t * u"m", sin(t) * u"m", 0.0u"m") for t in range(-pi, pi, length = 361)] - ) - - function f(p::P) where {P <: Meshes.Point} - ux = ustrip(p.coords.x) - (1 / sqrt(1 + cos(ux)^2)) * u"Ω/m" - end - fv(p) = fill(f(p), 3) - - # Scalar integrand - sol = 2π * u"Ω" - @test integral(f, curve, GaussLegendre(100))≈sol rtol=0.5e-2 - @test integral(f, curve, GaussKronrod())≈sol rtol=0.5e-2 - @test integral(f, curve, HAdaptiveCubature())≈sol rtol=0.5e-2 - - # Vector integrand - vsol = fill(sol, 3) @test integral(fv, curve, GaussLegendre(100))≈vsol rtol=0.5e-2 @test integral(fv, curve, GaussKronrod())≈vsol rtol=0.5e-2 @test integral(fv, curve, HAdaptiveCubature())≈vsol rtol=0.5e-2 @@ -577,6 +577,31 @@ end @test_throws "not supported" volumeintegral(f, segment) end +@testitem "Meshes.Sphere 3D" setup=[Setup] begin + origin = Point(0, 0, 0) + sphere = Sphere(origin, 4.4) + + f = p -> one(Float64) + fv(p) = fill(f(p), 3) + + # Scalar integrand + sol = Meshes.measure(sphere) + @test integral(f, sphere, GaussLegendre(100)) ≈ sol + @test integral(f, sphere, GaussKronrod()) ≈ sol + @test integral(f, sphere, HAdaptiveCubature()) ≈ sol + + # Vector integrand + vsol = fill(sol, 3) + @test integral(fv, sphere, GaussLegendre(100)) ≈ vsol + @test integral(fv, sphere, GaussKronrod()) ≈ vsol + @test integral(fv, sphere, HAdaptiveCubature()) ≈ vsol + + # Integral aliases + @test_throws "not supported" lineintegral(f, sphere) + @test surfaceintegral(f, sphere) ≈ sol + @test_throws "not supported" volumeintegral(f, sphere) +end + @testitem "Meshes.Tetrahedron" setup=[Setup] begin pt_n = Point(0, 1, 0) pt_w = Point(-1, 0, 0) From 68082bd84a61c9f40fb38dcfbfbef9543936142f Mon Sep 17 00:00:00 2001 From: Michael Ingold Date: Sat, 5 Oct 2024 14:28:08 -0400 Subject: [PATCH 13/19] Implement new tests for Sphere in 2D --- test/auto_tests.jl | 2 -- test/combinations.jl | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/test/auto_tests.jl b/test/auto_tests.jl index dc36a98f..df2d50ee 100644 --- a/test/auto_tests.jl +++ b/test/auto_tests.jl @@ -74,13 +74,11 @@ end # Test Geometries circle(T) = Circle(plane_xy(T), T(2.5)) disk(T) = Disk(plane_xy(T), T(2.5)) - sphere2d(T) = Sphere(origin2d(T), T(2.5)) SUPPORT_MATRIX(T) = [ # Name, T type, example, integral,line,surface,volume, GaussLegendre,GaussKronrod,HAdaptiveCubature SupportItem("Circle{$T}", T, circle(T), 1, 1, 0, 0, 1, 1, 1), SupportItem("Disk{$T}", T, disk(T), 1, 0, 1, 0, 1, 1, 1), - SupportItem("Sphere{2,$T}", T, sphere2d(T), 1, 1, 0, 0, 1, 1, 1), ] @testset "Float64 Geometries" verbose=true begin diff --git a/test/combinations.jl b/test/combinations.jl index b20e3bfa..16ef8e69 100644 --- a/test/combinations.jl +++ b/test/combinations.jl @@ -577,6 +577,31 @@ end @test_throws "not supported" volumeintegral(f, segment) end +@testitem "Meshes.Sphere 2D" setup=[Setup] begin + origin = Point(0, 0) + sphere = Sphere(origin, 4.4) + + f = p -> one(Float64) + fv(p) = fill(f(p), 3) + + # Scalar integrand + sol = Meshes.measure(sphere) + @test integral(f, sphere, GaussLegendre(100)) ≈ sol + @test integral(f, sphere, GaussKronrod()) ≈ sol + @test integral(f, sphere, HAdaptiveCubature()) ≈ sol + + # Vector integrand + vsol = fill(sol, 3) + @test integral(fv, sphere, GaussLegendre(100)) ≈ vsol + @test integral(fv, sphere, GaussKronrod()) ≈ vsol + @test integral(fv, sphere, HAdaptiveCubature()) ≈ vsol + + # Integral aliases + @test lineintegral(f, sphere) ≈ sol + @test_throws "not supported" surfaceintegral(f, sphere) + @test_throws "not supported" volumeintegral(f, sphere) +end + @testitem "Meshes.Sphere 3D" setup=[Setup] begin origin = Point(0, 0, 0) sphere = Sphere(origin, 4.4) From 92553381bba0c4a92697ce1ec6d5832172177d90 Mon Sep 17 00:00:00 2001 From: Michael Ingold Date: Sat, 5 Oct 2024 14:34:56 -0400 Subject: [PATCH 14/19] Fix accidental code movement --- test/combinations.jl | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/test/combinations.jl b/test/combinations.jl index 16ef8e69..6402e3ee 100644 --- a/test/combinations.jl +++ b/test/combinations.jl @@ -27,27 +27,7 @@ @test_throws "not supported" volumeintegral(f, ball) end - - -@testitem "Meshes.BezierCurve" setup=[Setup] begin - curve = BezierCurve( - [Point(t * u"m", sin(t) * u"m", 0.0u"m") for t in range(-pi, pi, length = 361)] - ) - - function f(p::P) where {P <: Meshes.Point} - ux = ustrip(p.coords.x) - (1 / sqrt(1 + cos(ux)^2)) * u"Ω/m" - end - fv(p) = fill(f(p), 3) - - # Scalar integrand - sol = 2π * u"Ω" - @test integral(f, curve, GaussLegendre(100))≈sol rtol=0.5e-2 - @test integral(f, curve, GaussKronrod())≈sol rtol=0.5e-2 - @test integral(f, curve, HAdaptiveCubature())≈sol rtol=0.5e-2 - - # Vector integrand - vsol = fill(sol, 3)@testitem "Meshes.Ball 3D" setup=[Setup] begin +@testitem "Meshes.Ball 3D" setup=[Setup] begin origin = Point(0, 0, 0) ball = Ball(origin, 2.8) @@ -71,6 +51,26 @@ end @test_throws "not supported" surfaceintegral(f, ball) @test volumeintegral(f, ball) ≈ sol end + +@testitem "Meshes.BezierCurve" setup=[Setup] begin + curve = BezierCurve( + [Point(t * u"m", sin(t) * u"m", 0.0u"m") for t in range(-pi, pi, length = 361)] + ) + + function f(p::P) where {P <: Meshes.Point} + ux = ustrip(p.coords.x) + (1 / sqrt(1 + cos(ux)^2)) * u"Ω/m" + end + fv(p) = fill(f(p), 3) + + # Scalar integrand + sol = 2π * u"Ω" + @test integral(f, curve, GaussLegendre(100))≈sol rtol=0.5e-2 + @test integral(f, curve, GaussKronrod())≈sol rtol=0.5e-2 + @test integral(f, curve, HAdaptiveCubature())≈sol rtol=0.5e-2 + + # Vector integrand + vsol = fill(sol, 3) @test integral(fv, curve, GaussLegendre(100))≈vsol rtol=0.5e-2 @test integral(fv, curve, GaussKronrod())≈vsol rtol=0.5e-2 @test integral(fv, curve, HAdaptiveCubature())≈vsol rtol=0.5e-2 From 3db37d70147827658ecb5f3ecf485e2d334abfe8 Mon Sep 17 00:00:00 2001 From: Michael Ingold Date: Sat, 5 Oct 2024 14:40:50 -0400 Subject: [PATCH 15/19] Implement new tests for Circle --- test/auto_tests.jl | 2 -- test/combinations.jl | 27 +++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/test/auto_tests.jl b/test/auto_tests.jl index df2d50ee..6a8c8fd0 100644 --- a/test/auto_tests.jl +++ b/test/auto_tests.jl @@ -67,12 +67,10 @@ end @testitem "Integrals" setup=[Setup, AutoTests] begin # Spatial descriptors origin3d(T) = Point(T(0), T(0), T(0)) - origin2d(T) = Point(T(0), T(0)) ẑ(T) = Vec(T(0), T(0), T(1)) plane_xy(T) = Plane(origin3d(T), ẑ(T)) # Test Geometries - circle(T) = Circle(plane_xy(T), T(2.5)) disk(T) = Disk(plane_xy(T), T(2.5)) SUPPORT_MATRIX(T) = [ diff --git a/test/combinations.jl b/test/combinations.jl index 6402e3ee..e47eb3c5 100644 --- a/test/combinations.jl +++ b/test/combinations.jl @@ -182,6 +182,33 @@ end @test_throws ArgumentError jacobian(box, zeros(2)) end +@testitem "Meshes.Circle" setup=[Setup] begin + origin = Point(0, 0, 0) + ẑ = Vec(0, 0, 1) + xy_plane = Plane(origin, ẑ) + circle = Circle(xy_plane, 2.5) + + f(p) = 1.0 + fv(p) = fill(f(p), 3) + + # Scalar integrand + sol = Meshes.measure(circle) + @test integral(f, circle, GaussLegendre(100)) ≈ sol + @test integral(f, circle, GaussKronrod()) ≈ sol + @test integral(f, circle, HAdaptiveCubature()) ≈ sol + + # Vector integrand + vsol = fill(sol, 3) + @test integral(fv, circle, GaussLegendre(100)) ≈ vsol + @test integral(fv, circle, GaussKronrod()) ≈ vsol + @test integral(fv, circle, HAdaptiveCubature()) ≈ vsol + + # Integral aliases + @test lineintegral(f, circle) ≈ sol + @test_throws "not supported" surfaceintegral(f, circle) + @test_throws "not supported" volumeintegral(f, circle) +end + @testitem "Meshes.Cone" setup=[Setup] begin r = 2.5u"m" h = 2.5u"m" From 547b32a3ec6d532417434befd9eca46ab91de223 Mon Sep 17 00:00:00 2001 From: Joshua Lampert <51029046+JoshuaLampert@users.noreply.github.com> Date: Sat, 5 Oct 2024 20:41:00 +0200 Subject: [PATCH 16/19] Apply suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- test/combinations.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/combinations.jl b/test/combinations.jl index 6402e3ee..62d5c06c 100644 --- a/test/combinations.jl +++ b/test/combinations.jl @@ -37,13 +37,13 @@ end # Scalar integrand sol = Meshes.measure(ball) @test integral(f, ball, GaussLegendre(100)) ≈ sol - @test_throws "not supported" integral(f, ball, GaussKronrod()) ≈ sol + @test_throws "not supported" integral(f, ball, GaussKronrod())≈sol @test integral(f, ball, HAdaptiveCubature()) ≈ sol # Vector integrand vsol = fill(sol, 3) @test integral(fv, ball, GaussLegendre(100)) ≈ vsol - @test_throws "not supported" integral(fv, ball, GaussKronrod()) ≈ vsol + @test_throws "not supported" integral(fv, ball, GaussKronrod())≈vsol @test integral(fv, ball, HAdaptiveCubature()) ≈ vsol # Integral aliases From f02a2fe22e5c345e1468295165b9ad95d933cf58 Mon Sep 17 00:00:00 2001 From: Michael Ingold Date: Sat, 5 Oct 2024 14:42:24 -0400 Subject: [PATCH 17/19] Implement new tests for Disk --- test/auto_tests.jl | 20 -------------------- test/combinations.jl | 27 +++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/test/auto_tests.jl b/test/auto_tests.jl index 6a8c8fd0..bfd7c049 100644 --- a/test/auto_tests.jl +++ b/test/auto_tests.jl @@ -63,23 +63,3 @@ end end end - -@testitem "Integrals" setup=[Setup, AutoTests] begin - # Spatial descriptors - origin3d(T) = Point(T(0), T(0), T(0)) - ẑ(T) = Vec(T(0), T(0), T(1)) - plane_xy(T) = Plane(origin3d(T), ẑ(T)) - - # Test Geometries - disk(T) = Disk(plane_xy(T), T(2.5)) - - SUPPORT_MATRIX(T) = [ - # Name, T type, example, integral,line,surface,volume, GaussLegendre,GaussKronrod,HAdaptiveCubature - SupportItem("Circle{$T}", T, circle(T), 1, 1, 0, 0, 1, 1, 1), - SupportItem("Disk{$T}", T, disk(T), 1, 0, 1, 0, 1, 1, 1), - ] - - @testset "Float64 Geometries" verbose=true begin - map(autotest, SUPPORT_MATRIX(Float64)) - end -end diff --git a/test/combinations.jl b/test/combinations.jl index e47eb3c5..2624e436 100644 --- a/test/combinations.jl +++ b/test/combinations.jl @@ -325,6 +325,33 @@ end @test_throws "not supported" volumeintegral(f, cyl) end +@testitem "Meshes.Disk" setup=[Setup] begin + origin = Point(0, 0, 0) + ẑ = Vec(0, 0, 1) + xy_plane = Plane(origin, ẑ) + disk = Disk(xy_plane, 2.5) + + f(p) = 1.0 + fv(p) = fill(f(p), 3) + + # Scalar integrand + sol = Meshes.measure(disk) + @test integral(f, disk, GaussLegendre(100)) ≈ sol + @test integral(f, disk, GaussKronrod()) ≈ sol + @test integral(f, disk, HAdaptiveCubature()) ≈ sol + + # Vector integrand + vsol = fill(sol, 3) + @test integral(fv, disk, GaussLegendre(100)) ≈ vsol + @test integral(fv, disk, GaussKronrod()) ≈ vsol + @test integral(fv, disk, HAdaptiveCubature()) ≈ vsol + + # Integral aliases + @test_throws "not supported" lineintegral(f, disk) + @test surfaceintegral(f, disk) ≈ sol + @test_throws "not supported" volumeintegral(f, disk) +end + @testitem "Meshes.FrustumSurface" setup=[Setup] begin # Create a frustum whose radius halves at the top, # i.e. the bottom half of a cone by height From 2e44836adae253f9e9f35c06db99099e86cc085f Mon Sep 17 00:00:00 2001 From: Michael Ingold Date: Sat, 5 Oct 2024 15:01:59 -0400 Subject: [PATCH 18/19] Apply suggestions from code review Co-authored-by: Joshua Lampert <51029046+JoshuaLampert@users.noreply.github.com> --- test/combinations.jl | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/test/combinations.jl b/test/combinations.jl index 812609dc..81384b79 100644 --- a/test/combinations.jl +++ b/test/combinations.jl @@ -6,7 +6,7 @@ origin = Point(0, 0) ball = Ball(origin, 2.8) - f = p -> one(Float64) + f(p) = 1.0 fv(p) = fill(f(p), 3) # Scalar integrand @@ -31,7 +31,7 @@ end origin = Point(0, 0, 0) ball = Ball(origin, 2.8) - f = p -> one(Float64) + f(p) = 1.0 fv(p) = fill(f(p), 3) # Scalar integrand @@ -278,7 +278,7 @@ end pt_e = Point(1, 0, 0) cyl = Cylinder(pt_e, pt_w, 2.5) - f = p -> one(Float64) + f(p) = 1.0 fv(p) = fill(f(p), 3) # Scalar integrand @@ -304,7 +304,7 @@ end pt_e = Point(1, 0, 0) cyl = CylinderSurface(pt_e, pt_w, 2.5) - f = p -> one(Float64) + f(p) = 1.0 fv(p) = fill(f(p), 3) # Scalar integrand @@ -425,7 +425,7 @@ end origin = Point(0, 0, 0) parab = ParaboloidSurface(origin, 2.5, 4.15) - f = p -> one(Float64) + f(p) = 1.0 fv(p) = fill(f(p), 3) # Scalar integrand @@ -635,7 +635,7 @@ end origin = Point(0, 0) sphere = Sphere(origin, 4.4) - f = p -> one(Float64) + f(p) = 1.0 fv(p) = fill(f(p), 3) # Scalar integrand @@ -660,7 +660,7 @@ end origin = Point(0, 0, 0) sphere = Sphere(origin, 4.4) - f = p -> one(Float64) + f(p) = 1.0 fv(p) = fill(f(p), 3) # Scalar integrand @@ -688,7 +688,7 @@ end ẑ = Vec(0, 0, 1) tetrahedron = Tetrahedron(pt_n, pt_w, pt_e, pt_n + ẑ) - f = p -> one(Float64) + f(p) = 1.0 fv(p) = fill(f(p), 3) # Scalar integrand @@ -714,7 +714,7 @@ end ẑ = Vec(0, 0, 1) torus = Torus(origin, ẑ, 3.5, 1.25) - f = p -> one(Float64) + f(p) = 1.0 fv(p) = fill(f(p), 3) # Scalar integrand @@ -739,9 +739,9 @@ end pt_n = Point(0, 1, 0) pt_w = Point(-1, 0, 0) pt_e = Point(1, 0, 0) - triangle = Ngon(pt_e, pt_n, pt_w) + triangle = Triangle(pt_e, pt_n, pt_w) - f = p -> one(Float64) + f(p) = 1.0 fv(p) = fill(f(p), 3) # Scalar integrand From 2fb6d2b2ca9551cbdd2b5a3e6a77a0f913c8b262 Mon Sep 17 00:00:00 2001 From: Joshua Lampert Date: Sat, 5 Oct 2024 22:22:35 +0200 Subject: [PATCH 19/19] remove auto_tests.jl --- test/auto_tests.jl | 65 ---------------------------------------------- 1 file changed, 65 deletions(-) delete mode 100644 test/auto_tests.jl diff --git a/test/auto_tests.jl b/test/auto_tests.jl deleted file mode 100644 index bfd7c049..00000000 --- a/test/auto_tests.jl +++ /dev/null @@ -1,65 +0,0 @@ -################################################################################ -# Automatic test generation -################################################################################ - -@testsnippet AutoTests begin - struct SupportItem{T, Dim, CRS, G <: Meshes.Geometry{Meshes.𝔼{Dim}, CRS}} - name::String - type::Type{T} - geometry::G - integral::Bool - lineintegral::Bool - surfaceintegral::Bool - volumeintegral::Bool - gausslegendre::Bool - gausskronrod::Bool - hadaptivecubature::Bool - end - - # Constructor to explicitly convert Ints (0,1) to Bool values - SupportItem(name, type, geometry, checkboxes::Vararg{I, 7}) where {I <: Integer} = SupportItem( - name, type, geometry, Bool.(checkboxes)...) - - # If method is supported, test it on scalar- and vector-valued functions. - # Otherwise, test that its use throws a MethodError - function integraltest(intf, geometry, rule, supported, T) - f(::Point) = T(1) - fv(::Point) = fill(T(1), 2) - - if supported - a1 = intf(f, geometry, rule) - b1 = measure(geometry) - @test a1 ≈ b1 - @test typeof(a1) == typeof(b1) - @test intf(fv, geometry, rule) ≈ fill(b1, 2) - else - @test_throws "not supported" intf(f, geometry, rule) - end - end - - # Generate a @testset for item - function autotest(item::SupportItem) - N = (item.type == Float32) ? 1000 : 100 - algorithm_set = [ - (GaussLegendre(N), item.gausslegendre), - (GaussKronrod(), item.gausskronrod), - (HAdaptiveCubature(), item.hadaptivecubature) - ] - - method_set = [ - (integral, item.integral), - (lineintegral, item.lineintegral), - (surfaceintegral, item.surfaceintegral), - (volumeintegral, item.volumeintegral) - ] - - itemsupport = Iterators.product(method_set, algorithm_set) - - # For each enabled solver type, run the test suite - @testset "$(item.name)" begin - for ((method, msupport), (alg, asupport)) in itemsupport - integraltest(method, item.geometry, alg, msupport && asupport, item.type) - end - end - end -end