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

trixi-framework / Trixi.jl / 25159898612

30 Apr 2026 10:13AM UTC coverage: 94.39% (-2.7%) from 97.132%
25159898612

push

github

web-flow
`VolumeIntegralAdaptive` with `VolumeIntegralSubcellLimiting` for 2D `TreeMesh` (#2924)

* refactor

* AVI additions

* todo

* experiment

* rm

* data

* rev

* work

* worlking

* cleaner

* fix

* comp

* rev fmt

* fmt

* rev

* rev

* checks

* try

* clean up

* cont

* cont

* greedy

* test

* continue instead of if

* fmt

* fmt

* rm bp

* Apply suggestions from code review

Co-authored-by: Benjamin Bolm <74359358+bennibolm@users.noreply.github.com>

* typo

* interfaces

* shorten

* Fix error

* Add `get_element_variables!` for a-priori olumeIntegralAdaptive`

* save bounds

* errors

* call

* tv

* save

* Add `if` for bounds computation at interfaces

Co-authored-by: Copilot <copilot@github.com>

* Decrease `alpha_min`

* Adapt errors

* Set `alpha_min=0`

* Adapt errors

* Reset `alpha_min=0.001`

* Update test/test_tree_2d_euler.jl

---------

Co-authored-by: Benjamin Bolm <74359358+bennibolm@users.noreply.github.com>
Co-authored-by: bennibolm <benjamin.bolm@gmx.de>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Joshua Lampert <51029046+JoshuaLampert@users.noreply.github.com>

23 of 90 new or added lines in 13 files covered. (25.56%)

1265 existing lines in 62 files now uncovered.

45780 of 48501 relevant lines covered (94.39%)

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

64
coordinates_min = (-10.0, -10.0)
65
coordinates_max = (10.0, 10.0)
66
refinement_patches = ((type = "box", coordinates_min = (0.0, -10.0),
67
                       coordinates_max = (10.0, 10.0)),)
68
mesh = TreeMesh(coordinates_min, coordinates_max,
69
                initial_refinement_level = 4,
70
                refinement_patches = refinement_patches,
71
                n_cells_max = 10_000, periodicity = true)
72

73
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver;
74
                                    boundary_conditions = boundary_condition_periodic)
75

76
###############################################################################
77
# ODE solvers, callbacks etc.
78

79
tspan = (0.0, 1.0)
80
ode = semidiscretize(semi, tspan)
81

82
summary_callback = SummaryCallback()
83

84
analysis_interval = 100
85
analysis_callback = AnalysisCallback(semi, interval = analysis_interval,
86
                                     save_analysis = true,
87
                                     extra_analysis_errors = (:conservation_error,),
88
                                     extra_analysis_integrals = (entropy, energy_total,
89
                                                                 energy_kinetic,
90
                                                                 energy_internal))
91

92
alive_callback = AliveCallback(analysis_interval = analysis_interval)
93

94
save_solution = SaveSolutionCallback(interval = 100,
95
                                     save_initial_solution = true,
96
                                     save_final_solution = true,
97
                                     solution_variables = cons2prim)
98

99
stepsize_callback = StepsizeCallback(cfl = 1.4)
100

101
callbacks = CallbackSet(summary_callback,
102
                        analysis_callback, alive_callback,
103
                        save_solution,
104
                        stepsize_callback)
105

106
###############################################################################
107
# run the simulation
108

109
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);
110
            dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
111
            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