Skip to content

Commit

Permalink
Add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ArseniyKholod committed Aug 30, 2023
1 parent 5c8f729 commit 05b1971
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/callbacks_step/save_restart.jl
Original file line number Diff line number Diff line change
Expand Up @@ -171,21 +171,22 @@ function load_adaptive_time_integrator!(integrator, restart_file::AbstractString
controller = integrator.opts.controller
# Read context information for controller
h5open(restart_file, "r") do file
# Ensure that necessary information was saved
# Ensure that the necessary information was saved
if !("time_integrator_qold" in keys(attributes(file))) ||
!("time_integrator_dtpropose" in keys(attributes(file))) ||
(hasproperty(controller, :err) &&
!("time_integrator_controller_err" in keys(attributes(file))))
error("Missing data in restart file: check the consistency of adaptive time controller with initial setup!")
end
# Load data that is required both for PIController and PIDController
integrator.qold = read(attributes(file)["time_integrator_qold"])
integrator.dtpropose = read(attributes(file)["time_integrator_dtpropose"])
# Accept step to use dtpropose already in the first step
integrator.accept_step = true
# Reevaluate integrator.fsal_first on the first step
integrator.reeval_fsal = true
# Load additional parameters for PIDController
if hasproperty(controller, :err)
if hasproperty(controller, :err) # Distinguish PIDController from PIController
controller.err[:] = read(attributes(file)["time_integrator_controller_err"])
end
end
Expand Down
5 changes: 2 additions & 3 deletions src/callbacks_step/save_restart_dg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -341,12 +341,11 @@ function save_adaptive_time_integrator(integrator,

# Open file (preserve existing content)
h5open(filename, "r+") do file
# Add context information as attributes
# Add context information as attributes both for PIController and PIDController
attributes(file)["time_integrator_qold"] = integrator.qold
# Ensure that `dtpropose` is written as a double precision scalar
attributes(file)["time_integrator_dtpropose"] = integrator.dtpropose
# For PIDController is necessary to save additional parameters
if hasproperty(controller, :err)
if hasproperty(controller, :err) # Distinguish PIDController from PIController
attributes(file)["time_integrator_controller_err"] = controller.err
end
end
Expand Down

0 comments on commit 05b1971

Please sign in to comment.