tAdd `let` ... `end` block to change scope of variables between loops - Granular.jl - Julia package for granular dynamics simulation
 (HTM) git clone git://src.adamsgaard.dk/Granular.jl
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 1fa99b4b2eb2d9ec752a5e76f9fffa411b0a5846
 (DIR) parent 232644c77c26f33e82af15b68f2b53862f8cb933
 (HTM) Author: Anders Damsgaard <anders@adamsgaard.dk>
       Date:   Mon, 11 Mar 2019 10:06:20 +0100
       
       Add `let` ... `end` block to change scope of variables between loops
       
       Diffstat:
         M examples/shear.jl                   |      10 ++--------
       
       1 file changed, 2 insertions(+), 8 deletions(-)
       ---
 (DIR) diff --git a/examples/shear.jl b/examples/shear.jl
       t@@ -7,6 +7,7 @@ import PyPlot
        ################################################################################
        #### SIMULATION PARAMETERS                                                     #
        ################################################################################
       +let
        
        # Common simulation identifier
        id_prefix = "test0"
       t@@ -121,7 +122,6 @@ Granular.zeroKinematics!(sim)
        # Add a dynamic wall to the top which adds a normal stress downwards.  The
        # normal of this wall is downwards, and we place it at the top of the granular
        # assemblage.  Here, the inter-grain viscosity is also removed.
       -let
        y_top = -Inf
        for grain in sim.grains
            grain.contact_viscosity_normal = 0.
       t@@ -132,14 +132,12 @@ end
        Granular.addWallLinearFrictionless!(sim, [0., 1.], y_top,
                                            bc="normal stress", normal_stress=-N,
                                            contact_viscosity_normal=1e3)
       -end
        @info "Placing top wall at y=$y_top"
        
        # Resize the grid to span the current state
        Granular.fitGridToGrains!(sim, sim.ocean)
        
        # Lock the grains at the very bottom so that the lower boundary is rough
       -let
        y_bot = Inf
        for grain in sim.grains
            if y_bot > grain.lin_pos[2] - grain.contact_radius
       t@@ -152,7 +150,6 @@ for grain in sim.grains
                grain.fixed = true  # set x and y acceleration to zero
            end
        end
       -end
        
        # Set current time to zero and reset output file counter
        Granular.resetTime!(sim)
       t@@ -225,7 +222,6 @@ shear_stress = Float64[]
        shear_strain = Float64[]
        dilation = Float64[]
        thickness_initial = sim.walls[1].pos - y_bot
       -let
        x_min = +Inf
        x_max = -Inf
        for grain in sim.grains
       t@@ -237,8 +233,6 @@ for grain in sim.grains
            end
        end
        surface_area = (x_max - x_min)
       -end
       -let
        shear_force = 0.
        while sim.time < sim.time_total
        
       t@@ -275,7 +269,6 @@ while sim.time < sim.time_total
            append!(dilation, (sim.walls[1].pos - y_bot)/thickness_initial)
        
        end
       -end
        
        # Try to render the simulation if `pvpython` is installed on the system
        Granular.render(sim, trim=false)
       t@@ -317,3 +310,4 @@ PyPlot.xlabel("Time [s]")
        PyPlot.ylabel("Shear strain [-]")
        PyPlot.savefig(sim.id * "-time_vs_shear-strain.pdf")
        PyPlot.clf()
       +end