Neko-TOP
A portable framework for high-order spectral element flow toplogy optimization.
Loading...
Searching...
No Matches
hip_mma_math.f90
1! Copyright (c) 2025, The Neko-TOP 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!
33module hip_mma_math
34 use num_types, only: rp, c_rp
35 use, intrinsic :: iso_c_binding, only: c_int, c_ptr
36
37 implicit none
38 public
39
40 interface
41 subroutine hip_hess(Hess_d, hijx_d, Ljjxinv_d, n, m) bind(c, name = 'hip_Hess')
42 import c_int, c_ptr
43 type(c_ptr), value :: Hess_d, hijx_d, Ljjxinv_d
44 integer(c_int) :: n, m
45 end subroutine hip_hess
46
47 subroutine mma_ljjxinv_hip(Ljjxinv_d,pjlambda_d, qjlambda_d, x_d, &
48 low_d, upp_d, alpha_d, beta_d, n) bind(c, name = 'mma_Ljjxinv_hip')
49 import c_int, c_ptr
50 type(c_ptr), value :: Ljjxinv_d, x_d, pjlambda_d, qjlambda_d, low_d, &
51 upp_d, alpha_d, beta_d
52 integer(c_int) :: n
53 end subroutine mma_ljjxinv_hip
54
55 subroutine mma_dipsolvesub1_hip(x_d, pjlambda_d, qjlambda_d, low_d, &
56 upp_d, alpha_d, beta_d, n) bind(c, name = 'mma_dipsolvesub1_hip')
57 import c_int, c_ptr
58 type(c_ptr), value :: x_d, pjlambda_d, qjlambda_d, low_d, &
59 upp_d, alpha_d, beta_d
60 integer(c_int) :: n
61 end subroutine mma_dipsolvesub1_hip
62
63 subroutine mattrans_v_mul_hip(output_d, pij_d, lambda_d, m, n) &
64 bind(c, name = 'mattrans_v_mul_hip')
65 import c_rp, c_int, c_ptr
66 type(c_ptr), value :: output_d, pij_d, lambda_d
67 integer(c_int) :: m, n
68 end subroutine mattrans_v_mul_hip
69 subroutine mma_gensub1_hip(low_d, upp_d, x_d, xmin_d, xmax_d, asyinit, n)&
70 bind(c, name = 'mma_gensub1_hip')
71 import c_rp, c_int, c_ptr
72 type(c_ptr), value :: low_d, upp_d, x_d, xmin_d, xmax_d
73 real(c_rp) :: asyinit
74 integer(c_int) :: n
75 end subroutine mma_gensub1_hip
76
77 subroutine mma_gensub2_hip(low_d, upp_d, x_d, xold1_d, xold2_d, xdiff_d, &
78 asydecr, asyincr, n) bind(c, name = 'mma_gensub2_hip')
79 import c_rp, c_int, c_ptr
80 type(c_ptr), value :: low_d, upp_d, x_d, xold1_d, xold2_d, xdiff_d
81 real(c_rp) :: asydecr, asyincr
82 integer(c_int) :: n
83 end subroutine mma_gensub2_hip
84
85 subroutine mma_gensub3_hip(x_d, df0dx_d, dfdx_d, low_d, upp_d, min_d, &
86 max_d, alpha_d, beta_d, p0j_d, q0j_d, pij_d, qij_d, n, m) &
87 bind(c, name = 'mma_gensub3_hip')
88 import c_int, c_ptr
89 type(c_ptr), value :: x_d, df0dx_d, dfdx_d, low_d, upp_d, min_d, max_d, &
90 alpha_d, beta_d, p0j_d, q0j_d, pij_d, qij_d
91 integer(c_int) :: n, m
92 end subroutine mma_gensub3_hip
93
94 subroutine mma_gensub4_hip(x_d, low_d, upp_d, pij_d, qij_d, n, m, bi_d) &
95 bind(c, name = 'mma_gensub4_hip')
96 import c_int, c_ptr
97 type(c_ptr), value :: x_d, low_d, upp_d, pij_d, qij_d, bi_d
98 integer(c_int) :: n, m
99 end subroutine mma_gensub4_hip
100
101 subroutine hip_mma_max(xsi_d, x_d, alpha_d, n) &
102 bind(c, name = 'hip_mma_max')
103 import c_int, c_ptr
104 type(c_ptr), value :: xsi_d, x_d, alpha_d
105 integer(c_int) :: n
106 end subroutine hip_mma_max
107
108 subroutine hip_rex(rex_d, x_d, low_d, upp_d, pij_d, p0j_d, qij_d, q0j_d, &
109 lambda_d, xsi_d, eta_d, n, m) bind(c, name = 'hip_rex')
110 import c_int, c_ptr
111 type(c_ptr), value :: rex_d, x_d, low_d, upp_d, pij_d, p0j_d, qij_d, &
112 q0j_d, lambda_d, xsi_d, eta_d
113 integer(c_int) :: n, m
114 end subroutine hip_rex
115
116 subroutine hip_relambda(relambda_d, x_d, upp_d, low_d, pij_d, qij_d, n, &
117 m) bind(c, name = 'hip_relambda')
118 import c_int, c_ptr
119 type(c_ptr), value :: relambda_d, x_d, upp_d, low_d, pij_d, qij_d
120 integer(c_int) :: n, m
121 end subroutine hip_relambda
122
123 subroutine hip_sub2cons2(rexsi_d, xsi_d, x_d, alpha_d, epsi, n) &
124 bind(c, name = 'hip_sub2cons2')
125 import c_rp, c_int, c_ptr
126 type(c_ptr), value :: rexsi_d, xsi_d, x_d, alpha_d
127 real(c_rp) :: epsi
128 integer(c_int) :: n
129 end subroutine hip_sub2cons2
130
131 real(c_rp) function hip_maxval(rex_d, n) bind(c, name = 'hip_maxval')
132 import c_rp, c_int, c_ptr
133 type(c_ptr), value :: rex_d
134 integer(c_int) :: n
135 end function hip_maxval
136
137 real(c_rp) function hip_norm(rex_d, n) bind(c, name = 'hip_norm')
138 import c_rp, c_int, c_ptr
139 type(c_ptr), value :: rex_d
140 integer(c_int) :: n
141 end function hip_norm
142
143 subroutine hip_delx(delx_d, x_d, low_d, upp_d, pij_d, qij_d, p0j_d, &
144 q0j_d, alpha_d, beta_d, lambda_d, epsi, n, m) &
145 bind(c, name = 'hip_delx')
146 import c_rp, c_int, c_ptr
147 type(c_ptr), value :: delx_d, x_d, low_d, upp_d, pij_d, qij_d, p0j_d, &
148 q0j_d, alpha_d, beta_d, lambda_d
149 real(c_rp) :: epsi
150 integer(c_int) :: n, m
151 end subroutine hip_delx
152
153
154
155 subroutine hip_gg(GG_d, x_d, low_d, upp_d, pij_d, qij_d, n, m) &
156 bind(c, name = 'hip_GG')
157 import c_int, c_ptr
158 type(c_ptr), value :: GG_d, x_d, low_d, upp_d, pij_d, qij_d
159 integer(c_int) :: n, m
160 end subroutine hip_gg
161
162 subroutine hip_diagx(diagx_d, x_d, xsi_d, low_d, upp_d, p0j_d, q0j_d, &
163 pij_d, qij_d, alpha_d, beta_d, eta_d, lambda_d, n, m) &
164 bind(c, name = 'hip_diagx')
165 import c_int, c_ptr
166 type(c_ptr), value :: diagx_d, x_d, xsi_d, low_d, upp_d, p0j_d, q0j_d, &
167 pij_d, qij_d, alpha_d, beta_d, eta_d, lambda_d
168 integer(c_int) :: n, m
169 end subroutine hip_diagx
170
171 subroutine hip_bb(bb_d, GG_d, delx_d, diagx_d, n, m) &
172 bind(c, name = 'hip_bb')
173 import c_int, c_ptr
174 type(c_ptr), value :: bb_d, GG_d, delx_d, diagx_d
175 integer(c_int) :: n, m
176 end subroutine hip_bb
177
178 subroutine hip_aa(AA_d, GG_d, diagx_d, n, m) bind(c, name = 'hip_AA')
179 import c_int, c_ptr
180 type(c_ptr), value :: AA_d, GG_d, diagx_d
181 integer(c_int) :: n, m
182 end subroutine hip_aa
183
184 subroutine hip_dx(dx_d, delx_d, diagx_d, GG_d, dlambda_d, n, m) &
185 bind(c, name = 'hip_dx')
186 import c_int, c_ptr
187 type(c_ptr), value :: dx_d, delx_d, diagx_d, GG_d, dlambda_d
188 integer(c_int) :: n, m
189 end subroutine hip_dx
190
191 subroutine hip_dxsi(dxsi_d, xsi_d, dx_d, x_d, alpha_d, epsi, n) &
192 bind(c, name = 'hip_dxsi')
193 import c_rp, c_int, c_ptr
194 type(c_ptr), value :: dxsi_d, xsi_d, dx_d, x_d, alpha_d
195 real(c_rp) :: epsi
196 integer(c_int) :: n
197 end subroutine hip_dxsi
198
199 subroutine hip_deta(deta_d, eta_d, dx_d, x_d, beta_d, epsi, n) &
200 bind(c, name = 'hip_deta')
201 import c_rp, c_int, c_ptr
202 type(c_ptr), value :: deta_d, eta_d, dx_d, x_d, beta_d
203 real(c_rp) :: epsi
204 integer(c_int) :: n
205 end subroutine hip_deta
206
207 real(c_rp) function hip_maxval2(dxx_d, xx_d, cons, n) &
208 bind(c, name = 'hip_maxval2')
209 import c_rp, c_int, c_ptr
210 type(c_ptr), value :: dxx_d, xx_d
211 real(c_rp) :: cons
212 integer(c_int) :: n
213 end function hip_maxval2
214
215 real(c_rp) function hip_maxval3(dx_d, x_d, alpha_d, cons, n) &
216 bind(c, name = 'hip_maxval3')
217 import c_rp, c_int, c_ptr
218 type(c_ptr), value :: dx_d, x_d, alpha_d
219 real(c_rp) :: cons
220 integer(c_int) :: n
221 end function hip_maxval3
222
223 subroutine hip_kkt_rex(rex_d, df0dx_d, dfdx_d, xsi_d, eta_d, lambda_d, &
224 n, m) bind(c, name = 'hip_kkt_rex')
225 import c_int, c_ptr
226 type(c_ptr), value :: rex_d, df0dx_d, dfdx_d, xsi_d, eta_d, lambda_d
227 integer(c_int) :: n, m
228 end subroutine hip_kkt_rex
229
230
231 subroutine hip_maxcons(a_d, b, c, d_d, n) bind(c, name = 'hip_maxcons')
232 import c_rp, c_int, c_ptr
233 type(c_ptr), value :: a_d, d_d
234 real(c_rp) :: b, c
235 integer(c_int) :: n
236 end subroutine hip_maxcons
237
238
239 real(c_rp) function hip_lcsc2(a_d, b_d, n) bind(c, name = 'hip_lcsc2')
240 import c_rp, c_int, c_ptr
241 type(c_ptr), value :: a_d, b_d
242 integer(c_int) :: n
243 end function hip_lcsc2
244
245 subroutine hip_mpisum(a_d, n) bind(c, name = 'hip_mpisum')
246 import c_int, c_ptr
247 type(c_ptr), value :: a_d
248 integer(c_int) :: n
249 end subroutine hip_mpisum
250
251 subroutine hip_add2inv2(a_d, b_d, c, n) bind(c, name = 'hip_add2inv2')
252 import c_rp, c_int, c_ptr
253 type(c_ptr), value :: a_d, b_d
254 integer(c_int) :: n
255 real(c_rp) :: c
256 end subroutine hip_add2inv2
257
258 subroutine hip_max2(a_d, b, c_d, d, n) bind(c, name = 'hip_max2')
259 import c_rp, c_int, c_ptr
260 type(c_ptr), value :: a_d, c_d
261 integer(c_int) :: n
262 real(c_rp) :: b, d
263 end subroutine hip_max2
264
265 subroutine hip_updatebb(bb_d, dellambda_d, dely_d, d_d, mu_d, y_d, delz, &
266 m) bind(c, name = 'hip_updatebb')
267 import c_rp, c_int, c_ptr
268 type(c_ptr), value :: bb_d, dellambda_d, dely_d, d_d, mu_d, y_d
269 integer(c_int) :: m
270 real(c_rp) :: delz
271 end subroutine hip_updatebb
272
273 subroutine hip_updateaa(AA_d, globaltmp_mm_d, s_d, lambda_d, d_d, mu_d, &
274 y_d, a_d, zeta, z, m) bind(c, name = 'hip_updateAA')
275 import c_rp, c_int, c_ptr
276 type(c_ptr), value :: AA_d, globaltmp_mm_d, s_d, lambda_d, d_d, mu_d, &
277 y_d, a_d
278 integer(c_int) :: m
279 real(c_rp) :: zeta, z
280 end subroutine hip_updateaa
281
282 subroutine hip_dy(dy_d, dely_d, dlambda_d, d_d, mu_d, y_d, n) &
283 bind(c, name = 'hip_dy')
284 import c_int, c_ptr
285 type(c_ptr), value :: dy_d, dely_d, dlambda_d, d_d, mu_d, y_d
286 integer(c_int) :: n
287 end subroutine hip_dy
288
289 end interface
290
291end module hip_mma_math