Path: blob/main/examples/structured_2d_dgsem/elixir_advection_waving_flag.jl
5586 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), periodicity = true)2526# A semidiscretization collects data structures and functions for the spatial discretization27semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver;28boundary_conditions = boundary_condition_periodic)2930###############################################################################31# ODE solvers, callbacks etc.3233# Create ODE problem with time span from 0.0 to 1.034ode = semidiscretize(semi, (0.0, 1.0))3536# At the beginning of the main loop, the SummaryCallback prints a summary of the simulation setup37# and resets the timers38summary_callback = SummaryCallback()3940# The AnalysisCallback allows to analyse the solution in regular intervals and prints the results41analysis_callback = AnalysisCallback(semi, interval = 100)4243# The SaveRestartCallback allows to save a file from which a Trixi.jl simulation can be restarted44save_restart = SaveRestartCallback(interval = 100,45save_final_restart = true)4647# The SaveSolutionCallback allows to save the solution to a file in regular intervals48save_solution = SaveSolutionCallback(interval = 100,49solution_variables = cons2prim)5051# The StepsizeCallback handles the re-calculation of the maximum Δt after each time step52stepsize_callback = StepsizeCallback(cfl = 1.4)5354# Create a CallbackSet to collect all callbacks such that they can be passed to the ODE solver55callbacks = CallbackSet(summary_callback, analysis_callback, save_restart, save_solution,56stepsize_callback)5758###############################################################################59# run the simulation6061# OrdinaryDiffEq's `solve` method evolves the solution in time and executes the passed callbacks62sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);63dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback64ode_default_options()..., callback = callbacks);656667