Skip to content

Commit

Permalink
remove grid requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
simone-silvestri committed Dec 15, 2024
1 parent a6a1a16 commit a8e00e6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/Models/Models.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import Oceananigans.Architectures: architecture
import Oceananigans.TimeSteppers: reset!
import Oceananigans.Solvers: iteration

import Base

# A prototype interface for AbstractModel.
#
# TODO: decide if we like this.
Expand All @@ -34,6 +36,7 @@ import Oceananigans.Solvers: iteration

iteration(model::AbstractModel) = model.clock.iteration
Base.time(model::AbstractModel) = model.clock.time
Base.eltype(model::AbstractModel) = eltype(model.grid)
architecture(model::AbstractModel) = model.grid.architecture
initialize!(model::AbstractModel) = nothing
total_velocities(model::AbstractModel) = nothing
Expand Down
2 changes: 1 addition & 1 deletion src/Simulations/simulation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function Simulation(model; Δt,

# Convert numbers to floating point; otherwise preserve type (eg for DateTime types)
# TODO: implement TT = timetype(model) and FT = eltype(model)
TT = eltype(model.grid)
TT = eltype(model)
Δt = Δt isa Number ? TT(Δt) : Δt
stop_time = stop_time isa Number ? TT(stop_time) : stop_time

Expand Down
2 changes: 1 addition & 1 deletion src/Simulations/time_step_wizard.jl
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function new_time_step(old_Δt, wizard, model)
new_Δt = min(wizard.max_change * old_Δt, new_Δt)
new_Δt = max(wizard.min_change * old_Δt, new_Δt)
new_Δt = clamp(new_Δt, wizard.min_Δt, wizard.max_Δt)
new_Δt = all_reduce(min, new_Δt, architecture(model.grid))
new_Δt = all_reduce(min, new_Δt, architecture(model))

return new_Δt
end
Expand Down

0 comments on commit a8e00e6

Please sign in to comment.