Neko-TOP
A portable framework for high-order spectral element flow toplogy optimization.
Loading...
Searching...
No Matches
SIMP_mapping_kernel.h
1
/*
2
Copyright (c) 2021-2023, 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 __NEKO_HIP_SIMP_MAPPING_KERNELS__
36
#define __NEKO_HIP_SIMP_MAPPING_KERNELS__
37
41
template
<
typename
T>
42
__global__
void
SIMP_mapping_apply_kernel(
43
const
T
f_min,
const
T
f_max,
const
T
p,
T
*
__restrict__
X_out_d
,
44
T
*
__restrict__
X_in_d
,
const
int
n) {
45
46
const
int
idx
=
blockIdx
.x *
blockDim
.x +
threadIdx
.x;
47
const
int
str
=
blockDim
.x *
gridDim
.x;
48
49
for
(
int
i =
idx
; i < n; i +=
str
) {
50
X_out_d
[i] = f_min + (f_max - f_min) *
pow
(
X_in_d
[i], p);
51
}
52
}
53
57
template
<
typename
T>
58
__global__
void
SIMP_mapping_apply_backward_kernel(
59
const
T
f_min,
const
T
f_max,
const
T
p,
T
*
__restrict__
sens_out_d
,
60
T
*
__restrict__
sens_in_d
,
T
*
__restrict__
X_in_d
,
const
int
n) {
61
62
const
int
idx
=
blockIdx
.x *
blockDim
.x +
threadIdx
.x;
63
const
int
str
=
blockDim
.x *
gridDim
.x;
64
65
for
(
int
i =
idx
; i < n; i +=
str
) {
66
sens_out_d
[i] =
sens_in_d
[i] *
67
(f_max - f_min) * p *
pow
(
X_in_d
[i], p - 1.0);
68
}
69
}
70
71
#endif
// __NEKO_CUDA_SIMP_MAPPING_KERNELS__
convex_down_RAMP_mapping_apply_kernel
__global__ void convex_down_RAMP_mapping_apply_kernel(const T f_min, const T f_max, const T q, T *__restrict__ X_out_d, T *__restrict__ X_in_d, const int n)
Definition
RAMP_mapping_kernel.h:44
sources
mapping_functions
bcknd
device
hip
SIMP_mapping_kernel.h
Generated by
1.9.8