Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/examples/tree_3d_dgsem/elixir_linearizedeuler_gauss_wall.jl
2055 views
1
using OrdinaryDiffEqLowStorageRK
2
using Trixi
3
4
###############################################################################
5
# semidiscretization of the linearized Euler equations
6
7
equations = LinearizedEulerEquations3D(v_mean_global = (0.5, 0.5, 0.5), c_mean_global = 1.0,
8
rho_mean_global = 1.0)
9
10
solver = DGSEM(polydeg = 5, surface_flux = flux_lax_friedrichs)
11
12
coordinates_min = (0.0, 0.0, 0.0)
13
coordinates_max = (90.0, 90.0, 90.0)
14
15
mesh = TreeMesh(coordinates_min, coordinates_max,
16
initial_refinement_level = 4,
17
n_cells_max = 100_000,
18
periodicity = false)
19
20
# Initialize density and pressure perturbation with a Gaussian bump
21
# that splits into radial waves which are advected with v - c and v + c.
22
function initial_condition_gauss_wall(x, t, equations::LinearizedEulerEquations3D)
23
v1_prime = 0.0
24
v2_prime = 0.0
25
v3_prime = 0.0
26
rho_prime = p_prime = 2 * exp(-((x[1] - 45)^2 + (x[2] - 45)^2) / 25)
27
return SVector(rho_prime, v1_prime, v2_prime, v3_prime, p_prime)
28
end
29
initial_condition = initial_condition_gauss_wall
30
31
# A semidiscretization collects data structures and functions for the spatial discretization
32
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver,
33
boundary_conditions = boundary_condition_wall)
34
35
###############################################################################
36
# ODE solvers, callbacks etc.
37
38
# At t = 30, the wave moving with v + c crashes into the wall
39
tspan = (0.0, 30.0)
40
ode = semidiscretize(semi, tspan)
41
42
# At the beginning of the main loop, the SummaryCallback prints a summary of the simulation setup
43
# and resets the timers
44
summary_callback = SummaryCallback()
45
46
# The AnalysisCallback allows to analyse the solution in regular intervals and prints the results
47
analysis_callback = AnalysisCallback(semi, interval = 100)
48
49
# The StepsizeCallback handles the re-calculation of the maximum Δt after each time step
50
stepsize_callback = StepsizeCallback(cfl = 0.9)
51
52
# Create a CallbackSet to collect all callbacks such that they can be passed to the ODE solver
53
callbacks = CallbackSet(summary_callback, analysis_callback,
54
stepsize_callback)
55
56
###############################################################################
57
# run the simulation
58
59
# OrdinaryDiffEq's `solve` method evolves the solution in time and executes the passed callbacks
60
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);
61
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
62
ode_default_options()..., callback = callbacks)
63
64