diff --git a/examples/fsi/dam_break_2d.jl b/examples/fsi/dam_break_2d.jl index 1ed161d10..5fc2dccd0 100644 --- a/examples/fsi/dam_break_2d.jl +++ b/examples/fsi/dam_break_2d.jl @@ -94,8 +94,8 @@ solid_container = SolidParticleContainer(particle_coordinates, particle_velociti # Relaxing of the fluid without solid semi = Semidiscretization(particle_container, boundary_container, neighborhood_search=SpatialHashingSearch) -tspan = (0.0, 3.0) -ode = semidiscretize(semi, tspan) +tspan_relaxing = (0.0, 3.0) +ode = semidiscretize(semi, tspan_relaxing) summary_callback = SummaryCallback() alive_callback = AliveCallback(alive_interval=100) diff --git a/examples/fsi/dam_break_gate_2d.jl b/examples/fsi/dam_break_gate_2d.jl index 27fee0b35..12b058135 100644 --- a/examples/fsi/dam_break_gate_2d.jl +++ b/examples/fsi/dam_break_gate_2d.jl @@ -8,6 +8,8 @@ using Pixie using OrdinaryDiffEq +# Note that the effect of the gate becomes is less pronounced with lower resolutions, +# since "larger" particles don't fit through the slightly opened gate. fluid_particle_spacing = 0.02 # Ratio of fluid particle spacing to boundary particle spacing beta = 3 diff --git a/examples/fsi/falling_water_column_2d.jl b/examples/fsi/falling_water_column_2d.jl index 13b75b86d..4f5ab5653 100644 --- a/examples/fsi/falling_water_column_2d.jl +++ b/examples/fsi/falling_water_column_2d.jl @@ -2,17 +2,15 @@ using Pixie using OrdinaryDiffEq fluid_particle_spacing = 0.0125 * 3 -# Ratio of fluid particle spacing to boundary particle spacing -beta = 3 -water_width = 0.5 -water_height = 1.0 +water_width = 0.525 +water_height = 1.0125 water_density = 1000.0 container_width = 4.0 container_height = 2.0 -setup = RectangularTank(fluid_particle_spacing, beta, water_width, water_height, +setup = RectangularTank(fluid_particle_spacing, 3, water_width, water_height, container_width, container_height, water_density) # Move water column diff --git a/src/containers/solid_container.jl b/src/containers/solid_container.jl index 7ad91deab..9d222032b 100644 --- a/src/containers/solid_container.jl +++ b/src/containers/solid_container.jl @@ -185,6 +185,15 @@ end end +@inline function get_particle_vel(particle, u, container::SolidParticleContainer) + if particle > n_moving_particles(container) + return SVector(ntuple(_ -> 0.0, Val(ndims(container)))) + end + + return SVector(ntuple(@inline(dim -> u[dim + ndims(container), particle]), Val(ndims(container)))) +end + + @inline get_correction_matrix(particle, container) = extract_smatrix(container.correction_matrix, particle, container) @inline get_deformation_gradient(particle, container) = extract_smatrix(container.deformation_grad, particle, container) @inline get_pk1_corrected(particle, container) = extract_smatrix(container.pk1_corrected, particle, container) diff --git a/test/Project.toml b/test/Project.toml index a2cd2f8d8..65f8dccaf 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -1,3 +1,4 @@ [deps] LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" +OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" diff --git a/test/runtests.jl b/test/runtests.jl index 3b40fcf3c..181cdf665 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -4,3 +4,4 @@ using LinearAlgebra include("containers/solid_container.jl") include("interactions/solid.jl") +include("system_tests.jl") diff --git a/test/system_tests.jl b/test/system_tests.jl new file mode 100644 index 000000000..554175b27 --- /dev/null +++ b/test/system_tests.jl @@ -0,0 +1,43 @@ +# Smoke tests, i.e., tests to verify that examples are running without crashing, +# but without checking the correctness of the solution. +@testset "System Tests" begin + @testset "Fluid" begin + @test_nowarn pixie_include(joinpath(examples_dir(), "fluid", "rectangular_tank_2d.jl"), tspan=(0.0, 0.1)) + @test sol.retcode == ReturnCode.Success + + @test_nowarn pixie_include(joinpath(examples_dir(), "fluid", "dam_break_2d.jl"), tspan=(0.0, 0.1)) + @test sol.retcode == ReturnCode.Success + + @test_nowarn pixie_include(joinpath(examples_dir(), "fluid", "dam_break_3d.jl"), tspan=(0.0, 0.1)) + @test sol.retcode == ReturnCode.Success + + @test_nowarn pixie_include(joinpath(examples_dir(), "fluid", "falling_water_column_2d.jl"), tspan=(0.0, 0.4)) + @test sol.retcode == ReturnCode.Success + end + + @testset "Solid" begin + @test_nowarn pixie_include(joinpath(examples_dir(), "solid", "oscillating_beam_2d.jl"), tspan=(0.0, 0.1)) + @test sol.retcode == ReturnCode.Success + end + + @testset "FSI" begin + @test_nowarn pixie_include(joinpath(examples_dir(), "fsi", "falling_water_column_2d.jl"), tspan=(0.0, 0.4)) + @test sol.retcode == ReturnCode.Success + + # Use rounded dimensions to avoid warnings + @test_nowarn pixie_include(joinpath(examples_dir(), "fsi", "dam_break_2d.jl"), + water_width=0.15, + water_height=0.29, + container_width=0.58, + tspan_relaxing=(0.0, 2.0), + tspan=(0.0, 0.4), + dtmax=1e-3) + @test sol.retcode == ReturnCode.Success + + @test_nowarn pixie_include(joinpath(examples_dir(), "fsi", "dam_break_gate_2d.jl"), + tspan_relaxing=(0.0, 2.0), + tspan=(0.0, 0.4), + dtmax=1e-3) + @test sol.retcode == ReturnCode.Success + end +end