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

trixi-framework / Trixi.jl / 25071984038

28 Apr 2026 06:59PM UTC coverage: 82.771% (-14.4%) from 97.129%
25071984038

push

github

ranocha
set development version to v0.16.7-DEV

40010 of 48338 relevant lines covered (82.77%)

34288212.65 hits per line

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

0.0
/examples/t8code_3d_dgsem/elixir_euler_ec.jl
1
using OrdinaryDiffEqLowStorageRK
2
using Trixi
3

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

7
equations = CompressibleEulerEquations3D(5 / 3)
8

9
initial_condition = initial_condition_weak_blast_wave
10

11
boundary_conditions = (; all = boundary_condition_slip_wall)
12

13
# Get the DG approximation space
14

15
volume_flux = flux_ranocha
16
solver = DGSEM(polydeg = 5, surface_flux = flux_ranocha,
17
               volume_integral = VolumeIntegralFluxDifferencing(volume_flux))
18

19
# Get the curved quad mesh from a file
20

21
# Mapping as described in https://arxiv.org/abs/2012.12040
22
function mapping(xi_, eta_, zeta_)
×
23
    # Transform input variables between -1 and 1 onto [0,3]
24
    xi = 1.5 * xi_ + 1.5
×
25
    eta = 1.5 * eta_ + 1.5
×
26
    zeta = 1.5 * zeta_ + 1.5
×
27

28
    y = eta +
×
29
        3 / 8 * (cos(1.5 * pi * (2 * xi - 3) / 3) *
30
         cos(0.5 * pi * (2 * eta - 3) / 3) *
31
         cos(0.5 * pi * (2 * zeta - 3) / 3))
32

33
    x = xi +
×
34
        3 / 8 * (cos(0.5 * pi * (2 * xi - 3) / 3) *
35
         cos(2 * pi * (2 * y - 3) / 3) *
36
         cos(0.5 * pi * (2 * zeta - 3) / 3))
37

38
    z = zeta +
×
39
        3 / 8 * (cos(0.5 * pi * (2 * x - 3) / 3) *
40
         cos(pi * (2 * y - 3) / 3) *
41
         cos(0.5 * pi * (2 * zeta - 3) / 3))
42

43
    return SVector(x, y, z)
×
44
end
45

46
# Unstructured mesh with 48 cells of the cube domain [-1, 1]^3
47
mesh_file = Trixi.download("https://gist.githubusercontent.com/efaulhaber/b8df0033798e4926dec515fc045e8c2c/raw/b9254cde1d1fb64b6acc8416bc5ccdd77a240227/cube_unstructured_2.inp",
48
                           joinpath(@__DIR__, "cube_unstructured_2.inp"))
49

50
mesh = T8codeMesh(mesh_file, 3; polydeg = 5,
51
                  mapping = mapping)
52

53
# Create the semidiscretization object.
54
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver;
55
                                    boundary_conditions = boundary_conditions)
56

57
###############################################################################
58
# ODE solvers, callbacks etc.
59

60
tspan = (0.0, 2.0)
61
ode = semidiscretize(semi, tspan)
62

63
summary_callback = SummaryCallback()
64

65
analysis_interval = 100
66
analysis_callback = AnalysisCallback(semi, interval = analysis_interval)
67

68
alive_callback = AliveCallback(analysis_interval = analysis_interval)
69

70
# Add `:thermodynamic_entropy` to `extra_node_variables` tuple ...
71
extra_node_variables = (:thermodynamic_entropy,)
72

73
# ... and specify the function `get_node_variable` for this symbol,
74
# with first argument matching the symbol (turned into a type via `Val`) for dispatching.
75
function Trixi.get_node_variable(::Val{:thermodynamic_entropy}, u, mesh, equations,
×
76
                                 dg, cache)
77
    n_nodes = nnodes(dg)
×
78
    n_elements = nelements(dg, cache)
×
79
    # By definition, the variable must be provided at every node of every element!
80
    # Otherwise, the `SaveSolutionCallback` will crash.
81
    entropy_array = zeros(eltype(cache.elements),
×
82
                          ntuple(_ -> n_nodes, ndims(mesh))..., # equivalent: `n_nodes, n_nodes, n_nodes`
×
83
                          n_elements)
84

85
    # We can accelerate the computation by thread-parallelizing the loop over elements
86
    # by using the `@threaded` macro.
87
    Trixi.@threaded for element in eachelement(dg, cache)
×
88
        for k in eachnode(dg), j in eachnode(dg), i in eachnode(dg)
×
89
            u_node = get_node_vars(u, equations, dg, i, j, k, element)
×
90

91
            entropy_array[i, j, k, element] = entropy_thermodynamic(u_node, equations)
×
92
        end
×
93
    end
×
94

95
    return entropy_array
×
96
end
97
save_solution = SaveSolutionCallback(interval = 100,
98
                                     save_initial_solution = true,
99
                                     save_final_solution = true,
100
                                     extra_node_variables = extra_node_variables) # Supply the additional `extra_node_variables` here
101

102
stepsize_callback = StepsizeCallback(cfl = 1.0)
103

104
callbacks = CallbackSet(summary_callback,
105
                        analysis_callback,
106
                        alive_callback,
107
                        save_solution,
108
                        stepsize_callback)
109

110
###############################################################################
111
# run the simulation
112

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