Path: blob/main/examples/tree_2d_dgsem/elixir_advection_restart_amr.jl
2055 views
using OrdinaryDiffEqLowStorageRK1using Trixi23###############################################################################4# Define time integration algorithm5alg = CarpenterKennedy2N54(williamson_condition = false)6# Create a restart file7trixi_include(@__MODULE__, joinpath(@__DIR__, "elixir_advection_extended.jl"), alg = alg,8tspan = (0.0, 3.0))910###############################################################################11# adapt the parameters that have changed compared to "elixir_advection_extended.jl"1213# Note: If you get a restart file from somewhere else, you need to provide14# appropriate setups in the elixir loading a restart file1516restart_filename = joinpath("out", "restart_000000040.h5")17mesh = load_mesh(restart_filename)1819semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver)2021tspan = (load_time(restart_filename), 5.0)22dt = load_dt(restart_filename)23ode = semidiscretize(semi, tspan, restart_filename)2425# Do not overwrite the initial snapshot written by elixir_advection_extended.jl.26save_solution.condition.save_initial_solution = false2728# Add AMR callback29amr_controller = ControllerThreeLevel(semi, IndicatorMax(semi, variable = first),30base_level = 3,31med_level = 4, med_threshold = 0.8,32max_level = 5, max_threshold = 1.2)33amr_callback = AMRCallback(semi, amr_controller,34interval = 5,35adapt_initial_condition = true,36adapt_initial_condition_only_refine = true)37callbacks_ext = CallbackSet(amr_callback, callbacks.discrete_callbacks...)3839integrator = init(ode, alg;40dt = dt, # solve needs some value here but it will be overwritten by the stepsize_callback41ode_default_options()..., callback = callbacks_ext, maxiters = 100_000)4243# Load saved context for adaptive time integrator44if integrator.opts.adaptive45load_adaptive_time_integrator!(integrator, restart_filename)46end4748# Get the last time index and work with that.49load_timestep!(integrator, restart_filename)5051###############################################################################52# run the simulation5354sol = solve!(integrator)555657