Neko 1.99.6
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
entropy_viscosity_cpu.f90
Go to the documentation of this file.
1! Copyright (c) 2025, The Neko Authors
2! All rights reserved.
3!
4! Redistribution and use in source and binary forms, with or without
5! modification, are permitted provided that the following conditions
6! are met:
7!
8! * Redistributions of source code must retain the above copyright
9! notice, this list of conditions and the following disclaimer.
10!
11! * Redistributions in binary form must reproduce the above
12! copyright notice, this list of conditions and the following
13! disclaimer in the documentation and/or other materials provided
14! with the distribution.
15!
16! * Neither the name of the authors nor the names of its
17! contributors may be used to endorse or promote products derived
18! from this software without specific prior written permission.
19!
20! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21! "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23! FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24! COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25! INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26! BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27! LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28! CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29! LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30! ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31! POSSIBILITY OF SUCH DAMAGE.
32!
35 use num_types, only : rp
36 implicit none
37 private
38
44
45contains
46
56 subroutine entropy_viscosity_compute_residual_cpu(entropy_residual, &
57 S, S_lag1, S_lag2, S_lag3, bdf_coeffs, dt, n)
58 integer, intent(in) :: n
59 real(kind=rp), dimension(n), intent(out) :: entropy_residual
60 real(kind=rp), dimension(n), intent(in) :: s, s_lag1, s_lag2, s_lag3
61 real(kind=rp), intent(in) :: bdf_coeffs(4)
62 real(kind=rp), intent(in) :: dt
63 integer :: i
64
65 !OCL NORECURRENCE, NOVREC, NOALIAS
66 !DIR$ CONCURRENT
67 !DIR$ IVDEP
68 !GCC$ ivdep
69 !$omp parallel do simd
70 do i = 1, n
71 entropy_residual(i) = (bdf_coeffs(1) * s(i) &
72 - bdf_coeffs(2) * s_lag1(i) &
73 - bdf_coeffs(3) * s_lag2(i) &
74 - bdf_coeffs(4) * s_lag3(i)) / dt
75 end do
76 !$omp end parallel do simd
77
79
88 entropy_residual, h, c_avisc_entropy, n_S, n)
89 integer, intent(in) :: n
90 real(kind=rp), dimension(n), intent(out) :: reg_coeff
91 real(kind=rp), dimension(n), intent(in) :: entropy_residual, h
92 real(kind=rp), intent(in) :: c_avisc_entropy, n_s
93 integer :: i
94
95 !OCL NORECURRENCE, NOVREC, NOALIAS
96 !DIR$ CONCURRENT
97 !DIR$ IVDEP
98 !GCC$ ivdep
99 !$omp parallel do simd
100 do i = 1, n
101 reg_coeff(i) = c_avisc_entropy * h(i) * h(i) * &
102 entropy_residual(i) / n_s
103 end do
104 !$omp end parallel do simd
105
107
112 subroutine entropy_viscosity_apply_element_max_cpu(reg_coeff, lx, nelv)
113 integer, intent(in) :: lx, nelv
114 real(kind=rp), dimension(lx, lx, lx, nelv), intent(inout) :: reg_coeff
115 integer :: i, j, k, el
116 real(kind=rp) :: max_visc_el
117
118 !$omp parallel do private(i, j, k, max_visc_el)
119 do el = 1, nelv
120 max_visc_el = 0.0_rp
121
122 do k = 1, lx
123 do j = 1, lx
124 !OCL NORECURRENCE, NOVREC, NOALIAS
125 !DIR$ CONCURRENT
126 !DIR$ IVDEP
127 !GCC$ ivdep
128 !$omp simd reduction(max:max_visc_el)
129 do i = 1, lx
130 max_visc_el = max(max_visc_el, reg_coeff(i, j, k, el))
131 end do
132 end do
133 end do
134
135 do k = 1, lx
136 do j = 1, lx
137 !OCL NORECURRENCE, NOVREC, NOALIAS
138 !DIR$ CONCURRENT
139 !DIR$ IVDEP
140 !GCC$ ivdep
141 !$omp simd
142 do i = 1, lx
143 reg_coeff(i, j, k, el) = max_visc_el
144 end do
145 end do
146 end do
147 end do
148 !$omp end parallel do
149
151
159 h, max_wave_speed, c_avisc_low, n)
160 integer, intent(in) :: n
161 real(kind=rp), dimension(n), intent(inout) :: reg_coeff
162 real(kind=rp), dimension(n), intent(in) :: h, max_wave_speed
163 real(kind=rp), intent(in) :: c_avisc_low
164 integer :: i
165 real(kind=rp) :: low_order_visc
166
167 !OCL NORECURRENCE, NOVREC, NOALIAS
168 !DIR$ CONCURRENT
169 !DIR$ IVDEP
170 !GCC$ ivdep
171 !$omp parallel do simd private(low_order_visc)
172 do i = 1, n
173 low_order_visc = c_avisc_low * h(i) * max_wave_speed(i)
174 reg_coeff(i) = min(reg_coeff(i), low_order_visc)
175 end do
176 !$omp end parallel do simd
177
179
186 temp_field, mult_field, n)
187 integer, intent(in) :: n
188 real(kind=rp), dimension(n), intent(out) :: reg_coeff
189 real(kind=rp), dimension(n), intent(in) :: temp_field, mult_field
190 integer :: i
191
192 !OCL NORECURRENCE, NOVREC, NOALIAS
193 !DIR$ CONCURRENT
194 !DIR$ IVDEP
195 !GCC$ ivdep
196 !$omp parallel do simd
197 do i = 1, n
198 reg_coeff(i) = temp_field(i) / mult_field(i)
199 end do
200 !$omp end parallel do simd
201
203
204end module entropy_viscosity_cpu
CPU backend for entropy viscosity regularization.
subroutine, public entropy_viscosity_compute_viscosity_cpu(reg_coeff, entropy_residual, h, c_avisc_entropy, n_s, n)
Compute viscosity from entropy residual on CPU.
subroutine, public entropy_viscosity_compute_residual_cpu(entropy_residual, s, s_lag1, s_lag2, s_lag3, bdf_coeffs, dt, n)
Compute entropy residual on CPU.
subroutine, public entropy_viscosity_smooth_divide_cpu(reg_coeff, temp_field, mult_field, n)
Divide by multiplicity for smoothing on CPU.
subroutine, public entropy_viscosity_clamp_to_low_order_cpu(reg_coeff, h, max_wave_speed, c_avisc_low, n)
Clamp regularization coefficient to low-order viscosity on CPU.
subroutine, public entropy_viscosity_apply_element_max_cpu(reg_coeff, lx, nelv)
Apply element-wise maximum on CPU.
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:12
#define max(a, b)
Definition tensor.cu:40