Neko 1.99.6
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
lpt_wall_collision_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!
35 use vector, only : vector_t
36 use utils, only : neko_error
37 use mesh, only : mesh_t
38 use dofmap, only : dofmap_t
39 use coefs, only : coef_t
40 use device, only : glb_cmd_queue
41 use, intrinsic :: iso_c_binding, only : c_int, c_ptr
42 implicit none
43 private
44
45#ifdef HAVE_HIP
46 interface
47
48 subroutine hip_lpt_handle_elastic_wall_collisions(wall_facet_mask, &
49 el_list, x_old, y_old, z_old, x, y, z, d, u, v, w, u_lag, &
50 v_lag, w_lag, u_laglag, v_laglag, w_laglag, acc_xlag, &
51 acc_ylag, acc_zlag, acc_xlaglag, acc_ylaglag, acc_zlaglag, &
52 u_old, v_old, w_old, acc_x, acc_y, acc_z, dm_x, dm_y, dm_z, &
53 nx, ny, nz, n, gdim, nelv, lx, ly, lz, lag_len, strm) &
54 bind(c, name = 'hip_lpt_handle_elastic_wall_collisions')
55 use, intrinsic :: iso_c_binding
56 implicit none
57 type(c_ptr), value :: wall_facet_mask, el_list
58 type(c_ptr), value :: x_old, y_old, z_old
59 type(c_ptr), value :: x, y, z, d, u, v, w
60 type(c_ptr), value :: u_lag, v_lag, w_lag
61 type(c_ptr), value :: u_laglag, v_laglag, w_laglag
62 type(c_ptr), value :: acc_xlag, acc_ylag, acc_zlag
63 type(c_ptr), value :: acc_xlaglag, acc_ylaglag, acc_zlaglag
64 type(c_ptr), value :: u_old, v_old, w_old
65 type(c_ptr), value :: acc_x, acc_y, acc_z
66 type(c_ptr), value :: dm_x, dm_y, dm_z
67 type(c_ptr), value :: nx, ny, nz, strm
68 integer(c_int) :: n, gdim, nelv, lx, ly, lz, lag_len
70 end interface
71#elif HAVE_CUDA
72 interface
73
74 subroutine cuda_lpt_handle_elastic_wall_collisions(wall_facet_mask, &
75 el_list, x_old, y_old, z_old, x, y, z, d, u, v, w, u_lag, &
76 v_lag, w_lag, u_laglag, v_laglag, w_laglag, acc_xlag, &
77 acc_ylag, acc_zlag, acc_xlaglag, acc_ylaglag, acc_zlaglag, &
78 u_old, v_old, w_old, acc_x, acc_y, acc_z, dm_x, dm_y, dm_z, &
79 nx, ny, nz, n, gdim, nelv, lx, ly, lz, lag_len, strm) &
80 bind(c, name = 'cuda_lpt_handle_elastic_wall_collisions')
81 use, intrinsic :: iso_c_binding
82 implicit none
83 type(c_ptr), value :: wall_facet_mask, el_list
84 type(c_ptr), value :: x_old, y_old, z_old
85 type(c_ptr), value :: x, y, z, d, u, v, w
86 type(c_ptr), value :: u_lag, v_lag, w_lag
87 type(c_ptr), value :: u_laglag, v_laglag, w_laglag
88 type(c_ptr), value :: acc_xlag, acc_ylag, acc_zlag
89 type(c_ptr), value :: acc_xlaglag, acc_ylaglag, acc_zlaglag
90 type(c_ptr), value :: u_old, v_old, w_old
91 type(c_ptr), value :: acc_x, acc_y, acc_z
92 type(c_ptr), value :: dm_x, dm_y, dm_z
93 type(c_ptr), value :: nx, ny, nz, strm
94 integer(c_int) :: n, gdim, nelv, lx, ly, lz, lag_len
96 end interface
97#endif
98
100
101contains
102
110 subroutine lpt_handle_elastic_wall_collisions_device(msh, dm_Xh, coef, &
111 wall_facet_mask_d, el_list_d, x_old, y_old, z_old, x, y, z, d, &
112 u, v, w, u_lag, v_lag, w_lag, u_laglag, v_laglag, w_laglag, &
113 acc_xlag, acc_ylag, acc_zlag, acc_xlaglag, acc_ylaglag, &
114 acc_zlaglag, u_old, v_old, w_old, acc_x, acc_y, acc_z, lag_len, &
115 n, strm)
116 type(mesh_t), intent(in) :: msh
117 type(dofmap_t), intent(in) :: dm_xh
118 type(coef_t), intent(in) :: coef
119 type(c_ptr), intent(in) :: wall_facet_mask_d
120 type(c_ptr), intent(in) :: el_list_d
121 type(vector_t), intent(in) :: x_old, y_old, z_old
122 type(vector_t), intent(inout) :: x, y, z
123 type(vector_t), intent(in) :: d
124 type(vector_t), intent(inout) :: u, v, w
125 type(vector_t), intent(inout) :: u_lag, v_lag, w_lag
126 type(vector_t), intent(inout) :: u_laglag, v_laglag, w_laglag
127 type(vector_t), intent(inout) :: acc_xlag, acc_ylag, acc_zlag
128 type(vector_t), intent(inout) :: acc_xlaglag, acc_ylaglag
129 type(vector_t), intent(inout) :: acc_zlaglag
130 type(vector_t), intent(inout) :: u_old, v_old, w_old
131 type(vector_t), intent(inout) :: acc_x, acc_y, acc_z
132 integer, intent(in) :: lag_len
133 integer, intent(in) :: n
134 type(c_ptr), optional :: strm
135 type(c_ptr) :: strm_
136 integer(c_int) :: n_
137 integer(c_int) :: gdim_
138 integer(c_int) :: nelv_
139 integer(c_int) :: lx_
140 integer(c_int) :: ly_
141 integer(c_int) :: lz_
142 integer(c_int) :: lag_len_
143
144 if (n .lt. 1) return
145
146 strm_ = glb_cmd_queue
147 if (present(strm)) strm_ = strm
148
149 n_ = int(n, c_int)
150 gdim_ = int(msh%gdim, c_int)
151 nelv_ = int(msh%nelv, c_int)
152 lx_ = int(dm_xh%Xh%lx, c_int)
153 ly_ = int(dm_xh%Xh%ly, c_int)
154 lz_ = int(dm_xh%Xh%lz, c_int)
155 lag_len_ = int(lag_len, c_int)
156
157#ifdef HAVE_HIP
158 call hip_lpt_handle_elastic_wall_collisions(wall_facet_mask_d, &
159 el_list_d, x_old%x_d, y_old%x_d, z_old%x_d, x%x_d, y%x_d, z%x_d, &
160 d%x_d, u%x_d, v%x_d, w%x_d, u_lag%x_d, v_lag%x_d, w_lag%x_d, &
161 u_laglag%x_d, v_laglag%x_d, w_laglag%x_d, acc_xlag%x_d, &
162 acc_ylag%x_d, acc_zlag%x_d, acc_xlaglag%x_d, acc_ylaglag%x_d, &
163 acc_zlaglag%x_d, u_old%x_d, v_old%x_d, w_old%x_d, acc_x%x_d, &
164 acc_y%x_d, acc_z%x_d, dm_xh%x_d, dm_xh%y_d, dm_xh%z_d, &
165 coef%nx_d, coef%ny_d, coef%nz_d, n_, gdim_, nelv_, lx_, ly_, &
166 lz_, lag_len_, strm_)
167#elif HAVE_CUDA
168 call cuda_lpt_handle_elastic_wall_collisions(wall_facet_mask_d, &
169 el_list_d, x_old%x_d, y_old%x_d, z_old%x_d, x%x_d, y%x_d, z%x_d, &
170 d%x_d, u%x_d, v%x_d, w%x_d, u_lag%x_d, v_lag%x_d, w_lag%x_d, &
171 u_laglag%x_d, v_laglag%x_d, w_laglag%x_d, acc_xlag%x_d, &
172 acc_ylag%x_d, acc_zlag%x_d, acc_xlaglag%x_d, acc_ylaglag%x_d, &
173 acc_zlaglag%x_d, u_old%x_d, v_old%x_d, w_old%x_d, acc_x%x_d, &
174 acc_y%x_d, acc_z%x_d, dm_xh%x_d, dm_xh%y_d, dm_xh%z_d, &
175 coef%nx_d, coef%ny_d, coef%nz_d, n_, gdim_, nelv_, lx_, ly_, &
176 lz_, lag_len_, strm_)
177#else
178 call neko_error('LPT wall collision device handling requires CUDA or HIP')
179#endif
181
HIP kernel entry point for elastic wall-collision reflection.
void cuda_lpt_handle_elastic_wall_collisions(void *wall_facet_mask, void *el_list, void *x_old, void *y_old, void *z_old, void *x, void *y, void *z, void *d, void *u, void *v, void *w, void *u_lag, void *v_lag, void *w_lag, void *u_laglag, void *v_laglag, void *w_laglag, void *acc_xlag, void *acc_ylag, void *acc_zlag, void *acc_xlaglag, void *acc_ylaglag, void *acc_zlaglag, void *u_old, void *v_old, void *w_old, void *acc_x, void *acc_y, void *acc_z, void *dm_x, void *dm_y, void *dm_z, void *nx, void *ny, void *nz, int *n, int *gdim, int *nelv, int *lx, int *ly, int *lz, int *lag_len, cudaStream_t strm)
Coefficients.
Definition coef.f90:34
Device abstraction, common interface for various accelerators.
Definition device.F90:34
type(c_ptr), bind(C), public glb_cmd_queue
Global command queue.
Definition device.F90:52
Defines a mapping of the degrees of freedom.
Definition dofmap.f90:35
Device dispatch for LPT elastic wall-collision handling.
subroutine, public lpt_handle_elastic_wall_collisions_device(msh, dm_xh, coef, wall_facet_mask_d, el_list_d, x_old, y_old, z_old, x, y, z, d, u, v, w, u_lag, v_lag, w_lag, u_laglag, v_laglag, w_laglag, acc_xlag, acc_ylag, acc_zlag, acc_xlaglag, acc_ylaglag, acc_zlaglag, u_old, v_old, w_old, acc_x, acc_y, acc_z, lag_len, n, strm)
Launch device kernel for elastic wall-collision reflection.
Defines a mesh.
Definition mesh.f90:34
Utilities.
Definition utils.f90:35
Defines a vector.
Definition vector.f90:34
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
Definition coef.f90:63