Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/examples/t8code_3d_dgsem/elixir_advection_amr.jl
2055 views
1
# The same setup as tree_3d_dgsem/elixir_advection_amr.jl
2
# to verify the T8codeMesh implementation against TreeMesh.
3
4
using OrdinaryDiffEqLowStorageRK
5
using Trixi
6
7
###############################################################################
8
# semidiscretization of the linear advection equation
9
10
advection_velocity = (0.2, -0.7, 0.5)
11
equations = LinearScalarAdvectionEquation3D(advection_velocity)
12
13
initial_condition = initial_condition_gauss
14
solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs)
15
16
coordinates_min = (-5.0, -5.0, -5.0)
17
coordinates_max = (5.0, 5.0, 5.0)
18
trees_per_dimension = (1, 1, 1)
19
20
# Note that it is not necessary to use mesh polydeg lower than the solver polydeg
21
# on a Cartesian mesh.
22
# See https://doi.org/10.1007/s10915-018-00897-9, Section 6.
23
mesh = T8codeMesh(trees_per_dimension, polydeg = 1,
24
coordinates_min = coordinates_min, coordinates_max = coordinates_max,
25
initial_refinement_level = 4)
26
27
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver)
28
29
###############################################################################
30
# ODE solvers, callbacks etc.
31
32
tspan = (0.0, 0.3)
33
ode = semidiscretize(semi, tspan)
34
35
summary_callback = SummaryCallback()
36
37
analysis_interval = 100
38
analysis_callback = AnalysisCallback(semi, interval = analysis_interval,
39
extra_analysis_integrals = (entropy,))
40
41
alive_callback = AliveCallback(analysis_interval = analysis_interval)
42
43
save_solution = SaveSolutionCallback(interval = 100,
44
save_initial_solution = true,
45
save_final_solution = true,
46
solution_variables = cons2prim)
47
48
amr_controller = ControllerThreeLevel(semi, IndicatorMax(semi, variable = first),
49
base_level = 4,
50
med_level = 5, med_threshold = 0.1,
51
max_level = 6, max_threshold = 0.6)
52
amr_callback = AMRCallback(semi, amr_controller,
53
interval = 5,
54
adapt_initial_condition = true,
55
adapt_initial_condition_only_refine = true,
56
dynamic_load_balancing = false)
57
# We disable `dynamic_load_balancing` for now, since t8code does not support
58
# partitioning for coarsening yet. That is, a complete family of elements always
59
# stays on rank and is not split up due to partitioning. Without this feature
60
# dynamic AMR simulations are not perfectly deterministic regarding to
61
# convergent tests. Once this feature is available in t8code load balancing is
62
# enabled again.
63
64
stepsize_callback = StepsizeCallback(cfl = 1.2)
65
66
callbacks = CallbackSet(summary_callback,
67
analysis_callback,
68
alive_callback,
69
save_solution,
70
amr_callback,
71
stepsize_callback)
72
73
###############################################################################
74
# run the simulation
75
76
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);
77
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
78
ode_default_options()..., callback = callbacks);
79
80