From 03fd900bd6bcadbc3cbc40ddfb0f8fec2f701105 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Thu, 19 Dec 2024 21:50:34 +0100 Subject: [PATCH] Remove grid from `OceanSeaIceModel` (#308) * remove grid from OceanSeaIceModel * change to nameof * correct summary * show method * remove grid --- .../ocean_sea_ice_surface_fluxes.jl | 7 +++++++ src/OceanSeaIceModels/ocean_sea_ice_model.jl | 16 +++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/OceanSeaIceModels/CrossRealmFluxes/ocean_sea_ice_surface_fluxes.jl b/src/OceanSeaIceModels/CrossRealmFluxes/ocean_sea_ice_surface_fluxes.jl index 3d8fdb3a..e6d856f1 100644 --- a/src/OceanSeaIceModels/CrossRealmFluxes/ocean_sea_ice_surface_fluxes.jl +++ b/src/OceanSeaIceModels/CrossRealmFluxes/ocean_sea_ice_surface_fluxes.jl @@ -56,6 +56,13 @@ const celsius_to_kelvin = 273.15 Base.summary(crf::OceanSeaIceSurfaceFluxes) = "OceanSeaIceSurfaceFluxes" Base.show(io::IO, crf::OceanSeaIceSurfaceFluxes) = print(io, summary(crf)) +function Base.show(io::IO, crf::OceanSeaIceSurfaceFluxes) + print(io, summary(crf), "\n") + print(io, "├── radiation: ", summary(crf.radiation), "\n") + print(io, "└── turbulent coefficients: ", summary(crf.turbulent), "\n") + return nothing +end + const SeaIceSimulation = Simulation{<:SeaIceModel} function OceanSeaIceSurfaceFluxes(ocean, sea_ice=nothing; diff --git a/src/OceanSeaIceModels/ocean_sea_ice_model.jl b/src/OceanSeaIceModels/ocean_sea_ice_model.jl index f41bb304..efc2ebe7 100644 --- a/src/OceanSeaIceModels/ocean_sea_ice_model.jl +++ b/src/OceanSeaIceModels/ocean_sea_ice_model.jl @@ -7,6 +7,7 @@ using SeawaterPolynomials: TEOS10EquationOfState # Simulations interface import Oceananigans: fields, prognostic_fields +import Oceananigans.Architectures: architecture import Oceananigans.Fields: set! import Oceananigans.Models: timestepper, NaNChecker, default_nan_checker import Oceananigans.OutputWriters: default_included_properties @@ -15,9 +16,8 @@ import Oceananigans.TimeSteppers: time_step!, update_state!, time import Oceananigans.Utils: prettytime import Oceananigans.Models: timestepper, NaNChecker, default_nan_checker -struct OceanSeaIceModel{I, A, O, F, C, G} <: AbstractModel{Nothing} +struct OceanSeaIceModel{I, A, O, F, C} <: AbstractModel{Nothing} clock :: C - grid :: G # TODO: make it so Oceananigans.Simulation does not require this atmosphere :: A sea_ice :: I ocean :: O @@ -27,9 +27,8 @@ end const OSIM = OceanSeaIceModel function Base.summary(model::OSIM) - A = nameof(typeof(architecture(model.grid))) - G = nameof(typeof(model.grid)) - return string("OceanSeaIceModel{$A, $G}", + A = nameof(typeof(architecture(model))) + return string("OceanSeaIceModel{$A}", "(time = ", prettytime(model.clock.time), ", iteration = ", model.clock.iteration, ")") end @@ -37,10 +36,14 @@ function Base.show(io::IO, cm::OSIM) print(io, summary(cm), "\n") print(io, "├── ocean: ", summary(cm.ocean.model), "\n") print(io, "├── atmosphere: ", summary(cm.atmosphere), "\n") - print(io, "└── sea_ice: ", summary(cm.sea_ice), "\n") + print(io, "├── sea_ice: ", summary(cm.sea_ice), "\n") + print(io, "└── fluxes: ", summary(cm.fluxes)) return nothing end +# Assumption: We have an ocean! +architecture(model::OSIM) = architecture(model.ocean) + prettytime(model::OSIM) = prettytime(model.clock.time) iteration(model::OSIM) = model.clock.iteration timestepper(::OSIM) = nothing @@ -98,7 +101,6 @@ function OceanSeaIceModel(ocean, sea_ice=FreezingLimitedOceanTemperature(); radiation) ocean_sea_ice_model = OceanSeaIceModel(clock, - ocean.model.grid, atmosphere, sea_ice, ocean,