Skip to content

Commit

Permalink
Move dam break corrections to test (#376)
Browse files Browse the repository at this point in the history
* Move dam break corrections example to test

* Add dam break corrections to tests

---------

Co-authored-by: Niklas Neher <[email protected]>
  • Loading branch information
efaulhaber and LasNikas authored Feb 7, 2024
1 parent b27aa2b commit a569824
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 104 deletions.
94 changes: 0 additions & 94 deletions examples/fluid/dam_break_2d_corrections.jl

This file was deleted.

98 changes: 98 additions & 0 deletions test/examples/dam_break_2d_corrections.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
@trixi_testset "dam_break_2d.jl with corrections" begin
fluid_density = 1000.0
particle_spacing = 0.05
tspan = (0.0, 0.1)

correction_dict = Dict(
"no_correction" => nothing,
"shepard_kernel_correction" => ShepardKernelCorrection(),
"akinci_free_surf_correction" => AkinciFreeSurfaceCorrection(fluid_density),
"kernel_gradient_summation_correction" => KernelCorrection(),
"kernel_gradient_continuity_correction" => KernelCorrection(),
"blended_gradient_summation_correction" => BlendedGradientCorrection(0.5),
"blended_gradient_continuity_correction" => BlendedGradientCorrection(0.2),
"gradient_summation_correction" => GradientCorrection(),
"mixed_kernel_gradient_summation_correction" => MixedKernelGradientCorrection(),
# "gradient_continuity_correction" => GradientCorrection(),
# "mixed_kernel_gradient_continuity_correction" => MixedKernelGradientCorrection(),
)

smoothing_length_dict = Dict(
"no_correction" => 3.0 * particle_spacing,
"shepard_kernel_correction" => 3.0 * particle_spacing,
"akinci_free_surf_correction" => 3.0 * particle_spacing,
"kernel_gradient_summation_correction" => 4.0 * particle_spacing,
"kernel_gradient_continuity_correction" => 3.5 * particle_spacing,
"blended_gradient_summation_correction" => 3.0 * particle_spacing,
"blended_gradient_continuity_correction" => 4.0 * particle_spacing,
"gradient_summation_correction" => 3.5 * particle_spacing,
"mixed_kernel_gradient_summation_correction" => 3.5 * particle_spacing,
"gradient_continuity_correction" => 4.5 * particle_spacing,
"mixed_kernel_gradient_continuity_correction" => 4.0 * particle_spacing,
)

density_calculator_dict = Dict(
"no_correction" => SummationDensity(),
"shepard_kernel_correction" => SummationDensity(),
"akinci_free_surf_correction" => SummationDensity(),
"kernel_gradient_summation_correction" => SummationDensity(),
"kernel_gradient_continuity_correction" => ContinuityDensity(),
"blended_gradient_summation_correction" => SummationDensity(),
"blended_gradient_continuity_correction" => ContinuityDensity(),
"gradient_summation_correction" => SummationDensity(),
"gradient_continuity_correction" => ContinuityDensity(),
"mixed_kernel_gradient_summation_correction" => SummationDensity(),
"mixed_kernel_gradient_continuity_correction" => ContinuityDensity(),
)

smoothing_kernel_dict = Dict(
"no_correction" => WendlandC2Kernel{2}(),
"shepard_kernel_correction" => WendlandC2Kernel{2}(),
"akinci_free_surf_correction" => WendlandC2Kernel{2}(),
"kernel_gradient_summation_correction" => WendlandC6Kernel{2}(),
"kernel_gradient_continuity_correction" => WendlandC6Kernel{2}(),
"blended_gradient_summation_correction" => WendlandC2Kernel{2}(),
"blended_gradient_continuity_correction" => WendlandC6Kernel{2}(),
"gradient_summation_correction" => WendlandC6Kernel{2}(),
"gradient_continuity_correction" => WendlandC6Kernel{2}(),
"mixed_kernel_gradient_summation_correction" => WendlandC6Kernel{2}(),
"mixed_kernel_gradient_continuity_correction" => WendlandC6Kernel{2}(),
)

@testset "continuity_reinit" begin
trixi_include(@__MODULE__, joinpath(examples_dir(), "fluid", "dam_break_2d.jl"),
fluid_particle_spacing=particle_spacing,
smoothing_length=3.0 * particle_spacing,
boundary_density_calculator=ContinuityDensity(),
fluid_density_calculator=ContinuityDensity(),
correction=nothing, use_reinit=true,
prefix="continuity_reinit", tspan=tspan,
fluid_density=fluid_density, density_diffusion=nothing)

@test sol.retcode == ReturnCode.Success
end

@testset verbose=true "$correction_name" for correction_name in keys(correction_dict)
local fluid_density_calculator = density_calculator_dict[correction_name]
local correction = correction_dict[correction_name]
local smoothing_kernel = smoothing_kernel_dict[correction_name]
local smoothing_length = smoothing_length_dict[correction_name]

println("="^100)
println("fluid/dam_break_2d.jl with ", correction_name)

trixi_include(@__MODULE__, joinpath(examples_dir(), "fluid", "dam_break_2d.jl"),
fluid_particle_spacing=particle_spacing,
smoothing_length=smoothing_length,
boundary_density_calculator=SummationDensity(),
fluid_density_calculator=fluid_density_calculator,
correction=correction, use_reinit=false,
clip_negative_pressure=(fluid_density_calculator isa SummationDensity),
smoothing_kernel=smoothing_kernel,
prefix="$(correction_name)", tspan=tspan,
fluid_density=fluid_density, density_diffusion=nothing,
boundary_layers=5)

@test sol.retcode == ReturnCode.Success
end
end
14 changes: 4 additions & 10 deletions test/examples/examples.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
joinpath(examples_dir(), "fluid",
"oscillating_drop_2d.jl"))
@test sol.retcode == ReturnCode.Success
# This is the error on an Apple M2 Pro. We need this tolerance to make CI pass.
@test isapprox(error_A, 0.0001717690010767381, atol=1e-8)
# This error varies between serial and multithreaded runs
@test isapprox(error_A, 0.0001717690010767381, atol=5e-7)
end

@trixi_testset "fluid/rectangular_tank_2d.jl" begin
Expand Down Expand Up @@ -63,14 +63,6 @@
@test sol.retcode == ReturnCode.Success
end

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

@trixi_testset "fluid/dam_break_3d.jl" begin
@test_nowarn_mod trixi_include(@__MODULE__,
joinpath(examples_dir(), "fluid",
Expand All @@ -94,6 +86,8 @@
tspan=(0.0, 0.4))
@test sol.retcode == ReturnCode.Success
end

include("dam_break_2d_corrections.jl")
end

@testset verbose=true "Solid" begin
Expand Down

0 comments on commit a569824

Please sign in to comment.