commit 3f419be9f4a6594ff17751aa7a85fdc6ef070cd2
parent c9448d73e65ad2b3d4b243b7ad6803774afbde1b
Author: Anders Damsgaard <andersd@riseup.net>
Date: Mon, 6 Nov 2017 16:30:15 -0500
add preliminary shear script, fix regular packing
Diffstat:
4 files changed, 99 insertions(+), 2 deletions(-)
diff --git a/examples/shear.jl b/examples/shear.jl
@@ -0,0 +1,94 @@
+#/usr/bin/env julia
+import Granular
+
+################################################################################
+#### Step 1: Create a loose granular assemblage and let it settle at -y #
+################################################################################
+sim = Granular.createSimulation(id="shear-init")
+
+# Generate 10 grains along x and 100 grains along y, with radii between 0.2 and
+# 1.0 m.
+Granular.regularPacking!(sim, [10, 100], 0.2, 1.0)
+
+# Create a grid for contact searching spanning the extent of the grains
+Granular.fitGridToGrains!(sim, sim.ocean)
+
+# Make the ocean grid drag grains uniformly towards -y
+sim.ocean.v[:, :, 1, 1] = -5.0
+
+# Make the top and bottom boundaries impermeable, and the side boundaries
+# periodic, which will come in handy during shear
+Granular.setGridBoundaryConditions!(sim.ocean, "impermeable", "north south")
+Granular.setGridBoundaryConditions!(sim.ocean, "periodic", "east west")
+
+# Automatically set the computational time step based on grain sizes and
+# properties
+Granular.setTimeStep!(sim)
+
+# Set the total simulation time for this step [s]
+Granular.setTotalTime!(sim, 30.)
+
+# Set the interval in model time between simulation files [s]
+Granular.setOutputFileInterval!(sim, .2)
+
+# Visualize the grain-size distribution
+Granular.plotGrainSizeDistribution(sim)
+
+# Start the simulation
+Granular.run!(sim)
+
+# Try to render the simulation if `pvpython` is installed on the system
+Granular.render(sim)
+
+
+
+
+
+
+
+
+
+
+################################################################################
+#### Step 2: Consolidate the previous output under a constant normal stress #
+################################################################################
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+################################################################################
+#### Step 3: Shear the consolidated assemblage with a constant velocity #
+################################################################################
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/grid.jl b/src/grid.jl
@@ -919,7 +919,10 @@ function fitGridToGrains!(simulation::Simulation, grid::Any;
const L::Vector{Float64} = [max_x - min_x, max_y - min_y]
const dx::Float64 = 2.*max_radius
const n = convert(Vector{Int}, floor.(L./dx))
- if 1 in n
+ if 0 in n || 1 in n
+ println("L = $L")
+ println("dx = $dx")
+ println("n = $n")
error("Grid is too small compared to grain size (n = $n). " *
"Use all-to-all contact search instead.")
end
diff --git a/src/packing.jl b/src/packing.jl
@@ -52,7 +52,7 @@ function regularPacking!(simulation::Simulation,
# Determine position from grid index and sample randomly from within
# padding
- pos .= [ix*dx - .5*dx, iy*dx - .5*dx] .+
+ pos = [ix*dx - .5*dx, iy*dx - .5*dx] .+
rand(2) .* dx_padding .- .5*dx_padding
addGrainCylindrical!(simulation, pos, r_rand, h, verbose=false)
diff --git a/grid-boundaries.jl b/test/grid-boundaries.jl