Path: blob/main/examples/tree_3d_dgsem/elixir_linearizedeuler_gauss_wall.jl
2055 views
using OrdinaryDiffEqLowStorageRK1using Trixi23###############################################################################4# semidiscretization of the linearized Euler equations56equations = LinearizedEulerEquations3D(v_mean_global = (0.5, 0.5, 0.5), c_mean_global = 1.0,7rho_mean_global = 1.0)89solver = DGSEM(polydeg = 5, surface_flux = flux_lax_friedrichs)1011coordinates_min = (0.0, 0.0, 0.0)12coordinates_max = (90.0, 90.0, 90.0)1314mesh = TreeMesh(coordinates_min, coordinates_max,15initial_refinement_level = 4,16n_cells_max = 100_000,17periodicity = false)1819# Initialize density and pressure perturbation with a Gaussian bump20# that splits into radial waves which are advected with v - c and v + c.21function initial_condition_gauss_wall(x, t, equations::LinearizedEulerEquations3D)22v1_prime = 0.023v2_prime = 0.024v3_prime = 0.025rho_prime = p_prime = 2 * exp(-((x[1] - 45)^2 + (x[2] - 45)^2) / 25)26return SVector(rho_prime, v1_prime, v2_prime, v3_prime, p_prime)27end28initial_condition = initial_condition_gauss_wall2930# A semidiscretization collects data structures and functions for the spatial discretization31semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver,32boundary_conditions = boundary_condition_wall)3334###############################################################################35# ODE solvers, callbacks etc.3637# At t = 30, the wave moving with v + c crashes into the wall38tspan = (0.0, 30.0)39ode = semidiscretize(semi, tspan)4041# At the beginning of the main loop, the SummaryCallback prints a summary of the simulation setup42# and resets the timers43summary_callback = SummaryCallback()4445# The AnalysisCallback allows to analyse the solution in regular intervals and prints the results46analysis_callback = AnalysisCallback(semi, interval = 100)4748# The StepsizeCallback handles the re-calculation of the maximum Δt after each time step49stepsize_callback = StepsizeCallback(cfl = 0.9)5051# Create a CallbackSet to collect all callbacks such that they can be passed to the ODE solver52callbacks = CallbackSet(summary_callback, analysis_callback,53stepsize_callback)5455###############################################################################56# run the simulation5758# OrdinaryDiffEq's `solve` method evolves the solution in time and executes the passed callbacks59sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);60dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback61ode_default_options()..., callback = callbacks)626364