commit e479a4b1311fe964447bee11d28c5b92a3299140
parent 03aa7f8728492b074ea986f70c9e953f3dc527fc
Author: Anders Damsgaard <andersd@riseup.net>
Date: Fri, 12 May 2017 19:22:16 -0400
add more tests for icefloe and simulation functionality
Diffstat:
4 files changed, 39 insertions(+), 9 deletions(-)
diff --git a/src/icefloe.jl b/src/icefloe.jl
@@ -53,15 +53,6 @@ function addIceFloeCylindrical(simulation::Simulation,
error("Linear acceleration must be a two-element array (lin_acc = ",
"$lin_acc)")
end
- if length(ang_pos) != 1
- error("Angular position must be a scalar (ang_pos = $ang_pos)")
- end
- if length(ang_vel) != 1
- error("Angular velocity must be a scalar (ang_vel = $ang_vel)")
- end
- if length(ang_acc) != 1
- error("Angular acceleration must be a scalar (ang_acc = $ang_acc)")
- end
if contact_radius <= 0.0
error("Radius must be greater than 0.0 (radius = $contact_radius m)")
end
diff --git a/test/icefloe.jl b/test/icefloe.jl
@@ -0,0 +1,20 @@
+#!/usr/bin/env julia
+
+# Check the basic icefloe functionality
+
+info("#### $(basename(@__FILE__)) ####")
+
+info("Writing simple simulation to VTK file")
+sim = SeaIce.createSimulation(id="test")
+SeaIce.addIceFloeCylindrical(sim, [ 0., 0.], 10., 1., verbose=false)
+SeaIce.printIceFloeInfo(sim.ice_floes[1])
+
+
+@test_throws ErrorException SeaIce.addIceFloeCylindrical(sim, [.1, .1, .1], 10., 1.)
+@test_throws ErrorException SeaIce.addIceFloeCylindrical(sim, [.1, .1], 10., 1.,
+ lin_vel=[.2,.2,.2])
+@test_throws ErrorException SeaIce.addIceFloeCylindrical(sim, [.1, .1], 10., 1.,
+ lin_acc=[.2,.2,.2])
+@test_throws ErrorException SeaIce.addIceFloeCylindrical(sim, [.1, .1], 0., 1.)
+@test_throws ErrorException SeaIce.addIceFloeCylindrical(sim, [.1, .1], 10., 1.,
+density=-2.)
diff --git a/test/runtests.jl b/test/runtests.jl
@@ -1,6 +1,7 @@
import SeaIce
using Base.Test
+include("icefloe.jl")
include("contact-search-and-geometry.jl")
include("collision-2floes-normal.jl")
include("collision-5floes-normal.jl")
diff --git a/test/vtk.jl b/test/vtk.jl
@@ -34,3 +34,21 @@ end
"test.ocean.1.vts\n"
SeaIce.removeSimulationFiles(sim)
+
+info("Testing VTK write during run!()")
+SeaIce.setOutputFileInterval!(sim, 1e-9)
+SeaIce.setTotalTime!(sim, 1.5)
+SeaIce.setTimeStep!(sim)
+sim.file_number = 0
+SeaIce.run!(sim, single_step=true)
+SeaIce.run!(sim, single_step=true)
+
+@test readstring(`$(cmd) test.icefloes.1.vtu$(cmd_post)`) ==
+"203030169e90d9ab9538074d2c196ae61dbd8dc3522fcc18e294d4ee70fe4504 " *
+"test.icefloes.1.vtu\n"
+
+@test readstring(`$(cmd) test.ocean.1.vts$(cmd_post)`) ==
+"f0117e414c4e71a0c55980f63865eb03b6c597fa2546983258b8a57eb4ff2a25 " *
+"test.ocean.1.vts\n"
+
+SeaIce.removeSimulationFiles(sim)