Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for Ellipsoid and Hexahedron #102

Merged
merged 6 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions docs/src/supportmatrix.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,22 @@ Cubature integration rules are recommended (and the default).
| `BezierCurve` | ✅ | ✅ | ✅ |
| `Box` in `𝔼{1}` | ✅ | ✅ | ✅ |
| `Box` in `𝔼{2}` | ✅ | ✅ | ✅ |
| `Box` in `𝔼{3}` | ✅ | 🛑 | ✅ |
| `Box` in `𝔼{3}` | ✅ | 🛑 | ✅ |
| `Circle` | ✅ | ✅ | ✅ |
| `Cone` | ✅ | ✅ | ✅ |
| `ConeSurface` | ✅ | ✅ | ✅ |
| `Cylinder` | ✅ | 🛑 | ✅ |
| `CylinderSurface` | ✅ | ✅ | ✅ |
| `Disk` | ✅ | ✅ | ✅ |
| `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) |
| `Ellipsoid` | ✅ | ✅ | ✅ |
| `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) |
| `FrustumSurface` | ✅ | ✅ | ✅ |
| `Hexahedron` | ✅ | ✅ | ✅ |
| `Line` | ✅ | ✅ | ✅ |
| `ParaboloidSurface` | ✅ | ✅ | ✅ |
| `Plane` | ✅ | ✅ | ✅ |
| `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) |
| `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) |
| `Quadrangle` | ✅ | ✅ | ✅ |
| `Ray` | ✅ | ✅ | ✅ |
| `Ring` | ✅ | ✅ | ✅ |
Expand All @@ -50,3 +54,4 @@ Cubature integration rules are recommended (and the default).
| `Tetrahedron` in `𝔼{3}` | [🎗️](https://github.com/mikeingold/MeshIntegrals.jl/issues/40) | ✅ | [🎗️](https://github.com/mikeingold/MeshIntegrals.jl/issues/40) |
| `Triangle` | ✅ | ✅ | ✅ |
| `Torus` | ✅ | ✅ | ✅ |
| `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) |
52 changes: 52 additions & 0 deletions test/combinations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,33 @@ end
@test_throws "not supported" volumeintegral(f, disk)
end

@testitem "Meshes.Ellipsoid" setup=[Setup] begin
origin = Point(0, 0, 0)
radii = (1.0, 2.0, 0.5)
ellipsoid = Ellipsoid(radii, origin)

f(p) = 1.0
fv(p) = fill(f(p), 3)

# Tolerances are higher due to `measure` being only an approximation
# Scalar integrand
sol = Meshes.measure(ellipsoid)
@test integral(f, ellipsoid, GaussLegendre(100))≈sol rtol=1e-2
@test integral(f, ellipsoid, GaussKronrod())≈sol rtol=1e-2
@test integral(f, ellipsoid, HAdaptiveCubature())≈sol rtol=1e-2

# Vector integrand
vsol = fill(sol, 3)
@test integral(fv, ellipsoid, GaussLegendre(100))≈vsol rtol=1e-2
@test integral(fv, ellipsoid, GaussKronrod())≈vsol rtol=1e-2
@test integral(fv, ellipsoid, HAdaptiveCubature())≈vsol rtol=1e-2

# Integral aliases
@test_throws "not supported" lineintegral(f, ellipsoid)
@test surfaceintegral(f, ellipsoid)≈sol rtol=1e-2
@test_throws "not supported" volumeintegral(f, ellipsoid)
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
Expand Down Expand Up @@ -409,6 +436,31 @@ end
@test integral(fv, frustum, HAdaptiveCubature()) ≈ vsol
end

@testitem "Meshes.Hexahedron" setup=[Setup] begin
hexahedron = Hexahedron(Point(0, 0, 0), Point(2, 0, 0), Point(2, 2, 0),
Point(0, 2, 0), Point(0, 0, 2), Point(1, 0, 2), Point(1, 1, 2), Point(0, 1, 2))

f(p) = 1.0
fv(p) = fill(f(p), 3)

# Scalar integrand
sol = Meshes.measure(hexahedron)
@test integral(f, hexahedron, GaussLegendre(100)) ≈ sol
@test_throws "not supported" integral(f, hexahedron, GaussKronrod())≈sol
@test integral(f, hexahedron, HAdaptiveCubature()) ≈ sol

# Vector integrand
vsol = fill(sol, 3)
@test integral(fv, hexahedron, GaussLegendre(100)) ≈ vsol
@test_throws "not supported" integral(fv, hexahedron, GaussKronrod())≈vsol
@test integral(fv, hexahedron, HAdaptiveCubature()) ≈ vsol

# Integral aliases
@test_throws "not supported" lineintegral(f, hexahedron)
@test_throws "not supported" surfaceintegral(f, hexahedron)
@test volumeintegral(f, hexahedron) ≈ sol
end

@testitem "Meshes.Line" setup=[Setup] begin
a = Point(0.0u"m", 0.0u"m", 0.0u"m")
b = Point(1.0u"m", 1.0u"m", 1.0u"m")
Expand Down
Loading