Skip to content
Open
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
9 changes: 5 additions & 4 deletions src/setups/rectangular_tank.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
10 changes: 10 additions & 0 deletions test/setups/rectangular_tank.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading