Granular.jl

Julia package for granular dynamics simulation
git clone git://src.adamsgaard.dk/Granular.jl
Log | Files | Refs | README | LICENSE

commit 5cebc5a55305db76a39653bd446f2972b401f63c
parent 1935a43410af86f80c260b1aa67c1c538fede904
Author: Anders Damsgaard <andersd@riseup.net>
Date:   Mon, 15 Jan 2018 11:14:03 -0500

Improve handling of grains when outside of grid

Diffstat:
Msrc/grid.jl | 9++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/grid.jl b/src/grid.jl @@ -203,9 +203,12 @@ function sortGrainsInGrid!(simulation::Simulation, grid::Any; verbose=true) end # remove grain if it is outside of the grid - if (!grid.regular_grid && i == 0 && j == 0 ) || + if (!grid.regular_grid && + (i < 1 || j < 1 || + i > size(grid.xh, 1) || j > size(grid.xh, 2))) || (grid.regular_grid && - (i < 1 || j < 1 || i > grid.n[1] || i > grid.n[2])) + (i < 1 || j < 1 || + i > grid.n[1] || j > grid.n[2])) if verbose info("Disabling grain $idx at pos (" * @@ -226,7 +229,7 @@ function sortGrainsInGrid!(simulation::Simulation, grid::Any; verbose=true) end # add grain to cell - push!(grid.grain_list[i, j], idx) + @inbounds push!(grid.grain_list[i, j], idx) end nothing end