Path: blob/main/examples/tree_1d_dgsem/elixir_linearizedeuler_convergence.jl
2055 views
using OrdinaryDiffEqLowStorageRK1using Trixi23###############################################################################4# semidiscretization of the linearized Euler equations56equations = LinearizedEulerEquations1D(v_mean_global = 0.0, c_mean_global = 1.0,7rho_mean_global = 1.0)89initial_condition = initial_condition_convergence_test1011# Create DG solver with polynomial degree = 3 and (local) Lax-Friedrichs/Rusanov flux as surface flux12solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs)1314coordinates_min = (-1.0)15coordinates_max = (1.0)1617# Create a uniformly refined mesh with periodic boundaries18mesh = TreeMesh(coordinates_min, coordinates_max,19initial_refinement_level = 4,20n_cells_max = 30_000)2122# A semidiscretization collects data structures and functions for the spatial discretization23semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver)2425###############################################################################26# ODE solvers, callbacks etc.2728tspan = (0.0, 1.0)29ode = semidiscretize(semi, tspan)3031# At the beginning of the main loop, the SummaryCallback prints a summary of the simulation setup32# and resets the timers33summary_callback = SummaryCallback()3435analysis_interval = 1003637# The AnalysisCallback allows to analyse the solution in regular intervals and prints the results38analysis_callback = AnalysisCallback(semi, interval = analysis_interval)3940# The AliveCallback prints short status information in regular intervals41alive_callback = AliveCallback(analysis_interval = analysis_interval)4243# The StepsizeCallback handles the re-calculation of the maximum Δt after each time step44stepsize_callback = StepsizeCallback(cfl = 0.8)4546# Create a CallbackSet to collect all callbacks such that they can be passed to the ODE solver47callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback,48stepsize_callback)4950###############################################################################51# run the simulation5253# OrdinaryDiffEq's `solve` method evolves the solution in time and executes the passed callbacks54sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);55dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback56ode_default_options()..., callback = callbacks);575859