Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add system tests (smoke tests for now) #47

Merged
merged 4 commits into from
Jan 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is wrong with having beta?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't actually use the boundaries from the setup here, only the water column. This will be replaced with #42 anyway.

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
LasNikas marked this conversation as resolved.
Show resolved Hide resolved

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"
LasNikas marked this conversation as resolved.
Show resolved Hide resolved
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