Path: blob/main/src/solvers/dgsem/special_volume_integrals.jl
5591 views
# By default, Julia/LLVM does not use fused multiply-add operations (FMAs).1# Since these FMAs can increase the performance of many numerical algorithms,2# we need to opt-in explicitly.3# See https://ranocha.de/blog/Optimizing_EC_Trixi for further details.4@muladd begin5#! format: noindent67# This file contains some specialized volume integrals that require some indicators already to be defined.89const VolumeIntegralAdaptiveEC_WF_DG = VolumeIntegralAdaptive{<:IndicatorEntropyChange,10<:VolumeIntegralWeakForm,11<:VolumeIntegralFluxDifferencing}1213"""14VolumeIntegralEntropyCorrection(indicator,15volume_integral_default,16volume_integral_entropy_stable)1718Entropy correction volume integral type for DG methods using a convex blending of19a `volume_integral_default` (for example, [`VolumeIntegralWeakForm`](@ref)) and20`volume_integral_entropy_stable` (for example, [`VolumeIntegralPureLGLFiniteVolume`](@ref)21with an entropy stable finite volume flux).2223This is intended to be used with [`IndicatorEntropyCorrection`](@ref), which determines the24amount of blending based on the violation of a cell entropy equality by the volume integral.2526The parameter `scaling ≥ 1` in [`IndicatorEntropyCorrection`](@ref) scales the DG-FV blending27parameter ``\\alpha``(see the [tutorial on shock-capturing](https://trixi-framework.github.io/TrixiDocumentation/stable/tutorials/shock_capturing/#Shock-capturing-with-flux-differencing))28by a constant, increasing the amount of the subcell FV added in (up to 1, i.e., pure subcell FV).29This can be used to add shock capturing-like behavior. Note though that ``\\alpha`` is computed30here from the entropy defect, **not** using [`IndicatorHennemannGassner`](@ref).3132The use of `VolumeIntegralEntropyCorrection` requires either33`entropy_potential(u, orientation, equations)` for TreeMesh, or34`entropy_potential(u, normal_direction, equations)` for other mesh types35to be defined.36"""37const VolumeIntegralEntropyCorrection = VolumeIntegralAdaptive{<:IndicatorEntropyCorrection}3839function get_element_variables!(element_variables, u, mesh, equations,40volume_integral::VolumeIntegralEntropyCorrection,41dg, cache)42element_variables[:indicator_shock_capturing] = volume_integral.indicator.cache.alpha43return nothing44end4546function create_cache(mesh, equations,47volume_integral::VolumeIntegralEntropyCorrection,48dg, cache_containers, uEltype)49cache_default = create_cache(mesh, equations,50volume_integral.volume_integral_default,51dg, cache_containers, uEltype)52cache_stabilized = create_cache(mesh, equations,53volume_integral.volume_integral_stabilized,54dg, cache_containers, uEltype)5556resize!(volume_integral.indicator.cache.alpha, nelements(dg, cache_containers))5758return (; cache_default..., cache_stabilized...)59end6061# `resize_volume_integral_cache!` is called after mesh adaptation in `reinitialize_containers!`.62# We only need to resize `volume_integral.indicator.cache.alpha`, which stores the blending factors63# for visualization.64function resize_volume_integral_cache!(cache, mesh,65volume_integral::VolumeIntegralEntropyCorrection,66new_size)67@unpack volume_integral_default, volume_integral_stabilized = volume_integral68resize_volume_integral_cache!(cache, mesh, volume_integral_default, new_size)69resize_volume_integral_cache!(cache, mesh, volume_integral_stabilized, new_size)7071resize!(volume_integral.indicator.cache.alpha, new_size)7273return nothing74end7576# `VolumeIntegralEntropyCorrectionShockCapturingCombined` combines the entropy correction77# indicator with a heuristic shock capturing indicator.78const VolumeIntegralEntropyCorrectionShockCapturingCombined = VolumeIntegralAdaptive{<:IndicatorEntropyCorrectionShockCapturingCombined}7980function get_element_variables!(element_variables, u, mesh, equations,81volume_integral::VolumeIntegralEntropyCorrectionShockCapturingCombined,82dg, cache)83# here, we reuse `indicator_shock_capturing.cache.alpha` to store the indicator variable84element_variables[:indicator_shock_capturing] = volume_integral.indicator.indicator_shock_capturing.cache.alpha85return nothing86end87end # @muladd888990