Skip to content

Commit

Permalink
Add system tests (smoke tests for now) (#47)
Browse files Browse the repository at this point in the history
* Fix out-of-bounds error when the velocity of a fixed solid particle was accessed

* Add system tests

Co-authored-by: LasNikas <[email protected]>
  • Loading branch information
efaulhaber and LasNikas authored Jan 11, 2023
1 parent 841b27f commit a1fcef1
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 7 deletions.
4 changes: 2 additions & 2 deletions examples/fsi/dam_break_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions examples/fsi/dam_break_gate_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 3 additions & 5 deletions examples/fsi/falling_water_column_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions src/containers/solid_container.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ using LinearAlgebra

include("containers/solid_container.jl")
include("interactions/solid.jl")
include("system_tests.jl")
43 changes: 43 additions & 0 deletions test/system_tests.jl
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit a1fcef1

Please sign in to comment.