• 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_2d_dgsem/elixir_euler_source_terms_nonconforming_unstructured_flag.jl
1
using OrdinaryDiffEqLowStorageRK
2
using Trixi
3

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

7
equations = CompressibleEulerEquations2D(1.4)
8

9
initial_condition = initial_condition_convergence_test
10

11
source_terms = source_terms_convergence_test
12

13
boundary_condition = BoundaryConditionDirichlet(initial_condition)
14
boundary_conditions = (; all = boundary_condition,)
15

16
# Up to version 0.13.0, `max_abs_speed_naive` was used as the default wave speed estimate of
17
# `const flux_lax_friedrichs = FluxLaxFriedrichs(), i.e., `FluxLaxFriedrichs(max_abs_speed = max_abs_speed_naive)`.
18
# In the `StepsizeCallback`, though, the less diffusive `max_abs_speeds` is employed which is consistent with `max_abs_speed`.
19
# Thus, we exchanged in PR#2458 the default wave speed used in the LLF flux to `max_abs_speed`.
20
# To ensure that every example still runs we specify explicitly `FluxLaxFriedrichs(max_abs_speed_naive)`.
21
# We remark, however, that the now default `max_abs_speed` is in general recommended due to compliance with the
22
# `StepsizeCallback` (CFL-Condition) and less diffusion.
23
solver = DGSEM(polydeg = 3, surface_flux = FluxLaxFriedrichs(max_abs_speed_naive))
24

25
# Deformed rectangle that looks like a waving flag,
26
# lower and upper faces are sinus curves, left and right are vertical lines.
27
f1(s) = SVector(-1.0, s - 1.0)
×
28
f2(s) = SVector(1.0, s + 1.0)
×
29
f3(s) = SVector(s, -1.0 + sin(0.5 * pi * s))
×
30
f4(s) = SVector(s, 1.0 + sin(0.5 * pi * s))
×
31
faces = (f1, f2, f3, f4)
32

33
Trixi.validate_faces(faces)
34
mapping_flag = Trixi.transfinite_mapping(faces)
35

36
# Get the uncurved mesh from a file (downloads the file if not available locally)
37
# Unstructured mesh with 24 cells of the square domain [-1, 1]^n
38
mesh_file = Trixi.download("https://gist.githubusercontent.com/efaulhaber/63ff2ea224409e55ee8423b3a33e316a/raw/7db58af7446d1479753ae718930741c47a3b79b7/square_unstructured_2.inp",
39
                           joinpath(@__DIR__, "square_unstructured_2.inp"))
40

41
mesh = T8codeMesh(mesh_file, 2; polydeg = 3,
42
                  mapping = mapping_flag,
43
                  initial_refinement_level = 1)
44

45
function adapt_callback(forest, ltreeid, eclass_scheme, lelemntid, elements, is_family,
×
46
                        user_data)
47
    vertex = Vector{Cdouble}(undef, 3)
×
48

49
    Trixi.t8_element_vertex_reference_coords(eclass_scheme, elements[1], 0, pointer(vertex))
×
50

51
    level = Trixi.t8_element_level(eclass_scheme, elements[1])
×
52

53
    # TODO: Make this condition more general.
54
    if vertex[1] < 1e-8 && vertex[2] < 1e-8 && level < 2
×
55
        # return true (refine)
56
        return 1
×
57
    else
58
        # return false (don't refine)
59
        return 0
×
60
    end
61
end
62

63
Trixi.adapt!(mesh, adapt_callback)
64

65
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver,
66
                                    source_terms = source_terms,
67
                                    boundary_conditions = boundary_conditions)
68

69
###############################################################################
70
# ODE solvers, callbacks etc.
71

72
tspan = (0.0, 1.0)
73
ode = semidiscretize(semi, tspan)
74

75
summary_callback = SummaryCallback()
76

77
analysis_interval = 100
78
analysis_callback = AnalysisCallback(semi, interval = analysis_interval)
79

80
alive_callback = AliveCallback(analysis_interval = analysis_interval)
81

82
save_restart = SaveRestartCallback(interval = 100,
83
                                   save_final_restart = true)
84

85
save_solution = SaveSolutionCallback(interval = 100,
86
                                     save_initial_solution = true,
87
                                     save_final_solution = true,
88
                                     solution_variables = cons2prim)
89

90
stepsize_callback = StepsizeCallback(cfl = 0.8)
91

92
callbacks = CallbackSet(summary_callback,
93
                        analysis_callback, alive_callback,
94
                        save_restart, save_solution,
95
                        stepsize_callback)
96
###############################################################################
97
# run the simulation
98

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