Path: blob/main/examples/structured_2d_dgsem/elixir_advection_waving_flag.jl
2055 views
using OrdinaryDiffEqLowStorageRK1using Trixi23###############################################################################4# semidiscretization of the linear advection equation56advection_velocity = (0.2, -0.7)7equations = LinearScalarAdvectionEquation2D(advection_velocity)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)1314# Deformed rectangle that looks like a waving flag,15# lower and upper faces are sinus curves, left and right are vertical lines.16f1(s) = SVector(-1.0, s - 1.0)17f2(s) = SVector(1.0, s + 1.0)18f3(s) = SVector(s, -1.0 + sin(0.5 * pi * s))19f4(s) = SVector(s, 1.0 + sin(0.5 * pi * s))2021cells_per_dimension = (16, 16)2223# Create curved mesh with 16 x 16 elements24mesh = StructuredMesh(cells_per_dimension, (f1, f2, f3, f4))2526# A semidiscretization collects data structures and functions for the spatial discretization27semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver)2829###############################################################################30# ODE solvers, callbacks etc.3132# Create ODE problem with time span from 0.0 to 1.033ode = semidiscretize(semi, (0.0, 1.0))3435# At the beginning of the main loop, the SummaryCallback prints a summary of the simulation setup36# and resets the timers37summary_callback = SummaryCallback()3839# The AnalysisCallback allows to analyse the solution in regular intervals and prints the results40analysis_callback = AnalysisCallback(semi, interval = 100)4142# The SaveRestartCallback allows to save a file from which a Trixi.jl simulation can be restarted43save_restart = SaveRestartCallback(interval = 100,44save_final_restart = true)4546# The SaveSolutionCallback allows to save the solution to a file in regular intervals47save_solution = SaveSolutionCallback(interval = 100,48solution_variables = cons2prim)4950# The StepsizeCallback handles the re-calculation of the maximum Δt after each time step51stepsize_callback = StepsizeCallback(cfl = 1.4)5253# Create a CallbackSet to collect all callbacks such that they can be passed to the ODE solver54callbacks = CallbackSet(summary_callback, analysis_callback, save_restart, save_solution,55stepsize_callback)5657###############################################################################58# run the simulation5960# OrdinaryDiffEq's `solve` method evolves the solution in time and executes the passed callbacks61sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);62dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback63ode_default_options()..., callback = callbacks);646566