Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add load_timestep! for restart setup #1614

Merged
merged 8 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions docs/src/restart.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ and its time step number, e.g.:
```julia
integrator = init(ode, CarpenterKennedy2N54(williamson_condition=false),
dt=dt, save_everystep=false, callback=callbacks);
integrator.iter = load_timestep(restart_filename)
integrator.stats.naccept = integrator.iter
load_timestep!(integrator, restart_filename)
```

Now we can compute the solution:
Expand Down
3 changes: 1 addition & 2 deletions examples/p4est_2d_dgsem/elixir_advection_restart.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ integrator = init(ode, CarpenterKennedy2N54(williamson_condition=false),
save_everystep=false, callback=callbacks);

# Get the last time index and work with that.
integrator.iter = load_timestep(restart_filename)
integrator.stats.naccept = integrator.iter
load_timestep!(integrator, restart_filename)


###############################################################################
Expand Down
3 changes: 1 addition & 2 deletions examples/p4est_3d_dgsem/elixir_advection_restart.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ integrator = init(ode, CarpenterKennedy2N54(williamson_condition=false),
save_everystep=false, callback=callbacks);

# Get the last time index and work with that.
integrator.iter = load_timestep(restart_filename)
integrator.stats.naccept = integrator.iter
load_timestep!(integrator, restart_filename)


###############################################################################
Expand Down
3 changes: 1 addition & 2 deletions examples/structured_2d_dgsem/elixir_advection_restart.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ integrator = init(ode, CarpenterKennedy2N54(williamson_condition=false),
save_everystep=false, callback=callbacks);

# Get the last time index and work with that.
integrator.iter = load_timestep(restart_filename)
integrator.stats.naccept = integrator.iter
load_timestep!(integrator, restart_filename)

###############################################################################
# run the simulation
Expand Down
3 changes: 1 addition & 2 deletions examples/structured_3d_dgsem/elixir_advection_restart.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ integrator = init(ode, CarpenterKennedy2N54(williamson_condition=false),
save_everystep=false, callback=callbacks);

# Get the last time index and work with that.
integrator.iter = load_timestep(restart_filename)
integrator.stats.naccept = integrator.iter
load_timestep!(integrator, restart_filename)


###############################################################################
Expand Down
3 changes: 1 addition & 2 deletions examples/tree_2d_dgsem/elixir_advection_restart.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ integrator = init(ode, alg,
save_everystep=false, callback=callbacks)

# Get the last time index and work with that.
integrator.iter = load_timestep(restart_filename)
integrator.stats.naccept = integrator.iter
load_timestep!(integrator, restart_filename)

###############################################################################
# run the simulation
Expand Down
3 changes: 1 addition & 2 deletions examples/tree_3d_dgsem/elixir_advection_restart.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ integrator = init(ode, CarpenterKennedy2N54(williamson_condition=false),
save_everystep=false, callback=callbacks);

# Get the last time index and work with that.
integrator.iter = load_timestep(restart_filename)
integrator.stats.naccept = integrator.iter
load_timestep!(integrator, restart_filename)


###############################################################################
Expand Down
3 changes: 1 addition & 2 deletions examples/unstructured_2d_dgsem/elixir_euler_restart.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ integrator = init(ode, CarpenterKennedy2N54(williamson_condition=false),
save_everystep=false, callback=callbacks);

# Get the last time index and work with that.
integrator.iter = load_timestep(restart_filename)
integrator.stats.naccept = integrator.iter
load_timestep!(integrator, restart_filename)


###############################################################################
Expand Down
2 changes: 1 addition & 1 deletion src/Trixi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ export SummaryCallback, SteadyStateCallback, AnalysisCallback, AliveCallback,
GlmSpeedCallback, LBMCollisionCallback, EulerAcousticsCouplingCallback,
TrivialCallback, AnalysisCallbackCoupled

export load_mesh, load_time, load_timestep, load_dt
export load_mesh, load_time, load_timestep, load_timestep!, load_dt

export ControllerThreeLevel, ControllerThreeLevelCombined,
IndicatorLöhner, IndicatorLoehner, IndicatorMax,
Expand Down
12 changes: 12 additions & 0 deletions src/callbacks_step/save_restart.jl
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,18 @@ function load_timestep(restart_file::AbstractString)
end
end

"""
load_timestep!(integrator, restart_file::AbstractString)

Load the time step number saved in a `restart_file` and assign it to both the time step
number and and the number of accepted steps
(`iter` and `stats.naccept` in OrdinaryDiffEq.jl, respectively) in `integrator`.
"""
function load_timestep!(integrator, restart_file::AbstractString)
integrator.iter = load_timestep(restart_file)
integrator.stats.naccept = integrator.iter
end

"""
load_dt(restart_file::AbstractString)

Expand Down