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_convergence.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.0, c_mean_global = 1.0,
8
rho_mean_global = 1.0)
9
10
initial_condition = initial_condition_convergence_test
11
12
# Create DG solver with polynomial degree = 3 and (local) Lax-Friedrichs/Rusanov flux as surface flux
13
solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs)
14
15
coordinates_min = (-1.0)
16
coordinates_max = (1.0)
17
18
# Create a uniformly refined mesh with periodic boundaries
19
mesh = TreeMesh(coordinates_min, coordinates_max,
20
initial_refinement_level = 4,
21
n_cells_max = 30_000)
22
23
# A semidiscretization collects data structures and functions for the spatial discretization
24
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver)
25
26
###############################################################################
27
# ODE solvers, callbacks etc.
28
29
tspan = (0.0, 1.0)
30
ode = semidiscretize(semi, tspan)
31
32
# At the beginning of the main loop, the SummaryCallback prints a summary of the simulation setup
33
# and resets the timers
34
summary_callback = SummaryCallback()
35
36
analysis_interval = 100
37
38
# The AnalysisCallback allows to analyse the solution in regular intervals and prints the results
39
analysis_callback = AnalysisCallback(semi, interval = analysis_interval)
40
41
# The AliveCallback prints short status information in regular intervals
42
alive_callback = AliveCallback(analysis_interval = analysis_interval)
43
44
# The StepsizeCallback handles the re-calculation of the maximum Δt after each time step
45
stepsize_callback = StepsizeCallback(cfl = 0.8)
46
47
# Create a CallbackSet to collect all callbacks such that they can be passed to the ODE solver
48
callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback,
49
stepsize_callback)
50
51
###############################################################################
52
# run the simulation
53
54
# OrdinaryDiffEq's `solve` method evolves the solution in time and executes the passed callbacks
55
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);
56
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
57
ode_default_options()..., callback = callbacks);
58
59