Path: blob/main/examples/t8code_2d_dgsem/elixir_advection_restart_amr.jl
5586 views
using OrdinaryDiffEqLowStorageRK1using Trixi2using Accessors: @reset34###############################################################################5# create a restart file67elixir_file = "elixir_advection_extended.jl"8restart_file = "restart_000000021.h5"910trixi_include(@__MODULE__, joinpath(@__DIR__, elixir_file))1112###############################################################################13# adapt the parameters that have changed compared to "elixir_advection_extended.jl"1415# Note: If you get a restart file from somewhere else, you need to provide16# appropriate setups in the elixir loading a restart file1718restart_filename = joinpath("out", restart_file)19mesh = load_mesh(restart_filename)2021semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver;22boundary_conditions = boundary_conditions)2324tspan = (load_time(restart_filename), 2.0)25dt = load_dt(restart_filename)26ode = semidiscretize(semi, tspan, restart_filename)2728# Do not overwrite the initial snapshot written by elixir_advection_extended.jl.29@reset save_solution.condition.save_initial_solution = false3031# Add AMR callback32amr_controller = ControllerThreeLevel(semi, IndicatorMax(semi, variable = first),33base_level = 0,34med_level = 0, med_threshold = 0.8,35max_level = 1, max_threshold = 1.2)36amr_callback = AMRCallback(semi, amr_controller,37interval = 5,38adapt_initial_condition = true,39adapt_initial_condition_only_refine = true,40dynamic_load_balancing = false)41# We disable `dynamic_load_balancing` for now, since t8code does not support42# partitioning for coarsening yet. That is, a complete family of elements always43# stays on rank and is not split up due to partitioning. Without this feature44# dynamic AMR simulations are not perfectly deterministic regarding to45# convergent tests. Once this feature is available in t8code load balancing is46# enabled again.4748callbacks_ext = CallbackSet(amr_callback, callbacks.discrete_callbacks...)4950integrator = init(ode, CarpenterKennedy2N54(williamson_condition = false);51dt = dt, # solve needs some value here but it will be overwritten by the stepsize_callback52ode_default_options()..., callback = callbacks_ext, maxiters = 100_000);5354# Get the last time index and work with that.55load_timestep!(integrator, restart_filename)5657###############################################################################58# run the simulation5960sol = solve!(integrator)616263