Path: blob/main/examples/unstructured_2d_dgsem/elixir_euler_time_series.jl
2055 views
# An elixir that has an alternative convergence test that uses1# the `TimeSeriesCallback` on several gauge points. Many of the2# gauge points are selected as "stress tests" for the element3# identification, e.g., a gauge point that lies on an4# element corner of a curvilinear mesh56using OrdinaryDiffEqLowStorageRK7using Trixi89###############################################################################10# semidiscretization of the compressible Euler equations1112equations = CompressibleEulerEquations2D(1.4)1314# Modify the manufactured solution test to use `L = sqrt(2)`15# in the initial condition and source terms16function initial_condition_convergence_shifted(x, t,17equations::CompressibleEulerEquations2D)18c = 219A = 0.120L = sqrt(2)21f = 1 / L22ω = 2 * pi * f23ini = c + A * sin(ω * (x[1] + x[2] - t))2425rho = ini26rho_v1 = ini27rho_v2 = ini28rho_e = ini^22930return SVector(rho, rho_v1, rho_v2, rho_e)31end3233@inline function source_terms_convergence_shifted(u, x, t,34equations::CompressibleEulerEquations2D)35# Same settings as in `initial_condition`36c = 237A = 0.138L = sqrt(2)39f = 1 / L40ω = 2 * pi * f41γ = equations.gamma4243x1, x2 = x44si, co = sincos(ω * (x1 + x2 - t))45rho = c + A * si46rho_x = ω * A * co47# Note that d/dt rho = -d/dx rho = -d/dy rho.4849tmp = (2 * rho - 1) * (γ - 1)5051du1 = rho_x52du2 = rho_x * (1 + tmp)53du3 = du254du4 = 2 * rho_x * (rho + tmp)5556return SVector(du1, du2, du3, du4)57end5859initial_condition = initial_condition_convergence_shifted6061source_term = source_terms_convergence_shifted6263###############################################################################64# Get the DG approximation space6566# Up to version 0.13.0, `max_abs_speed_naive` was used as the default wave speed estimate of67# `const flux_lax_friedrichs = FluxLaxFriedrichs(), i.e., `FluxLaxFriedrichs(max_abs_speed = max_abs_speed_naive)`.68# In the `StepsizeCallback`, though, the less diffusive `max_abs_speeds` is employed which is consistent with `max_abs_speed`.69# Thus, we exchanged in PR#2458 the default wave speed used in the LLF flux to `max_abs_speed`.70# To ensure that every example still runs we specify explicitly `FluxLaxFriedrichs(max_abs_speed_naive)`.71# We remark, however, that the now default `max_abs_speed` is in general recommended due to compliance with the72# `StepsizeCallback` (CFL-Condition) and less diffusion.73solver = DGSEM(polydeg = 6, surface_flux = FluxLaxFriedrichs(max_abs_speed_naive))7475###############################################################################76# Get the curved quad mesh from a file (downloads the file if not available locally)7778mesh_file = Trixi.download("https://gist.githubusercontent.com/andrewwinters5000/b434e724e3972a9c4ee48d58c80cdcdb/raw/55c916cd8c0294a2d4a836e960dac7247b7c8ccf/mesh_multiple_flips.mesh",79joinpath(@__DIR__, "mesh_multiple_flips.mesh"))8081mesh = UnstructuredMesh2D(mesh_file, periodicity = true)8283###############################################################################84# create the semi discretization object8586semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver,87source_terms = source_term)8889###############################################################################90# ODE solvers, callbacks etc.9192tspan = (0.0, 1.0)93ode = semidiscretize(semi, tspan)9495summary_callback = SummaryCallback()9697analysis_interval = 100098analysis_callback = AnalysisCallback(semi, interval = analysis_interval)99100alive_callback = AliveCallback(analysis_interval = analysis_interval)101102time_series = TimeSeriesCallback(semi,103[(0.75, 0.7), (1.23, 0.302), (0.8, 1.0),104(0.353553390593274, 0.353553390593274),105(0.505, 1.125), (1.37, 0.89), (0.349, 0.7153),106(0.883883476483184, 0.406586401289607),107(sqrt(2), sqrt(2))];108interval = 10)109110callbacks = CallbackSet(summary_callback,111analysis_callback,112time_series,113alive_callback)114115###############################################################################116# run the simulation117118sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-6, reltol = 1.0e-6,119ode_default_options()..., callback = callbacks);120121122