@@ -51,7 +51,7 @@ function DGSEM(RealT, polydeg::Integer,
5151end
5252
5353# This API is no longer documented, and we recommend avoiding its public use.
54- function DGSEM (polydeg, surface_flux = flux_central,
54+ function DGSEM (polydeg:: Integer , surface_flux = flux_central,
5555 volume_integral = VolumeIntegralWeakForm ())
5656 DGSEM (Float64, polydeg, surface_flux, volume_integral)
5757end
7171@inline polydeg (dg:: DGSEM ) = polydeg (dg. basis)
7272
7373Base. summary (io:: IO , dg:: DGSEM ) = print (io, " DGSEM(polydeg=$(polydeg (dg)) )" )
74+
75+ # `compute_u_mean` used in:
76+ # (Stage-) Callbacks `EntropyBoundedLimiter` and `PositivityPreservingLimiterZhangShu`
77+
78+ # positional arguments `mesh` and `cache` passed in to match signature of 2D/3D functions
79+ @inline function compute_u_mean (u:: AbstractArray{<:Any, 3} , element,
80+ mesh:: AbstractMesh{1} , equations, dg:: DGSEM , cache)
81+ @unpack weights = dg. basis
82+
83+ u_mean = zero (get_node_vars (u, equations, dg, 1 , element))
84+ for i in eachnode (dg)
85+ u_node = get_node_vars (u, equations, dg, i, element)
86+ u_mean += u_node * weights[i]
87+ end
88+ # normalize with the total volume
89+ # note that the reference element is [-1,1], thus the weights sum to 2
90+ return 0.5f0 * u_mean
91+ end
92+
93+ @inline function compute_u_mean (u:: AbstractArray{<:Any, 4} , element,
94+ mesh:: AbstractMesh{2} , equations, dg:: DGSEM , cache)
95+ @unpack weights = dg. basis
96+ @unpack inverse_jacobian = cache. elements
97+
98+ node_volume = zero (real (mesh))
99+ total_volume = zero (node_volume)
100+
101+ u_mean = zero (get_node_vars (u, equations, dg, 1 , 1 , element))
102+ for j in eachnode (dg), i in eachnode (dg)
103+ volume_jacobian = abs (inv (get_inverse_jacobian (inverse_jacobian, mesh,
104+ i, j, element)))
105+ node_volume = weights[i] * weights[j] * volume_jacobian
106+ total_volume += node_volume
107+
108+ u_node = get_node_vars (u, equations, dg, i, j, element)
109+ u_mean += u_node * node_volume
110+ end
111+ return u_mean / total_volume # normalize with the total volume
112+ end
113+
114+ @inline function compute_u_mean (u:: AbstractArray{<:Any, 5} , element,
115+ mesh:: AbstractMesh{3} , equations, dg:: DGSEM , cache)
116+ @unpack weights = dg. basis
117+ @unpack inverse_jacobian = cache. elements
118+
119+ node_volume = zero (real (mesh))
120+ total_volume = zero (node_volume)
121+
122+ u_mean = zero (get_node_vars (u, equations, dg, 1 , 1 , 1 , element))
123+ for k in eachnode (dg), j in eachnode (dg), i in eachnode (dg)
124+ volume_jacobian = abs (inv (get_inverse_jacobian (inverse_jacobian, mesh,
125+ i, j, k, element)))
126+ node_volume = weights[i] * weights[j] * weights[k] * volume_jacobian
127+ total_volume += node_volume
128+
129+ u_node = get_node_vars (u, equations, dg, i, j, k, element)
130+ u_mean += u_node * node_volume
131+ end
132+ return u_mean / total_volume # normalize with the total volume
133+ end
74134end # @muladd
0 commit comments