commit 5e33f9737e5908bfdacf969015e884d4fbe45d3e
parent 9f95ef0e27e951353b7bdc87e100391de0971c3a
Author: Anders Damsgaard <andersd@riseup.net>
Date: Wed, 20 Dec 2017 14:42:09 -0500
Fix grid-index correction
Diffstat:
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/contact_search.jl b/src/contact_search.jl
@@ -124,14 +124,9 @@ function findContactsInGrid!(simulation::Simulation, grid::Any)
for i=(grid_pos[1] - 1):(grid_pos[1] + 1)
for j=(grid_pos[2] - 1):(grid_pos[2] + 1)
- # i and j are not corrected for periodic boundaries
- i_corrected = i
- j_corrected = j
-
# correct indexes if necessary
- periodicBoundaryCorrection!(grid, i, j,
- i_corrected, j_corrected,
- distance_modifier)
+ i_corrected, j_corrected = periodicBoundaryCorrection!(grid,
+ i, j, distance_modifier)
# skip iteration if target still falls outside grid after
# periodicity correction
@@ -159,13 +154,16 @@ Determine the geometric correction and grid-index adjustment required across
periodic boundaries.
"""
function periodicBoundaryCorrection!(grid::Any, i::Integer, j::Integer,
- i_corrected::Integer, j_corrected::Integer,
distance_modifier::Vector{Float64})
# vector for correcting inter-particle distance in case of
# boundary periodicity
distance_modifier .= [0., 0.]
+ # i and j are not corrected for periodic boundaries
+ i_corrected = i
+ j_corrected = j
+
# only check for contacts within grid boundaries, and wrap
# around if they are periodic
if i < 1 || i > size(grid.xh)[1] || j < 1 || j > size(grid.xh)[2]
@@ -186,6 +184,8 @@ function periodicBoundaryCorrection!(grid::Any, i::Integer, j::Integer,
j_corrected = 1
end
end
+
+ return i_corrected, j_corrected
end
export checkAndAddContact!