Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/examples/tree_2d_dgsem/elixir_advection_restart.jl
5586 views
1
using OrdinaryDiffEqLowStorageRK
2
using Trixi
3
using Accessors: @reset
4
5
###############################################################################
6
# Define time integration algorithm
7
alg = CarpenterKennedy2N54(williamson_condition = false)
8
# Create a restart file
9
base_elixir = "elixir_advection_extended.jl"
10
trixi_include(@__MODULE__, joinpath(@__DIR__, base_elixir), alg = alg,
11
tspan = (0.0, 10.0))
12
13
###############################################################################
14
# adapt the parameters that have changed compared to "elixir_advection_extended.jl"
15
16
# Note: If you get a restart file from somewhere else, you need to provide
17
# appropriate setups in the elixir loading a restart file
18
19
restart_filename = joinpath("out", "restart_000000040.h5")
20
mesh = load_mesh(restart_filename)
21
22
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver;
23
boundary_conditions = boundary_condition_periodic)
24
25
tspan = (load_time(restart_filename), 10.0)
26
dt = load_dt(restart_filename)
27
ode = semidiscretize(semi, tspan, restart_filename)
28
29
# Do not overwrite the initial snapshot written by elixir_advection_extended.jl.
30
@reset save_solution.condition.save_initial_solution = false
31
32
integrator = init(ode, alg;
33
dt = dt, # solve needs some value here but it will be overwritten by the stepsize_callback
34
callback = callbacks,
35
ode_default_options()...); # default options because an adaptive time stepping method is used in test_mpi_tree.jl
36
37
# Load saved context for adaptive time integrator
38
if integrator.opts.adaptive
39
load_adaptive_time_integrator!(integrator, restart_filename)
40
end
41
42
# Get the last time index and work with that.
43
load_timestep!(integrator, restart_filename)
44
45
###############################################################################
46
# run the simulation
47
48
sol = solve!(integrator)
49
50