Neko 1.99.9
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
lpt_wall_collision.c
Go to the documentation of this file.
1/*
2 Copyright (c) 2026, The Neko Authors
3 All rights reserved.
4
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions
7 are met:
8
9 * Redistributions of source code must retain the above copyright
10 notice, this list of conditions and the following disclaimer.
11
12 * Redistributions in binary form must reproduce the above
13 copyright notice, this list of conditions and the following
14 disclaimer in the documentation and/or other materials provided
15 with the distribution.
16
17 * Neither the name of the authors nor the names of its
18 contributors may be used to endorse or promote products derived
19 from this software without specific prior written permission.
20
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 POSSIBILITY OF SUCH DAMAGE.
33*/
34
35#ifdef __APPLE__
36#include <OpenCL/cl.h>
37#else
38#include <CL/cl.h>
39#endif
40
42#include <device/opencl/check.h>
43#include <device/opencl/jit.h>
45
46#include "lpt_wall_collision_kernel.cl.h"
47
50 void *wall_facet_mask, void *el_list,
51 void *x_old, void *y_old, void *z_old,
52 void *x, void *y, void *z,
53 void *d, void *u, void *v, void *w,
54 void *u_lag, void *v_lag, void *w_lag,
55 void *u_laglag, void *v_laglag, void *w_laglag,
56 void *acc_xlag, void *acc_ylag, void *acc_zlag,
57 void *acc_xlaglag, void *acc_ylaglag, void *acc_zlaglag,
58 void *u_old, void *v_old, void *w_old,
59 void *acc_x, void *acc_y, void *acc_z,
60 void *dm_x, void *dm_y, void *dm_z,
61 void *nx, void *ny, void *nz,
62 int *n, int *gdim, int *nelv,
63 int *lx, int *ly, int *lz, int *lag_len, void *strm) {
64 cl_int err;
65
66 if (*n < 1) return;
67
71 }
72
75 "lpt_handle_elastic_wall_collisions_kernel", &err);
77
78 void *bufs[36] = { wall_facet_mask, el_list,
80 x, y, z,
81 d, u, v, w,
82 u_lag, v_lag, w_lag,
83 u_laglag, v_laglag, w_laglag,
84 acc_xlag, acc_ylag, acc_zlag,
85 acc_xlaglag, acc_ylaglag, acc_zlaglag,
87 acc_x, acc_y, acc_z,
88 dm_x, dm_y, dm_z,
89 nx, ny, nz };
90
91 /* The lag arrays are only read when lag_len allows it, but every slot
92 still needs a valid memory object */
93 for (int i = 0; i < 36; i++) {
94 if (bufs[i] == NULL) bufs[i] = x;
95 }
96
97 for (int i = 0; i < 36; i++) {
98 CL_CHECK(clSetKernelArg(kernel, i, sizeof(cl_mem), (void *) &bufs[i]));
99 }
100 CL_CHECK(clSetKernelArg(kernel, 36, sizeof(int), n));
101 CL_CHECK(clSetKernelArg(kernel, 37, sizeof(int), gdim));
102 CL_CHECK(clSetKernelArg(kernel, 38, sizeof(int), nelv));
103 CL_CHECK(clSetKernelArg(kernel, 39, sizeof(int), lx));
104 CL_CHECK(clSetKernelArg(kernel, 40, sizeof(int), ly));
105 CL_CHECK(clSetKernelArg(kernel, 41, sizeof(int), lz));
106 CL_CHECK(clSetKernelArg(kernel, 42, sizeof(int), lag_len));
107
108 const int nb = ((*n) + 256 - 1) / 256;
109 const size_t global_item_size = 256 * nb;
110 const size_t local_item_size = 256;
111
114 &local_item_size, 0, NULL, NULL));
115
117}
__global__ void ale_add_kinematics_kernel(const int n, T *__restrict__ wx, T *__restrict__ wy, T *__restrict__ wz, const T *__restrict__ x_ref, const T *__restrict__ y_ref, const T *__restrict__ z_ref, const T *__restrict__ phi, const T *__restrict__ x, const T *__restrict__ y, const T *__restrict__ z, const kinematics_params_t kin_params)
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ w
const int i
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ u
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ v
__global__ void const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const int nelv
__global__ void const T *__restrict__ x
void opencl_kernel_jit(const char *kernel, cl_program *program)
Definition jit.c:50
void opencl_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, void *strm)
#define CL_CHECK(err)
Definition check.h:12
void * lpt_wall_collision_program