Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/examples/p4est_3d_dgsem/elixir_linearizedeuler_convergence.jl
5586 views
1
using OrdinaryDiffEqLowStorageRK
2
using Trixi
3
4
###############################################################################
5
# semidiscretization of the linearized Euler equations
6
7
equations = LinearizedEulerEquations3D(v_mean_global = (0.0, 0.0, 0.0), c_mean_global = 1.0,
8
rho_mean_global = 1.0)
9
10
initial_condition = initial_condition_convergence_test
11
12
solver = DGSEM(polydeg = 3, surface_flux = flux_hll)
13
14
coordinates_min = (-1.0, -1.0, -1.0) # minimum coordinates (min(x), min(y), min(z))
15
coordinates_max = (1.0, 1.0, 1.0) # maximum coordinates (max(x), max(y), max(z))
16
17
# `initial_refinement_level` is provided here to allow for a
18
# convenient convergence test, see
19
# https://trixi-framework.github.io/TrixiDocumentation/stable/#Performing-a-convergence-analysis
20
trees_per_dimension = (4, 4, 4)
21
mesh = P4estMesh(trees_per_dimension, polydeg = 3,
22
coordinates_min = coordinates_min,
23
coordinates_max = coordinates_max,
24
initial_refinement_level = 0,
25
periodicity = true)
26
27
# A semidiscretization collects data structures and functions for the spatial discretization
28
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver;
29
boundary_conditions = boundary_condition_periodic)
30
31
###############################################################################
32
# ODE solvers, callbacks etc.
33
34
# Create ODE problem with time span from 0.0 to 0.2
35
tspan = (0.0, 0.2)
36
ode = semidiscretize(semi, tspan)
37
38
# At the beginning of the main loop, the SummaryCallback prints a summary of the simulation setup
39
# and resets the timers
40
summary_callback = SummaryCallback()
41
42
analysis_interval = 100
43
44
# The AnalysisCallback allows to analyse the solution in regular intervals and prints the results
45
analysis_callback = AnalysisCallback(semi, interval = analysis_interval)
46
47
# The AliveCallback prints short status information in regular intervals
48
alive_callback = AliveCallback(analysis_interval = analysis_interval)
49
50
# The StepsizeCallback handles the re-calculation of the maximum Δt after each time step
51
stepsize_callback = StepsizeCallback(cfl = 0.8)
52
53
# Create a CallbackSet to collect all callbacks such that they can be passed to the ODE solver
54
callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback,
55
stepsize_callback)
56
57
###############################################################################
58
# run the simulation
59
60
# OrdinaryDiffEq's `solve` method evolves the solution in time and executes the passed callbacks
61
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);
62
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
63
ode_default_options()..., callback = callbacks);
64
65