Path: blob/main/examples/tree_3d_dgsem/elixir_euler_amr.jl
2055 views
using OrdinaryDiffEqLowStorageRK1using Trixi23###############################################################################4# semidiscretization of the compressible Euler equations56equations = CompressibleEulerEquations3D(1.4)78"""9initial_condition_density_pulse(x, t, equations::CompressibleEulerEquations3D)1011A Gaussian pulse in the density with constant velocity and pressure; reduces the12compressible Euler equations to the linear advection equations.13"""14function initial_condition_density_pulse(x, t, equations::CompressibleEulerEquations3D)15rho = 1 + exp(-(x[1]^2 + x[2]^2 + x[3]^2)) / 216v1 = 117v2 = 118v3 = 119rho_v1 = rho * v120rho_v2 = rho * v221rho_v3 = rho * v322p = 123rho_e = p / (equations.gamma - 1) + 1 / 2 * rho * (v1^2 + v2^2 + v3^2)24return SVector(rho, rho_v1, rho_v2, rho_v3, rho_e)25end26initial_condition = initial_condition_density_pulse27# Up to version 0.13.0, `max_abs_speed_naive` was used as the default wave speed estimate of28# `const flux_lax_friedrichs = FluxLaxFriedrichs(), i.e., `FluxLaxFriedrichs(max_abs_speed = max_abs_speed_naive)`.29# In the `StepsizeCallback`, though, the less diffusive `max_abs_speeds` is employed which is consistent with `max_abs_speed`.30# Thus, we exchanged in PR#2458 the default wave speed used in the LLF flux to `max_abs_speed`.31# To ensure that every example still runs we specify explicitly `FluxLaxFriedrichs(max_abs_speed_naive)`.32# We remark, however, that the now default `max_abs_speed` is in general recommended due to compliance with the33# `StepsizeCallback` (CFL-Condition) and less diffusion.34solver = DGSEM(polydeg = 3, surface_flux = FluxLaxFriedrichs(max_abs_speed_naive))3536coordinates_min = (-5.0, -5.0, -5.0)37coordinates_max = (5.0, 5.0, 5.0)38mesh = TreeMesh(coordinates_min, coordinates_max,39initial_refinement_level = 4,40n_cells_max = 10_000)4142semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver)4344###############################################################################45# ODE solvers, callbacks etc.4647tspan = (0.0, 10.0)48ode = semidiscretize(semi, tspan)4950summary_callback = SummaryCallback()5152analysis_interval = 10053analysis_callback = AnalysisCallback(semi, interval = analysis_interval,54extra_analysis_integrals = (entropy,))5556alive_callback = AliveCallback(analysis_interval = analysis_interval)5758save_restart = SaveRestartCallback(interval = 100,59save_final_restart = true)6061save_solution = SaveSolutionCallback(interval = 100,62save_initial_solution = true,63save_final_solution = true,64solution_variables = cons2prim)6566amr_controller = ControllerThreeLevel(semi, IndicatorMax(semi, variable = first),67base_level = 4,68med_level = 5, med_threshold = 1.05,69max_level = 6, max_threshold = 1.3)70amr_callback = AMRCallback(semi, amr_controller,71interval = 5,72adapt_initial_condition = true,73adapt_initial_condition_only_refine = true)7475stepsize_callback = StepsizeCallback(cfl = 0.9)7677callbacks = CallbackSet(summary_callback,78analysis_callback, alive_callback,79save_restart, save_solution,80amr_callback, stepsize_callback);8182###############################################################################83# run the simulation8485sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);86dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback87ode_default_options()..., callback = callbacks);888990