Granular.jl

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

commit 44d111b2b68c2f33de09016bb1d8cc4deb7af478
parent d0323bbd5778d9fa552a76d59ea3b5cf7a2496cd
Author: Anders Damsgaard <andersd@riseup.net>
Date:   Thu, 16 Nov 2017 07:55:06 -0800

keep grid BCs during resize, fix plotting in shear example

Diffstat:
Mexamples/shear.jl | 18++++++++++--------
Msrc/atmosphere.jl | 8++++++--
Msrc/grid.jl | 13+++++++++++--
Msrc/ocean.jl | 8++++++--
4 files changed, 33 insertions(+), 14 deletions(-)

diff --git a/examples/shear.jl b/examples/shear.jl @@ -25,7 +25,8 @@ Granular.fitGridToGrains!(sim, sim.ocean) # 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, "impermeable", "north south", + verbose=false) Granular.setGridBoundaryConditions!(sim.ocean, "periodic", "east west") # Add gravitational acceleration to all grains and disable ocean-grid drag @@ -131,10 +132,9 @@ defined_normal_stress = ones(length(effective_normal_stress)) * Granular.getWallNormalStress(sim, stress_type="effective") PyPlot.subplot(211) PyPlot.subplots_adjust(hspace=0.0) -ax1 = gca() +ax1 = PyPlot.gca() PyPlot.setp(ax1[:get_xticklabels](),visible=false) # Disable x tick labels PyPlot.plot(time, compaction) -PyPlot.xlabel("Time [s]") PyPlot.ylabel("Top wall height [m]") PyPlot.subplot(212, sharex=ax1) PyPlot.plot(time, defined_normal_stress) @@ -242,26 +242,28 @@ Granular.render(sim, trim=false) # Plot time vs. shear stress and dilation PyPlot.subplot(211) PyPlot.subplots_adjust(hspace=0.0) -ax1 = gca() +ax1 = PyPlot.gca() PyPlot.setp(ax1[:get_xticklabels](),visible=false) # Disable x tick labels PyPlot.plot(time, shear_stress) +PyPlot.ylabel("Shear stress [Pa]") PyPlot.subplot(212, sharex=ax1) PyPlot.plot(time, dilation) PyPlot.xlabel("Time [s]") -PyPlot.ylabel("Shear stress [Pa]") +PyPlot.ylabel("Volumetric strain [-]") PyPlot.savefig(sim.id * "-time_vs_shear-stress.pdf") PyPlot.clf() # Plot shear strain vs. shear stress and dilation PyPlot.subplot(211) PyPlot.subplots_adjust(hspace=0.0) -ax1 = gca() +ax1 = PyPlot.gca() PyPlot.setp(ax1[:get_xticklabels](),visible=false) # Disable x tick labels -PyPlot.plot(time, shear_stress) +PyPlot.plot(shear_strain, shear_stress) +PyPlot.ylabel("Shear stress [Pa]") PyPlot.subplot(212, sharex=ax1) PyPlot.plot(shear_strain, dilation) PyPlot.xlabel("Shear strain [-]") -PyPlot.ylabel("Shear stress [Pa]") +PyPlot.ylabel("Volumetric strain [-]") PyPlot.savefig(sim.id * "-shear-strain_vs_shear-stress.pdf") PyPlot.clf() diff --git a/src/atmosphere.jl b/src/atmosphere.jl @@ -110,7 +110,11 @@ function createRegularAtmosphereGrid(n::Vector{Int}, L::Vector{Float64}; origo::Vector{Float64} = zeros(2), time::Array{Float64, 1} = zeros(1), - name::String = "unnamed") + name::String = "unnamed", + bc_west::Integer = 1, + bc_south::Integer = 1, + bc_east::Integer = 1, + bc_north::Integer = 1) xq = repmat(linspace(origo[1], origo[1] + L[1], n[1] + 1), 1, n[2] + 1) yq = repmat(linspace(origo[2], origo[2] + L[2], n[2] + 1)', n[1] + 1, 1) @@ -133,7 +137,7 @@ function createRegularAtmosphereGrid(n::Vector{Int}, zl, u, v, Array{Array{Int, 1}}(size(xh, 1), size(xh, 2)), - 1, 1, 1, 1, + bc_west, bc_south, bc_east, bc_north) false) end diff --git a/src/grid.jl b/src/grid.jl @@ -928,17 +928,26 @@ function fitGridToGrains!(simulation::Simulation, grid::Any; "Use all-to-all contact search instead.") end + if typeof(grid) == Ocean simulation.ocean = createRegularOceanGrid(vcat(n, 1), vcat(L, 1.), origo=[min_x, min_y], - time=[0.], name="fitted") + time=[0.], name="fitted", + bc_west = grid.bc_west, + bc_south = grid.bc_south, + bc_east = grid.bc_east, + bc_north = grid.bc_north) elseif typeof(grid) == Atmosphere simulation.atmosphere = createRegularAtmosphereGrid(vcat(n, 1), vcat(L, 1.), origo=[min_x, min_y], time=[0.], - name="fitted") + name="fitted", + bc_west = grid.bc_west, + bc_south = grid.bc_south, + bc_east = grid.bc_east, + bc_north = grid.bc_north) end if verbose diff --git a/src/ocean.jl b/src/ocean.jl @@ -220,7 +220,11 @@ function createRegularOceanGrid(n::Array{Int, 1}, L::Vector{Float64}; origo::Vector{Float64} = zeros(2), time::Vector{Float64} = zeros(1), - name::String = "unnamed") + name::String = "unnamed", + bc_west::Integer = 1, + bc_south::Integer = 1, + bc_east::Integer = 1, + bc_north::Integer = 1) xq = repmat(linspace(origo[1], origo[1] + L[1], n[1] + 1), 1, n[2] + 1) yq = repmat(linspace(origo[2], origo[2] + L[2], n[2] + 1)', n[1] + 1, 1) @@ -246,7 +250,7 @@ function createRegularOceanGrid(n::Array{Int, 1}, zl, zi, u, v, h, e, Array{Array{Int, 1}}(size(xh, 1), size(xh, 2)), - 1, 1, 1, 1) + bc_west, bc_south, bc_east, bc_north) end export addOceanDrag!