tImprove handling of grains when outside of grid - Granular.jl - Julia package … | |
git clone git://src.adamsgaard.dk/Granular.jl | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 5cebc5a55305db76a39653bd446f2972b401f63c | |
parent 1935a43410af86f80c260b1aa67c1c538fede904 | |
Author: Anders Damsgaard <[email protected]> | |
Date: Mon, 15 Jan 2018 11:14:03 -0500 | |
Improve handling of grains when outside of grid | |
Diffstat: | |
M src/grid.jl | 9 ++++++--- | |
1 file changed, 6 insertions(+), 3 deletions(-) | |
--- | |
diff --git a/src/grid.jl b/src/grid.jl | |
t@@ -203,9 +203,12 @@ function sortGrainsInGrid!(simulation::Simulation, grid::… | |
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 (" * | |
t@@ -226,7 +229,7 @@ function sortGrainsInGrid!(simulation::Simulation, grid::A… | |
end | |
# add grain to cell | |
- push!(grid.grain_list[i, j], idx) | |
+ @inbounds push!(grid.grain_list[i, j], idx) | |
end | |
nothing | |
end |