commit 79be92c76c555a8cf2d990dd9ce379387582beff
parent 736b7d41cce0d5f2bf87d96382db514ba71a634e
Author: Anders Damsgaard <andersd@riseup.net>
Date: Wed, 7 Jun 2017 09:13:09 -0400
put simulation output in separate folders
Diffstat:
2 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/src/io.jl b/src/io.jl
@@ -12,6 +12,8 @@ can be visualized by applying a *Glyph* filter.
If the simulation contains an `Ocean` data structure, it's contents will be
written to separate `.vtu` files. This can be disabled by setting the argument
`ocean=false`. The same is true for the atmosphere.
+
+The VTK files will be saved in a subfolder named after the simulation.
"""
function writeVTK(simulation::Simulation;
folder::String=".",
@@ -20,6 +22,9 @@ function writeVTK(simulation::Simulation;
atmosphere::Bool=true)
simulation.file_number += 1
+ folder = folder * "/" * simulation.id
+ mkpath(folder)
+
filename = string(folder, "/", simulation.id, ".icefloes.",
simulation.file_number)
writeIceFloeVTK(simulation, filename, verbose=verbose)
@@ -445,7 +450,9 @@ export removeSimulationFiles
Remove all simulation output files from the specified folder.
"""
function removeSimulationFiles(simulation::Simulation; folder::String=".")
+ folder = folder * "/" * simulation.id
run(`bash -c "rm -rf $(folder)/$(simulation.id).*.vtu"`)
run(`bash -c "rm -rf $(folder)/$(simulation.id).*.vtp"`)
run(`bash -c "rm -rf $(folder)/$(simulation.id).*.vts"`)
+ run(`bash -c "rmdir $(folder)"`)
end
diff --git a/test/vtk.jl b/test/vtk.jl
@@ -26,16 +26,18 @@ else
error("checksum verification of VTK file not supported on this platform")
end
+icefloepath = "test/test.icefloes.1.vtu"
icefloechecksum =
"c75ffde29fbdd80161dafd524e690fbcbae2136d4f68c29f725d2d2454c6a162 " *
-"test.icefloes.1.vtu\n"
+icefloepath * "\n"
+oceanpath = "test/test.ocean.1.vts"
oceanchecksum =
"d56ffb109841a803f2b2b94c74c87f7a497237204841d557d2b1043694d51f0d " *
-"test.ocean.1.vts\n"
+oceanpath * "\n"
-@test readstring(`$(cmd) test.icefloes.1.vtu$(cmd_post)`) == icefloechecksum
-@test readstring(`$(cmd) test.ocean.1.vts$(cmd_post)`) == oceanchecksum
+@test readstring(`$(cmd) $(icefloepath)$(cmd_post)`) == icefloechecksum
+@test readstring(`$(cmd) $(oceanpath)$(cmd_post)`) == oceanchecksum
SeaIce.removeSimulationFiles(sim)
@@ -46,7 +48,7 @@ SeaIce.setTimeStep!(sim)
sim.file_number = 0
SeaIce.run!(sim, single_step=true)
-@test readstring(`$(cmd) test.icefloes.1.vtu$(cmd_post)`) == icefloechecksum
-@test readstring(`$(cmd) test.ocean.1.vts$(cmd_post)`) == oceanchecksum
+@test readstring(`$(cmd) $(icefloepath)$(cmd_post)`) == icefloechecksum
+@test readstring(`$(cmd) $(oceanpath)$(cmd_post)`) == oceanchecksum
SeaIce.removeSimulationFiles(sim)