Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/src/solvers/dgsem/special_volume_integrals.jl
5591 views
1
# By default, Julia/LLVM does not use fused multiply-add operations (FMAs).
2
# Since these FMAs can increase the performance of many numerical algorithms,
3
# we need to opt-in explicitly.
4
# See https://ranocha.de/blog/Optimizing_EC_Trixi for further details.
5
@muladd begin
6
#! format: noindent
7
8
# This file contains some specialized volume integrals that require some indicators already to be defined.
9
10
const VolumeIntegralAdaptiveEC_WF_DG = VolumeIntegralAdaptive{<:IndicatorEntropyChange,
11
<:VolumeIntegralWeakForm,
12
<:VolumeIntegralFluxDifferencing}
13
14
"""
15
VolumeIntegralEntropyCorrection(indicator,
16
volume_integral_default,
17
volume_integral_entropy_stable)
18
19
Entropy correction volume integral type for DG methods using a convex blending of
20
a `volume_integral_default` (for example, [`VolumeIntegralWeakForm`](@ref)) and
21
`volume_integral_entropy_stable` (for example, [`VolumeIntegralPureLGLFiniteVolume`](@ref)
22
with an entropy stable finite volume flux).
23
24
This is intended to be used with [`IndicatorEntropyCorrection`](@ref), which determines the
25
amount of blending based on the violation of a cell entropy equality by the volume integral.
26
27
The parameter `scaling ≥ 1` in [`IndicatorEntropyCorrection`](@ref) scales the DG-FV blending
28
parameter ``\\alpha``(see the [tutorial on shock-capturing](https://trixi-framework.github.io/TrixiDocumentation/stable/tutorials/shock_capturing/#Shock-capturing-with-flux-differencing))
29
by a constant, increasing the amount of the subcell FV added in (up to 1, i.e., pure subcell FV).
30
This can be used to add shock capturing-like behavior. Note though that ``\\alpha`` is computed
31
here from the entropy defect, **not** using [`IndicatorHennemannGassner`](@ref).
32
33
The use of `VolumeIntegralEntropyCorrection` requires either
34
`entropy_potential(u, orientation, equations)` for TreeMesh, or
35
`entropy_potential(u, normal_direction, equations)` for other mesh types
36
to be defined.
37
"""
38
const VolumeIntegralEntropyCorrection = VolumeIntegralAdaptive{<:IndicatorEntropyCorrection}
39
40
function get_element_variables!(element_variables, u, mesh, equations,
41
volume_integral::VolumeIntegralEntropyCorrection,
42
dg, cache)
43
element_variables[:indicator_shock_capturing] = volume_integral.indicator.cache.alpha
44
return nothing
45
end
46
47
function create_cache(mesh, equations,
48
volume_integral::VolumeIntegralEntropyCorrection,
49
dg, cache_containers, uEltype)
50
cache_default = create_cache(mesh, equations,
51
volume_integral.volume_integral_default,
52
dg, cache_containers, uEltype)
53
cache_stabilized = create_cache(mesh, equations,
54
volume_integral.volume_integral_stabilized,
55
dg, cache_containers, uEltype)
56
57
resize!(volume_integral.indicator.cache.alpha, nelements(dg, cache_containers))
58
59
return (; cache_default..., cache_stabilized...)
60
end
61
62
# `resize_volume_integral_cache!` is called after mesh adaptation in `reinitialize_containers!`.
63
# We only need to resize `volume_integral.indicator.cache.alpha`, which stores the blending factors
64
# for visualization.
65
function resize_volume_integral_cache!(cache, mesh,
66
volume_integral::VolumeIntegralEntropyCorrection,
67
new_size)
68
@unpack volume_integral_default, volume_integral_stabilized = volume_integral
69
resize_volume_integral_cache!(cache, mesh, volume_integral_default, new_size)
70
resize_volume_integral_cache!(cache, mesh, volume_integral_stabilized, new_size)
71
72
resize!(volume_integral.indicator.cache.alpha, new_size)
73
74
return nothing
75
end
76
77
# `VolumeIntegralEntropyCorrectionShockCapturingCombined` combines the entropy correction
78
# indicator with a heuristic shock capturing indicator.
79
const VolumeIntegralEntropyCorrectionShockCapturingCombined = VolumeIntegralAdaptive{<:IndicatorEntropyCorrectionShockCapturingCombined}
80
81
function get_element_variables!(element_variables, u, mesh, equations,
82
volume_integral::VolumeIntegralEntropyCorrectionShockCapturingCombined,
83
dg, cache)
84
# here, we reuse `indicator_shock_capturing.cache.alpha` to store the indicator variable
85
element_variables[:indicator_shock_capturing] = volume_integral.indicator.indicator_shock_capturing.cache.alpha
86
return nothing
87
end
88
end # @muladd
89
90