Skip to content

Commit a445f66

Browse files
Add tests for Meshes.Quadrangle (#95)
* add tests for Meshes.Quadrangle * add Quadrangle to support matrix in docs
1 parent 4086902 commit a445f66

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

docs/src/supportmatrix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Cubature integration rules are recommended (and the default).
3939
| `Line` ||||
4040
| `ParaboloidSurface` ||||
4141
| `Plane` ||||
42+
| `Quadrangle` ||||
4243
| `Ray` ||||
4344
| `Ring` ||||
4445
| `Rope` ||||

test/Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
33
ExplicitImports = "7d51a73a-1435-4ff3-83d9-f097790105c7"
44
Meshes = "eacbb407-ea5a-433e-ab97-5258b1ca43fa"
55
QuadGK = "1fd47b50-473d-5c70-9696-f719f8f3bcdc"
6+
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
67
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
78
TestItemRunner = "f8b46487-2199-4994-9208-9a1283c18c0a"
89
TestItems = "1c621080-faea-4a02-84b6-bbd5e436b8fe"
@@ -13,6 +14,7 @@ Aqua = "0.7, 0.8"
1314
ExplicitImports = "1.6.0"
1415
Meshes = "0.50, 0.51"
1516
QuadGK = "2.1.1"
17+
SpecialFunctions = "2"
1618
TestItemRunner = "1"
1719
TestItems = "1"
1820
Unitful = "1.19"

test/combinations.jl

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,35 @@ end
203203
@test_throws "not supported" volumeintegral(f, plane)
204204
end
205205

206+
@testitem "Meshes.Quadrangle" setup=[Setup] begin
207+
using SpecialFunctions: erf
208+
quadrangle = Quadrangle((-1.0, 0.0), (-1.0, 1.0), (1.0, 1.0), (1.0, 0.0))
209+
210+
function f(p::P) where {P <: Meshes.Point}
211+
ur = hypot(p.coords.x, p.coords.y)
212+
r = ustrip(u"m", ur)
213+
exp(-r^2)
214+
end
215+
fv(p) = fill(f(p), 3)
216+
217+
# Scalar integrand
218+
sol = 0.5 * π * erf(1)^2 * u"m^2"
219+
@test integral(f, quadrangle, GaussLegendre(100)) sol
220+
@test integral(f, quadrangle, GaussKronrod()) sol
221+
@test integral(f, quadrangle, HAdaptiveCubature()) sol
222+
223+
# Vector integrand
224+
vsol = fill(sol, 3)
225+
@test integral(fv, quadrangle, GaussLegendre(100)) vsol
226+
@test integral(fv, quadrangle, GaussKronrod()) vsol
227+
@test integral(fv, quadrangle, HAdaptiveCubature()) vsol
228+
229+
# Integral aliases
230+
@test_throws "not supported" lineintegral(f, quadrangle)
231+
@test surfaceintegral(f, quadrangle) sol
232+
@test_throws "not supported" volumeintegral(f, quadrangle)
233+
end
234+
206235
@testitem "Meshes.Ray" setup=[Setup] begin
207236
a = Point(0.0u"m", 0.0u"m", 0.0u"m")
208237
v = Vec(1.0u"m", 1.0u"m", 1.0u"m")

0 commit comments

Comments
 (0)