Skip to content

Commit

Permalink
Return nothing from mutating BMI functions
Browse files Browse the repository at this point in the history
  • Loading branch information
visr committed Nov 11, 2024
1 parent 8cdea9f commit 3659262
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions core/src/bmi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,27 @@ BMI.initialize(T::Type{Model}, config_path::AbstractString)::Model = Model(confi
Write all results to the configured files.
"""
BMI.finalize(model::Model)::Model = write_results(model)
function BMI.finalize(model::Model)::Nothing
write_results(model)
return nothing
end

function BMI.update(model::Model)::Model
function BMI.update(model::Model)::Nothing
step!(model.integrator)
return model
return nothing
end

function BMI.update_until(model::Model, time::Float64)::Model
function BMI.update_until(model::Model, time::Float64)::Nothing
(; t) = model.integrator
dt = time - t
if dt < 0
error("The model has already passed the given timestamp.")
elseif dt == 0
return model
return nothing
else
step!(model, dt)
end
return model
return nothing
end

function BMI.get_value_ptr(model::Model, name::AbstractString)::AbstractVector{Float64}
Expand Down Expand Up @@ -55,8 +58,12 @@ function BMI.get_value_ptr(model::Model, name::AbstractString)::AbstractVector{F
end
end

BMI.get_current_time(model::Model) = model.integrator.t
BMI.get_start_time(model::Model) = 0.0
BMI.get_end_time(model::Model) = seconds_since(model.config.endtime, model.config.starttime)
BMI.get_time_units(model::Model) = "s"
BMI.get_time_step(model::Model) = get_proposed_dt(model.integrator)
BMI.get_current_time(model::Model)::Float64 = model.integrator.t
BMI.get_start_time(model::Model)::Float64 = 0.0
BMI.get_time_step(model::Model)::Float64 = get_proposed_dt(model.integrator)

function BMI.get_end_time(model::Model)::Float64
seconds_since(model.config.endtime, model.config.starttime)
end

BMI.get_time_units(model::Model)::String = "s"

0 comments on commit 3659262

Please sign in to comment.