Neko  0.8.99
A portable framework for high-order spectral element flow simulations
makeext_kernel.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2022, 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 #ifndef __COMMON_MAKEEXT_KERNEL__
36 #define __COMMON_MAKEEXT_KERNEL__
37 
38 template< typename T >
39 __global__ void makeext_kernel(T * __restrict__ abx1,
40  T * __restrict__ aby1,
41  T * __restrict__ abz1,
42  T * __restrict__ abx2,
43  T * __restrict__ aby2,
44  T * __restrict__ abz2,
45  T * __restrict__ bfx,
46  T * __restrict__ bfy,
47  T * __restrict__ bfz,
48  const T rho,
49  const T ab1,
50  const T ab2,
51  const T ab3,
52  const int n) {
53 
54  const int idx = blockIdx.x * blockDim.x + threadIdx.x;
55  const int str = blockDim.x * gridDim.x;
56 
57  for (int i = idx; i < n; i += str) {
58  T ta1_val = ab2 * abx1[i] + ab3 * abx2[i];
59  T ta2_val = ab2 * aby1[i] + ab3 * aby2[i];
60  T ta3_val = ab2 * abz1[i] + ab3 * abz2[i];
61 
62  abx2[i] = abx1[i];
63  aby2[i] = aby1[i];
64  abz2[i] = abz1[i];
65  abx1[i] = bfx[i];
66  aby1[i] = bfy[i];
67  abz1[i] = bfz[i];
68 
69  bfx[i] = (ab1 * bfx[i] + ta1_val) * rho;
70  bfy[i] = (ab1 * bfy[i] + ta2_val) * rho;
71  bfz[i] = (ab1 * bfz[i] + ta3_val) * rho;
72  }
73 
74 }
75 
76 template< typename T >
77 __global__ void scalar_makeext_kernel(T * __restrict__ fs_lag,
78  T * __restrict__ fs_laglag,
79  T * __restrict__ fs,
80  const T rho,
81  const T ext1,
82  const T ext2,
83  const T ext3,
84  const int n) {
85 
86  const int idx = blockIdx.x * blockDim.x + threadIdx.x;
87  const int str = blockDim.x * gridDim.x;
88 
89  for (int i = idx; i < n; i += str) {
90  T ta1_val = ext2 * fs_lag[i] + ext3 * fs_laglag[i];
91 
92  fs_laglag[i] = fs_lag[i];
93  fs_lag[i] = fs[i];
94 
95  fs[i] = (ext1 * fs[i] + ta1_val) * rho;
96  }
97 
98 }
99 
100 #endif // __COMMON_MAKEEXT_KERNEL__
const int i
Definition: cdtp_kernel.h:128
__global__ void makeext_kernel(T *__restrict__ abx1, T *__restrict__ aby1, T *__restrict__ abz1, T *__restrict__ abx2, T *__restrict__ aby2, T *__restrict__ abz2, T *__restrict__ bfx, T *__restrict__ bfy, T *__restrict__ bfz, const T rho, const T ab1, const T ab2, const T ab3, const int n)
__global__ void scalar_makeext_kernel(T *__restrict__ fs_lag, T *__restrict__ fs_laglag, T *__restrict__ fs, const T rho, const T ext1, const T ext2, const T ext3, const int n)