Path: blob/main/examples/tree_1d_dgsem/elixir_linearizedeuler_gauss_wall.jl
2055 views
using OrdinaryDiffEqLowStorageRK1using Trixi23###############################################################################4# semidiscretization of the linearized Euler equations56equations = LinearizedEulerEquations1D(v_mean_global = 0.5, c_mean_global = 1.0,7rho_mean_global = 1.0)89solver = DGSEM(polydeg = 5, surface_flux = flux_hll)1011coordinates_min = (0.0,)12coordinates_max = (90.0,)1314mesh = TreeMesh(coordinates_min, coordinates_max,15initial_refinement_level = 6,16n_cells_max = 100_000,17periodicity = false)1819# Initialize density and pressure perturbation with a Gaussian bump20# that is advected to left with v - c and to the right with v + c.21# Correspondigly, the bump splits in half.22function initial_condition_gauss_wall(x, t, equations::LinearizedEulerEquations1D)23v1_prime = 024rho_prime = p_prime = 2 * exp(-(x[1] - 45)^2 / 25)25return SVector(rho_prime, v1_prime, p_prime)26end27initial_condition = initial_condition_gauss_wall2829# A semidiscretization collects data structures and functions for the spatial discretization30semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver,31boundary_conditions = boundary_condition_wall)3233###############################################################################34# ODE solvers, callbacks etc.3536# Create ODE problem with time span from 0.0 to 30.037tspan = (0.0, 30.0)38ode = semidiscretize(semi, tspan)3940# At the beginning of the main loop, the SummaryCallback prints a summary of the simulation setup41# and resets the timers42summary_callback = SummaryCallback()4344# The AnalysisCallback allows to analyse the solution in regular intervals and prints the results45analysis_callback = AnalysisCallback(semi, interval = 100)4647# The StepsizeCallback handles the re-calculation of the maximum Δt after each time step48stepsize_callback = StepsizeCallback(cfl = 0.7)4950# Create a CallbackSet to collect all callbacks such that they can be passed to the ODE solver51callbacks = CallbackSet(summary_callback, analysis_callback,52stepsize_callback)5354###############################################################################55# run the simulation5657# OrdinaryDiffEq's `solve` method evolves the solution in time and executes the passed callbacks58sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);59dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback60ode_default_options()..., callback = callbacks)616263