commit ddf1f4d1c0e72b369fcae11a7cd37e9267265f65
parent 4a79e477b83eb068b4024f6695bca0295a5a06c4
Author: Anders Damsgaard <andersd@riseup.net>
Date: Mon, 1 May 2017 09:40:30 -0400
use conformal mapping by default during cell binning
Diffstat:
3 files changed, 20 insertions(+), 10 deletions(-)
diff --git a/examples/nares_strait.jl b/examples/nares_strait.jl
@@ -104,8 +104,6 @@ end
n = length(sim.ice_floes) - n_walls
info("added $(n) ice floes")
-SeaIce.writeVTK(sim)
-
# Run temporal loop
SeaIce.setTotalTime!(sim, 24.*60.*60.)
SeaIce.setOutputFileInterval!(sim, 60.)
diff --git a/src/grid.jl b/src/grid.jl
@@ -61,13 +61,16 @@ end
export findCellContainingPoint
"""
Returns the `i`, `j` index of the ocean grid cell containing the `point`.
+The function uses either an area-based approach (`method = "Area"`), or a
+conformal mapping approach (`method = "Conformal"`). The area-based approach is
+more robust. This function returns the coordinates of the cell or raises an
+error.
"""
-function findCellContainingPoint(ocean::Ocean, point::Array{float, 1})
-
- found = false
+function findCellContainingPoint(ocean::Ocean, point::Array{float, 1};
+ method::String="Conformal")
for i=1:size(ocean.xh, 1)
for j=1:size(ocean.yh, 2)
- if isPointInCell(ocean, i, j, point)
+ if isPointInCell(ocean, i, j, point, method=method)
return i, j
end
end
diff --git a/test/grid.jl b/test/grid.jl
@@ -79,10 +79,19 @@ ocean.u[1, 2, 1, 1] = 0.0
@test SeaIce.bilinearInterpolation(ocean.u, .25, .25, 1, 1, 1, 1) ≈ .75
@test SeaIce.bilinearInterpolation(ocean.u, .75, .75, 1, 1, 1, 1) ≈ .25
-info("Testing cell binning")
-@test SeaIce.findCellContainingPoint(ocean, [6.2, 53.4]) == (1, 1)
-@test SeaIce.findCellContainingPoint(ocean, [7.2, 53.4]) == (2, 1)
-@test_throws ErrorException SeaIce.findCellContainingPoint(ocean, [0.2, 53.4])
+info("Testing cell binning - Area-based approach")
+@test SeaIce.findCellContainingPoint(ocean, [6.2,53.4], method="Area") == (1, 1)
+@test SeaIce.findCellContainingPoint(ocean, [7.2,53.4], method="Area") == (2, 1)
+@test_throws ErrorException SeaIce.findCellContainingPoint(ocean, [0.2, 53.4],
+ method="Area")
+
+info("Testing cell binning - Conformal mapping")
+@test SeaIce.findCellContainingPoint(ocean, [6.2,53.4], method="Conformal") ==
+ (1, 1)
+@test SeaIce.findCellContainingPoint(ocean, [7.2,53.4], method="Conformal") ==
+ (2, 1)
+@test_throws ErrorException SeaIce.findCellContainingPoint(ocean, [0.2, 53.4],
+ method="Conformal")
sim = SeaIce.createSimulation()
sim.ocean = SeaIce.readOceanNetCDF("Baltic/00010101.ocean_month.nc",