commit 0b36c038e19adaf7a13391c4e268f5af9059c355
parent fc78b773abae9afacfa551f4580ce64174c1bb20
Author: Anders Damsgaard <andersd@riseup.net>
Date: Thu, 15 Jun 2017 11:33:26 -0400
Merge branch 'master' of github.com:anders-dc/SeaIce.jl
Diffstat:
6 files changed, 71 insertions(+), 18 deletions(-)
diff --git a/src/simulation.jl b/src/simulation.jl
@@ -50,8 +50,9 @@ export run!
verbose::Bool = true,
status_interval = 100.,
show_file_output = true,
- single_step=false,
- temporal_integration_method="Three-term Taylor"])
+ single_step = false,
+ temporal_integration_method = "Three-term Taylor"],
+ write_jld = false)
Run the `simulation` through time until `simulation.time` equals or exceeds
`simulatim.time_total`. This function requires that all ice floes are added to
@@ -75,13 +76,16 @@ to disk.
is increased accordingly.
* `temporal_integration_method::String="Three-term Taylor"`: type of integration
method to use. See `updateIceFloeKinematics` for details.
+* `write_jld::Bool=false`: write simulation state to disk as JLD files (see
+ `SeaIce.writeSimulation(...)` whenever saving VTK output.
"""
function run!(simulation::Simulation;
verbose::Bool=true,
status_interval::Int=100,
show_file_output::Bool=true,
single_step::Bool=false,
- temporal_integration_method::String="Three-term Taylor")
+ temporal_integration_method::String="Three-term Taylor",
+ write_jld::Bool=false)
if single_step && simulation.time >= simulation.time_total
simulation.time_total += simulation.time_step
@@ -100,7 +104,9 @@ function run!(simulation::Simulation;
if show_file_output
println()
end
- writeSimulation(simulation, verbose=show_file_output)
+ if write_jld
+ writeSimulation(simulation, verbose=show_file_output)
+ end
writeVTK(simulation, verbose=show_file_output)
writeSimulationStatus(simulation, verbose=show_file_output)
simulation.file_time_since_output_file = 0.0
diff --git a/test/atmosphere.jl b/test/atmosphere.jl
@@ -129,3 +129,9 @@ E_kin_rot_final = SeaIce.totalIceFloeKineticRotationalEnergy(sim)
@test sim.ice_floes[1].ang_pos > 0. # check angular position orientation
@test E_kin_rot_init < E_kin_rot_final # rotation after due to atm vortex
@test E_kin_lin_init ≈ E_kin_lin_final # no linear velocity gained
+
+sim = SeaIce.createSimulation()
+sim.atmosphere = SeaIce.createRegularAtmosphereGrid([6, 6, 6], [1., 1., 1.])
+sim2 = SeaIce.createSimulation()
+sim2.atmosphere = SeaIce.createRegularAtmosphereGrid([6, 6, 6], [1., 1., 1.])
+SeaIce.compareAtmospheres(sim.atmosphere, sim2.atmosphere)
diff --git a/test/icefloe.jl b/test/icefloe.jl
@@ -19,3 +19,8 @@ SeaIce.printIceFloeInfo(sim.ice_floes[1])
@test_throws ErrorException SeaIce.addIceFloeCylindrical(sim, [.1, .1], 10., 1.,
density=-2.)
@test_throws ErrorException SeaIce.disableIceFloe!(sim, 0)
+
+sim = SeaIce.createSimulation(id="test")
+SeaIce.addIceFloeCylindrical(sim, [ 0., 0.], 10., 1., verbose=false)
+SeaIce.addIceFloeCylindrical(sim, [ 0., 0.], 10., 1., verbose=false)
+SeaIce.compareIceFloes(sim.ice_floes[1], sim.ice_floes[2])
diff --git a/test/profiling.jl b/test/profiling.jl
@@ -1,5 +1,7 @@
#!/usr/bin/env julia
import Plots
+import SeaIce
+using Base.Test
info("#### $(basename(@__FILE__)) ####")
@@ -36,22 +38,32 @@ function timeSingleStepInDenseSimulation(nx::Int; verbose::Bool=true,
end
end
info("number of ice floes: $(length(sim.ice_floes))")
+ if grid_sorting
+ info("using cell-based spatial decomposition")
+ else
+ info("using all-to-all contact search")
+ end
SeaIce.setTotalTime!(sim, 1.0)
SeaIce.setTimeStep!(sim)
SeaIce.run!(sim, single_step=true, verbose=true)
- SeaIce.run!(sim, single_step=true, verbose=true)
- SeaIce.run!(sim, single_step=true, verbose=true)
if profile
@profile SeaIce.run!(sim, single_step=true, verbose=true)
if verbose
Profile.print()
- #@time SeaIce.run!(sim, single_step=true, verbose=true)
+ end
+ SeaIce.run!(sim, single_step=true, verbose=true)
+ end
+ n_runs = 4
+ t_elapsed = 1e12
+ for i=1:n_runs
+ tic()
+ @time SeaIce.run!(sim, single_step=true, verbose=true)
+ t = toc()
+ if t < t_elapsed
+ t_elapsed = t
end
end
- tic()
- SeaIce.run!(sim, single_step=true, verbose=true)
- t_elapsed = toc()
#SeaIce.writeVTK(sim)
@@ -64,20 +76,32 @@ function timeSingleStepInDenseSimulation(nx::Int; verbose::Bool=true,
return t_elapsed
end
-#nx = Int[4 8 16 32 64 128]
-nx = Int[4 8 16 32 64]
+#nx = Int[4 8 10 12 16 19 24 28 32 36 42 50 64]
+nx = round(logspace(1, 2, 16))
+elements = zeros(length(nx))
t_elapsed = zeros(length(nx))
+t_elapsed_all_to_all = zeros(length(nx))
+t_elapsed_cell_sorting = zeros(length(nx))
for i=1:length(nx)
info("nx = $(nx[i])")
- t_elapsed[i] = timeSingleStepInDenseSimulation(nx[i])
+ t_elapsed_all_to_all[i] =
+ timeSingleStepInDenseSimulation(Int(nx[i]), grid_sorting=false)
+ t_elapsed_cell_sorting[i] =
+ timeSingleStepInDenseSimulation(Int(nx[i]), grid_sorting=true)
+ elements[i] = nx[i]*nx[i]
end
#Plots.gr()
Plots.pyplot()
-Plots.title!("Performance analysis of dense granular system")
-Plots.plot(nx.*nx, t_elapsed,
- xscale=:log10,
- yscale=:log10)
+Plots.scatter(elements, t_elapsed_all_to_all,
+ xscale=:log10,
+ yscale=:log10,
+ label="All to all")
+Plots.scatter!(elements, t_elapsed_cell_sorting,
+ xscale=:log10,
+ yscale=:log10,
+ label="Cell-based spatial decomposition")
+Plots.title!("Dense granular system " * "(host: $(gethostname()))")
Plots.xaxis!("Number of ice floes")
-Plots.yaxis!("Elapsed time")
+Plots.yaxis!("Wall time per time step [s]")
Plots.savefig("profiling.pdf")
diff --git a/test/temporal.jl b/test/temporal.jl
@@ -16,3 +16,6 @@ SeaIce.addIceFloeCylindrical(sim, [.1,.1], 2., 2.)
sim.ice_floes[1].mass = 0.
@test_throws ErrorException SeaIce.setTimeStep!(sim)
+sim = SeaIce.createSimulation()
+sim2 = SeaIce.createSimulation()
+SeaIce.compareSimulations(sim, sim2)
diff --git a/test/vtk.jl b/test/vtk.jl
@@ -31,12 +31,19 @@ icefloechecksum =
"c75ffde29fbdd80161dafd524e690fbcbae2136d4f68c29f725d2d2454c6a162 " *
icefloepath * "\n"
+icefloeinteractionpath = "test/test.icefloe-interaction.1.vtp"
+icefloeinteractionchecksum =
+"881598f8f7279ece4301f6c94cb8f9146eb695f8c710edb446f49c1f7a061b84 " *
+icefloeinteractionpath * "\n"
+
oceanpath = "test/test.ocean.1.vts"
oceanchecksum =
"d56ffb109841a803f2b2b94c74c87f7a497237204841d557d2b1043694d51f0d " *
oceanpath * "\n"
@test readstring(`$(cmd) $(icefloepath)$(cmd_post)`) == icefloechecksum
+@test readstring(`$(cmd) $(icefloeinteractionpath)$(cmd_post)`) ==
+ icefloeinteractionchecksum
@test readstring(`$(cmd) $(oceanpath)$(cmd_post)`) == oceanchecksum
SeaIce.removeSimulationFiles(sim)
@@ -49,6 +56,8 @@ sim.file_number = 0
SeaIce.run!(sim, single_step=true)
@test readstring(`$(cmd) $(icefloepath)$(cmd_post)`) == icefloechecksum
+@test readstring(`$(cmd) $(icefloeinteractionpath)$(cmd_post)`) ==
+ icefloeinteractionchecksum
@test readstring(`$(cmd) $(oceanpath)$(cmd_post)`) == oceanchecksum
@test SeaIce.readSimulationStatus(sim.id) == 1