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