Granular.jl

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

commit f8aa00babd9ab63c2f2454e05f18043c6f62a1d8
parent 91f282a51512fbae23efa708eb91ae3d1fc100f0
Author: Anders Damsgaard <andersd@riseup.net>
Date:   Fri,  2 Jun 2017 16:20:32 -0400

fix numerous issues related to grid function rewrite

Diffstat:
Msrc/contact_search.jl | 5+++++
Msrc/grid.jl | 2+-
Msrc/simulation.jl | 18+++++++++++++++++-
Mtest/contact-search-and-geometry.jl | 10+++++-----
Mtest/grid.jl | 6+++---
5 files changed, 31 insertions(+), 10 deletions(-)

diff --git a/src/contact_search.jl b/src/contact_search.jl @@ -22,8 +22,13 @@ function findContacts!(simulation::Simulation; if method == "all to all" findContactsAllToAll!(simulation) + elseif method == "ocean grid" findContactsOceanGrid!(simulation) + + elseif method == "atmosphere grid" + error("not yet implemented") + else error("Unknown contact search method '$method'") end diff --git a/src/grid.jl b/src/grid.jl @@ -71,7 +71,7 @@ export sortIceFloesInGrid! """ Find ice-floe positions in grid, based on their center positions. """ -function sortIceFloesInGrid!(grid::Any; verbose=false) +function sortIceFloesInGrid!(simulation::Simulation, grid::Any; verbose=false) grid.ice_floe_list = Array{Array{Int, 1}}(size(grid.xh, 1), size(grid.xh, 2)) diff --git a/src/simulation.jl b/src/simulation.jl @@ -109,16 +109,32 @@ function run!(simulation::Simulation; end zeroForcesAndTorques!(simulation) + + if typeof(simulation.atmosphere.input_file) != Bool + sortIceFloesInGrid!(sim, sim.atmosphere) + end + if typeof(simulation.ocean.input_file) != Bool - sortIceFloesInOceanGrid!(simulation) + sortIceFloesInGrid!(simulation, simulation.ocean) findContacts!(simulation, method="ocean grid") + + elseif typeof(simulation.atmosphere.input_file) != Bool + findContacts!(simulation, method="atmosphere grid") + else findContacts!(simulation, method="all to all") end + interact!(simulation) + if typeof(simulation.ocean.input_file) != Bool addOceanDrag!(simulation) end + + if typeof(simulation.atmosphere.input_file) != Bool + addAtmosphereDrag!(simulation) + end + updateIceFloeKinematics!(simulation, method=temporal_integration_method) # Update time variables diff --git a/test/contact-search-and-geometry.jl b/test/contact-search-and-geometry.jl @@ -122,10 +122,10 @@ end @test 1 == sim.ice_floes[2].n_contacts -info("Testing findContactsOceanGrid(...)") +info("Testing findContactsGrid(...)") sim = deepcopy(sim_copy) sim.ocean = SeaIce.createRegularOceanGrid([4, 4, 2], [80., 80., 2.]) -SeaIce.sortIceFloesInOceanGrid!(sim) +SeaIce.sortIceFloesInGrid!(sim, sim.ocean) SeaIce.findContactsOceanGrid!(sim) @test 2 == sim.ice_floes[1].contacts[1] @@ -144,7 +144,7 @@ end sim = deepcopy(sim_copy) sim.ocean = SeaIce.createRegularOceanGrid([4, 4, 2], [80., 80., 2.]) sim.ice_floes[1].fixed = true -SeaIce.sortIceFloesInOceanGrid!(sim) +SeaIce.sortIceFloesInGrid!(sim, sim.ocean) SeaIce.findContactsOceanGrid!(sim) @test 2 == sim.ice_floes[1].contacts[1] @@ -164,7 +164,7 @@ sim = deepcopy(sim_copy) sim.ocean = SeaIce.createRegularOceanGrid([4, 4, 2], [80., 80., 2.]) sim.ice_floes[1].fixed = true sim.ice_floes[2].fixed = true -SeaIce.sortIceFloesInOceanGrid!(sim) +SeaIce.sortIceFloesInGrid!(sim, sim.ocean) SeaIce.findContactsOceanGrid!(sim) for ic=1:32 @@ -181,7 +181,7 @@ end info("Testing findContacts(...)") sim = deepcopy(sim_copy) sim.ocean = SeaIce.createRegularOceanGrid([4, 4, 2], [80., 80., 2.]) -SeaIce.sortIceFloesInOceanGrid!(sim) +SeaIce.sortIceFloesInGrid!(sim, sim.ocean) SeaIce.findContacts!(sim) @test 2 == sim.ice_floes[1].contacts[1] diff --git a/test/grid.jl b/test/grid.jl @@ -106,7 +106,7 @@ sim.ocean = SeaIce.readOceanNetCDF("Baltic/00010101.ocean_month.nc", SeaIce.addIceFloeCylindrical(sim, [6.5, 53.5], 10., 1., verbose=verbose) SeaIce.addIceFloeCylindrical(sim, [6.6, 53.5], 10., 1., verbose=verbose) SeaIce.addIceFloeCylindrical(sim, [7.5, 53.5], 10., 1., verbose=verbose) -SeaIce.sortIceFloesInOceanGrid!(sim, verbose=verbose) +SeaIce.sortIceFloesInGrid!(sim, sim.ocean, verbose=verbose) @test sim.ice_floes[1].ocean_grid_pos == [1, 1] @test sim.ice_floes[2].ocean_grid_pos == [1, 1] @test sim.ice_floes[3].ocean_grid_pos == [2, 1] @@ -119,7 +119,7 @@ sim.ocean = SeaIce.createRegularOceanGrid([4, 4, 2], [4., 4., 2.]) sim.ocean.u[:,:,1,1] = 5. SeaIce.addIceFloeCylindrical(sim, [2.5, 3.5], 1., 1., verbose=verbose) SeaIce.addIceFloeCylindrical(sim, [2.6, 2.5], 1., 1., verbose=verbose) -SeaIce.sortIceFloesInOceanGrid!(sim, verbose=verbose) +SeaIce.sortIceFloesInGrid!(sim, sim.ocean, verbose=verbose) sim.time = ocean.time[1] SeaIce.addOceanDrag!(sim) @test sim.ice_floes[1].force[1] > 0. @@ -130,7 +130,7 @@ sim.ocean.u[:,:,1,1] = -5. sim.ocean.v[:,:,1,1] = 5. SeaIce.addIceFloeCylindrical(sim, [2.5, 3.5], 1., 1., verbose=verbose) SeaIce.addIceFloeCylindrical(sim, [2.6, 2.5], 1., 1., verbose=verbose) -SeaIce.sortIceFloesInOceanGrid!(sim, verbose=verbose) +SeaIce.sortIceFloesInGrid!(sim, sim.ocean, verbose=verbose) sim.time = ocean.time[1] SeaIce.addOceanDrag!(sim) @test sim.ice_floes[1].force[1] < 0.