diff --git a/src/setups/rectangular_tank.jl b/src/setups/rectangular_tank.jl index 2b59bbc8b0..52cc5a01e5 100644 --- a/src/setups/rectangular_tank.jl +++ b/src/setups/rectangular_tank.jl @@ -737,6 +737,7 @@ The selected walls of the tank will be placed at the new positions. """ function reset_wall!(rectangular_tank, reset_faces, positions) (; boundary, particle_spacing, spacing_ratio, n_layers, face_indices) = rectangular_tank + boundary_spacing = particle_spacing / spacing_ratio for face in eachindex(reset_faces) dim = div(face - 1, 2) + 1 @@ -749,17 +750,17 @@ function reset_wall!(rectangular_tank, reset_faces, positions) # For "odd" faces the layer direction is outwards # and for "even" faces inwards. layer_shift = if iseven(face) - (layer - 1) * particle_spacing / spacing_ratio + (layer - 1) * boundary_spacing else - # Odd faces need to be shifted outwards by `particle_spacing` + # Odd faces need to be shifted outwards by `boundary_spacing` # to be outside of the fluid. - -(layer - 1) * particle_spacing / spacing_ratio - particle_spacing + -(layer - 1) * boundary_spacing - boundary_spacing end # Set position boundary.coordinates[dim, particle] = positions[face] + layer_shift + - 0.5particle_spacing + 0.5boundary_spacing end end end diff --git a/test/setups/rectangular_tank.jl b/test/setups/rectangular_tank.jl index c8dc286013..1a1fc88508 100644 --- a/test/setups/rectangular_tank.jl +++ b/test/setups/rectangular_tank.jl @@ -89,6 +89,16 @@ @test isapprox(tank.boundary.coordinates, expected_coordinates[i]) end + + @testset "Spacing Ratio" begin + tank = RectangularTank(0.1, (0.2, 0.2), (0.3, 0.3), water_density, + spacing_ratio=3) + expected_coordinates = copy(tank.boundary.coordinates) + + reset_wall!(tank, (true, true, true, true), (0.0, 0.3, 0.0, 0.3)) + + @test isapprox(tank.boundary.coordinates, expected_coordinates) + end end @testset "Info and Error" begin