tAdd argument to choose if output plots are generated or not - Granular.jl - Ju… | |
git clone git://src.adamsgaard.dk/Granular.jl | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 026453ac365e0acd332634c91088f60639517aec | |
parent 718e4f5ed4e304281c1af295e803b8261fdc7a0a | |
Author: Anders Damsgaard <[email protected]> | |
Date: Thu, 21 Dec 2017 07:51:26 -0500 | |
Add argument to choose if output plots are generated or not | |
Diffstat: | |
M src/packing.jl | 15 ++++++++++++--- | |
M test/packing.jl | 8 ++++++++ | |
2 files changed, 20 insertions(+), 3 deletions(-) | |
--- | |
diff --git a/src/packing.jl b/src/packing.jl | |
t@@ -84,6 +84,9 @@ end | |
export irregularPacking! | |
""" | |
+ irregularPacking!(simulation[, radius_max, radius_min, sample_limit, | |
+ thickness, seed, plot_during_packing, verbose) | |
+ | |
Generate a dense disc packing in 2D using Poisson disc sampling with O(N) | |
complexity, as described by [Robert Bridson (2007) "Fast Poisson disk sampling | |
in arbitrary dimensions"](https://doi.org/10.1145/1278780.1278807). The | |
t@@ -97,6 +100,8 @@ in arbitrary dimensions"](https://doi.org/10.1145/1278780.1… | |
* `sample_limit::Integer=30`: number of points to sample around each grain | |
before giving up. | |
* `seed::Integer`: seed value to the pseudo-random number generator. | |
+* `plot_during_packing::Bool=false`: produce successive plots as the packing is | |
+ generated. Requires gnuplot (default). | |
* `verbose::Bool=true`: show diagnostic information to stdout. | |
""" | |
function irregularPacking!(simulation::Simulation; | |
t@@ -105,6 +110,7 @@ function irregularPacking!(simulation::Simulation; | |
sample_limit::Integer=30, | |
thickness::Real=1., | |
seed::Integer=1, | |
+ plot_during_packing::Bool=false, | |
verbose::Bool=true) | |
srand(seed) | |
t@@ -234,9 +240,12 @@ function irregularPacking!(simulation::Simulation; | |
deleteat!(active_list, i) | |
end | |
println("Active points: $(length(active_list))") | |
- n += 1 | |
- filepostfix = @sprintf("packing.%05d.png", n) | |
- plotGrains(simulation, filetype=filepostfix, show_figure=false) | |
+ | |
+ if plot_during_packing | |
+ n += 1 | |
+ filepostfix = @sprintf("packing.%05d.png", n) | |
+ plotGrains(simulation, filetype=filepostfix, show_figure=false) | |
+ end | |
end | |
if verbose | |
info("Generated $(length(simulation.grains) - np_init) points") | |
diff --git a/test/packing.jl b/test/packing.jl | |
t@@ -54,3 +54,11 @@ Granular.irregularPacking!(sim, | |
radius_max=.1, | |
radius_min=.001, | |
verbose=true) | |
+ | |
+info("Testing irregular (Poisson-disk) packing generation (intermediate PSD)") | |
+sim = Granular.createSimulation("poisson3") | |
+sim.ocean = Granular.createRegularOceanGrid([1, 1, 1], [1., 1., 1.]) | |
+Granular.irregularPacking!(sim, | |
+ radius_max=.1, | |
+ radius_min=.01, | |
+ verbose=true) |