Neko 1.99.9
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
device_deardorff_nut.F90
Go to the documentation of this file.
1! Copyright (c) 2025-2026, 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!
34
36 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
37 use num_types, only : rp, c_rp
38 use utils, only : neko_error
40 use mpi_f08, only : mpi_sum, mpi_in_place, mpi_allreduce
41
42 implicit none
43 private
44
45#ifdef HAVE_HIP
46 interface
47 subroutine hip_deardorff_nut_compute(TKE_d, &
48 dTdx_d, dTdy_d, dTdz_d, &
49 a11_d, a12_d, a13_d, &
50 a21_d, a22_d, a23_d, &
51 a31_d, a32_d, a33_d, &
52 delta_d, nut_d, temperature_alphat, TKE_alphat, TKE_source, &
53 c_k, T0, g1, g2, g3, &
54 eps, n) &
55 bind(c, name = 'hip_deardorff_nut_compute')
56 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
57 import c_rp
58 type(c_ptr), value :: TKE_d, &
59 dTdx_d, dTdy_d, dTdz_d, &
60 a11_d, a12_d, a13_d, &
61 a21_d, a22_d, a23_d, &
62 a31_d, a32_d, a33_d, &
63 delta_d, nut_d, temperature_alphat, &
64 TKE_alphat, TKE_source
65 integer(c_int) :: n
66 real(c_rp) :: c_k, T0, g1, g2, g3, eps
67 end subroutine hip_deardorff_nut_compute
68 end interface
69#elif HAVE_CUDA
70 interface
71 subroutine cuda_deardorff_nut_compute(TKE_d, &
72 dTdx_d, dTdy_d, dTdz_d, &
73 a11_d, a12_d, a13_d, &
74 a21_d, a22_d, a23_d, &
75 a31_d, a32_d, a33_d, &
76 delta_d, nut_d, temperature_alphat, TKE_alphat, TKE_source, &
77 c_k, T0, g1, g2, g3, &
78 eps, n) &
79 bind(c, name = 'cuda_deardorff_nut_compute')
80 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
81 import c_rp
82 type(c_ptr), value :: TKE_d, &
83 dTdx_d, dTdy_d, dTdz_d, &
84 a11_d, a12_d, a13_d, &
85 a21_d, a22_d, a23_d, &
86 a31_d, a32_d, a33_d, &
87 delta_d, nut_d, temperature_alphat, &
88 TKE_alphat, TKE_source
89 integer(c_int) :: n
90 real(c_rp) :: c_k, T0, g1, g2, g3, eps
91 end subroutine cuda_deardorff_nut_compute
92 end interface
93#elif HAVE_OPENCL
94 interface
95 subroutine opencl_deardorff_nut_compute(TKE_d, &
96 dTdx_d, dTdy_d, dTdz_d, &
97 a11_d, a12_d, a13_d, &
98 a21_d, a22_d, a23_d, &
99 a31_d, a32_d, a33_d, &
100 delta_d, nut_d, temperature_alphat, TKE_alphat, TKE_source, &
101 c_k, T0, g1, g2, g3, &
102 eps, n) &
103 bind(c, name = 'opencl_deardorff_nut_compute')
104 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
105 import c_rp
106 type(c_ptr), value :: TKE_d, &
107 dTdx_d, dTdy_d, dTdz_d, &
108 a11_d, a12_d, a13_d, &
109 a21_d, a22_d, a23_d, &
110 a31_d, a32_d, a33_d, &
111 delta_d, nut_d, temperature_alphat, &
112 TKE_alphat, TKE_source
113 integer(c_int) :: n
114 real(c_rp) :: c_k, T0, g1, g2, g3, eps
115 end subroutine opencl_deardorff_nut_compute
116 end interface
117#elif HAVE_METAL
118 interface
119 subroutine metal_deardorff_nut_compute(TKE_d, &
120 dTdx_d, dTdy_d, dTdz_d, &
121 a11_d, a12_d, a13_d, &
122 a21_d, a22_d, a23_d, &
123 a31_d, a32_d, a33_d, &
124 delta_d, nut_d, temperature_alphat, TKE_alphat, TKE_source, &
125 c_k, T0, g1, g2, g3, &
126 eps, n) &
127 bind(c, name = 'metal_deardorff_nut_compute')
128 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
129 import c_rp
130 type(c_ptr), value :: TKE_d, &
131 dTdx_d, dTdy_d, dTdz_d, &
132 a11_d, a12_d, a13_d, &
133 a21_d, a22_d, a23_d, &
134 a31_d, a32_d, a33_d, &
135 delta_d, nut_d, temperature_alphat, &
136 TKE_alphat, TKE_source
137 integer(c_int) :: n
138 real(c_rp) :: c_k, T0, g1, g2, g3, eps
139 end subroutine metal_deardorff_nut_compute
140 end interface
141#endif
142
144
145contains
146
172 dTdx_d, dTdy_d, dTdz_d, a11_d, a12_d, a13_d, &
173 a21_d, a22_d, a23_d, &
174 a31_d, a32_d, a33_d, &
175 delta_d, &
176 nut_d, temperature_alphat, TKE_alphat, TKE_source, &
177 c_k, T0, g, eps, n)
178 type(c_ptr) :: tke_d, dtdx_d, dtdy_d, dtdz_d, &
179 a11_d, a12_d, a13_d, &
180 a21_d, a22_d, a23_d, &
181 a31_d, a32_d, a33_d, &
182 delta_d, nut_d, temperature_alphat, tke_alphat, tke_source
183 integer :: n
184 real(kind=rp) :: c_k, t0, g(3), eps
185#if HAVE_HIP
186 call hip_deardorff_nut_compute(tke_d, &
187 dtdx_d, dtdy_d, dtdz_d, &
188 a11_d, a12_d, a13_d, &
189 a21_d, a22_d, a23_d, &
190 a31_d, a32_d, a33_d, &
191 delta_d, nut_d, temperature_alphat, tke_alphat, tke_source, &
192 c_k, t0, g(1), g(2), g(3), eps, n)
193#elif HAVE_CUDA
194 call cuda_deardorff_nut_compute(tke_d, &
195 dtdx_d, dtdy_d, dtdz_d, &
196 a11_d, a12_d, a13_d, &
197 a21_d, a22_d, a23_d, &
198 a31_d, a32_d, a33_d, &
199 delta_d, nut_d, temperature_alphat, tke_alphat, tke_source, &
200 c_k, t0, g(1), g(2), g(3), eps, n)
201#elif HAVE_OPENCL
202 call opencl_deardorff_nut_compute(tke_d, &
203 dtdx_d, dtdy_d, dtdz_d, &
204 a11_d, a12_d, a13_d, &
205 a21_d, a22_d, a23_d, &
206 a31_d, a32_d, a33_d, &
207 delta_d, nut_d, temperature_alphat, tke_alphat, tke_source, &
208 c_k, t0, g(1), g(2), g(3), eps, n)
209#elif HAVE_METAL
210 call metal_deardorff_nut_compute(tke_d, &
211 dtdx_d, dtdy_d, dtdz_d, &
212 a11_d, a12_d, a13_d, &
213 a21_d, a22_d, a23_d, &
214 a31_d, a32_d, a33_d, &
215 delta_d, nut_d, temperature_alphat, tke_alphat, tke_source, &
216 c_k, t0, g(1), g(2), g(3), eps, n)
217#else
218 call neko_error('no device backend configured')
219#endif
220 end subroutine device_deardorff_nut_compute
221
222
223end module device_deardorff_nut
void opencl_deardorff_nut_compute(void *TKE, void *dTdx, void *dTdy, void *dTdz, void *a11, void *a12, void *a13, void *a21, void *a22, void *a23, void *a31, void *a32, void *a33, void *delta, void *nut, void *temperature_alphat, void *TKE_alphat, void *TKE_source, real *c_k, real *T0, real *g1, real *g2, real *g3, real *eps, int *n)
void cuda_deardorff_nut_compute(void *TKE, void *dTdx, void *dTdy, void *dTdz, void *a11, void *a12, void *a13, void *a21, void *a22, void *a23, void *a31, void *a32, void *a33, void *delta, void *nut, void *temperature_alphat, void *TKE_alphat, void *TKE_source, real *c_k, real *T0, real *g1, real *g2, real *g3, real *eps, int *n)
Definition comm.F90:1
type(mpi_datatype), public mpi_real_precision
MPI type for working precision of REAL types.
Definition comm.F90:54
integer, public pe_size
MPI size of communicator.
Definition comm.F90:62
type(mpi_comm), public neko_comm
MPI communicator.
Definition comm.F90:46
Device kernel wrapper for computing Deardorff SGS quantities.
subroutine, public device_deardorff_nut_compute(tke_d, dtdx_d, dtdy_d, dtdz_d, a11_d, a12_d, a13_d, a21_d, a22_d, a23_d, a31_d, a32_d, a33_d, delta_d, nut_d, temperature_alphat, tke_alphat, tke_source, c_k, t0, g, eps, n)
Compute Deardorff SGS quantities on the device backend.
integer, parameter, public c_rp
Definition num_types.f90:15
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:14
Utilities.
Definition utils.f90:35