commit 66c6d64d02ab1b6e1126f8533382f22e96ac3b85
parent 5c6adb1e8c835eafaaa67d10dcd96132fb920c33
Author: Anders Damsgaard <andersd@riseup.net>
Date: Wed, 22 Nov 2017 08:56:36 -0500
do not protrude outside grid during findEmptyPositionInGridCell
Diffstat:
1 file changed, 11 insertions(+), 0 deletions(-)
diff --git a/src/grid.jl b/src/grid.jl
@@ -559,6 +559,17 @@ function findEmptyPositionInGridCell(simulation::Simulation,
info("trying poisition $pos in cell $i,$j")
end
+ # do not penetrate outside of grid boundaries
+ if i == 1 && pos[1] - r < grid.xq[1,1]
+ continue
+ elseif i == nx && pos[1] + r > grid.xq[end,end]
+ continue
+ elseif j == 1 && pos[2] - r < grid.yq[1,1]
+ continue
+ elseif j == nx && pos[2] + r > grid.yq[end,end]
+ continue
+ end
+
# search for contacts in current and eight neighboring cells
for i_neighbor_corr=[0 -1 1]
for j_neighbor_corr=[0 -1 1]