• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

trixi-framework / Trixi.jl / 21639639306

03 Feb 2026 05:01PM UTC coverage: 14.281% (-82.8%) from 97.034%
21639639306

Pull #2601

github

web-flow
Merge fd2e0cdf8 into ead0db32a
Pull Request #2601: Adaptive Volume Integral

28 of 281 new or added lines in 41 files covered. (9.96%)

36284 existing lines in 548 files now uncovered.

6317 of 44235 relevant lines covered (14.28%)

100377.05 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/examples/tree_2d_dgsem/elixir_euler_vortex_mortar_split.jl
1
using OrdinaryDiffEqLowStorageRK
2
using Trixi
3

4
###############################################################################
5
# semidiscretization of the compressible Euler equations
6

7
equations = CompressibleEulerEquations2D(1.4)
8

9
"""
10
    initial_condition_isentropic_vortex(x, t, equations::CompressibleEulerEquations2D)
11

12
The classical isentropic vortex test case of
13
- Chi-Wang Shu (1997)
14
  Essentially Non-Oscillatory and Weighted Essentially Non-Oscillatory
15
  Schemes for Hyperbolic Conservation Laws
16
  [NASA/CR-97-206253](https://ntrs.nasa.gov/citations/19980007543)
17
"""
UNCOV
18
function initial_condition_isentropic_vortex(x, t, equations::CompressibleEulerEquations2D)
×
19
    # needs appropriate mesh size, e.g. [-10,-10]x[10,10]
20
    # for error convergence: make sure that the end time is such that the vortex is back at the initial state!!
21
    # for the current velocity and domain size: t_end should be a multiple of 20s
22
    # initial center of the vortex
UNCOV
23
    RealT = eltype(x)
×
UNCOV
24
    inicenter = SVector(0, 0)
×
25
    # size and strength of the vortex
UNCOV
26
    iniamplitude = 5
×
27
    # base flow
UNCOV
28
    rho = 1
×
UNCOV
29
    v1 = 1
×
UNCOV
30
    v2 = 1
×
UNCOV
31
    vel = SVector(v1, v2)
×
UNCOV
32
    p = convert(RealT, 25)
×
UNCOV
33
    rt = p / rho                  # ideal gas equation
×
UNCOV
34
    t_loc = 0
×
UNCOV
35
    cent = inicenter + vel * t_loc      # advection of center
×
36
    # ATTENTION: handle periodic BC, but only for v1 = v2 = 1.0 (!!!!)
UNCOV
37
    cent = x - cent # distance to center point
×
38
    # cent = cross(iniaxis, cent) # distance to axis, tangent vector, length r
39
    # cross product with iniaxis = [0, 0, 1]
UNCOV
40
    cent = SVector(-cent[2], cent[1])
×
UNCOV
41
    r2 = cent[1]^2 + cent[2]^2
×
UNCOV
42
    du = iniamplitude / (2 * convert(RealT, pi)) * exp(0.5f0 * (1 - r2)) # vel. perturbation
×
UNCOV
43
    dtemp = -(equations.gamma - 1) / (2 * equations.gamma * rt) * du^2 # isentropic
×
UNCOV
44
    rho = rho * (1 + dtemp)^(1 / (equations.gamma - 1))
×
UNCOV
45
    vel = vel + du * cent
×
UNCOV
46
    v1, v2 = vel
×
UNCOV
47
    p = p * (1 + dtemp)^(equations.gamma / (equations.gamma - 1))
×
UNCOV
48
    prim = SVector(rho, v1, v2, p)
×
UNCOV
49
    return prim2cons(prim, equations)
×
50
end
51
initial_condition = initial_condition_isentropic_vortex
52

53
# Up to version 0.13.0, `max_abs_speed_naive` was used as the default wave speed estimate of
54
# `const flux_lax_friedrichs = FluxLaxFriedrichs(), i.e., `FluxLaxFriedrichs(max_abs_speed = max_abs_speed_naive)`.
55
# In the `StepsizeCallback`, though, the less diffusive `max_abs_speeds` is employed which is consistent with `max_abs_speed`.
56
# Thus, we exchanged in PR#2458 the default wave speed used in the LLF flux to `max_abs_speed`.
57
# To ensure that every example still runs we specify explicitly `FluxLaxFriedrichs(max_abs_speed_naive)`.
58
# We remark, however, that the now default `max_abs_speed` is in general recommended due to compliance with the 
59
# `StepsizeCallback` (CFL-Condition) and less diffusion.
60
surface_flux = FluxLaxFriedrichs(max_abs_speed_naive)
61
volume_flux = flux_shima_etal
62

63
polydeg = 3
64
basis = LobattoLegendreBasis(polydeg)
65
indicator_sc = IndicatorHennemannGassner(equations, basis,
66
                                         alpha_max = 0.5,
67
                                         alpha_min = 0.001,
68
                                         alpha_smooth = true,
69
                                         variable = density_pressure)
70
volume_integral = VolumeIntegralShockCapturingHG(indicator_sc;
71
                                                 volume_flux_dg = volume_flux,
72
                                                 volume_flux_fv = surface_flux)
73
solver = DGSEM(basis, surface_flux, volume_integral)
74

75
coordinates_min = (-10.0, -10.0)
76
coordinates_max = (10.0, 10.0)
77
mesh = TreeMesh(coordinates_min, coordinates_max,
78
                initial_refinement_level = 4,
79
                n_cells_max = 10_000)
80

81
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver)
82

83
###############################################################################
84
# ODE solvers, callbacks etc.
85

86
tspan = (0.0, 1.0)
87
ode = semidiscretize(semi, tspan)
88

89
summary_callback = SummaryCallback()
90

91
analysis_interval = 100
92
analysis_callback = AnalysisCallback(semi, interval = analysis_interval,
93
                                     save_analysis = true,
94
                                     extra_analysis_errors = (:conservation_error,),
95
                                     extra_analysis_integrals = (entropy, energy_total,
96
                                                                 energy_kinetic,
97
                                                                 energy_internal))
98

99
alive_callback = AliveCallback(analysis_interval = analysis_interval)
100

101
save_restart = SaveRestartCallback(interval = 100,
102
                                   save_final_restart = true)
103

104
save_solution = SaveSolutionCallback(interval = 100,
105
                                     save_initial_solution = true,
106
                                     save_final_solution = true,
107
                                     solution_variables = cons2prim)
108

109
stepsize_callback = StepsizeCallback(cfl = 0.7)
110

111
callbacks = CallbackSet(summary_callback,
112
                        analysis_callback, alive_callback,
113
                        save_restart, save_solution,
114
                        stepsize_callback)
115

116
###############################################################################
117
# run the simulation
118

119
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);
120
            dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
121
            ode_default_options()..., callback = callbacks);
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc