|
370 | 370 | @test_throws "not supported" volumeintegral(f, disk)
|
371 | 371 | end
|
372 | 372 |
|
| 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 | + |
373 | 400 | @testitem "Meshes.FrustumSurface" setup=[Setup] begin
|
374 | 401 | # Create a frustum whose radius halves at the top,
|
375 | 402 | # i.e. the bottom half of a cone by height
|
|
409 | 436 | @test integral(fv, frustum, HAdaptiveCubature()) ≈ vsol
|
410 | 437 | end
|
411 | 438 |
|
| 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 | + |
412 | 464 | @testitem "Meshes.Line" setup=[Setup] begin
|
413 | 465 | a = Point(0.0u"m", 0.0u"m", 0.0u"m")
|
414 | 466 | b = Point(1.0u"m", 1.0u"m", 1.0u"m")
|
|
0 commit comments