Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/src/solvers/dgsem_structured/indicators_2d.jl
5590 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
function apply_smoothing!(mesh::StructuredMesh{2}, alpha, alpha_tmp, dg, cache)
9
# Diffuse alpha values by setting each alpha to at least 50% of neighboring elements' alpha
10
# Copy alpha values such that smoothing is indpedenent of the element access order
11
alpha_tmp .= alpha
12
13
# So far, alpha smoothing doesn't work for non-periodic initial conditions for structured meshes.
14
@assert isperiodic(mesh) "alpha smoothing for structured meshes works only with periodic initial conditions so far"
15
16
# Loop over elements, because there is no interface container
17
for element in eachelement(dg, cache)
18
# Get neighboring element ids
19
left = cache.elements.left_neighbors[1, element]
20
lower = cache.elements.left_neighbors[2, element]
21
22
# Apply smoothing
23
alpha[left] = max(alpha_tmp[left], 0.5f0 * alpha_tmp[element], alpha[left])
24
alpha[element] = max(alpha_tmp[element], 0.5f0 * alpha_tmp[left],
25
alpha[element])
26
27
alpha[lower] = max(alpha_tmp[lower], 0.5f0 * alpha_tmp[element], alpha[lower])
28
alpha[element] = max(alpha_tmp[element], 0.5f0 * alpha_tmp[lower],
29
alpha[element])
30
end
31
32
return nothing
33
end
34
end # @muladd
35
36