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 official support for Frustum, Pyramid, and Wedge geometries #168

Merged
merged 18 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from 14 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
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# Branch TODO

- Add official support/tests for `Frustum`, `Pyramid`, and `Wedge`
- Verify `Frustum`
- Verify `Pyramid`
- Verify `Wedge`
- Update the Support Matrix in docs

# MeshIntegrals.jl

[![Docs-stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://JuliaGeometry.github.io/MeshIntegrals.jl/stable/)
Expand Down
6 changes: 3 additions & 3 deletions docs/src/support.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ designed to check for accuracy.
| `CylinderSurface` | ⚠️ | ✅ | ✅ |
| `Disk` | ⚠️ | ✅ | ✅ |
| `Ellipsoid` | ✅ | ✅ | ✅ |
| `Frustum` | 🛑 | [🎗️](https://github.com/JuliaGeometry/MeshIntegrals.jl/issues/28) | [🎗️](https://github.com/JuliaGeometry/MeshIntegrals.jl/issues/28) |
| `Frustum` | ⚠️ | | |
| `FrustumSurface` | ⚠️ | ✅ | ✅ |
| `Hexahedron` | ✅ | ✅ | ✅ |
| `Line` | ✅ | ✅ | ✅ |
| `ParaboloidSurface` | ⚠️ | ✅ | ✅ |
| `ParametrizedCurve` | ✅ | ✅ | ✅ |
| `Plane` | ✅ | ✅ | ✅ |
| `Polyarea` | 🛑 | [🎗️](https://github.com/JuliaGeometry/MeshIntegrals.jl/issues/28) | [🎗️](https://github.com/JuliaGeometry/MeshIntegrals.jl/issues/28) |
| `Pyramid` | 🛑 | [🎗️](https://github.com/JuliaGeometry/MeshIntegrals.jl/issues/28) | [🎗️](https://github.com/JuliaGeometry/MeshIntegrals.jl/issues/28) |
| `Pyramid` | ⚠️ | | |
| `Quadrangle` | ⚠️ | ✅ | ✅ |
| `Ray` | ✅ | ✅ | ✅ |
| `Ring` | ✅ | ✅ | ✅ |
Expand All @@ -61,7 +61,7 @@ designed to check for accuracy.
| `Tetrahedron` | ⚠️ | ✅ | ✅ |
| `Triangle` | ✅ | ✅ | ✅ |
| `Torus` | ⚠️ | ✅ | ✅ |
| `Wedge` | 🛑 | [🎗️](https://github.com/JuliaGeometry/MeshIntegrals.jl/issues/28) | [🎗️](https://github.com/JuliaGeometry/MeshIntegrals.jl/issues/28) |
| `Wedge` | ⚠️ | | |

| Symbol | Support Level |
|--------|---------|
Expand Down
72 changes: 72 additions & 0 deletions test/combinations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,31 @@ end
runtests(testable; rtol = 1e-2)
end

@testitem "Meshes.Frustum" setup=[Combinations] begin
if pkgversion(Meshes) >= v"0.52.12"
# Geometry
r = 2.5u"m"
h = 3.5u"m"
origin = Point(0, 0, 0)
midpoint = Point(0.0u"m", 0.0u"m", 0.5 * h)
apex = Point(0.0u"m", 0.0u"m", h)
ẑ = Vec(0, 0, 1)
xy_plane = Plane(origin, ẑ)
base = Disk(xy_plane, r)
mid_plane = Plane(midpoint, ẑ)
mid_disk = Disk(mid_plane, 0.5 * r)
frustum = Frustum(base, mid_disk)

# Integrand & Solution
integrand(p) = 1.0u"A"
solution = (7 // 8) * (π * r^2 * h / 3) * u"A"

# Package and run tests
testable = TestableGeometry(integrand, frustum, solution)
runtests(testable)
end
end

@testitem "Meshes.FrustumSurface" setup=[Combinations] begin
# Geometry
# Create a frustum whose radius halves at the top, i.e. the bottom half of a cone
Expand Down Expand Up @@ -491,6 +516,7 @@ end
end

@testitem "Meshes.ParaboloidSurface" setup=[Combinations] begin
# Geometry
origin = Point(0, 0, 0)
parab = ParaboloidSurface(origin, 2.5, 4.15)

Expand Down Expand Up @@ -546,6 +572,28 @@ end
runtests(testable)
end

@testitem "Meshes.Pyramid" setup=[Combinations] begin
if pkgversion(Meshes) >= v"0.52.12"
# Geometry
a = Point(-1, -1, 0)
b = Point(1, -1, 0)
c = Point(1, 1, 0)
d = Point(-1, 1, 0)
apex = Point(0, 0, 1)
pyramid = Pyramid(a, b, c, d, apex)

# Integrand & Solution
integrand(p) = 1.0u"A"
w = norm(b - a)
h = norm(d - a)
solution = (1 // 3) * w * h * u"A*m"

# Package and run tests
testable = TestableGeometry(integrand, pyramid, solution)
runtests(testable)
end
end

@testitem "Meshes.Quadrangle" setup=[Combinations] begin
using SpecialFunctions: erf

Expand Down Expand Up @@ -739,3 +787,27 @@ end
testable = TestableGeometry(integrand, triangle, solution)
runtests(testable)
end

@testitem "Meshes.Wedge" setup=[Combinations] begin
if pkgversion(Meshes) >= v"0.52.12"
# Geometry
a₀ = Point(0, 0, 0)
b₀ = Point(1, 0, 0)
c₀ = Point(0, 1, 0)
a₁ = Point(0, 0, 1)
b₁ = Point(1, 0, 1)
c₁ = Point(0, 1, 1)
wedge = Wedge(a₀, b₀, c₀, a₁, b₁, c₁)

# Integrand & Solution
function integrand(p::Meshes.Point)
x, y, z = ustrip.(u"m", to(p))
(x + 2y + 3z) * u"A"
end
solution = (5 // 4) * u"A*m^3"

# Package and run tests
testable = TestableGeometry(integrand, wedge, solution)
runtests(testable)
end
end
Loading