Skip to content

Commit 08222a8

Browse files
Add tests for Ellipsoid and Hexahedron (#102)
* add tests for Ellipsoid and Hexahedron * Apply suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * add comment about rtol * update link to issue * Box in >= 3 dims --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 711d5b4 commit 08222a8

File tree

2 files changed

+59
-2
lines changed

2 files changed

+59
-2
lines changed

docs/src/supportmatrix.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,22 @@ Cubature integration rules are recommended (and the default).
2727
| `BezierCurve` ||||
2828
| `Box` in `𝔼{1}` ||||
2929
| `Box` in `𝔼{2}` ||||
30-
| `Box` in `𝔼{3}` || 🛑 ||
30+
| `Box` in `𝔼{3}` || 🛑 ||
3131
| `Circle` ||||
3232
| `Cone` ||||
3333
| `ConeSurface` ||||
3434
| `Cylinder` || 🛑 ||
3535
| `CylinderSurface` ||||
3636
| `Disk` ||||
37-
| `Frustum` | [🎗️](https://github.com/mikeingold/MeshIntegrals.jl/issues/57) | [🎗️](https://github.com/mikeingold/MeshIntegrals.jl/issues/57) | [🎗️](https://github.com/mikeingold/MeshIntegrals.jl/issues/57) |
37+
| `Ellipsoid` ||||
38+
| `Frustum` | [🎗️](https://github.com/mikeingold/MeshIntegrals.jl/issues/28) | [🎗️](https://github.com/mikeingold/MeshIntegrals.jl/issues/28) | [🎗️](https://github.com/mikeingold/MeshIntegrals.jl/issues/28) |
3839
| `FrustumSurface` ||||
40+
| `Hexahedron` ||||
3941
| `Line` ||||
4042
| `ParaboloidSurface` ||||
4143
| `Plane` ||||
44+
| `Polyarea` | [🎗️](https://github.com/mikeingold/MeshIntegrals.jl/issues/28) | [🎗️](https://github.com/mikeingold/MeshIntegrals.jl/issues/28) | [🎗️](https://github.com/mikeingold/MeshIntegrals.jl/issues/28) |
45+
| `Pyramid` | [🎗️](https://github.com/mikeingold/MeshIntegrals.jl/issues/28) | [🎗️](https://github.com/mikeingold/MeshIntegrals.jl/issues/28) | [🎗️](https://github.com/mikeingold/MeshIntegrals.jl/issues/28) |
4246
| `Quadrangle` ||||
4347
| `Ray` ||||
4448
| `Ring` ||||
@@ -50,3 +54,4 @@ Cubature integration rules are recommended (and the default).
5054
| `Tetrahedron` in `𝔼{3}` | [🎗️](https://github.com/mikeingold/MeshIntegrals.jl/issues/40) || [🎗️](https://github.com/mikeingold/MeshIntegrals.jl/issues/40) |
5155
| `Triangle` ||||
5256
| `Torus` ||||
57+
| `Wedge` | [🎗️](https://github.com/mikeingold/MeshIntegrals.jl/issues/28) | [🎗️](https://github.com/mikeingold/MeshIntegrals.jl/issues/28) | [🎗️](https://github.com/mikeingold/MeshIntegrals.jl/issues/28) |

test/combinations.jl

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,33 @@ end
370370
@test_throws "not supported" volumeintegral(f, disk)
371371
end
372372

373+
@testitem "Meshes.Ellipsoid" setup=[Setup] begin
374+
origin = Point(0, 0, 0)
375+
radii = (1.0, 2.0, 0.5)
376+
ellipsoid = Ellipsoid(radii, origin)
377+
378+
f(p) = 1.0
379+
fv(p) = fill(f(p), 3)
380+
381+
# Tolerances are higher due to `measure` being only an approximation
382+
# Scalar integrand
383+
sol = Meshes.measure(ellipsoid)
384+
@test integral(f, ellipsoid, GaussLegendre(100))sol rtol=1e-2
385+
@test integral(f, ellipsoid, GaussKronrod())sol rtol=1e-2
386+
@test integral(f, ellipsoid, HAdaptiveCubature())sol rtol=1e-2
387+
388+
# Vector integrand
389+
vsol = fill(sol, 3)
390+
@test integral(fv, ellipsoid, GaussLegendre(100))vsol rtol=1e-2
391+
@test integral(fv, ellipsoid, GaussKronrod())vsol rtol=1e-2
392+
@test integral(fv, ellipsoid, HAdaptiveCubature())vsol rtol=1e-2
393+
394+
# Integral aliases
395+
@test_throws "not supported" lineintegral(f, ellipsoid)
396+
@test surfaceintegral(f, ellipsoid)sol rtol=1e-2
397+
@test_throws "not supported" volumeintegral(f, ellipsoid)
398+
end
399+
373400
@testitem "Meshes.FrustumSurface" setup=[Setup] begin
374401
# Create a frustum whose radius halves at the top,
375402
# i.e. the bottom half of a cone by height
@@ -409,6 +436,31 @@ end
409436
@test integral(fv, frustum, HAdaptiveCubature()) vsol
410437
end
411438

439+
@testitem "Meshes.Hexahedron" setup=[Setup] begin
440+
hexahedron = Hexahedron(Point(0, 0, 0), Point(2, 0, 0), Point(2, 2, 0),
441+
Point(0, 2, 0), Point(0, 0, 2), Point(1, 0, 2), Point(1, 1, 2), Point(0, 1, 2))
442+
443+
f(p) = 1.0
444+
fv(p) = fill(f(p), 3)
445+
446+
# Scalar integrand
447+
sol = Meshes.measure(hexahedron)
448+
@test integral(f, hexahedron, GaussLegendre(100)) sol
449+
@test_throws "not supported" integral(f, hexahedron, GaussKronrod())sol
450+
@test integral(f, hexahedron, HAdaptiveCubature()) sol
451+
452+
# Vector integrand
453+
vsol = fill(sol, 3)
454+
@test integral(fv, hexahedron, GaussLegendre(100)) vsol
455+
@test_throws "not supported" integral(fv, hexahedron, GaussKronrod())vsol
456+
@test integral(fv, hexahedron, HAdaptiveCubature()) vsol
457+
458+
# Integral aliases
459+
@test_throws "not supported" lineintegral(f, hexahedron)
460+
@test_throws "not supported" surfaceintegral(f, hexahedron)
461+
@test volumeintegral(f, hexahedron) sol
462+
end
463+
412464
@testitem "Meshes.Line" setup=[Setup] begin
413465
a = Point(0.0u"m", 0.0u"m", 0.0u"m")
414466
b = Point(1.0u"m", 1.0u"m", 1.0u"m")

0 commit comments

Comments
 (0)