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

trixi-framework / Trixi.jl / 21638916092

03 Feb 2026 04:42PM UTC coverage: 25.939% (-71.1%) from 97.034%
21638916092

Pull #2754

github

web-flow
Merge ee9b4b1c0 into ead0db32a
Pull Request #2754: `VolumeIntegralAdaptive` with `IndicatorEntropyChange`

0 of 83 new or added lines in 6 files covered. (0.0%)

31545 existing lines in 536 files now uncovered.

11563 of 44578 relevant lines covered (25.94%)

469675.74 hits per line

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

0.0
/examples/tree_2d_dgsem/elixir_diffusion_steady_state_linear_map.jl
1
using Trixi
2

3
###############################################################################
4

5
# Build pure diffusion (Laplace) operator
6
advection_velocity = (0, 0)
7
equations = LinearScalarAdvectionEquation2D(advection_velocity)
UNCOV
8
diffusivity() = 1
×
9
equations_parabolic = LaplaceDiffusion2D(diffusivity(), equations)
10

11
# The hyperbolic flux does not matter for this example since
12
# the hyperbolic part is zero.
13
solver = DGSEM(polydeg = 5, surface_flux = flux_central)
14

15
coordinates_min = (0.0, 0.0)
16
coordinates_max = (1.0, 1.0)
17
mesh = TreeMesh(coordinates_min, coordinates_max,
18
                initial_refinement_level = 2,
19
                n_cells_max = 80_000,
20
                periodicity = false)
21

22
# Analytical/continuous steady-state solution
UNCOV
23
function continuous_solution(x, t, equations)
×
UNCOV
24
    a = (1 - cosh(2 * pi)) / (sinh(2 * pi))
×
25

UNCOV
26
    u_sol = (cosh(2 * pi * x[2]) + a * sinh(2 * pi * x[2])) * sinpi(2 * x[1])
×
UNCOV
27
    return SVector(u_sol)
×
28
end
29
initial_condition = continuous_solution
30

UNCOV
31
function bc_homogeneous(x, t, equations)
×
UNCOV
32
    return SVector(0)
×
33
end
34
bc_homogeneous_dirichlet = BoundaryConditionDirichlet(bc_homogeneous)
35

UNCOV
36
function bc_sin(x, t, equations)
×
UNCOV
37
    return SVector(sinpi(2 * x[1]))
×
38
end
39
bc_sin_dirichlet = BoundaryConditionDirichlet(bc_sin)
40

41
# Same boundary conditions for hyperbolic and parabolic part
42
boundary_conditions = (; x_neg = bc_homogeneous_dirichlet,
43
                       y_neg = bc_sin_dirichlet,
44
                       y_pos = bc_sin_dirichlet,
45
                       x_pos = bc_homogeneous_dirichlet)
46

47
# `solver_parabolic = ViscousFormulationLocalDG()` strictly required for elliptic/diffusion-dominated problem
48
semi = SemidiscretizationHyperbolicParabolic(mesh,
49
                                             (equations, equations_parabolic),
50
                                             initial_condition, solver;
51
                                             solver_parabolic = ViscousFormulationLocalDG(),
52
                                             boundary_conditions = (boundary_conditions,
53
                                                                    boundary_conditions))
54

55
# Note that `linear_structure` does not access the `initial_condition`/steady-state solution
56
A_map, b = linear_structure(semi)
57

58
# Direct solve, with explicit sparse matrix construction.
59
# Has trouble due to poor conditioning, visible in top right corner
60
#=
61
using SparseArrays
62
A_matrix = sparse(A_map)
63
u_ls = A_matrix \ b
64
=#
65

66
# Iterative solve, works directly on the linear map, no explicit matrix construction required!
67
using Krylov
68

69
# This solves the Laplace equation (i.e., steady-state diffusion/heat equation).
70
# Note that we do not use CG since the operator `A_map` itself is only
71
# symmetric and positive definite with respect to the inner product induced by
72
# the DGSEM quadrature, not the standard Euclidean inner product. Standard CG
73
# would require multiplying the result of `A_map * u` (and `b`) by the mass matrix.
74
u_ls, stats = gmres(A_map, b, atol = 1.0e-11, rtol = 1.0e-10)
75

76
###############################################################################
77

78
# Construct the ODE problem for easy plotting and comparison to analytical solution
79
# Note that we only solve a steady-state problem, i.e., `tspan` has a range of zero.
80
tspan = (0.0, 0.0)
81
ode = semidiscretize(semi, tspan)
82

83
summary_callback = SummaryCallback()
84
# Analysis callback quantifies discretization/interpolation error of the exact solution
85
analysis_callback = AnalysisCallback(semi)
86
callbacks = CallbackSet(summary_callback,
87
                        analysis_callback)
88

89
# Choice of ODE Solver does not matter here
90
using OrdinaryDiffEqLowStorageRK
91

92
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);
93
            dt = 1e-4,
94
            ode_default_options()..., callback = callbacks);
95

96
# Check interpolation errors due to choice of number of cells & polynomial degree
97
interpolation_errors = analysis_callback(sol)
98

99
using Plots
100
# Plot analytical solution (interpolated initial condition)
101
plot(sol)
102

103
# Inject linear system solution for plotting & error computation
104
sol.u[end] = u_ls
105
plot(sol)
106

107
# Check linear system solution errors
108
linear_solution_errors = analysis_callback(sol)
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