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__,