@@ -3,9 +3,12 @@ using CondaPkg
33using ClimaOcean. OceanSeaIceModels: reference_density, heat_capacity, SeaIceSimulation
44
55import Oceananigans. Fields: set!
6- import Oceananigans. TimeSteppers: time_step!
6+ import Oceananigans. TimeSteppers: time_step!, initialize!
77
8- import ClimaOcean. OceanSeaIceModels: OceanSeaIceModel
8+ import ClimaOcean. OceanSeaIceModels: OceanSeaIceModel, default_nan_checker
9+ import Oceananigans. Architectures: architecture
10+
11+ import Base: eltype
912
1013"""
1114 install_veros()
@@ -24,7 +27,12 @@ struct VerosOceanSimulation{S}
2427 setup :: S
2528end
2629
27- time_step! (sim:: VerosOceanSimulation , Δt) = sim. setup. step ()
30+ default_nan_checker (model:: OceanSeaIceModel{<:Any, <:Any, <:VerosOceanSimulation} ) = nothing
31+
32+ initialize! (:: ClimaOceanPythonCallExt.VerosOceanSimulation{Py} ) = nothing
33+ time_step! (ocean:: VerosOceanSimulation , Δt) = ocean. setup. step (ocean. setup. state)
34+ architecture (model:: OceanSeaIceModel{<:Any, <:Any, <:VerosOceanSimulation} ) = CPU ()
35+ eltype (model:: OceanSeaIceModel{<:Any, <:Any, <:VerosOceanSimulation} ) = Float64
2836
2937function remove_outputs (setup:: Symbol )
3038 rm (" $(setup) .averages.nc" , force= true )
@@ -34,15 +42,31 @@ function remove_outputs(setup::Symbol)
3442 return nothing
3543end
3644
37- const Field2D = Field{<: Any , <: Any , <: Nothing }
45+ const CCField2D = Field{<: Center , <: Center , <: Nothing }
46+ const FCField2D = Field{<: Face , <: Center , <: Nothing }
47+ const CFField2D = Field{<: Center , <: Face , <: Nothing }
3848
39- function set! (field:: Field2D , pyarray:: Py , k= pyconvert (Int, pyarray. shape[2 ]))
49+ function set! (field:: CCField2D , pyarray:: Py , k= pyconvert (Int, pyarray. shape[2 ]))
4050 array = PyArray (pyarray)
4151 Nx, Ny, Nz = size (array)
4252 set! (field, view (array, 3 : Nx- 2 , 3 : Ny- 2 , k, 1 ))
4353 return field
4454end
4555
56+ function set! (field:: FCField2D , pyarray:: Py , k= pyconvert (Int, pyarray. shape[2 ]))
57+ array = PyArray (pyarray)
58+ Nx, Ny, Nz = size (array)
59+ set! (field, view (array, 3 : Nx- 2 , 3 : Ny- 2 , k, 1 ))
60+ return field
61+ end
62+
63+ function set! (field:: CFField2D , pyarray:: Py , k= pyconvert (Int, pyarray. shape[2 ]))
64+ array = PyArray (pyarray)
65+ Nx, Ny, Nz = size (array)
66+ set! (field, view (array, 3 : Nx- 2 , 2 : Ny- 2 , k, 1 ))
67+ return field
68+ end
69+
4670function veros_ocean_simulation (setup, setup_name)
4771 setups = pyimport (" veros.setups." * setup)
4872 setup = @eval $ setups.$ setup_name ()
@@ -53,13 +77,13 @@ function veros_ocean_simulation(setup, setup_name)
5377 return VerosOceanSimulation (setup)
5478end
5579
56- function surface_grid (setup :: VerosOceanSimulation )
80+ function surface_grid (ocean :: VerosOceanSimulation )
5781
58- xf = Array (PyArray (setup. state. variables. xu))
59- yf = Array (PyArray (setup. state. variables. yu))
82+ xf = Array (PyArray (ocean . setup. state. variables. xu))
83+ yf = Array (PyArray (ocean . setup. state. variables. yu))
6084
61- xc = Array (PyArray (setup. state. variables. xt))
62- yc = Array (PyArray (setup. state. variables. yt))
85+ xc = Array (PyArray (ocean . setup. state. variables. xt))
86+ yc = Array (PyArray (ocean . setup. state. variables. yt))
6387
6488 xf = xf[2 : end - 2 ]
6589 yf = yf[2 : end - 2 ]
@@ -79,7 +103,7 @@ function surface_grid(setup::VerosOceanSimulation)
79103 Nx = length (xc)
80104 Ny = length (yc)
81105
82- return LatitudeLongitudeGrid (size= (Nx, Ny), longitude= xf, latitude= yf, topology= (TX, Bounded, Flat))
106+ return LatitudeLongitudeGrid (size= (Nx, Ny), longitude= xf, latitude= yf, topology= (TX, Bounded, Flat), halo = ( 2 , 2 ) )
83107end
84108
85109function veros_set! (ocean:: VerosOceanSimulation , v, x)
0 commit comments