Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/examples/t8code_2d_dgsem/elixir_eulergravity_convergence.jl
5585 views
1
using OrdinaryDiffEqLowStorageRK
2
using Trixi
3
4
initial_condition = initial_condition_eoc_test_coupled_euler_gravity
5
6
###############################################################################
7
# semidiscretization of the compressible Euler equations
8
gamma = 2.0
9
equations_euler = CompressibleEulerEquations2D(gamma)
10
11
polydeg = 3
12
solver_euler = DGSEM(polydeg, FluxHLL(min_max_speed_naive))
13
14
coordinates_min = (0.0, 0.0)
15
coordinates_max = (2.0, 2.0)
16
17
trees_per_dimension = (1, 1)
18
19
mesh = T8codeMesh(trees_per_dimension, polydeg = 1,
20
coordinates_min = coordinates_min, coordinates_max = coordinates_max,
21
initial_refinement_level = 2,
22
periodicity = true)
23
24
semi_euler = SemidiscretizationHyperbolic(mesh, equations_euler, initial_condition,
25
solver_euler;
26
source_terms = source_terms_eoc_test_coupled_euler_gravity,
27
boundary_conditions = boundary_condition_periodic)
28
29
###############################################################################
30
# semidiscretization of the hyperbolic diffusion equations
31
equations_gravity = HyperbolicDiffusionEquations2D()
32
33
# Up to version 0.13.0, `max_abs_speed_naive` was used as the default wave speed estimate of
34
# `const flux_lax_friedrichs = FluxLaxFriedrichs(), i.e., `FluxLaxFriedrichs(max_abs_speed = max_abs_speed_naive)`.
35
# In the `StepsizeCallback`, though, the less diffusive `max_abs_speeds` is employed which is consistent with `max_abs_speed`.
36
# Thus, we exchanged in PR#2458 the default wave speed used in the LLF flux to `max_abs_speed`.
37
# To ensure that every example still runs we specify explicitly `FluxLaxFriedrichs(max_abs_speed_naive)`.
38
# We remark, however, that the now default `max_abs_speed` is in general recommended due to compliance with the
39
# `StepsizeCallback` (CFL-Condition) and less diffusion.
40
solver_gravity = DGSEM(polydeg, FluxLaxFriedrichs(max_abs_speed_naive))
41
42
semi_gravity = SemidiscretizationHyperbolic(mesh, equations_gravity, initial_condition,
43
solver_gravity;
44
source_terms = source_terms_harmonic,
45
boundary_conditions = boundary_condition_periodic)
46
47
###############################################################################
48
# combining both semidiscretizations for Euler + self-gravity
49
parameters = ParametersEulerGravity(background_density = 2.0, # aka rho0
50
# rho0 is (ab)used to add a "+8π" term to the source terms
51
# for the manufactured solution
52
gravitational_constant = 1.0, # aka G
53
cfl = 1.1,
54
resid_tol = 1.0e-10,
55
n_iterations_max = 1000,
56
timestep_gravity = timestep_gravity_erk52_3Sstar!)
57
58
semi = SemidiscretizationEulerGravity(semi_euler, semi_gravity, parameters)
59
60
###############################################################################
61
# ODE solvers, callbacks etc.
62
tspan = (0.0, 0.5)
63
ode = semidiscretize(semi, tspan)
64
65
summary_callback = SummaryCallback()
66
67
stepsize_callback = StepsizeCallback(cfl = 0.8)
68
69
save_solution = SaveSolutionCallback(interval = 10,
70
save_initial_solution = true,
71
save_final_solution = true,
72
solution_variables = cons2prim)
73
74
save_restart = SaveRestartCallback(interval = 100,
75
save_final_restart = true)
76
77
analysis_interval = 100
78
alive_callback = AliveCallback(analysis_interval = analysis_interval)
79
80
analysis_callback = AnalysisCallback(semi_euler, interval = analysis_interval,
81
save_analysis = true)
82
83
callbacks = CallbackSet(summary_callback, stepsize_callback,
84
save_restart, save_solution,
85
analysis_callback, alive_callback)
86
87
###############################################################################
88
# run the simulation
89
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);
90
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
91
ode_default_options()..., callback = callbacks);
92
93
println("Number of gravity subcycles: ", semi.gravity_counter.ncalls_since_readout)
94
95