Skip to content

Commit

Permalink
Remove grid from OceanSeaIceModel (#308)
Browse files Browse the repository at this point in the history
* remove grid from OceanSeaIceModel

* change to nameof

* correct summary

* show method

* remove grid
  • Loading branch information
simone-silvestri authored Dec 19, 2024
1 parent b3ae3fe commit 03fd900
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
16 changes: 9 additions & 7 deletions src/OceanSeaIceModels/ocean_sea_ice_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -27,20 +27,23 @@ 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

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
Expand Down Expand Up @@ -98,7 +101,6 @@ function OceanSeaIceModel(ocean, sea_ice=FreezingLimitedOceanTemperature();
radiation)

ocean_sea_ice_model = OceanSeaIceModel(clock,
ocean.model.grid,
atmosphere,
sea_ice,
ocean,
Expand Down

0 comments on commit 03fd900

Please sign in to comment.