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