Neko 1.99.11
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
reichardt_device.F90
Go to the documentation of this file.
1! Copyright (c) 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!
33!> Implements the device kernel for the `reichardt_t` type.
35 use num_types, only : rp, c_rp
36 use, intrinsic :: iso_c_binding, only : c_ptr
37 use utils, only : neko_error
38 implicit none
39 private
40
41#ifdef HAVE_HIP
42 interface
43 subroutine hip_reichardt_compute(u_d, v_d, w_d, &
44 n_x_d, n_y_d, n_z_d, nu_d, rho_w_d, h_d, &
45 tau_x_d, tau_y_d, tau_z_d, n_nodes, &
46 kappa, C, B1, B2, tstep) &
47 bind(c, name = 'hip_reichardt_compute')
48 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
49 use num_types, only : c_rp
50 implicit none
51 type(c_ptr), value :: u_d, v_d, w_d, rho_w_d
52 type(c_ptr), value :: n_x_d, n_y_d, n_z_d, h_d, nu_d
53 real(c_rp) :: kappa, C, B1, B2
54 type(c_ptr), value :: tau_x_d, tau_y_d, tau_z_d
55 integer(c_int) :: n_nodes, tstep
56 end subroutine hip_reichardt_compute
57 end interface
58#elif HAVE_CUDA
59 interface
60 subroutine cuda_reichardt_compute(u_d, v_d, w_d, &
61 n_x_d, n_y_d, n_z_d, nu_d, rho_w_d, h_d, &
62 tau_x_d, tau_y_d, tau_z_d, n_nodes, &
63 kappa, C, B1, B2, tstep) &
64 bind(c, name = 'cuda_reichardt_compute')
65 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
66 use num_types, only : c_rp
67 implicit none
68 type(c_ptr), value :: u_d, v_d, w_d, rho_w_d
69 type(c_ptr), value :: n_x_d, n_y_d, n_z_d, h_d, nu_d
70 real(c_rp) :: kappa, C, B1, B2
71 type(c_ptr), value :: tau_x_d, tau_y_d, tau_z_d
72 integer(c_int) :: n_nodes, tstep
73 end subroutine cuda_reichardt_compute
74 end interface
75#elif HAVE_OPENCL
76 interface
77 subroutine opencl_reichardt_compute(u_d, v_d, w_d, &
78 n_x_d, n_y_d, n_z_d, nu_d, rho_w_d, h_d, &
79 tau_x_d, tau_y_d, tau_z_d, n_nodes, &
80 kappa, C, B1, B2, tstep) &
81 bind(c, name = 'opencl_reichardt_compute')
82 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
83 use num_types, only : c_rp
84 implicit none
85 type(c_ptr), value :: u_d, v_d, w_d, rho_w_d
86 type(c_ptr), value :: n_x_d, n_y_d, n_z_d, h_d, nu_d
87 real(c_rp) :: kappa, C, B1, B2
88 type(c_ptr), value :: tau_x_d, tau_y_d, tau_z_d
89 integer(c_int) :: n_nodes, tstep
90 end subroutine opencl_reichardt_compute
91 end interface
92#elif HAVE_METAL
93 interface
94 subroutine metal_reichardt_compute(u_d, v_d, w_d, &
95 n_x_d, n_y_d, n_z_d, nu_d, rho_w_d, h_d, &
96 tau_x_d, tau_y_d, tau_z_d, n_nodes, &
97 kappa, C, B1, B2, tstep) &
98 bind(c, name = 'metal_reichardt_compute')
99 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
100 use num_types, only : c_rp
101 implicit none
102 type(c_ptr), value :: u_d, v_d, w_d, rho_w_d
103 type(c_ptr), value :: n_x_d, n_y_d, n_z_d, h_d, nu_d
104 real(c_rp) :: kappa, C, B1, B2
105 type(c_ptr), value :: tau_x_d, tau_y_d, tau_z_d
106 integer(c_int) :: n_nodes, tstep
107 end subroutine metal_reichardt_compute
108 end interface
109#endif
111
112contains
113 !> Compute the wall shear stress on device using Reichardt's law.
114 !! @param u_d The x component of the sampled velocity.
115 !! @param v_d The y component of the sampled velocity.
116 !! @param w_d The z component of the sampled velocity.
117 !! @param n_x_d The x component of the wall normal.
118 !! @param n_y_d The y component of the wall normal.
119 !! @param n_z_d The z component of the wall normal.
120 !! @param nu_d The kinematic viscosity at the wall.
121 !! @param rho_w_d The density at the wall.
122 !! @param h_d The wall-normal distance of the sampling point.
123 !! @param tau_x_d The x component of the wall shear stress.
124 !! @param tau_y_d The y component of the wall shear stress.
125 !! @param tau_z_d The z component of the wall shear stress.
126 !! @param n_nodes The number of wall nodes.
127 !! @param kappa The von Karman coefficient.
128 !! @param C The amplitude of the exponential correction.
129 !! @param B1 The damping length scale, in wall units.
130 !! @param B2 The decay length scale of the second exponential term, in
131 !! wall units.
132 !! @param tstep The current time-step.
133 subroutine reichardt_compute_device(u_d, v_d, w_d, &
134 n_x_d, n_y_d, n_z_d, nu_d, rho_w_d, h_d, tau_x_d, tau_y_d, tau_z_d, &
135 n_nodes, kappa, C, B1, B2, tstep)
136 integer, intent(in) :: n_nodes, tstep
137 type(c_ptr), intent(in) :: u_d, v_d, w_d, rho_w_d
138 type(c_ptr), intent(in) :: n_x_d, n_y_d, n_z_d, h_d, nu_d
139 type(c_ptr), intent(inout) :: tau_x_d, tau_y_d, tau_z_d
140 real(kind=rp), intent(in) :: kappa, c, b1, b2
141
142#if HAVE_HIP
143 call hip_reichardt_compute(u_d, v_d, w_d, &
144 n_x_d, n_y_d, n_z_d, nu_d, rho_w_d, h_d, &
145 tau_x_d, tau_y_d, tau_z_d, n_nodes, kappa, c, b1, b2, &
146 tstep)
147#elif HAVE_CUDA
148 call cuda_reichardt_compute(u_d, v_d, w_d, &
149 n_x_d, n_y_d, n_z_d, nu_d, rho_w_d, h_d, &
150 tau_x_d, tau_y_d, tau_z_d, n_nodes, kappa, c, b1, b2, &
151 tstep)
152#elif HAVE_OPENCL
153 call opencl_reichardt_compute(u_d, v_d, w_d, &
154 n_x_d, n_y_d, n_z_d, nu_d, rho_w_d, h_d, &
155 tau_x_d, tau_y_d, tau_z_d, n_nodes, kappa, c, b1, b2, &
156 tstep)
157#elif HAVE_METAL
158 call metal_reichardt_compute(u_d, v_d, w_d, &
159 n_x_d, n_y_d, n_z_d, nu_d, rho_w_d, h_d, &
160 tau_x_d, tau_y_d, tau_z_d, n_nodes, kappa, c, b1, b2, &
161 tstep)
162#else
163 call neko_error('No device backend configured')
164#endif
165
166 end subroutine reichardt_compute_device
167end module reichardt_device
integer, parameter, public c_rp
Definition num_types.f90:15
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:14
Implements the device kernel for the reichardt_t type.
subroutine, public reichardt_compute_device(u_d, v_d, w_d, n_x_d, n_y_d, n_z_d, nu_d, rho_w_d, h_d, tau_x_d, tau_y_d, tau_z_d, n_nodes, kappa, c, b1, b2, tstep)
Compute the wall shear stress on device using Reichardt's law.
Utilities.
Definition utils.f90:35
void opencl_reichardt_compute(void *u_d, void *v_d, void *w_d, void *n_x_d, void *n_y_d, void *n_z_d, void *nu_d, void *rho_w_d, void *h_d, void *tau_x_d, void *tau_y_d, void *tau_z_d, int *n_nodes, real *kappa, real *C, real *B1, real *B2, int *tstep)
Definition reichardt.c:69
void cuda_reichardt_compute(void *u_d, void *v_d, void *w_d, void *n_x_d, void *n_y_d, void *n_z_d, void *nu_d, void *rho_w_d, void *h_d, void *tau_x_d, void *tau_y_d, void *tau_z_d, int *n_nodes, real *kappa, real *C, real *B1, real *B2, int *tstep)
Definition reichardt.cu:62