Path: blob/main/examples/structured_1d_dgsem/elixir_advection_basic.jl
2055 views
# The same setup as tree_1d_dgsem/elixir_advection_basic.jl1# to verify the StructuredMesh implementation against TreeMesh23using OrdinaryDiffEqLowStorageRK4using Trixi56###############################################################################7# semidiscretization of the linear advection equation89advection_velocity = 1.010equations = LinearScalarAdvectionEquation1D(advection_velocity)1112# Create DG solver with polynomial degree = 3 and (local) Lax-Friedrichs/Rusanov flux as surface flux13solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs)1415coordinates_min = (-1.0,) # minimum coordinate16coordinates_max = (1.0,) # maximum coordinate17cells_per_dimension = (16,)1819# Create curved mesh with 16 cells20mesh = StructuredMesh(cells_per_dimension, coordinates_min, coordinates_max)2122# A semidiscretization collects data structures and functions for the spatial discretization23semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test,24solver)2526###############################################################################27# ODE solvers, callbacks etc.2829# Create ODE problem with time span from 0.0 to 1.030ode = semidiscretize(semi, (0.0, 1.0))3132# At the beginning of the main loop, the SummaryCallback prints a summary of the simulation setup33# and resets the timers34summary_callback = SummaryCallback()3536# The AnalysisCallback allows to analyse the solution in regular intervals and prints the results37analysis_callback = AnalysisCallback(semi, interval = 100)3839# The SaveSolutionCallback allows to save the solution to a file in regular intervals40save_solution = SaveSolutionCallback(interval = 100,41solution_variables = cons2prim)4243# The StepsizeCallback handles the re-calculation of the maximum Δt after each time step44stepsize_callback = StepsizeCallback(cfl = 1.6)4546# Create a CallbackSet to collect all callbacks such that they can be passed to the ODE solver47callbacks = CallbackSet(summary_callback, analysis_callback, save_solution,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