Skip to content

Commit

Permalink
Implement for CylinderSurface and Disk
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeingold committed Dec 5, 2024
1 parent 6bccee1 commit fe5138c
Showing 1 changed file with 18 additions and 42 deletions.
60 changes: 18 additions & 42 deletions test/combinations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -376,73 +376,49 @@ end
pt_e = Point(1, 0, 0)
cyl = Cylinder(pt_e, pt_w, 2.5)

# Integrand
# Integrand & Solution
integrand(p) = 1.0u"A"

# Solution
solution = Meshes.measure(cyl) * u"A"

# Package and run tests
testable = TestableGeometry(integrand, cyl, solution)
runtests(testable, SupportStatus(:volume))
end

@testitem "Meshes.CylinderSurface" setup=[Setup] begin
@testitem "Meshes.CylinderSurface" setup=[Combinations] begin
# Geometry
pt_w = Point(-1, 0, 0)
pt_e = Point(1, 0, 0)
cyl = CylinderSurface(pt_e, pt_w, 2.5)

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

# Scalar integrand
sol = Meshes.measure(cyl)
@test integral(f, cyl, GaussLegendre(100)) sol
@test integral(f, cyl, GaussKronrod()) sol
@test integral(f, cyl, HAdaptiveCubature()) sol

# Vector integrand
vsol = fill(sol, 3)
@test integral(fv, cyl, GaussLegendre(100)) vsol
@test integral(fv, cyl, GaussKronrod()) vsol
@test integral(fv, cyl, HAdaptiveCubature()) vsol
# Integrand & Solution
integrand(p) = 1.0u"A"
solution = Meshes.measure(cyl) * u"A"

# Integral aliases
@test_throws "not supported" lineintegral(f, cyl)
@test surfaceintegral(f, cyl) sol
@test_throws "not supported" volumeintegral(f, cyl)
# Package and run tests
testable = TestableGeometry(integrand, cyl, solution)
runtests(testable, SupportStatus(:surface))
end

@testitem "Meshes.Disk" setup=[Setup] begin
@testitem "Meshes.Disk" setup=[Combinations] begin
# Geometry
center = Point(1, 2, 3)
= Vec(1 / 2, 1 / 2, sqrt(2) / 2)
plane = Plane(center, n̂)
radius = 2.5
disk = Disk(plane, radius)

function f(p::P) where {P <: Meshes.Point}
# Integrand & Solution
function integrand(p::P) where {P <: Meshes.Point}
offset = p - center
r = ustrip(u"m", norm(offset))
exp(-r^2)
exp(-r^2) * u"A"
end
fv(p) = fill(f(p), 3)
solution = - π * exp(-radius^2)) * u"A*m^2"

# Scalar integrand
sol =- π * exp(-radius^2)) * u"m^2"
@test integral(f, disk, GaussLegendre(100)) sol
@test integral(f, disk, GaussKronrod()) sol
@test integral(f, disk, HAdaptiveCubature()) sol

# Vector integrand
vsol = fill(sol, 3)
@test integral(fv, disk, GaussLegendre(100)) vsol
@test integral(fv, disk, GaussKronrod()) vsol
@test integral(fv, disk, HAdaptiveCubature()) vsol

# Integral aliases
@test_throws "not supported" lineintegral(f, disk)
@test surfaceintegral(f, disk) sol
@test_throws "not supported" volumeintegral(f, disk)
# Package and run tests
testable = TestableGeometry(integrand, disk, solution)
runtests(testable, SupportStatus(:surface))
end

@testitem "Meshes.Ellipsoid" setup=[Setup] begin
Expand Down

0 comments on commit fe5138c

Please sign in to comment.