From 95d6a012d4878b2ca089e3981c520021b6bda005 Mon Sep 17 00:00:00 2001 From: Sven Berger Date: Wed, 7 Aug 2024 01:21:28 +0200 Subject: [PATCH 01/15] extend hydrostatic_water_column tests --- examples/fluid/hydrostatic_water_column_2d.jl | 7 +- .../fluid/hydrostatic_water_column_edac_2d.jl | 35 ----- test/examples/examples.jl | 132 ++++++++++++------ 3 files changed, 93 insertions(+), 81 deletions(-) delete mode 100644 examples/fluid/hydrostatic_water_column_edac_2d.jl diff --git a/examples/fluid/hydrostatic_water_column_2d.jl b/examples/fluid/hydrostatic_water_column_2d.jl index b35b6933f..227355d5e 100644 --- a/examples/fluid/hydrostatic_water_column_2d.jl +++ b/examples/fluid/hydrostatic_water_column_2d.jl @@ -28,10 +28,11 @@ tank = RectangularTank(fluid_particle_spacing, initial_fluid_size, tank_size, fl # ========================================================================================== # ==== Fluid -smoothing_length = 1.2 * fluid_particle_spacing -smoothing_kernel = SchoenbergCubicSplineKernel{2}() +smoothing_length = 3.0 * fluid_particle_spacing +smoothing_kernel = WendlandC2Kernel{2}() -viscosity = ArtificialViscosityMonaghan(alpha=0.02, beta=0.0) +alpha = 0.02 +viscosity = ArtificialViscosityMonaghan(alpha=alpha, beta=0.0) fluid_density_calculator = ContinuityDensity() fluid_system = WeaklyCompressibleSPHSystem(tank.fluid, fluid_density_calculator, diff --git a/examples/fluid/hydrostatic_water_column_edac_2d.jl b/examples/fluid/hydrostatic_water_column_edac_2d.jl deleted file mode 100644 index 701a1ccdb..000000000 --- a/examples/fluid/hydrostatic_water_column_edac_2d.jl +++ /dev/null @@ -1,35 +0,0 @@ -using TrixiParticles - -# Import the setup from `hydrostatic_water_column_2d.jl` -trixi_include(@__MODULE__, - joinpath(examples_dir(), "fluid", "hydrostatic_water_column_2d.jl"), - fluid_particle_spacing=0.05, initial_fluid_size=(1.0, 0.9), - tank_size=(1.0, 1.0), state_equation=nothing, fluid_system=nothing, - semi=nothing, ode=nothing, sol=nothing) # Overwrite `sol` assignment to skip time integration - -# ========================================================================================== -# ==== Experiment Setup -tspan = (0.0, 1.0) - -# ========================================================================================== -# ==== Fluid -alpha = 0.02 -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)) - -# ========================================================================================== -# ==== Simulation -semi = Semidiscretization(fluid_system, boundary_system) -ode = semidiscretize(semi, tspan) - -info_callback = InfoCallback(interval=50) -saving_callback = SolutionSavingCallback(dt=0.02, prefix="") - -callbacks = CallbackSet(info_callback, saving_callback) - -# Use a Runge-Kutta method with automatic (error based) time step size control -sol = solve(ode, RDPK3SpFSAL35(), save_everystep=false, callback=callbacks); diff --git a/test/examples/examples.jl b/test/examples/examples.jl index dac2a2979..d964fa452 100644 --- a/test/examples/examples.jl +++ b/test/examples/examples.jl @@ -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), + "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)) + @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 @@ -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", @@ -87,11 +133,12 @@ @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", ] @@ -99,12 +146,20 @@ @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", ] @@ -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", From 3a990f51732d0e5b91e20a5e7552140dd82dc575 Mon Sep 17 00:00:00 2001 From: Sven Berger Date: Wed, 7 Aug 2024 01:23:30 +0200 Subject: [PATCH 02/15] revert --- examples/fluid/hydrostatic_water_column_2d.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/fluid/hydrostatic_water_column_2d.jl b/examples/fluid/hydrostatic_water_column_2d.jl index 227355d5e..098c06643 100644 --- a/examples/fluid/hydrostatic_water_column_2d.jl +++ b/examples/fluid/hydrostatic_water_column_2d.jl @@ -28,8 +28,8 @@ tank = RectangularTank(fluid_particle_spacing, initial_fluid_size, tank_size, fl # ========================================================================================== # ==== Fluid -smoothing_length = 3.0 * fluid_particle_spacing -smoothing_kernel = WendlandC2Kernel{2}() +smoothing_length = 1.2 * fluid_particle_spacing +smoothing_kernel = SchoenbergCubicSplineKernel{2}() alpha = 0.02 viscosity = ArtificialViscosityMonaghan(alpha=alpha, beta=0.0) From 20d222b817f3a2cf2b512b7f4fe60c7d047cb50b Mon Sep 17 00:00:00 2001 From: Sven Berger Date: Wed, 7 Aug 2024 14:43:37 +0200 Subject: [PATCH 03/15] remove surface tension example with dam break --- .../fluid/dam_break_2d_surface_tension.jl | 31 ------------------- test/examples/examples.jl | 31 ++++++++++++------- test/runtests.jl | 8 ++--- 3 files changed, 23 insertions(+), 47 deletions(-) delete mode 100644 examples/fluid/dam_break_2d_surface_tension.jl diff --git a/examples/fluid/dam_break_2d_surface_tension.jl b/examples/fluid/dam_break_2d_surface_tension.jl deleted file mode 100644 index d83eb9865..000000000 --- a/examples/fluid/dam_break_2d_surface_tension.jl +++ /dev/null @@ -1,31 +0,0 @@ -# This example shows how surface tension can be applied to existing cases -# and which parameters have to be changed! -using TrixiParticles - -fluid_density = 1000.0 - -H = 0.6 -fluid_particle_spacing = H / 60 - -# Set the surface tension to a value that is accurate in your case. -# Note: This usually requires calibration to be physically accurate! -surface_tension = SurfaceTensionAkinci(surface_tension_coefficient=0.025) - -# `density_diffusion` is deactivated since the interaction with the surface tension model can -# cause stability problems. -# `adhesion_coefficient` needs to be set to a value so that the fluid doesn't separate -# from the boundary. -# Note: The surface tension model leads to an increase in compressibility of the fluid, -# which needs to be rectified by an increase of the `sound_speed`. -# Note: The Wendland Kernels don't work very well here since the `SurfaceTensionAkinci` -# model is optimized for a compact support of `2 * particle_spacing`, which would result -# in a too small `smoothing_length` for the Wendland Kernel functions. -# Note: Adhesion will result in additional friction at the boundary. -trixi_include(@__MODULE__, joinpath(examples_dir(), "fluid", "dam_break_2d.jl"), - surface_tension=surface_tension, - fluid_particle_spacing=fluid_particle_spacing, - smoothing_kernel=SchoenbergCubicSplineKernel{2}(), - smoothing_length=1.0 * fluid_particle_spacing, - correction=AkinciFreeSurfaceCorrection(fluid_density), - density_diffusion=nothing, adhesion_coefficient=0.05, - sound_speed=100.0, tspan=(0.0, 2.0)) diff --git a/test/examples/examples.jl b/test/examples/examples.jl index d964fa452..2917c6ed0 100644 --- a/test/examples/examples.jl +++ b/test/examples/examples.jl @@ -86,14 +86,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/hydrostatic_water_column_3d.jl" begin @test_nowarn_mod trixi_include(@__MODULE__, joinpath(examples_dir(), "fluid", @@ -146,11 +138,26 @@ @test count_rhs_allocations(sol, semi) == 0 end - @trixi_testset "fluid/dam_break_2d_surface_tension.jl" begin + @trixi_testset "fluid/dam_break_2d.jl with SurfaceTensionAkinci" begin + # import variables into scope + trixi_include(@__MODULE__, joinpath(examples_dir(), "fluid", "dam_break_2d.jl"), + sol=nothing, semi=nothing, ode=nothing) + @test_nowarn_mod trixi_include(@__MODULE__, joinpath(examples_dir(), "fluid", - "dam_break_2d_surface_tension.jl"), - tspan=(0.0, 0.1)) + "dam_break_2d.jl"), + tspan=(0.0, 0.05), + surface_tension=SurfaceTensionAkinci(surface_tension_coefficient=0.025), + fluid_particle_spacing=0.5 * fluid_particle_spacing, + smoothing_kernel=SchoenbergCubicSplineKernel{2}(), + smoothing_length=0.5 * fluid_particle_spacing, + correction=AkinciFreeSurfaceCorrection(fluid_density), + density_diffusion=nothing, + adhesion_coefficient=0.05, + sound_speed=100.0) [ + 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 @@ -159,7 +166,7 @@ @test_nowarn_mod trixi_include(@__MODULE__, joinpath(examples_dir(), "fluid", "dam_break_oil_film_2d.jl"), - tspan=(0.0, 0.1)) [ + tspan=(0.0, 0.05)) [ r"┌ Info: The desired tank length in y-direction .*\n", r"└ New tank length in y-direction.*\n", ] diff --git a/test/runtests.jl b/test/runtests.jl index 9c732c77b..d9461451f 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -3,12 +3,12 @@ include("test_util.jl") const TRIXIPARTICLES_TEST = lowercase(get(ENV, "TRIXIPARTICLES_TEST", "all")) @testset "All Tests" verbose=true begin - if TRIXIPARTICLES_TEST in ("all", "unit") - include("unittest.jl") - end + # if TRIXIPARTICLES_TEST in ("all", "unit") + # # include("unittest.jl") + # end if TRIXIPARTICLES_TEST in ("all", "examples") include("examples/examples.jl") - include("validation/validation.jl") + # include("validation/validation.jl") end end; From 91aa702a35071d5e9c4fdf166e0381ae440eaaf4 Mon Sep 17 00:00:00 2001 From: Sven Berger Date: Wed, 7 Aug 2024 15:00:41 +0200 Subject: [PATCH 04/15] simplify accelerated_tank example --- examples/fluid/accelerated_tank_2d.jl | 52 ++----------------- examples/fluid/hydrostatic_water_column_2d.jl | 4 +- 2 files changed, 5 insertions(+), 51 deletions(-) diff --git a/examples/fluid/accelerated_tank_2d.jl b/examples/fluid/accelerated_tank_2d.jl index a179a035c..d1d6dc9e6 100644 --- a/examples/fluid/accelerated_tank_2d.jl +++ b/examples/fluid/accelerated_tank_2d.jl @@ -4,30 +4,10 @@ using TrixiParticles using OrdinaryDiffEq -# ========================================================================================== -# ==== Resolution +# # ========================================================================================== +# # ==== Resolution fluid_particle_spacing = 0.05 -# Make sure that the kernel support of fluid particles at a boundary is always fully sampled -boundary_layers = 3 - -# ========================================================================================== -# ==== Experiment Setup -tspan = (0.0, 1.0) - -# Boundary geometry and initial fluid particle positions -initial_fluid_size = (1.0, 0.9) -tank_size = (1.0, 1.0) - -fluid_density = 1000.0 -sound_speed = 10.0 -state_equation = StateEquationCole(; sound_speed, reference_density=fluid_density, - exponent=7, clip_negative_pressure=false) - -tank = RectangularTank(fluid_particle_spacing, initial_fluid_size, tank_size, fluid_density, - acceleration=(0.0, -9.81), state_equation=state_equation, - n_layers=boundary_layers, spacing_ratio=1.0) - # Function for moving boundaries movement_function(t) = SVector(0.0, 0.5 * 9.81 * t^2) @@ -35,32 +15,6 @@ is_moving(t) = true boundary_movement = BoundaryMovement(movement_function, is_moving) -# Import the setup from `hydrostatic_water_column_2d.jl` trixi_include(@__MODULE__, joinpath(examples_dir(), "fluid", "hydrostatic_water_column_2d.jl"), - fluid_particle_spacing=fluid_particle_spacing, movement=boundary_movement, - acceleration=(0.0, 0.0), tank=tank, semi=nothing, ode=nothing, - sol=nothing) # Overwrite `sol` assignment to skip time integration - -# ========================================================================================== -# ==== Simulation -semi = Semidiscretization(fluid_system, boundary_system) -ode = semidiscretize(semi, tspan) - -info_callback = InfoCallback(interval=50) -saving_callback = SolutionSavingCallback(dt=0.02, prefix="") - -callbacks = CallbackSet(info_callback, saving_callback) - -# Use a Runge-Kutta method with automatic (error based) time step size control. -# Limiting of the maximum stepsize is necessary to prevent crashing. -# When particles are approaching a wall in a uniform way, they can be advanced -# with large time steps. Close to the wall, the stepsize has to be reduced drastically. -# Sometimes, the method fails to do so because forces become extremely large when -# fluid particles are very close to boundary particles, and the time integration method -# interprets this as an instability. -sol = solve(ode, RDPK3SpFSAL35(), - abstol=1e-5, # Default abstol is 1e-6 (may need to be tuned to prevent boundary penetration) - reltol=1e-3, # Default reltol is 1e-3 (may need to be tuned to prevent boundary penetration) - dtmax=1e-2, # Limit stepsize to prevent crashing - save_everystep=false, callback=callbacks); + fluid_particle_spacing=fluid_particle_spacing, movement=boundary_movement) diff --git a/examples/fluid/hydrostatic_water_column_2d.jl b/examples/fluid/hydrostatic_water_column_2d.jl index 098c06643..3ad587312 100644 --- a/examples/fluid/hydrostatic_water_column_2d.jl +++ b/examples/fluid/hydrostatic_water_column_2d.jl @@ -23,8 +23,8 @@ state_equation = StateEquationCole(; sound_speed, reference_density=fluid_densit exponent=7, clip_negative_pressure=false) tank = RectangularTank(fluid_particle_spacing, initial_fluid_size, tank_size, fluid_density, - n_layers=boundary_layers, - acceleration=(0.0, -gravity), state_equation=state_equation) + n_layers=boundary_layers, acceleration=(0.0, -gravity), + state_equation=state_equation) # ========================================================================================== # ==== Fluid From 499343328d7f21e8eaa5055d9ceaf57b30f0a0c7 Mon Sep 17 00:00:00 2001 From: Sven Berger Date: Wed, 7 Aug 2024 16:48:19 +0200 Subject: [PATCH 05/15] fix --- examples/fluid/accelerated_tank_2d.jl | 3 +- examples/fluid/dam_break_2d.jl | 2 + src/general/semidiscretization.jl | 32 +++- test/examples/examples.jl | 242 ++++++++++++++------------ 4 files changed, 162 insertions(+), 117 deletions(-) diff --git a/examples/fluid/accelerated_tank_2d.jl b/examples/fluid/accelerated_tank_2d.jl index d1d6dc9e6..9f64aacd5 100644 --- a/examples/fluid/accelerated_tank_2d.jl +++ b/examples/fluid/accelerated_tank_2d.jl @@ -4,8 +4,7 @@ using TrixiParticles using OrdinaryDiffEq -# # ========================================================================================== -# # ==== Resolution +# Resolution fluid_particle_spacing = 0.05 # Function for moving boundaries diff --git a/examples/fluid/dam_break_2d.jl b/examples/fluid/dam_break_2d.jl index 117dde772..d5cf7caaf 100644 --- a/examples/fluid/dam_break_2d.jl +++ b/examples/fluid/dam_break_2d.jl @@ -71,6 +71,8 @@ boundary_model = BoundaryModelDummyParticles(tank.boundary.density, tank.boundar boundary_density_calculator, smoothing_kernel, smoothing_length, correction=nothing) +# boundary_model = BoundaryModelMonaghanKajtar(gravity, spacing_ratio, boundary_particle_spacing, +# tank.boundary.mass) boundary_system = BoundarySPHSystem(tank.boundary, boundary_model, adhesion_coefficient=0.0) diff --git a/src/general/semidiscretization.jl b/src/general/semidiscretization.jl index 112131dc9..5b49e0092 100644 --- a/src/general/semidiscretization.jl +++ b/src/general/semidiscretization.jl @@ -715,19 +715,27 @@ function update_nhs!(neighborhood_search, points_moving=(true, neighbor.ismoving[])) end +# If declared as a union with the TotalLagrangianSPHSystem version will be ambiguous with another dispatch function update_nhs!(neighborhood_search, - system::BoundarySPHSystem, - neighbor::Union{FluidSystem, TotalLagrangianSPHSystem, - BoundarySPHSystem}, - u_system, u_neighbor) - # Don't update. This NHS is never used. - return neighborhood_search + system::BoundarySPHSystem{<:BoundaryModelDummyParticles}, + neighbor::FluidSystem, u_system, u_neighbor) + # Depending on the density calculator of the boundary model, this NHS is used for + # - kernel summation (`SummationDensity`) + # - continuity equation (`ContinuityDensity`) + # - pressure extrapolation (`AdamiPressureExtrapolation`) + # + # Boundary coordinates only change over time when `neighbor.ismoving[]`. + # The current coordinates of fluids and solids change over time. + update!(neighborhood_search, system, + current_coordinates(u_system, system), + current_coordinates(u_neighbor, neighbor), + points_moving=(system.ismoving[], true)) end +# If declared as a union with the FluidSystem version will be ambiguous with another dispatch function update_nhs!(neighborhood_search, system::BoundarySPHSystem{<:BoundaryModelDummyParticles}, - neighbor::Union{FluidSystem, TotalLagrangianSPHSystem}, - u_system, u_neighbor) + neighbor::TotalLagrangianSPHSystem, u_system, u_neighbor) # Depending on the density calculator of the boundary model, this NHS is used for # - kernel summation (`SummationDensity`) # - continuity equation (`ContinuityDensity`) @@ -773,6 +781,14 @@ function update_nhs!(neighborhood_search, points_moving=(true, false)) end +function update_nhs!(neighborhood_search, + system::BoundarySPHSystem, + neighbor::FluidSystem, + u_system, u_neighbor) + # Don't update. This NHS is never used. + return neighborhood_search +end + function update_nhs!(neighborhood_search, system::BoundaryDEMSystem, neighbor::Union{DEMSystem, BoundaryDEMSystem}, diff --git a/test/examples/examples.jl b/test/examples/examples.jl index 2917c6ed0..c18f2ae0b 100644 --- a/test/examples/examples.jl +++ b/test/examples/examples.jl @@ -2,50 +2,140 @@ # but without checking the correctness of the solution. @testset verbose=true "Examples" begin @testset verbose=true "Fluid" begin - @trixi_testset "fluid/hydrostatic_water_column_2d.jl" begin - hydrostatic_water_column_tests = Dict( + # @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), + # "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)) + + # @test_nowarn_mod trixi_include(@__MODULE__, + # joinpath(examples_dir(), "fluid", + # "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/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_3d.jl" begin + # @test_nowarn_mod trixi_include(@__MODULE__, + # joinpath(examples_dir(), "fluid", + # "hydrostatic_water_column_3d.jl"), + # tspan=(0.0, 0.1)) + # @test sol.retcode == ReturnCode.Success + # @test count_rhs_allocations(sol, semi) == 0 + # end + + # @trixi_testset "fluid/hydrostatic_water_column_3d.jl with SummationDensity" begin + # @test_nowarn_mod trixi_include(@__MODULE__, + # joinpath(examples_dir(), "fluid", + # "hydrostatic_water_column_3d.jl"), + # tspan=(0.0, 0.1), + # fluid_density_calculator=SummationDensity(), + # clip_negative_pressure=true) + # @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", + # "accelerated_tank_2d.jl")) + # @test sol.retcode == ReturnCode.Success + # @test count_rhs_allocations(sol, semi) == 0 + # end + + @trixi_testset "fluid/dam_break_2d.jl" begin + dam_break_tests = Dict( "default" => (), - "with source term damping" => (source_terms=SourceTermDamping(damping_coefficient=1e-4),), "with SummationDensity" => (fluid_density_calculator=SummationDensity(), clip_negative_pressure=true), - "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}()), + "with DensityDiffusionMolteniColagrossi" => (density_diffusion=DensityDiffusionMolteniColagrossi(delta=0.1),), + "no denisty diffusion" => (density_diffusion=nothing,), + "with KernelAbstractions" => (data_type=Array,), ) - for (test_description, kwargs) in hydrostatic_water_column_tests + for (test_description, kwargs) in dam_break_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...) + "dam_break_2d.jl"); + kwargs...) [ + 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 @@ -53,84 +143,21 @@ end end - @trixi_testset "fluid/hydrostatic_water_column_2d.jl with EDAC" begin + @trixi_testset "fluid/dam_break_2d.jl with BoundaryModelMonaghanKajtar" 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)) - - @test_nowarn_mod trixi_include(@__MODULE__, - joinpath(examples_dir(), "fluid", - "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/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_3d.jl" begin - @test_nowarn_mod trixi_include(@__MODULE__, - joinpath(examples_dir(), "fluid", - "hydrostatic_water_column_3d.jl"), - tspan=(0.0, 0.1)) - @test sol.retcode == ReturnCode.Success - @test count_rhs_allocations(sol, semi) == 0 - end - - @trixi_testset "fluid/hydrostatic_water_column_3d.jl with SummationDensity" begin - @test_nowarn_mod trixi_include(@__MODULE__, - joinpath(examples_dir(), "fluid", - "hydrostatic_water_column_3d.jl"), - tspan=(0.0, 0.1), - fluid_density_calculator=SummationDensity(), - clip_negative_pressure=true) - @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", - "accelerated_tank_2d.jl")) - @test sol.retcode == ReturnCode.Success - @test count_rhs_allocations(sol, semi) == 0 - end + trixi_include(@__MODULE__, joinpath(examples_dir(), "fluid", "dam_break_2d.jl"), + boundary_layers=1, spacing_ratio=3, sol=nothing, semi=nothing, + ode=nothing) - @trixi_testset "fluid/dam_break_2d.jl" begin - @test_nowarn_mod trixi_include(@__MODULE__, - joinpath(examples_dir(), "fluid", - "dam_break_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", - ] - @test sol.retcode == ReturnCode.Success - @test count_rhs_allocations(sol, semi) == 0 - end + boundary_model = BoundaryModelMonaghanKajtar(gravity, spacing_ratio, + boundary_particle_spacing, + tank.boundary.mass) - @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_2d.jl"), tspan=(0.0, 0.1), - data_type=Array) [ + "dam_break_2d.jl"), + tspan=(0.0, 0.1), boundary_model=boundary_model, + boundary_layers=1, spacing_ratio=3) [ r"┌ Info: The desired tank length in y-direction .*\n", r"└ New tank length in y-direction.*\n", ] @@ -148,7 +175,8 @@ "dam_break_2d.jl"), tspan=(0.0, 0.05), surface_tension=SurfaceTensionAkinci(surface_tension_coefficient=0.025), - fluid_particle_spacing=0.5 * fluid_particle_spacing, + fluid_particle_spacing=0.5 * + fluid_particle_spacing, smoothing_kernel=SchoenbergCubicSplineKernel{2}(), smoothing_length=0.5 * fluid_particle_spacing, correction=AkinciFreeSurfaceCorrection(fluid_density), From 4e4f7bf47cf9d49c93a51ad39de400dc85cc2487 Mon Sep 17 00:00:00 2001 From: Sven Berger Date: Wed, 7 Aug 2024 23:57:56 +0200 Subject: [PATCH 06/15] fix --- test/examples/examples.jl | 224 +++++++++++++++++++------------------- 1 file changed, 112 insertions(+), 112 deletions(-) diff --git a/test/examples/examples.jl b/test/examples/examples.jl index c18f2ae0b..7376b516f 100644 --- a/test/examples/examples.jl +++ b/test/examples/examples.jl @@ -2,117 +2,117 @@ # but without checking the correctness of the solution. @testset verbose=true "Examples" begin @testset verbose=true "Fluid" begin - # @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), - # "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)) - - # @test_nowarn_mod trixi_include(@__MODULE__, - # joinpath(examples_dir(), "fluid", - # "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/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_3d.jl" begin - # @test_nowarn_mod trixi_include(@__MODULE__, - # joinpath(examples_dir(), "fluid", - # "hydrostatic_water_column_3d.jl"), - # tspan=(0.0, 0.1)) - # @test sol.retcode == ReturnCode.Success - # @test count_rhs_allocations(sol, semi) == 0 - # end - - # @trixi_testset "fluid/hydrostatic_water_column_3d.jl with SummationDensity" begin - # @test_nowarn_mod trixi_include(@__MODULE__, - # joinpath(examples_dir(), "fluid", - # "hydrostatic_water_column_3d.jl"), - # tspan=(0.0, 0.1), - # fluid_density_calculator=SummationDensity(), - # clip_negative_pressure=true) - # @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", - # "accelerated_tank_2d.jl")) - # @test sol.retcode == ReturnCode.Success - # @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), + "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)) + + @test_nowarn_mod trixi_include(@__MODULE__, + joinpath(examples_dir(), "fluid", + "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/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_3d.jl" begin + @test_nowarn_mod trixi_include(@__MODULE__, + joinpath(examples_dir(), "fluid", + "hydrostatic_water_column_3d.jl"), + tspan=(0.0, 0.1)) + @test sol.retcode == ReturnCode.Success + @test count_rhs_allocations(sol, semi) == 0 + end + + @trixi_testset "fluid/hydrostatic_water_column_3d.jl with SummationDensity" begin + @test_nowarn_mod trixi_include(@__MODULE__, + joinpath(examples_dir(), "fluid", + "hydrostatic_water_column_3d.jl"), + tspan=(0.0, 0.1), + fluid_density_calculator=SummationDensity(), + clip_negative_pressure=true) + @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", + "accelerated_tank_2d.jl")) + @test sol.retcode == ReturnCode.Success + @test count_rhs_allocations(sol, semi) == 0 + end @trixi_testset "fluid/dam_break_2d.jl" begin dam_break_tests = Dict( @@ -120,7 +120,7 @@ "with SummationDensity" => (fluid_density_calculator=SummationDensity(), clip_negative_pressure=true), "with DensityDiffusionMolteniColagrossi" => (density_diffusion=DensityDiffusionMolteniColagrossi(delta=0.1),), - "no denisty diffusion" => (density_diffusion=nothing,), + "no density diffusion" => (density_diffusion=nothing,), "with KernelAbstractions" => (data_type=Array,), ) From c5d162d3a5134bc31a065ef9914fc50ed51b3a53 Mon Sep 17 00:00:00 2001 From: Sven Berger Date: Thu, 8 Aug 2024 00:01:00 +0200 Subject: [PATCH 07/15] fix --- examples/fluid/dam_break_2d.jl | 2 -- test/runtests.jl | 8 ++++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/examples/fluid/dam_break_2d.jl b/examples/fluid/dam_break_2d.jl index d5cf7caaf..117dde772 100644 --- a/examples/fluid/dam_break_2d.jl +++ b/examples/fluid/dam_break_2d.jl @@ -71,8 +71,6 @@ boundary_model = BoundaryModelDummyParticles(tank.boundary.density, tank.boundar boundary_density_calculator, smoothing_kernel, smoothing_length, correction=nothing) -# boundary_model = BoundaryModelMonaghanKajtar(gravity, spacing_ratio, boundary_particle_spacing, -# tank.boundary.mass) boundary_system = BoundarySPHSystem(tank.boundary, boundary_model, adhesion_coefficient=0.0) diff --git a/test/runtests.jl b/test/runtests.jl index d9461451f..9c732c77b 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -3,12 +3,12 @@ include("test_util.jl") const TRIXIPARTICLES_TEST = lowercase(get(ENV, "TRIXIPARTICLES_TEST", "all")) @testset "All Tests" verbose=true begin - # if TRIXIPARTICLES_TEST in ("all", "unit") - # # include("unittest.jl") - # end + if TRIXIPARTICLES_TEST in ("all", "unit") + include("unittest.jl") + end if TRIXIPARTICLES_TEST in ("all", "examples") include("examples/examples.jl") - # include("validation/validation.jl") + include("validation/validation.jl") end end; From 3778b05a5afdc39dd386f7c6355722b296b63400 Mon Sep 17 00:00:00 2001 From: Sven Berger Date: Thu, 8 Aug 2024 00:56:19 +0200 Subject: [PATCH 08/15] fix accelerated_tank --- examples/fluid/accelerated_tank_2d.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/fluid/accelerated_tank_2d.jl b/examples/fluid/accelerated_tank_2d.jl index 9f64aacd5..25d62e1c2 100644 --- a/examples/fluid/accelerated_tank_2d.jl +++ b/examples/fluid/accelerated_tank_2d.jl @@ -16,4 +16,5 @@ boundary_movement = BoundaryMovement(movement_function, is_moving) trixi_include(@__MODULE__, joinpath(examples_dir(), "fluid", "hydrostatic_water_column_2d.jl"), - fluid_particle_spacing=fluid_particle_spacing, movement=boundary_movement) + fluid_particle_spacing=fluid_particle_spacing, movement=boundary_movement, + tspan=(0.0, 1.0)) From 6ac02cda796e2b78b44e8afd3592805efc002a31 Mon Sep 17 00:00:00 2001 From: Sven Berger Date: Thu, 8 Aug 2024 00:57:50 +0200 Subject: [PATCH 09/15] reduce run time --- test/examples/examples.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/examples/examples.jl b/test/examples/examples.jl index 7376b516f..4499c4c10 100644 --- a/test/examples/examples.jl +++ b/test/examples/examples.jl @@ -132,7 +132,7 @@ @test_nowarn_mod trixi_include(@__MODULE__, joinpath(examples_dir(), "fluid", "dam_break_2d.jl"); - kwargs...) [ + tspan=(0, 0.1), kwargs...) [ r"┌ Info: The desired tank length in y-direction .*\n", r"└ New tank length in y-direction.*\n", ] From a756ef5efe83dec2d5b6f735d680418767966cf3 Mon Sep 17 00:00:00 2001 From: Sven Berger Date: Thu, 8 Aug 2024 09:19:29 +0200 Subject: [PATCH 10/15] run more tests for EDAC --- src/general/semidiscretization.jl | 4 +-- test/examples/examples.jl | 57 ++++++++++++++++++++++++++----- 2 files changed, 51 insertions(+), 10 deletions(-) diff --git a/src/general/semidiscretization.jl b/src/general/semidiscretization.jl index 5b49e0092..bd8d4563b 100644 --- a/src/general/semidiscretization.jl +++ b/src/general/semidiscretization.jl @@ -715,7 +715,7 @@ function update_nhs!(neighborhood_search, points_moving=(true, neighbor.ismoving[])) end -# If declared as a union with the TotalLagrangianSPHSystem version will be ambiguous with another dispatch +# If declared as a union with the `TotalLagrangianSPHSystem` version will be ambiguous with another dispatch function update_nhs!(neighborhood_search, system::BoundarySPHSystem{<:BoundaryModelDummyParticles}, neighbor::FluidSystem, u_system, u_neighbor) @@ -732,7 +732,7 @@ function update_nhs!(neighborhood_search, points_moving=(system.ismoving[], true)) end -# If declared as a union with the FluidSystem version will be ambiguous with another dispatch +# If declared as a union with the `FluidSystem` version will be ambiguous with another dispatch function update_nhs!(neighborhood_search, system::BoundarySPHSystem{<:BoundaryModelDummyParticles}, neighbor::TotalLagrangianSPHSystem, u_system, u_neighbor) diff --git a/test/examples/examples.jl b/test/examples/examples.jl index 4499c4c10..58be38490 100644 --- a/test/examples/examples.jl +++ b/test/examples/examples.jl @@ -2,7 +2,7 @@ # but without checking the correctness of the solution. @testset verbose=true "Examples" begin @testset verbose=true "Fluid" begin - @trixi_testset "fluid/hydrostatic_water_column_2d.jl" begin + @trixi_testset "fluid/hydrostatic_water_column_2d.jl (WCSPH) " begin hydrostatic_water_column_tests = Dict( "default" => (), "with source term damping" => (source_terms=SourceTermDamping(damping_coefficient=1e-4),), @@ -53,7 +53,7 @@ end end - @trixi_testset "fluid/hydrostatic_water_column_2d.jl with EDAC" begin + @trixi_testset "fluid/hydrostatic_water_column_2d.jl (EDAC) " begin # import variables into scope trixi_include(@__MODULE__, joinpath(examples_dir(), "fluid", @@ -67,13 +67,54 @@ density_calculator=ContinuityDensity(), acceleration=(0.0, -gravity)) - @test_nowarn_mod trixi_include(@__MODULE__, - joinpath(examples_dir(), "fluid", - "hydrostatic_water_column_2d.jl"); - fluid_system=fluid_system) + 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), + "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}()), + ) - @test sol.retcode == ReturnCode.Success - @test count_rhs_allocations(sol, semi) == 0 + 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"); + fluid_system=fluid_system, kwargs...) + + @test sol.retcode == ReturnCode.Success + @test count_rhs_allocations(sol, semi) == 0 + end + end end @trixi_testset "fluid/oscillating_drop_2d.jl" begin From b734f29d02ba31a323dc0f4d35b85bf23a8a6c82 Mon Sep 17 00:00:00 2001 From: Sven Berger Date: Thu, 8 Aug 2024 09:39:24 +0200 Subject: [PATCH 11/15] update --- test/examples/examples.jl | 163 +++++++++++++++++--------------------- 1 file changed, 72 insertions(+), 91 deletions(-) diff --git a/test/examples/examples.jl b/test/examples/examples.jl index 58be38490..844da6192 100644 --- a/test/examples/examples.jl +++ b/test/examples/examples.jl @@ -2,103 +2,84 @@ # but without checking the correctness of the solution. @testset verbose=true "Examples" begin @testset verbose=true "Fluid" begin - @trixi_testset "fluid/hydrostatic_water_column_2d.jl (WCSPH) " 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), - "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 (EDAC) " begin + @trixi_testset "fluid/hydrostatic_water_column_2d.jl" 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)) - 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), - "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}()), + "(WCSPH) default" => (), + "(WCSPH) with source term damping" => (source_terms=SourceTermDamping(damping_coefficient=1e-4),), + "(WCSPH) with SummationDensity" => (fluid_density_calculator=SummationDensity(), + clip_negative_pressure=true), + "(WCSPH) with ViscosityAdami" => ( + # from 0.02*10.0*1.2*0.05/8 + viscosity=ViscosityAdami(nu=0.0015),), + "(WCSPH) with ViscosityMorris" => ( + # from 0.02*10.0*1.2*0.05/8 + viscosity=ViscosityMorris(nu=0.0015),), + "(WCSPH) 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), + "(WCSPH) 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), + "(WCSPH) with smoothing_length=1.3" => (smoothing_length=1.3,), + "(WCSPH) with SchoenbergQuarticSplineKernel" => (smoothing_length=1.1, + smoothing_kernel=SchoenbergQuarticSplineKernel{2}()), + "(WCSPH) with SchoenbergQuinticSplineKernel" => (smoothing_length=1.1, + smoothing_kernel=SchoenbergQuinticSplineKernel{2}()), + "(WCSPH) with WendlandC2Kernel" => (smoothing_length=3.0, + smoothing_kernel=WendlandC2Kernel{2}()), + "(WCSPH) with WendlandC4Kernel" => (smoothing_length=3.5, + smoothing_kernel=WendlandC4Kernel{2}()), + "(WCSPH) with WendlandC6Kernel" => (smoothing_length=4.0, + smoothing_kernel=WendlandC6Kernel{2}()), + "(EDAC) with source term damping" => (source_terms=SourceTermDamping(damping_coefficient=1e-4), + fluid_system=EntropicallyDampedSPHSystem(tank.fluid, + smoothing_kernel, + smoothing_length, + sound_speed, + viscosity=viscosity, + density_calculator=ContinuityDensity(), + acceleration=(0.0, + -gravity))), + "(EDAC) with SummationDensity" => (fluid_system=EntropicallyDampedSPHSystem(tank.fluid, + smoothing_kernel, + smoothing_length, + sound_speed, + viscosity=viscosity, + density_calculator=SummationDensity(), + acceleration=(0.0, + -gravity)),), + "(EDAC) with ViscosityAdami" => ( + # from 0.02*10.0*1.2*0.05/8 + viscosity=ViscosityAdami(nu=0.0015), + fluid_system=EntropicallyDampedSPHSystem(tank.fluid, + smoothing_kernel, + smoothing_length, + sound_speed, + viscosity=viscosity, + density_calculator=SummationDensity(), + acceleration=(0.0, + -gravity))), + "(EDAC) with ViscosityMorris" => ( + # from 0.02*10.0*1.2*0.05/8 + viscosity=ViscosityMorris(nu=0.0015), + fluid_system=EntropicallyDampedSPHSystem(tank.fluid, + smoothing_kernel, + smoothing_length, + sound_speed, + viscosity=viscosity, + density_calculator=SummationDensity(), + acceleration=(0.0, + -gravity))), ) for (test_description, kwargs) in hydrostatic_water_column_tests @@ -109,7 +90,7 @@ @test_nowarn_mod trixi_include(@__MODULE__, joinpath(examples_dir(), "fluid", "hydrostatic_water_column_2d.jl"); - fluid_system=fluid_system, kwargs...) + kwargs...) @test sol.retcode == ReturnCode.Success @test count_rhs_allocations(sol, semi) == 0 From 3d1050d27b7d71ec33e22f99fa4f8faa13a6f99b Mon Sep 17 00:00:00 2001 From: Sven Berger Date: Thu, 8 Aug 2024 10:08:34 +0200 Subject: [PATCH 12/15] fix edac tests --- test/examples/examples.jl | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/test/examples/examples.jl b/test/examples/examples.jl index 844da6192..1b2bbf869 100644 --- a/test/examples/examples.jl +++ b/test/examples/examples.jl @@ -49,7 +49,7 @@ viscosity=viscosity, density_calculator=ContinuityDensity(), acceleration=(0.0, - -gravity))), + -gravity)),), "(EDAC) with SummationDensity" => (fluid_system=EntropicallyDampedSPHSystem(tank.fluid, smoothing_kernel, smoothing_length, @@ -58,28 +58,22 @@ density_calculator=SummationDensity(), acceleration=(0.0, -gravity)),), - "(EDAC) with ViscosityAdami" => ( - # from 0.02*10.0*1.2*0.05/8 - viscosity=ViscosityAdami(nu=0.0015), - fluid_system=EntropicallyDampedSPHSystem(tank.fluid, + "(EDAC) with ViscosityAdami" => (fluid_system=EntropicallyDampedSPHSystem(tank.fluid, smoothing_kernel, smoothing_length, sound_speed, - viscosity=viscosity, - density_calculator=SummationDensity(), + viscosity=ViscosityAdami(nu=0.0015), + density_calculator=ContinuityDensity(), acceleration=(0.0, - -gravity))), - "(EDAC) with ViscosityMorris" => ( - # from 0.02*10.0*1.2*0.05/8 - viscosity=ViscosityMorris(nu=0.0015), - fluid_system=EntropicallyDampedSPHSystem(tank.fluid, + -gravity)),), + "(EDAC) with ViscosityMorris" => (fluid_system=EntropicallyDampedSPHSystem(tank.fluid, smoothing_kernel, smoothing_length, sound_speed, - viscosity=viscosity, - density_calculator=SummationDensity(), + viscosity=ViscosityMorris(nu=0.0015), + density_calculator=ContinuityDensity(), acceleration=(0.0, - -gravity))), + -gravity)),), ) for (test_description, kwargs) in hydrostatic_water_column_tests From c21168f35f7115f104dba652df1f8d0c96124f3a Mon Sep 17 00:00:00 2001 From: Sven Berger Date: Thu, 8 Aug 2024 10:17:08 +0200 Subject: [PATCH 13/15] format --- test/examples/examples.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/examples/examples.jl b/test/examples/examples.jl index 1b2bbf869..481d0c849 100644 --- a/test/examples/examples.jl +++ b/test/examples/examples.jl @@ -49,7 +49,7 @@ viscosity=viscosity, density_calculator=ContinuityDensity(), acceleration=(0.0, - -gravity)),), + -gravity))), "(EDAC) with SummationDensity" => (fluid_system=EntropicallyDampedSPHSystem(tank.fluid, smoothing_kernel, smoothing_length, From d6c316d81b353d454d101b22fbc77480845844d0 Mon Sep 17 00:00:00 2001 From: Sven Berger Date: Fri, 9 Aug 2024 16:21:35 +0200 Subject: [PATCH 14/15] combine them --- examples/fluid/accelerated_tank_2d.jl | 2 +- examples/fluid/hydrostatic_water_column_2d.jl | 5 +- src/general/semidiscretization.jl | 4 +- test/examples/examples.jl | 232 ++++++++++-------- 4 files changed, 133 insertions(+), 110 deletions(-) diff --git a/examples/fluid/accelerated_tank_2d.jl b/examples/fluid/accelerated_tank_2d.jl index 25d62e1c2..efaf91cd4 100644 --- a/examples/fluid/accelerated_tank_2d.jl +++ b/examples/fluid/accelerated_tank_2d.jl @@ -17,4 +17,4 @@ boundary_movement = BoundaryMovement(movement_function, is_moving) trixi_include(@__MODULE__, joinpath(examples_dir(), "fluid", "hydrostatic_water_column_2d.jl"), fluid_particle_spacing=fluid_particle_spacing, movement=boundary_movement, - tspan=(0.0, 1.0)) + tspan=(0.0, 1.0), system_acceleration=(0.0, 0.0)) diff --git a/examples/fluid/hydrostatic_water_column_2d.jl b/examples/fluid/hydrostatic_water_column_2d.jl index 3ad587312..86d392c5b 100644 --- a/examples/fluid/hydrostatic_water_column_2d.jl +++ b/examples/fluid/hydrostatic_water_column_2d.jl @@ -35,10 +35,13 @@ alpha = 0.02 viscosity = ArtificialViscosityMonaghan(alpha=alpha, beta=0.0) fluid_density_calculator = ContinuityDensity() + +# This is to set acceleration with `trixi_include` +system_acceleration = (0.0, -gravity) fluid_system = WeaklyCompressibleSPHSystem(tank.fluid, fluid_density_calculator, state_equation, smoothing_kernel, smoothing_length, viscosity=viscosity, - acceleration=(0.0, -gravity), + acceleration=system_acceleration, source_terms=nothing) # ========================================================================================== diff --git a/src/general/semidiscretization.jl b/src/general/semidiscretization.jl index bd8d4563b..600d573d5 100644 --- a/src/general/semidiscretization.jl +++ b/src/general/semidiscretization.jl @@ -715,7 +715,7 @@ function update_nhs!(neighborhood_search, points_moving=(true, neighbor.ismoving[])) end -# If declared as a union with the `TotalLagrangianSPHSystem` version will be ambiguous with another dispatch +# This function is the same as the one below to avoid ambiguous dispatch when using `Union` function update_nhs!(neighborhood_search, system::BoundarySPHSystem{<:BoundaryModelDummyParticles}, neighbor::FluidSystem, u_system, u_neighbor) @@ -732,7 +732,7 @@ function update_nhs!(neighborhood_search, points_moving=(system.ismoving[], true)) end -# If declared as a union with the `FluidSystem` version will be ambiguous with another dispatch +# This function is the same as the one above to avoid ambiguous dispatch when using `Union` function update_nhs!(neighborhood_search, system::BoundarySPHSystem{<:BoundaryModelDummyParticles}, neighbor::TotalLagrangianSPHSystem, u_system, u_neighbor) diff --git a/test/examples/examples.jl b/test/examples/examples.jl index 481d0c849..02551c848 100644 --- a/test/examples/examples.jl +++ b/test/examples/examples.jl @@ -3,77 +3,77 @@ @testset verbose=true "Examples" begin @testset verbose=true "Fluid" begin @trixi_testset "fluid/hydrostatic_water_column_2d.jl" begin - # import variables into scope + # 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) hydrostatic_water_column_tests = Dict( - "(WCSPH) default" => (), - "(WCSPH) with source term damping" => (source_terms=SourceTermDamping(damping_coefficient=1e-4),), - "(WCSPH) with SummationDensity" => (fluid_density_calculator=SummationDensity(), - clip_negative_pressure=true), - "(WCSPH) with ViscosityAdami" => ( - # from 0.02*10.0*1.2*0.05/8 - viscosity=ViscosityAdami(nu=0.0015),), - "(WCSPH) with ViscosityMorris" => ( - # from 0.02*10.0*1.2*0.05/8 - viscosity=ViscosityMorris(nu=0.0015),), - "(WCSPH) 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), - "(WCSPH) 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), - "(WCSPH) with smoothing_length=1.3" => (smoothing_length=1.3,), - "(WCSPH) with SchoenbergQuarticSplineKernel" => (smoothing_length=1.1, - smoothing_kernel=SchoenbergQuarticSplineKernel{2}()), - "(WCSPH) with SchoenbergQuinticSplineKernel" => (smoothing_length=1.1, - smoothing_kernel=SchoenbergQuinticSplineKernel{2}()), - "(WCSPH) with WendlandC2Kernel" => (smoothing_length=3.0, - smoothing_kernel=WendlandC2Kernel{2}()), - "(WCSPH) with WendlandC4Kernel" => (smoothing_length=3.5, - smoothing_kernel=WendlandC4Kernel{2}()), - "(WCSPH) with WendlandC6Kernel" => (smoothing_length=4.0, - smoothing_kernel=WendlandC6Kernel{2}()), - "(EDAC) with source term damping" => (source_terms=SourceTermDamping(damping_coefficient=1e-4), - fluid_system=EntropicallyDampedSPHSystem(tank.fluid, - smoothing_kernel, - smoothing_length, - sound_speed, - viscosity=viscosity, - density_calculator=ContinuityDensity(), - acceleration=(0.0, - -gravity))), - "(EDAC) with SummationDensity" => (fluid_system=EntropicallyDampedSPHSystem(tank.fluid, - smoothing_kernel, - smoothing_length, - sound_speed, - viscosity=viscosity, - density_calculator=SummationDensity(), - acceleration=(0.0, - -gravity)),), - "(EDAC) with ViscosityAdami" => (fluid_system=EntropicallyDampedSPHSystem(tank.fluid, + "WCSPH default" => (), + "WCSPH with source term damping" => (source_terms=SourceTermDamping(damping_coefficient=1e-4),), + "WCSPH with SummationDensity" => (fluid_density_calculator=SummationDensity(), + clip_negative_pressure=true), + "WCSPH with ViscosityAdami" => ( + # from 0.02*10.0*1.2*0.05/8 + viscosity=ViscosityAdami(nu=0.0015),), + "WCSPH with ViscosityMorris" => ( + # from 0.02*10.0*1.2*0.05/8 + viscosity=ViscosityMorris(nu=0.0015),), + "WCSPH 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), + "WCSPH 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), + "WCSPH with smoothing_length=1.3" => (smoothing_length=1.3,), + "WCSPH with SchoenbergQuarticSplineKernel" => (smoothing_length=1.1, + smoothing_kernel=SchoenbergQuarticSplineKernel{2}()), + "WCSPH with SchoenbergQuinticSplineKernel" => (smoothing_length=1.1, + smoothing_kernel=SchoenbergQuinticSplineKernel{2}()), + "WCSPH with WendlandC2Kernel" => (smoothing_length=3.0, + smoothing_kernel=WendlandC2Kernel{2}()), + "WCSPH with WendlandC4Kernel" => (smoothing_length=3.5, + smoothing_kernel=WendlandC4Kernel{2}()), + "WCSPH with WendlandC6Kernel" => (smoothing_length=4.0, + smoothing_kernel=WendlandC6Kernel{2}()), + "EDAC with source term damping" => (source_terms=SourceTermDamping(damping_coefficient=1e-4), + fluid_system=EntropicallyDampedSPHSystem(tank.fluid, + smoothing_kernel, + smoothing_length, + sound_speed, + viscosity=viscosity, + density_calculator=ContinuityDensity(), + acceleration=(0.0, + -gravity))), + "EDAC with SummationDensity" => (fluid_system=EntropicallyDampedSPHSystem(tank.fluid, smoothing_kernel, smoothing_length, sound_speed, - viscosity=ViscosityAdami(nu=0.0015), - density_calculator=ContinuityDensity(), + viscosity=viscosity, + density_calculator=SummationDensity(), acceleration=(0.0, -gravity)),), - "(EDAC) with ViscosityMorris" => (fluid_system=EntropicallyDampedSPHSystem(tank.fluid, - smoothing_kernel, - smoothing_length, - sound_speed, - viscosity=ViscosityMorris(nu=0.0015), - density_calculator=ContinuityDensity(), - acceleration=(0.0, - -gravity)),), + "EDAC with ViscosityAdami" => (fluid_system=EntropicallyDampedSPHSystem(tank.fluid, + smoothing_kernel, + smoothing_length, + sound_speed, + viscosity=ViscosityAdami(nu=0.0015), + density_calculator=ContinuityDensity(), + acceleration=(0.0, + -gravity)),), + "EDAC with ViscosityMorris" => (fluid_system=EntropicallyDampedSPHSystem(tank.fluid, + smoothing_kernel, + smoothing_length, + sound_speed, + viscosity=ViscosityMorris(nu=0.0015), + density_calculator=ContinuityDensity(), + acceleration=(0.0, + -gravity)),), ) for (test_description, kwargs) in hydrostatic_water_column_tests @@ -131,6 +131,11 @@ end @trixi_testset "fluid/dam_break_2d.jl" begin + # Import variables into scope + trixi_include(@__MODULE__, joinpath(examples_dir(), "fluid", "dam_break_2d.jl"), + boundary_layers=1, spacing_ratio=3, sol=nothing, semi=nothing, + ode=nothing) + dam_break_tests = Dict( "default" => (), "with SummationDensity" => (fluid_density_calculator=SummationDensity(), @@ -138,6 +143,21 @@ "with DensityDiffusionMolteniColagrossi" => (density_diffusion=DensityDiffusionMolteniColagrossi(delta=0.1),), "no density diffusion" => (density_diffusion=nothing,), "with KernelAbstractions" => (data_type=Array,), + "with BoundaryModelMonaghanKajtar" => (boundary_model=BoundaryModelMonaghanKajtar(gravity, + spacing_ratio, + boundary_particle_spacing, + tank.boundary.mass), + boundary_layers=1, spacing_ratio=3), + "with SurfaceTensionAkinci" => (surface_tension=SurfaceTensionAkinci(surface_tension_coefficient=0.025), + fluid_particle_spacing=0.5 * + fluid_particle_spacing, + smoothing_kernel=SchoenbergCubicSplineKernel{2}(), + smoothing_length=0.5 * + fluid_particle_spacing, + correction=AkinciFreeSurfaceCorrection(fluid_density), + density_diffusion=nothing, + adhesion_coefficient=0.05, + sound_speed=100.0), ) for (test_description, kwargs) in dam_break_tests @@ -159,52 +179,52 @@ end end - @trixi_testset "fluid/dam_break_2d.jl with BoundaryModelMonaghanKajtar" begin - # import variables into scope - trixi_include(@__MODULE__, joinpath(examples_dir(), "fluid", "dam_break_2d.jl"), - boundary_layers=1, spacing_ratio=3, sol=nothing, semi=nothing, - ode=nothing) - - boundary_model = BoundaryModelMonaghanKajtar(gravity, spacing_ratio, - boundary_particle_spacing, - tank.boundary.mass) - - @test_nowarn_mod trixi_include(@__MODULE__, - joinpath(examples_dir(), "fluid", - "dam_break_2d.jl"), - tspan=(0.0, 0.1), boundary_model=boundary_model, - boundary_layers=1, spacing_ratio=3) [ - 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 SurfaceTensionAkinci" begin - # import variables into scope - trixi_include(@__MODULE__, joinpath(examples_dir(), "fluid", "dam_break_2d.jl"), - sol=nothing, semi=nothing, ode=nothing) - - @test_nowarn_mod trixi_include(@__MODULE__, - joinpath(examples_dir(), "fluid", - "dam_break_2d.jl"), - tspan=(0.0, 0.05), - surface_tension=SurfaceTensionAkinci(surface_tension_coefficient=0.025), - fluid_particle_spacing=0.5 * - fluid_particle_spacing, - smoothing_kernel=SchoenbergCubicSplineKernel{2}(), - smoothing_length=0.5 * fluid_particle_spacing, - correction=AkinciFreeSurfaceCorrection(fluid_density), - density_diffusion=nothing, - adhesion_coefficient=0.05, - sound_speed=100.0) [ - 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 BoundaryModelMonaghanKajtar" begin + # # import variables into scope + # trixi_include(@__MODULE__, joinpath(examples_dir(), "fluid", "dam_break_2d.jl"), + # boundary_layers=1, spacing_ratio=3, sol=nothing, semi=nothing, + # ode=nothing) + + # boundary_model = BoundaryModelMonaghanKajtar(gravity, spacing_ratio, + # boundary_particle_spacing, + # tank.boundary.mass) + + # @test_nowarn_mod trixi_include(@__MODULE__, + # joinpath(examples_dir(), "fluid", + # "dam_break_2d.jl"), + # tspan=(0.0, 0.1), boundary_model=boundary_model, + # boundary_layers=1, spacing_ratio=3) [ + # 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 SurfaceTensionAkinci" begin + # # import variables into scope + # trixi_include(@__MODULE__, joinpath(examples_dir(), "fluid", "dam_break_2d.jl"), + # sol=nothing, semi=nothing, ode=nothing) + + # @test_nowarn_mod trixi_include(@__MODULE__, + # joinpath(examples_dir(), "fluid", + # "dam_break_2d.jl"), + # tspan=(0.0, 0.05), + # surface_tension=SurfaceTensionAkinci(surface_tension_coefficient=0.025), + # fluid_particle_spacing=0.5 * + # fluid_particle_spacing, + # smoothing_kernel=SchoenbergCubicSplineKernel{2}(), + # smoothing_length=0.5 * fluid_particle_spacing, + # correction=AkinciFreeSurfaceCorrection(fluid_density), + # density_diffusion=nothing, + # adhesion_coefficient=0.05, + # sound_speed=100.0) [ + # 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_oil_film_2d.jl" begin @test_nowarn_mod trixi_include(@__MODULE__, From d91177c7b954d753ad163fabeac5ea555f815d81 Mon Sep 17 00:00:00 2001 From: Sven Berger Date: Fri, 9 Aug 2024 17:16:59 +0200 Subject: [PATCH 15/15] cleanup --- test/examples/examples.jl | 47 --------------------------------------- 1 file changed, 47 deletions(-) diff --git a/test/examples/examples.jl b/test/examples/examples.jl index 02551c848..c962b5912 100644 --- a/test/examples/examples.jl +++ b/test/examples/examples.jl @@ -179,53 +179,6 @@ end end - # @trixi_testset "fluid/dam_break_2d.jl with BoundaryModelMonaghanKajtar" begin - # # import variables into scope - # trixi_include(@__MODULE__, joinpath(examples_dir(), "fluid", "dam_break_2d.jl"), - # boundary_layers=1, spacing_ratio=3, sol=nothing, semi=nothing, - # ode=nothing) - - # boundary_model = BoundaryModelMonaghanKajtar(gravity, spacing_ratio, - # boundary_particle_spacing, - # tank.boundary.mass) - - # @test_nowarn_mod trixi_include(@__MODULE__, - # joinpath(examples_dir(), "fluid", - # "dam_break_2d.jl"), - # tspan=(0.0, 0.1), boundary_model=boundary_model, - # boundary_layers=1, spacing_ratio=3) [ - # 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 SurfaceTensionAkinci" begin - # # import variables into scope - # trixi_include(@__MODULE__, joinpath(examples_dir(), "fluid", "dam_break_2d.jl"), - # sol=nothing, semi=nothing, ode=nothing) - - # @test_nowarn_mod trixi_include(@__MODULE__, - # joinpath(examples_dir(), "fluid", - # "dam_break_2d.jl"), - # tspan=(0.0, 0.05), - # surface_tension=SurfaceTensionAkinci(surface_tension_coefficient=0.025), - # fluid_particle_spacing=0.5 * - # fluid_particle_spacing, - # smoothing_kernel=SchoenbergCubicSplineKernel{2}(), - # smoothing_length=0.5 * fluid_particle_spacing, - # correction=AkinciFreeSurfaceCorrection(fluid_density), - # density_diffusion=nothing, - # adhesion_coefficient=0.05, - # sound_speed=100.0) [ - # 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_oil_film_2d.jl" begin @test_nowarn_mod trixi_include(@__MODULE__, joinpath(examples_dir(), "fluid",