Path: blob/main/examples/tree_2d_dgsem/elixir_advection_restart_amr.jl
5586 views
using OrdinaryDiffEqLowStorageRK1using Trixi2using Accessors: @reset34###############################################################################5# Define time integration algorithm6alg = CarpenterKennedy2N54(williamson_condition = false)7# Create a restart file8trixi_include(@__MODULE__, joinpath(@__DIR__, "elixir_advection_extended.jl"), alg = alg,9tspan = (0.0, 3.0))1011###############################################################################12# adapt the parameters that have changed compared to "elixir_advection_extended.jl"1314# Note: If you get a restart file from somewhere else, you need to provide15# appropriate setups in the elixir loading a restart file1617restart_filename = joinpath("out", "restart_000000040.h5")18mesh = load_mesh(restart_filename)1920semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver;21boundary_conditions = boundary_condition_periodic)2223tspan = (load_time(restart_filename), 5.0)24dt = load_dt(restart_filename)25ode = semidiscretize(semi, tspan, restart_filename)2627# Do not overwrite the initial snapshot written by elixir_advection_extended.jl.28@reset save_solution.condition.save_initial_solution = false2930# Add AMR callback31amr_controller = ControllerThreeLevel(semi, IndicatorMax(semi, variable = first),32base_level = 3,33med_level = 4, med_threshold = 0.8,34max_level = 5, max_threshold = 1.2)35amr_callback = AMRCallback(semi, amr_controller,36interval = 5,37adapt_initial_condition = true,38adapt_initial_condition_only_refine = true)39callbacks_ext = CallbackSet(amr_callback, callbacks.discrete_callbacks...)4041integrator = init(ode, alg;42dt = dt, # solve needs some value here but it will be overwritten by the stepsize_callback43ode_default_options()..., callback = callbacks_ext, maxiters = 100_000)4445# Load saved context for adaptive time integrator46if integrator.opts.adaptive47load_adaptive_time_integrator!(integrator, restart_filename)48end4950# Get the last time index and work with that.51load_timestep!(integrator, restart_filename)5253###############################################################################54# run the simulation5556sol = solve!(integrator)575859