211211
212212 # Integrand & Solution
213213 function integrand (p:: Meshes.Point )
214- x₁ = only (ustrip .(( to (p) )))
214+ x₁ = only (ustrip .(to (p)))
215215 √ (a^ 2 - x₁^ 2 ) * u " A"
216216 end
217217 solution = π * a^ 2 / 4 * u " A*m"
@@ -222,12 +222,13 @@ end
222222end
223223
224224@testitem " Meshes.Box 2D" setup= [Combinations] begin
225+ # Geometry
225226 a = π
226227 box = Box (Point (0 , 0 ), Point (a, a))
227228
228229 # Integrand & Solution
229230 function integrand (p:: Meshes.Point )
230- x₁, x₂ = ustrip .(( to (p) ))
231+ x₁, x₂ = ustrip .(to (p))
231232 (√ (a^ 2 - x₁^ 2 ) + √ (a^ 2 - x₂^ 2 )) * u " A"
232233 end
233234 solution = 2 a * (π * a^ 2 / 4 ) * u " A*m^2"
244245
245246 # Integrand & Solution
246247 function integrand (p:: Meshes.Point )
247- x₁, x₂, x₃ = ustrip .(( to (p) ))
248+ x₁, x₂, x₃ = ustrip .(to (p))
248249 (√ (a^ 2 - x₁^ 2 ) + √ (a^ 2 - x₂^ 2 ) + √ (a^ 2 - x₃^ 2 )) * u " A"
249250 end
250251 solution = 3 a^ 2 * (π * a^ 2 / 4 ) * u " A*m^3"
@@ -405,12 +406,15 @@ end
405406@testitem " Meshes.Ellipsoid" setup= [Combinations] begin
406407 # Geometry
407408 origin = Point (0 , 0 , 0 )
408- radii = ( 1.0 , 2.0 , 0.5 )
409- ellipsoid = Ellipsoid (radii , origin)
409+ R = r₁ = r₂ = r₃ = 4.1
410+ ellipsoid = Ellipsoid ((r₁, r₂, r₃) , origin)
410411
411412 # Integrand & Solution
412- integrand (p) = 1.0 u " A"
413- solution = Meshes. measure (ellipsoid) * u " A"
413+ function integrand (p:: Meshes.Point )
414+ x, y, z = ustrip .(u " m" , to (p))
415+ (z^ 2 ) * u " A"
416+ end
417+ solution = (4 π * R^ 4 / 3 ) * u " A*m^2"
414418
415419 # Package and run tests
416420 # Tolerances are higher due to `measure` being only an approximation
@@ -452,16 +456,20 @@ end
452456
453457@testitem " Meshes.Hexahedron" setup= [Combinations] begin
454458 # Geometry
455- hexahedron = Hexahedron (Point (0 , 0 , 0 ), Point (2 , 0 , 0 ), Point (2 , 2 , 0 ),
456- Point (0 , 2 , 0 ), Point (0 , 0 , 2 ), Point (1 , 0 , 2 ), Point (1 , 1 , 2 ), Point (0 , 1 , 2 ))
459+ a = π
460+ box = Box (Point (0 , 0 , 0 ), Point (a, a, a))
461+ hexahedron = Hexahedron (discretize (box). vertices... )
457462
458463 # Integrand & Solution
459- integrand (p) = 1.0 u " A"
460- solution = Meshes. measure (hexahedron) * u " A"
464+ function integrand (p:: Meshes.Point )
465+ x₁, x₂, x₃ = ustrip .(to (p))
466+ (√ (a^ 2 - x₁^ 2 ) + √ (a^ 2 - x₂^ 2 ) + √ (a^ 2 - x₃^ 2 )) * u " A"
467+ end
468+ solution = 3 a^ 2 * (π * a^ 2 / 4 ) * u " A*m^3"
461469
462470 # Package and run tests
463471 testable = TestableGeometry (integrand, hexahedron, solution)
464- runtests (testable)
472+ runtests (testable; rtol = 1e-6 )
465473end
466474
467475@testitem " Meshes.Line" setup= [Combinations] begin
@@ -675,15 +683,18 @@ end
675683
676684@testitem " Meshes.Tetrahedron" setup= [Combinations] begin
677685 # Geometry
678- pt_n = Point (0 , 3 , 0 )
679- pt_w = Point (- 7 , 0 , 0 )
680- pt_e = Point (8 , 0 , 0 )
681- ẑ = Vec (0 , 0 , 1 )
682- tetrahedron = Tetrahedron (pt_n, pt_w, pt_e, pt_n + ẑ )
686+ a = Point (0 , 0 , 0 )
687+ b = Point (1 , 0 , 0 )
688+ c = Point (0 , 1 , 0 )
689+ d = Point (0 , 0 , 1 )
690+ tetrahedron = Tetrahedron (a, b, c, d )
683691
684692 # Integrand & Solution
685- integrand (p) = 1.0 u " A"
686- solution = Meshes. measure (tetrahedron) * u " A"
693+ function integrand (p:: Meshes.Point )
694+ x, y, z = ustrip .(u " m" , to (p))
695+ (x + 2 y + 3 z) * u " A"
696+ end
697+ solution = (1 // 4 ) * u " A*m^3"
687698
688699 # Package and run tests
689700 testable = TestableGeometry (integrand, tetrahedron, solution)
@@ -692,13 +703,18 @@ end
692703
693704@testitem " Meshes.Torus" setup= [Combinations] begin
694705 # Geometry
695- origin = Point (0 , 0 , 0 )
706+ center = Point (0 , 0 , 0 )
696707 ẑ = Vec (0 , 0 , 1 )
697- torus = Torus (origin, ẑ, 3.5 , 1.25 )
708+ R = 3.5 # radius from axis-of-revolution to center of circle being revolved
709+ r = 1.2 # radius of circle being revolved
710+ torus = Torus (center, ẑ, R, r)
698711
699712 # Integrand & Solution
700- integrand (p) = 1.0 u " A"
701- solution = Meshes. measure (torus) * u " A"
713+ function integrand (p:: Meshes.Point )
714+ x, y, z = ustrip .(u " m" , to (p))
715+ (x^ 2 + y^ 2 ) * u " A"
716+ end
717+ solution = (2 π^ 2 * r * R * (2 R^ 2 + 3 r^ 2 )) * u " A*m^2"
702718
703719 # Package and run tests
704720 testable = TestableGeometry (integrand, torus, solution)
@@ -707,14 +723,17 @@ end
707723
708724@testitem " Meshes.Triangle" setup= [Combinations] begin
709725 # Geometry
710- pt_n = Point (0 , 1 , 0 )
711- pt_w = Point (- 1 , 0 , 0 )
712- pt_e = Point (1 , 0 , 0 )
713- triangle = Triangle (pt_e, pt_n, pt_w )
726+ a = Point (0 , 0 , 0 )
727+ b = Point (1 , 0 , 0 )
728+ c = Point (0 , 1 , 0 )
729+ triangle = Triangle (a, b, c )
714730
715731 # Integrand & Solution
716- integrand (p) = 1.0 u " A"
717- solution = Meshes. measure (triangle) * u " A"
732+ function integrand (p:: Meshes.Point )
733+ x, y, z = ustrip .(u " m" , to (p))
734+ (x + 2 y + 3 z) * u " A"
735+ end
736+ solution = (1 // 2 ) * u " A*m^2"
718737
719738 # Package and run tests
720739 testable = TestableGeometry (integrand, triangle, solution)
0 commit comments