tAdd porosity fields in ocean and atmosphere grids - Granular.jl - Julia packag… | |
git clone git://src.adamsgaard.dk/Granular.jl | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit e30a25e68ebefda2139e2a878784f47745b5903b | |
parent 1dab14f9bc7ecc1d4aa70eb5f8ac0979b2fe1247 | |
Author: Anders Damsgaard <[email protected]> | |
Date: Tue, 30 Jan 2018 12:43:14 -0500 | |
Add porosity fields in ocean and atmosphere grids | |
Diffstat: | |
M src/atmosphere.jl | 2 ++ | |
M src/datatypes.jl | 3 +++ | |
M src/io.jl | 11 ++++++++++- | |
M src/ocean.jl | 3 +++ | |
M test/memory-management.jl | 2 +- | |
M test/vtk.jl | 2 +- | |
6 files changed, 20 insertions(+), 3 deletions(-) | |
--- | |
diff --git a/src/atmosphere.jl b/src/atmosphere.jl | |
t@@ -18,6 +18,7 @@ function createEmptyAtmosphere() | |
zeros(1,1,1,1), | |
Array{Vector{Int}}(1, 1), | |
+ zeros(1,1), | |
1, 1, 1, 1, | |
t@@ -154,6 +155,7 @@ function createRegularAtmosphereGrid(n::Vector{Int}, | |
zl, | |
u, v, | |
Array{Array{Int, 1}}(size(xh, 1), size(xh, 2)), | |
+ zeros(size(xh)), | |
bc_west, bc_south, bc_east, bc_north, | |
false, | |
true, origo, L, n, dx) | |
diff --git a/src/datatypes.jl b/src/datatypes.jl | |
t@@ -231,6 +231,7 @@ mutable struct Ocean | |
# Grains in grid cells | |
grain_list::Array{Vector{Int}, 2} | |
+ porosity::Array{Float64, 2} | |
# Boundary conditions for grains | |
bc_west::Integer | |
t@@ -312,7 +313,9 @@ mutable struct Atmosphere | |
u::Array{Float64, 4} | |
v::Array{Float64, 4} | |
+ # Grains in grid cells | |
grain_list::Array{Vector{Int}, 2} | |
+ porosity::Array{Float64, 2} | |
# Boundary conditions for grains | |
bc_west::Integer | |
diff --git a/src/io.jl b/src/io.jl | |
t@@ -734,9 +734,18 @@ function writeGridVTK(grid::Any, | |
end | |
end | |
end | |
- | |
WriteVTK.vtk_point_data(vtkfile, vel, "Velocity vector [m/s]") | |
+ # Porosity is in the grids stored on the cell center, but is here | |
+ # interpolated to the cell corners | |
+ porosity = zeros(size(xq, 1), size(xq, 2), size(xq, 3)) | |
+ for ix=1:size(grid.xh, 1) | |
+ for iy=1:size(grid.xh, 2) | |
+ @inbounds porosity[ix, iy, 1] = grid.porosity[ix, iy] | |
+ end | |
+ end | |
+ WriteVTK.vtk_point_data(vtkfile, porosity, "Porosity [-]") | |
+ | |
if typeof(grid) == Ocean | |
WriteVTK.vtk_point_data(vtkfile, grid.h[:, :, :, 1], | |
"h: Layer thickness [m]") | |
diff --git a/src/ocean.jl b/src/ocean.jl | |
t@@ -20,6 +20,7 @@ function createEmptyOcean() | |
zeros(1,1,1,1), | |
zeros(1,1,1,1), | |
Array{Array{Int, 1}}(1, 1), | |
+ zeros(1,1), | |
1, 1, 1, 1, | |
false, [0.,0.,0.], [1.,1.,1.], [1,1,1], [1.,1.,1.]) | |
end | |
t@@ -67,6 +68,7 @@ function readOceanNetCDF(velocity_file::String, grid_file::S… | |
h, | |
e, | |
Array{Array{Int, 1}}(size(xh, 1), size(xh, 2)), | |
+ zeros(size(xh)), | |
1, 1, 1, 1, | |
false, [0.,0.,0.], [1.,1.,1.], [1,1,1], [1.,1.,1.] | |
t@@ -272,6 +274,7 @@ function createRegularOceanGrid(n::Vector{Int}, | |
zl, zi, | |
u, v, h, e, | |
Array{Array{Int, 1}}(size(xh, 1), size(xh, 2)), | |
+ zeros(size(xh)), | |
bc_west, bc_south, bc_east, bc_north, | |
true, origo, L, n, dx) | |
end | |
diff --git a/test/memory-management.jl b/test/memory-management.jl | |
t@@ -6,7 +6,7 @@ info("Testing memory footprint of Granular types") | |
sim = Granular.createSimulation() | |
empty_sim_size = 104 | |
-empty_sim_size_recursive = 816 | |
+empty_sim_size_recursive = 848 | |
@test sizeof(sim) == empty_sim_size | |
@test Base.summarysize(sim) == empty_sim_size_recursive | |
diff --git a/test/vtk.jl b/test/vtk.jl | |
t@@ -39,7 +39,7 @@ graininteractionpath * "\n" | |
oceanpath = "test/test.ocean.1.vts" | |
oceanchecksum = | |
-"d56ffb109841a803f2b2b94c74c87f7a497237204841d557d2b1043694d51f0d " * | |
+"b65f00942f1cbef7335921948c9eb73d137574eb806c33dea8b0e9b638665f3b " * | |
oceanpath * "\n" | |
@test read(`$(cmd) $(grainpath)$(cmd_post)`, String) == grainchecksum |