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

Cleanup examples #592

Merged
merged 16 commits into from
Aug 12, 2024
3 changes: 2 additions & 1 deletion examples/fluid/hydrostatic_water_column_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ tank = RectangularTank(fluid_particle_spacing, initial_fluid_size, tank_size, fl
smoothing_length = 1.2 * fluid_particle_spacing
smoothing_kernel = SchoenbergCubicSplineKernel{2}()

viscosity = ArtificialViscosityMonaghan(alpha=0.02, beta=0.0)
alpha = 0.02
viscosity = ArtificialViscosityMonaghan(alpha=alpha, beta=0.0)
svchb marked this conversation as resolved.
Show resolved Hide resolved

fluid_density_calculator = ContinuityDensity()
fluid_system = WeaklyCompressibleSPHSystem(tank.fluid, fluid_density_calculator,
Expand Down
35 changes: 0 additions & 35 deletions examples/fluid/hydrostatic_water_column_edac_2d.jl

This file was deleted.

132 changes: 89 additions & 43 deletions test/examples/examples.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,94 @@
# but without checking the correctness of the solution.
@testset verbose=true "Examples" begin
@testset verbose=true "Fluid" begin
@trixi_testset "fluid/oscillating_drop_2d.jl" begin
@test_nowarn_mod trixi_include(@__MODULE__,
joinpath(examples_dir(), "fluid",
"oscillating_drop_2d.jl"))
@test sol.retcode == ReturnCode.Success
# This error varies between serial and multithreaded runs
@test isapprox(error_A, 0.0, atol=1.73e-4)
@test count_rhs_allocations(sol, semi) == 0
end

@trixi_testset "fluid/hydrostatic_water_column_2d.jl" begin
hydrostatic_water_column_tests = Dict(
"default" => (),
"with source term damping" => (source_terms=SourceTermDamping(damping_coefficient=1e-4),),
"with SummationDensity" => (fluid_density_calculator=SummationDensity(),
clip_negative_pressure=true),
svchb marked this conversation as resolved.
Show resolved Hide resolved
"with ViscosityAdami" => (
# from 0.02*10.0*1.2*0.05/8
viscosity=ViscosityAdami(nu=0.0015),),
"with ViscosityMorris" => (
# from 0.02*10.0*1.2*0.05/8
viscosity=ViscosityMorris(nu=0.0015),),
"with ViscosityAdami and SummationDensity" => (
# from 0.02*10.0*1.2*0.05/8
viscosity=ViscosityAdami(nu=0.0015),
fluid_density_calculator=SummationDensity(),
clip_negative_pressure=true),
"with ViscosityMorris and SummationDensity" => (
# from 0.02*10.0*1.2*0.05/8
viscosity=ViscosityMorris(nu=0.0015),
fluid_density_calculator=SummationDensity(),
clip_negative_pressure=true),
"with smoothing_length=1.3" => (smoothing_length=1.3,),
"with SchoenbergQuarticSplineKernel" => (smoothing_length=1.1,
smoothing_kernel=SchoenbergQuarticSplineKernel{2}()),
"with SchoenbergQuinticSplineKernel" => (smoothing_length=1.1,
smoothing_kernel=SchoenbergQuinticSplineKernel{2}()),
"with WendlandC2Kernel" => (smoothing_length=3.0,
smoothing_kernel=WendlandC2Kernel{2}()),
"with WendlandC4Kernel" => (smoothing_length=3.5,
smoothing_kernel=WendlandC4Kernel{2}()),
"with WendlandC6Kernel" => (smoothing_length=4.0,
smoothing_kernel=WendlandC6Kernel{2}()),
)

for (test_description, kwargs) in hydrostatic_water_column_tests
@testset "$test_description" begin
println("═"^100)
println("$test_description")

@test_nowarn_mod trixi_include(@__MODULE__,
joinpath(examples_dir(), "fluid",
"hydrostatic_water_column_2d.jl");
kwargs...)

@test sol.retcode == ReturnCode.Success
@test count_rhs_allocations(sol, semi) == 0
end
end
end

@trixi_testset "fluid/hydrostatic_water_column_2d.jl with EDAC" begin
# import variables into scope
trixi_include(@__MODULE__,
joinpath(examples_dir(), "fluid",
"hydrostatic_water_column_2d.jl"),
fluid_system=nothing, sol=nothing, semi=nothing, ode=nothing)

viscosity = ViscosityAdami(nu=alpha * smoothing_length * sound_speed / 8)
fluid_system = EntropicallyDampedSPHSystem(tank.fluid, smoothing_kernel,
smoothing_length, sound_speed,
viscosity=viscosity,
density_calculator=ContinuityDensity(),
acceleration=(0.0, -gravity))
svchb marked this conversation as resolved.
Show resolved Hide resolved

@test_nowarn_mod trixi_include(@__MODULE__,
joinpath(examples_dir(), "fluid",
"hydrostatic_water_column_2d.jl"))
"hydrostatic_water_column_2d.jl");
fluid_system=fluid_system)

@test sol.retcode == ReturnCode.Success
@test count_rhs_allocations(sol, semi) == 0
end

@trixi_testset "fluid/hydrostatic_water_column_2d.jl with source term damping" begin
@trixi_testset "fluid/oscillating_drop_2d.jl" begin
@test_nowarn_mod trixi_include(@__MODULE__,
joinpath(examples_dir(), "fluid",
"hydrostatic_water_column_2d.jl"),
source_terms=SourceTermDamping(;
damping_coefficient=1e-4))
"oscillating_drop_2d.jl"))
@test sol.retcode == ReturnCode.Success
# This error varies between serial and multithreaded runs
@test isapprox(error_A, 0.0, atol=1.73e-4)
@test count_rhs_allocations(sol, semi) == 0
end

@trixi_testset "fluid/hydrostatic_water_column_2d.jl with SummationDensity" begin
@trixi_testset "fluid/hydrostatic_water_column_edac_2d.jl" begin
@test_nowarn_mod trixi_include(@__MODULE__,
joinpath(examples_dir(), "fluid",
"hydrostatic_water_column_2d.jl"),
fluid_density_calculator=SummationDensity(),
clip_negative_pressure=true)
"hydrostatic_water_column_edac_2d.jl"))
@test sol.retcode == ReturnCode.Success
@test count_rhs_allocations(sol, semi) == 0
end
Expand All @@ -60,14 +114,6 @@
@test count_rhs_allocations(sol, semi) == 0
end

@trixi_testset "fluid/hydrostatic_water_column_edac_2d.jl" begin
@test_nowarn_mod trixi_include(@__MODULE__,
joinpath(examples_dir(), "fluid",
"hydrostatic_water_column_edac_2d.jl"))
@test sol.retcode == ReturnCode.Success
@test count_rhs_allocations(sol, semi) == 0
end

@trixi_testset "fluid/accelerated_tank_2d.jl" begin
@test_nowarn_mod trixi_include(@__MODULE__, tspan=(0.0, 0.5),
joinpath(examples_dir(), "fluid",
Expand All @@ -87,24 +133,33 @@
@test count_rhs_allocations(sol, semi) == 0
end

@trixi_testset "fluid/dam_break_oil_film_2d.jl" begin
@trixi_testset "fluid/dam_break_2d.jl with KernelAbstractions.jl" begin
# Emulate the GPU code on the CPU by passing `data_type = Array`
@test_nowarn_mod trixi_include(@__MODULE__,
joinpath(examples_dir(), "fluid",
"dam_break_oil_film_2d.jl"),
tspan=(0.0, 0.1)) [
"dam_break_2d.jl"), tspan=(0.0, 0.1),
data_type=Array) [
r"┌ Info: The desired tank length in y-direction .*\n",
r"└ New tank length in y-direction.*\n",
]
@test sol.retcode == ReturnCode.Success
@test count_rhs_allocations(sol, semi) == 0
end

@trixi_testset "fluid/dam_break_2d.jl with KernelAbstractions.jl" begin
# Emulate the GPU code on the CPU by passing `data_type = Array`
@trixi_testset "fluid/dam_break_2d_surface_tension.jl" begin
@test_nowarn_mod trixi_include(@__MODULE__,
joinpath(examples_dir(), "fluid",
"dam_break_2d.jl"), tspan=(0.0, 0.1),
data_type=Array) [
"dam_break_2d_surface_tension.jl"),
tspan=(0.0, 0.1))
@test sol.retcode == ReturnCode.Success
@test count_rhs_allocations(sol, semi) == 0
end

@trixi_testset "fluid/dam_break_oil_film_2d.jl" begin
@test_nowarn_mod trixi_include(@__MODULE__,
joinpath(examples_dir(), "fluid",
"dam_break_oil_film_2d.jl"),
tspan=(0.0, 0.1)) [
r"┌ Info: The desired tank length in y-direction .*\n",
r"└ New tank length in y-direction.*\n",
]
Expand Down Expand Up @@ -147,15 +202,6 @@
@test count_rhs_allocations(sol, semi) == 0
end

@trixi_testset "fluid/dam_break_2d_surface_tension.jl" begin
@test_nowarn_mod trixi_include(@__MODULE__,
joinpath(examples_dir(), "fluid",
"dam_break_2d_surface_tension.jl"),
tspan=(0.0, 0.1))
@test sol.retcode == ReturnCode.Success
@test count_rhs_allocations(sol, semi) == 0
end

@trixi_testset "fluid/sphere_surface_tension_2d.jl" begin
@test_nowarn_mod trixi_include(@__MODULE__,
joinpath(examples_dir(), "fluid",
Expand Down
Loading