ADflow  v1.0
ADflow is a finite volume RANS solver tailored for gradient-based aerodynamic design optimization.
surfaceIntegrations.F90
Go to the documentation of this file.
2 
3 contains
4 
5  subroutine getcostfunctions(globalVals, funcValues)
6 
7  use constants
15  use inputtsstabderiv, only: tsstability
16  use utils, only: computetsderivatives
17  use flowutils, only: getdirvector
18  implicit none
19 
20  ! Input/Output
21  real(kind=realtype), intent(in), dimension(:, :) :: globalvals
22  real(Kind=realtype), intent(out), dimension(:) :: funcvalues
23 
24  ! Working
25  real(kind=realtype) :: fact, factmoment, ovrnts
26  real(kind=realtype), dimension(3, nTimeIntervalsSpectral) :: force, forcep, forcev, forcem, &
27  moment, cforce, cforcep, cforcev, cforcem, &
28  cmoment, cofx, cofy, cofz
29  real(kind=realtype), dimension(3) :: vcoordref, vfreestreamref
30  real(kind=realtype) :: mavgptot, mavgttot, mavgrho, mavgps, mflow, mavgmn, mavga, &
31  mavgvx, mavgvy, mavgvz, garea, mavgvi, fxlift, fylift, fzlift
32 
33  real(kind=realtype) :: vdotn, mag, u, v, w, ks_comp
34  integer(kind=intType) :: sps
35  real(kind=realtype), dimension(8) :: dcdq, dcdqdot
36  real(kind=realtype), dimension(8) :: dcdalpha, dcdalphadot
37  real(kind=realtype), dimension(8) :: coef0
38 
39  ! Factor used for time-averaged quantities.
40  ovrnts = one / ntimeintervalsspectral
41 
42  ! Sum pressure and viscous contributions
43  force = globalvals(ifp:ifp + 2, :) + globalvals(ifv:ifv + 2, :) + globalvals(iflowfm:iflowfm + 2, :)
44  forcep = globalvals(ifp:ifp + 2, :)
45  forcev = globalvals(ifv:ifv + 2, :)
46  forcem = globalvals(iflowfm:iflowfm + 2, :)
47 
48  cofx = globalvals(icoforcex:icoforcex + 2, :)
49  cofy = globalvals(icoforcey:icoforcey + 2, :)
50  cofz = globalvals(icoforcez:icoforcez + 2, :)
51 
52  moment = globalvals(imp:imp + 2, :) + globalvals(imv:imv + 2, :) + globalvals(iflowmm:iflowmm + 2, :)
53 
54  fact = two / (gammainf * machcoef * machcoef &
55  * surfaceref * lref * lref * pref)
56  cforce = fact * force
57  cforcep = fact * forcep
58  cforcev = fact * forcev
59  cforcem = fact * forcem
60 
61  ! Moment factor has an extra lengthRef
62  fact = fact / (lengthref * lref)
63  cmoment = fact * moment
64 
65  ! Zero values since we are summing.
66  funcvalues = zero
67 
68  ! Here we finally assign the final function values
69  !$AD II-LOOP
70  do sps = 1, ntimeintervalsspectral
71  funcvalues(costfuncforcex) = funcvalues(costfuncforcex) + ovrnts * force(1, sps)
72  funcvalues(costfuncforcey) = funcvalues(costfuncforcey) + ovrnts * force(2, sps)
73  funcvalues(costfuncforcez) = funcvalues(costfuncforcez) + ovrnts * force(3, sps)
74 
75  funcvalues(costfuncforcexpressure) = funcvalues(costfuncforcexpressure) + ovrnts * forcep(1, sps)
76  funcvalues(costfuncforceypressure) = funcvalues(costfuncforceypressure) + ovrnts * forcep(2, sps)
77  funcvalues(costfuncforcezpressure) = funcvalues(costfuncforcezpressure) + ovrnts * forcep(3, sps)
78 
79  funcvalues(costfuncforcexviscous) = funcvalues(costfuncforcexviscous) + ovrnts * forcev(1, sps)
80  funcvalues(costfuncforceyviscous) = funcvalues(costfuncforceyviscous) + ovrnts * forcev(2, sps)
81  funcvalues(costfuncforcezviscous) = funcvalues(costfuncforcezviscous) + ovrnts * forcev(3, sps)
82 
83  funcvalues(costfuncforcexmomentum) = funcvalues(costfuncforcexmomentum) + ovrnts * forcem(1, sps)
84  funcvalues(costfuncforceymomentum) = funcvalues(costfuncforceymomentum) + ovrnts * forcem(2, sps)
85  funcvalues(costfuncforcezmomentum) = funcvalues(costfuncforcezmomentum) + ovrnts * forcem(3, sps)
86 
87  ! ------------
88 
89  funcvalues(costfuncforcexcoef) = funcvalues(costfuncforcexcoef) + ovrnts * cforce(1, sps)
90  funcvalues(costfuncforceycoef) = funcvalues(costfuncforceycoef) + ovrnts * cforce(2, sps)
91  funcvalues(costfuncforcezcoef) = funcvalues(costfuncforcezcoef) + ovrnts * cforce(3, sps)
92 
93  funcvalues(costfuncforcexcoefpressure) = funcvalues(costfuncforcexcoefpressure) + ovrnts * cforcep(1, sps)
94  funcvalues(costfuncforceycoefpressure) = funcvalues(costfuncforceycoefpressure) + ovrnts * cforcep(2, sps)
95  funcvalues(costfuncforcezcoefpressure) = funcvalues(costfuncforcezcoefpressure) + ovrnts * cforcep(3, sps)
96 
97  funcvalues(costfuncforcexcoefviscous) = funcvalues(costfuncforcexcoefviscous) + ovrnts * cforcev(1, sps)
98  funcvalues(costfuncforceycoefviscous) = funcvalues(costfuncforceycoefviscous) + ovrnts * cforcev(2, sps)
99  funcvalues(costfuncforcezcoefviscous) = funcvalues(costfuncforcezcoefviscous) + ovrnts * cforcev(3, sps)
100 
101  funcvalues(costfuncforcexcoefmomentum) = funcvalues(costfuncforcexcoefmomentum) + ovrnts * cforcem(1, sps)
102  funcvalues(costfuncforceycoefmomentum) = funcvalues(costfuncforceycoefmomentum) + ovrnts * cforcem(2, sps)
103  funcvalues(costfuncforcezcoefmomentum) = funcvalues(costfuncforcezcoefmomentum) + ovrnts * cforcem(3, sps)
104 
105  ! ------------
106 
107  ! center of pressure (these are actually center of all forces)
108  ! protect the divisions against zero, and divide the weighed sum by the force magnitude
109  ! for this time spectral instance before we add it to the sum
110  if (force(1, sps) /= zero) then
111  cofx(:, sps) = cofx(:, sps) / force(1, sps)
112  else
113  cofx(:, sps) = zero
114  end if
115 
116  if (force(2, sps) /= zero) then
117  cofy(:, sps) = cofy(:, sps) / force(2, sps)
118  else
119  cofy(:, sps) = zero
120  end if
121 
122  if (force(3, sps) /= zero) then
123  cofz(:, sps) = cofz(:, sps) / force(3, sps)
124  else
125  cofz(:, sps) = zero
126  end if
127 
128  ! Fx
129  funcvalues(costfunccoforcexx) = funcvalues(costfunccoforcexx) + ovrnts * cofx(1, sps)
130  funcvalues(costfunccoforcexy) = funcvalues(costfunccoforcexy) + ovrnts * cofx(2, sps)
131  funcvalues(costfunccoforcexz) = funcvalues(costfunccoforcexz) + ovrnts * cofx(3, sps)
132 
133  ! Fy
134  funcvalues(costfunccoforceyx) = funcvalues(costfunccoforceyx) + ovrnts * cofy(1, sps)
135  funcvalues(costfunccoforceyy) = funcvalues(costfunccoforceyy) + ovrnts * cofy(2, sps)
136  funcvalues(costfunccoforceyz) = funcvalues(costfunccoforceyz) + ovrnts * cofy(3, sps)
137 
138  ! Fz
139  funcvalues(costfunccoforcezx) = funcvalues(costfunccoforcezx) + ovrnts * cofz(1, sps)
140  funcvalues(costfunccoforcezy) = funcvalues(costfunccoforcezy) + ovrnts * cofz(2, sps)
141  funcvalues(costfunccoforcezz) = funcvalues(costfunccoforcezz) + ovrnts * cofz(3, sps)
142 
143  ! ------------
144 
145  funcvalues(costfuncmomx) = funcvalues(costfuncmomx) + ovrnts * moment(1, sps)
146  funcvalues(costfuncmomy) = funcvalues(costfuncmomy) + ovrnts * moment(2, sps)
147  funcvalues(costfuncmomz) = funcvalues(costfuncmomz) + ovrnts * moment(3, sps)
148 
149  funcvalues(costfuncmomxcoef) = funcvalues(costfuncmomxcoef) + ovrnts * cmoment(1, sps)
150  funcvalues(costfuncmomycoef) = funcvalues(costfuncmomycoef) + ovrnts * cmoment(2, sps)
151  funcvalues(costfuncmomzcoef) = funcvalues(costfuncmomzcoef) + ovrnts * cmoment(3, sps)
152 
153  ! final part of the KS computation
154  if (computesepsensorks) then
155  ! only calculate the log part if we are actually computing for separation for KS method.
156  ks_comp = ovrnts * (sepsenmaxfamily(sps) + &
157  log(globalvals(isepsensorks, sps)) / sepsenmaxrho)
158 
159  funcvalues(costfuncsepsensorks) = funcvalues(costfuncsepsensorks) + ks_comp
160 
161  funcvalues(costfuncsepsensorksarea) = funcvalues(costfuncsepsensorksarea) + &
162  ovrnts * globalvals(isepsensorksarea, sps) * ks_comp * &
163  one / (one + exp(2 * sepsensorkssharpness &
164  * (ks_comp + sepsensorksoffset))) + &
165  ovrnts * globalvals(isepsensorarea, sps)
166 
167  end if
168 
169  funcvalues(costfuncsepsensor) = funcvalues(costfuncsepsensor) + ovrnts * globalvals(isepsensor, sps)
170 
171  funcvalues(costfunccavitation) = funcvalues(costfunccavitation) + ovrnts * globalvals(icavitation, sps)
172  ! final part of the KS computation
173  if (computecavitation) then
174  ! only calculate the log part if we are actually computing for cavitation.
175  ! If we are not computing cavitation, the iCpMin in globalVals will be zero,
176  ! which doesn't play well with log. we just want to return zero here.
177  funcvalues(costfunccpmin) = funcvalues(costfunccpmin) + ovrnts * &
178  (cpmin_family(sps) - log(globalvals(icpmin, sps)) / cpmin_rho)
179  end if
180 
181  funcvalues(costfuncaxismoment) = funcvalues(costfuncaxismoment) + ovrnts * globalvals(iaxismoment, sps)
182  funcvalues(costfuncsepsensoravgx) = funcvalues(costfuncsepsensoravgx) + ovrnts * globalvals(isepavg, sps)
183  funcvalues(costfuncsepsensoravgy) = funcvalues(costfuncsepsensoravgy) + &
184  ovrnts * globalvals(isepavg + 1, sps)
185  funcvalues(costfuncsepsensoravgz) = funcvalues(costfuncsepsensoravgz) + &
186  ovrnts * globalvals(isepavg + 2, sps)
187  funcvalues(costfuncarea) = funcvalues(costfuncarea) + ovrnts * globalvals(iarea, sps)
188  funcvalues(costfuncflowpower) = funcvalues(costfuncflowpower) + ovrnts * globalvals(ipower, sps)
189 
190  funcvalues(costfunccperror2) = funcvalues(costfunccperror2) + ovrnts * globalvals(icperror2, sps)
191 
192  ! Mass flow like objective
193  mflow = globalvals(imassflow, sps)
194  if (mflow /= zero) then
195  mavgptot = globalvals(imassptot, sps) / mflow
196  mavgttot = globalvals(imassttot, sps) / mflow
197  mavgrho = globalvals(imassrho, sps) / mflow
198  mavgps = globalvals(imassps, sps) / mflow
199  mavgmn = globalvals(imassmn, sps) / mflow
200  mavga = globalvals(imassa, sps) / mflow
201 
202  mavgvx = globalvals(imassvx, sps) / mflow
203  mavgvy = globalvals(imassvy, sps) / mflow
204  mavgvz = globalvals(imassvz, sps) / mflow
205 
206  mavgvi = (globalvals(imassvi, sps) / mflow)
207 
208  mag = sqrt(globalvals(imassnx, sps)**2 + &
209  globalvals(imassny, sps)**2 + &
210  globalvals(imassnz, sps)**2)
211 
212  else
213  mavgptot = zero
214  mavgttot = zero
215  mavgrho = zero
216  mavgps = zero
217  mavgmn = zero
218  mavga = zero
219  mavgvx = zero
220  mavgvy = zero
221  mavgvz = zero
222  mavgvi = zero
223 
224  end if
225 
226  ! area averaged objectives
227  garea = globalvals(iarea, sps)
228  if (garea /= zero) then
229  ! area averaged pressure
230  funcvalues(costfuncaavgptot) = funcvalues(costfuncaavgptot) + &
231  ovrnts * globalvals(iareaptot, sps) / garea
232  funcvalues(costfuncaavgps) = funcvalues(costfuncaavgps) + &
233  ovrnts * globalvals(iareaps, sps) / garea
234  end if
235 
236  funcvalues(costfuncmdot) = funcvalues(costfuncmdot) + ovrnts * mflow
237  funcvalues(costfuncmavgptot) = funcvalues(costfuncmavgptot) + ovrnts * mavgptot
238  funcvalues(costfuncmavgttot) = funcvalues(costfuncmavgttot) + ovrnts * mavgttot
239  funcvalues(costfuncmavgrho) = funcvalues(costfuncmavgrho) + ovrnts * mavgrho
240  funcvalues(costfuncmavgps) = funcvalues(costfuncmavgps) + ovrnts * mavgps
241  funcvalues(costfuncmavgmn) = funcvalues(costfuncmavgmn) + ovrnts * mavgmn
242  funcvalues(costfuncmavga) = funcvalues(costfuncmavga) + ovrnts * mavga
243  funcvalues(costfuncmavgvx) = funcvalues(costfuncmavgvx) + ovrnts * mavgvx
244  funcvalues(costfuncmavgvy) = funcvalues(costfuncmavgvy) + ovrnts * mavgvy
245  funcvalues(costfuncmavgvz) = funcvalues(costfuncmavgvz) + ovrnts * mavgvz
246  funcvalues(costfuncmavgvi) = funcvalues(costfuncmavgvi) + ovrnts * mavgvi
247  ! Bending moment calc - also broken.
248  ! call computeRootBendingMoment(cForce, cMoment, liftIndex, bendingMoment)
249  ! funcValues(costFuncBendingCoef) = funcValues(costFuncBendingCoef) + ovrNTS*bendingMoment
250 
251  end do
252 
253  ! Lift and Drag (coefficients): Dot product with the lift/drag direction.
254  funcvalues(costfunclift) = &
255  funcvalues(costfuncforcex) * liftdirection(1) + &
256  funcvalues(costfuncforcey) * liftdirection(2) + &
257  funcvalues(costfuncforcez) * liftdirection(3)
258 
259  funcvalues(costfuncliftpressure) = &
260  funcvalues(costfuncforcexpressure) * liftdirection(1) + &
261  funcvalues(costfuncforceypressure) * liftdirection(2) + &
262  funcvalues(costfuncforcezpressure) * liftdirection(3)
263 
264  funcvalues(costfuncliftviscous) = &
265  funcvalues(costfuncforcexviscous) * liftdirection(1) + &
266  funcvalues(costfuncforceyviscous) * liftdirection(2) + &
267  funcvalues(costfuncforcezviscous) * liftdirection(3)
268 
269  funcvalues(costfuncliftmomentum) = &
270  funcvalues(costfuncforcexmomentum) * liftdirection(1) + &
271  funcvalues(costfuncforceymomentum) * liftdirection(2) + &
272  funcvalues(costfuncforcezmomentum) * liftdirection(3)
273 
274  !-----
275 
276  funcvalues(costfuncdrag) = &
277  funcvalues(costfuncforcex) * dragdirection(1) + &
278  funcvalues(costfuncforcey) * dragdirection(2) + &
279  funcvalues(costfuncforcez) * dragdirection(3)
280 
281  funcvalues(costfuncdragpressure) = &
282  funcvalues(costfuncforcexpressure) * dragdirection(1) + &
283  funcvalues(costfuncforceypressure) * dragdirection(2) + &
284  funcvalues(costfuncforcezpressure) * dragdirection(3)
285 
286  funcvalues(costfuncdragviscous) = &
287  funcvalues(costfuncforcexviscous) * dragdirection(1) + &
288  funcvalues(costfuncforceyviscous) * dragdirection(2) + &
289  funcvalues(costfuncforcezviscous) * dragdirection(3)
290 
291  funcvalues(costfuncdragmomentum) = &
292  funcvalues(costfuncforcexmomentum) * dragdirection(1) + &
293  funcvalues(costfuncforceymomentum) * dragdirection(2) + &
294  funcvalues(costfuncforcezmomentum) * dragdirection(3)
295 
296  !-----
297 
298  funcvalues(costfuncliftcoef) = &
299  funcvalues(costfuncforcexcoef) * liftdirection(1) + &
300  funcvalues(costfuncforceycoef) * liftdirection(2) + &
301  funcvalues(costfuncforcezcoef) * liftdirection(3)
302 
303  funcvalues(costfuncliftcoefpressure) = &
304  funcvalues(costfuncforcexcoefpressure) * liftdirection(1) + &
305  funcvalues(costfuncforceycoefpressure) * liftdirection(2) + &
307 
308  funcvalues(costfuncliftcoefviscous) = &
309  funcvalues(costfuncforcexcoefviscous) * liftdirection(1) + &
310  funcvalues(costfuncforceycoefviscous) * liftdirection(2) + &
312 
313  funcvalues(costfuncliftcoefmomentum) = &
314  funcvalues(costfuncforcexcoefmomentum) * liftdirection(1) + &
315  funcvalues(costfuncforceycoefmomentum) * liftdirection(2) + &
317 
318  !-----
319 
320  funcvalues(costfuncdragcoef) = &
321  funcvalues(costfuncforcexcoef) * dragdirection(1) + &
322  funcvalues(costfuncforceycoef) * dragdirection(2) + &
323  funcvalues(costfuncforcezcoef) * dragdirection(3)
324 
325  funcvalues(costfuncdragcoefpressure) = &
326  funcvalues(costfuncforcexcoefpressure) * dragdirection(1) + &
327  funcvalues(costfuncforceycoefpressure) * dragdirection(2) + &
329 
330  funcvalues(costfuncdragcoefviscous) = &
331  funcvalues(costfuncforcexcoefviscous) * dragdirection(1) + &
332  funcvalues(costfuncforceycoefviscous) * dragdirection(2) + &
334 
335  funcvalues(costfuncdragcoefmomentum) = &
336  funcvalues(costfuncforcexcoefmomentum) * dragdirection(1) + &
337  funcvalues(costfuncforceycoefmomentum) * dragdirection(2) + &
339 
340  ! ----- Center of Lift
341 
342  ! dot product the 3 forces with the lift direction separately
343  fxlift = funcvalues(costfuncforcex) * liftdirection(1)
344  fylift = funcvalues(costfuncforcey) * liftdirection(2)
345  fzlift = funcvalues(costfuncforcez) * liftdirection(3)
346 
347  ! run the weighed average for the 3 components of center of lift
348  ! protect against division by zero
349  if ((fxlift + fylift + fzlift) /= zero) then
350  funcvalues(costfunccofliftx) = (fxlift * funcvalues(costfunccoforcexx) + &
351  fylift * funcvalues(costfunccoforceyx) + &
352  fzlift * funcvalues(costfunccoforcezx)) / &
353  (fxlift + fylift + fzlift)
354  funcvalues(costfunccoflifty) = (fxlift * funcvalues(costfunccoforcexy) + &
355  fylift * funcvalues(costfunccoforceyy) + &
356  fzlift * funcvalues(costfunccoforcezy)) / &
357  (fxlift + fylift + fzlift)
358  funcvalues(costfunccofliftz) = (fxlift * funcvalues(costfunccoforcexz) + &
359  fylift * funcvalues(costfunccoforceyz) + &
360  fzlift * funcvalues(costfunccoforcezz)) / &
361  (fxlift + fylift + fzlift)
362  else
363  funcvalues(costfunccofliftx) = zero
364  funcvalues(costfunccoflifty) = zero
365  funcvalues(costfunccofliftz) = zero
366  end if
367 
368  ! -------------------- Time Spectral Objectives ------------------
369 
370  if (tsstability) then
371  print *, 'Error: TSStabilityDerivatives are *BROKEN*. They need to be '&
372  &'completely verifed from scratch'
373  stop
374 
375  call computetsderivatives(force, moment, coef0, dcdalpha, &
376  dcdalphadot, dcdq, dcdqdot)
377 
378  funcvalues(costfunccl0) = coef0(1)
379  funcvalues(costfunccd0) = coef0(2)
380  funcvalues(costfunccfy0) = coef0(4)
381  funcvalues(costfunccm0) = coef0(8)
382 
383  funcvalues(costfuncclalpha) = dcdalpha(1)
384  funcvalues(costfunccdalpha) = dcdalpha(2)
385  funcvalues(costfunccfyalpha) = dcdalpha(4)
386  funcvalues(costfunccmzalpha) = dcdalpha(8)
387 
388  funcvalues(costfuncclalphadot) = dcdalphadot(1)
389  funcvalues(costfunccdalphadot) = dcdalphadot(2)
390  funcvalues(costfunccfyalphadot) = dcdalphadot(4)
391  funcvalues(costfunccmzalphadot) = dcdalphadot(8)
392 
393  funcvalues(costfuncclq) = dcdq(1)
394  funcvalues(costfunccdq) = dcdq(2)
395  funcvalues(costfunccfyq) = dcdq(4)
396  funcvalues(costfunccmzq) = dcdq(8)
397 
398  funcvalues(costfuncclqdot) = dcdqdot(1)
399  funcvalues(costfunccdqdot) = dcdqdot(2)
400  funcvalues(costfunccfyqdot) = dcdqdot(4)
401  funcvalues(costfunccmzqdot) = dcdqdot(8)
402  end if
403 
404  end subroutine getcostfunctions
405 
406  subroutine wallintegrationface(localValues, mm)
407  !
408  ! wallIntegrations computes the contribution of the block
409  ! given by the pointers in blockPointers to the force and
410  ! moment of the geometry. A distinction is made
411  ! between the inviscid and viscous parts. In case the maximum
412  ! yplus value must be monitored (only possible for rans), this
413  ! value is also computed. The separation sensor and the cavita-
414  ! tion sensor is also computed
415  ! here.
416  !
417  use constants
418  use communication
419  use blockpointers
420  use flowvarrefstate
425  use bcpointers
426  implicit none
427 
428  ! Input/output variables
429  real(kind=realtype), dimension(nLocalValues), intent(inout) :: localvalues
430  integer(kind=intType) :: mm
431 
432  ! Local variables.
433  real(kind=realtype), dimension(3) :: fp, fv, mp, mv
434  real(kind=realtype), dimension(3) :: cofsumfx, cofsumfy, cofsumfz
435  real(kind=realtype) :: yplusmax, sepsensorks, sepsensor, sepsensoravg(3), &
436  sepsensorarea, cavitation, cpmin_ks_sum, sepsensorksarea
437  integer(kind=intType) :: i, j, ii, blk
438 
439  real(kind=realtype) :: pm1, fx, fy, fz, fn
440  real(kind=realtype) :: vecttangential(3)
441  real(kind=realtype) :: vectdotproductfsnormal
442  real(kind=realtype) :: xc, xco, yc, yco, zc, zco, qf(3), r(3), n(3), l
443  real(kind=realtype) :: fact, rho, mul, yplus, dwall
444  real(kind=realtype) :: v(3), sensor, sensor1, cp, tmp, plocal, ks_exponent
445  real(kind=realtype) :: tauxx, tauyy, tauzz
446  real(kind=realtype) :: tauxy, tauxz, tauyz
447 
448  real(kind=realtype), dimension(3) :: refpoint
449  real(kind=realtype), dimension(3, 2) :: axispoints
450  real(kind=realtype) :: mx, my, mz, cellarea, m0x, m0y, m0z, mvaxis, mpaxis
451  real(kind=realtype) :: cperror, cperror2
452 
453  select case (bcfaceid(mm))
454  case (imin, jmin, kmin)
455  fact = -one
456  case (imax, jmax, kmax)
457  fact = one
458  end select
459 
460  ! Determine the reference point for the moment computation in
461  ! meters.
462 
463  refpoint(1) = lref * pointref(1)
464  refpoint(2) = lref * pointref(2)
465  refpoint(3) = lref * pointref(3)
466 
467  ! Determine the points defining the axis about which to compute a moment
468  axispoints(1, 1) = lref * momentaxis(1, 1)
469  axispoints(1, 2) = lref * momentaxis(1, 2)
470  axispoints(2, 1) = lref * momentaxis(2, 1)
471  axispoints(2, 2) = lref * momentaxis(2, 2)
472  axispoints(3, 1) = lref * momentaxis(3, 1)
473  axispoints(3, 2) = lref * momentaxis(3, 2)
474 
475  ! Initialize the force and moment coefficients to 0 as well as
476  ! yplusMax.
477 
478  fp = zero; fv = zero;
479  mp = zero; mv = zero;
480  cofsumfx = zero; cofsumfy = zero; cofsumfz = zero
481  yplusmax = zero
482  sepsensor = zero
483  sepsensorks = zero
484  sepsensorarea = zero
485  sepsensorksarea = zero
486  cavitation = zero
487  cpmin_ks_sum = zero
488  sepsensoravg = zero
489  mpaxis = zero; mvaxis = zero;
490  cperror2 = zero;
491  !
492  ! Integrate the inviscid contribution over the solid walls,
493  ! either inviscid or viscous. The integration is done with
494  ! cp. For closed contours this is equal to the integration
495  ! of p; for open contours this is not the case anymore.
496  ! Question is whether a force for an open contour is
497  ! meaningful anyway.
498  !
499 
500  ! Loop over the quadrilateral faces of the subface. Note that
501  ! the nodal range of BCData must be used and not the cell
502  ! range, because the latter may include the halo's in i and
503  ! j-direction. The offset +1 is there, because inBeg and jnBeg
504  ! refer to nodal ranges and not to cell ranges. The loop
505  ! (without the AD stuff) would look like:
506  !
507  ! do j=(BCData(mm)%jnBeg+1),BCData(mm)%jnEnd
508  ! do i=(BCData(mm)%inBeg+1),BCData(mm)%inEnd
509 
510  !$AD II-LOOP
511  do ii = 0, (bcdata(mm)%jnEnd - bcdata(mm)%jnBeg) * (bcdata(mm)%inEnd - bcdata(mm)%inBeg) - 1
512  i = mod(ii, (bcdata(mm)%inEnd - bcdata(mm)%inBeg)) + bcdata(mm)%inBeg + 1
513  j = ii / (bcdata(mm)%inEnd - bcdata(mm)%inBeg) + bcdata(mm)%jnBeg + 1
514 
515  ! Compute the average pressure minus 1 and the coordinates
516  ! of the centroid of the face relative from from the
517  ! moment reference point. Due to the usage of pointers for
518  ! the coordinates, whose original array starts at 0, an
519  ! offset of 1 must be used. The pressure is multipled by
520  ! fact to account for the possibility of an inward or
521  ! outward pointing normal.
522 
523  pm1 = fact * (half * (pp2(i, j) + pp1(i, j)) - pinf) * pref
524 
525  tmp = two / (gammainf * pinf * machcoef * machcoef)
526  cp = (half * (pp2(i, j) + pp1(i, j)) - pinf) * tmp
527  cperror = (cp - bcdata(mm)%CpTarget(i, j))
528  cperror2 = cperror2 + cperror * cperror
529 
530  xc = fourth * (xx(i, j, 1) + xx(i + 1, j, 1) &
531  + xx(i, j + 1, 1) + xx(i + 1, j + 1, 1)) - refpoint(1)
532  yc = fourth * (xx(i, j, 2) + xx(i + 1, j, 2) &
533  + xx(i, j + 1, 2) + xx(i + 1, j + 1, 2)) - refpoint(2)
534  zc = fourth * (xx(i, j, 3) + xx(i + 1, j, 3) &
535  + xx(i, j + 1, 3) + xx(i + 1, j + 1, 3)) - refpoint(3)
536 
537  ! Compute the force components.
538  blk = max(bcdata(mm)%iblank(i, j), 0)
539  fx = pm1 * ssi(i, j, 1)
540  fy = pm1 * ssi(i, j, 2)
541  fz = pm1 * ssi(i, j, 3)
542 
543  ! Note from AY: Technically, we can just compute the moments using the center of force
544  ! terms. However, the moment computations coded here distinguish pressure,
545  ! viscous, and momentum contributions to moment. Even though these individual
546  ! contributions are not exposed to python, I still wanted to keep how it's done in the
547  ! code in case its useful in the future. This is also true for the face integrations
548 
549  ! Update the inviscid force and moment coefficients. Iblank as we sum
550  fp(1) = fp(1) + fx * blk
551  fp(2) = fp(2) + fy * blk
552  fp(3) = fp(3) + fz * blk
553 
554  mx = yc * fz - zc * fy
555  my = zc * fx - xc * fz
556  mz = xc * fy - yc * fx
557 
558  mp(1) = mp(1) + mx * blk
559  mp(2) = mp(2) + my * blk
560  mp(3) = mp(3) + mz * blk
561 
562  ! the force integral for the center of pressure computation.
563  ! We need the cell centers wrt origin
564  xco = fourth * (xx(i, j, 1) + xx(i + 1, j, 1) &
565  + xx(i, j + 1, 1) + xx(i + 1, j + 1, 1))
566  yco = fourth * (xx(i, j, 2) + xx(i + 1, j, 2) &
567  + xx(i, j + 1, 2) + xx(i + 1, j + 1, 2))
568  zco = fourth * (xx(i, j, 3) + xx(i + 1, j, 3) &
569  + xx(i, j + 1, 3) + xx(i + 1, j + 1, 3))
570 
571  ! accumulate in the sums. each force component is tracked separately
572 
573  ! Force-X
574  cofsumfx(1) = cofsumfx(1) + xco * fx * blk
575  cofsumfx(2) = cofsumfx(2) + yco * fx * blk
576  cofsumfx(3) = cofsumfx(3) + zco * fx * blk
577 
578  ! Force-Y
579  cofsumfy(1) = cofsumfy(1) + xco * fy * blk
580  cofsumfy(2) = cofsumfy(2) + yco * fy * blk
581  cofsumfy(3) = cofsumfy(3) + zco * fy * blk
582 
583  ! Force-Z
584  cofsumfz(1) = cofsumfz(1) + xco * fz * blk
585  cofsumfz(2) = cofsumfz(2) + yco * fz * blk
586  cofsumfz(3) = cofsumfz(3) + zco * fz * blk
587 
588  ! Compute the r and n vectores for the moment around an
589  ! axis computation where r is the distance from the
590  ! force to the first point on the axis and n is a unit
591  ! normal in the direction of the axis
592  r(1) = fourth * (xx(i, j, 1) + xx(i + 1, j, 1) &
593  + xx(i, j + 1, 1) + xx(i + 1, j + 1, 1)) - axispoints(1, 1)
594  r(2) = fourth * (xx(i, j, 2) + xx(i + 1, j, 2) &
595  + xx(i, j + 1, 2) + xx(i + 1, j + 1, 2)) - axispoints(2, 1)
596  r(3) = fourth * (xx(i, j, 3) + xx(i + 1, j, 3) &
597  + xx(i, j + 1, 3) + xx(i + 1, j + 1, 3)) - axispoints(3, 1)
598 
599  l = sqrt((axispoints(1, 2) - axispoints(1, 1))**2 &
600  + (axispoints(2, 2) - axispoints(2, 1))**2 &
601  + (axispoints(3, 2) - axispoints(3, 1))**2)
602 
603  n(1) = (axispoints(1, 2) - axispoints(1, 1)) / l
604  n(2) = (axispoints(2, 2) - axispoints(2, 1)) / l
605  n(3) = (axispoints(3, 2) - axispoints(3, 1)) / l
606 
607  ! Compute the moment of the force about the first point
608  ! used to define the axis, and the project that axis in
609  ! the n direction
610  m0x = r(2) * fz - r(3) * fy
611  m0y = r(3) * fx - r(1) * fz
612  m0z = r(1) * fy - r(2) * fx
613  mpaxis = mpaxis + (m0x * n(1) + m0y * n(2) + m0z * n(3)) * blk
614 
615  ! Save the face-based forces and area
616  bcdata(mm)%Fp(i, j, 1) = fx
617  bcdata(mm)%Fp(i, j, 2) = fy
618  bcdata(mm)%Fp(i, j, 3) = fz
619  cellarea = sqrt(ssi(i, j, 1)**2 + ssi(i, j, 2)**2 + ssi(i, j, 3)**2)
620 
621  bcdata(mm)%area(i, j) = cellarea
622 
623  ! Get normalized surface velocity:
624  v(1) = ww2(i, j, ivx)
625  v(2) = ww2(i, j, ivy)
626  v(3) = ww2(i, j, ivz)
627  v = v / (sqrt(v(1)**2 + v(2)**2 + v(3)**2) + 1e-16)
628 
629  if (computesepsensorks) then
630  ! Freestream projection over the surface.
631  vectdotproductfsnormal = veldirfreestream(1) * bcdata(mm)%norm(i, j, 1) + &
632  veldirfreestream(2) * bcdata(mm)%norm(i, j, 2) + &
633  veldirfreestream(3) * bcdata(mm)%norm(i, j, 3)
634  ! Tangential Vector on the surface, which is the freestream projected vector
635  vecttangential(1) = veldirfreestream(1) - vectdotproductfsnormal * bcdata(mm)%norm(i, j, 1)
636  vecttangential(2) = veldirfreestream(2) - vectdotproductfsnormal * bcdata(mm)%norm(i, j, 2)
637  vecttangential(3) = veldirfreestream(3) - vectdotproductfsnormal * bcdata(mm)%norm(i, j, 3)
638 
639  vecttangential = vecttangential / (sqrt(vecttangential(1)**2 + vecttangential(2)**2 + &
640  vecttangential(3)**2) + 1e-16)
641 
642  ! computing separation sensor
643  ! velocity dot products
644  sensor = (v(1) * vecttangential(1) + v(2) * vecttangential(2) + &
645  v(3) * vecttangential(3))
646 
647  ! sepsensor value
648  sensor = (cos(degtorad * sepsensorksphi) - sensor) / &
649  (-cos(degtorad * sepsensorksphi) + cos(zero) + 1e-16)
650 
651  ! also do the ks-based spensenor max computation
653 
654  sepsensorksarea = sepsensorksarea + blk * cellarea
655  sepsensorarea = cellarea * blk * one / (one + exp(-2 * sepsensorkssharpness &
656  * (sensor + sepsensorksoffset))) + sepsensorarea
657 
658  sepsensorks = sepsensorks + ks_exponent * blk
659 
660  end if
661 
662  ! Dot product with free stream
663  sensor = -(v(1) * veldirfreestream(1) + v(2) * veldirfreestream(2) + &
664  v(3) * veldirfreestream(3))
665 
666  !Now run through a smooth heaviside function:
667  sensor = one / (one + exp(-2 * sepsensorsharpness * (sensor - sepsensoroffset)))
668 
669  ! And integrate over the area of this cell and save, blanking as we go.
670  sensor = sensor * cellarea * blk
671  sepsensor = sepsensor + sensor
672 
673  ! Also accumulate into the sepSensorAvg
674  ! x-y-zco are computed above for center of force computations
675  sepsensoravg(1) = sepsensoravg(1) + sensor * xco
676  sepsensoravg(2) = sepsensoravg(2) + sensor * yco
677  sepsensoravg(3) = sepsensoravg(3) + sensor * zco
678 
679  if (computecavitation) then
680  plocal = pp2(i, j)
681  tmp = two / (gammainf * machcoef * machcoef)
682  cp = tmp * (plocal - pinf)
683  sensor1 = -cp - cavitationnumber
684  sensor1 = (sensor1**cavexponent) / (one + exp(2 * cavsensorsharpness * (-sensor1 + cavsensoroffset)))
685  sensor1 = sensor1 * cellarea * blk
686  cavitation = cavitation + sensor1
687 
688  ! also do the ks-based cpmin computation
689  ks_exponent = exp(cpmin_rho * (-cp + cpmin_family(spectralsol)))
690  cpmin_ks_sum = cpmin_ks_sum + ks_exponent * blk
691  end if
692  end do
693 
694  !
695  ! Integration of the viscous forces.
696  ! Only for viscous boundaries.
697  !
698  visforce: if (bctype(mm) == nswalladiabatic .or. &
699  bctype(mm) == nswallisothermal) then
700 
701  ! Initialize dwall for the laminar case and set the pointer
702  ! for the unit normals.
703 
704  dwall = zero
705 
706  ! Loop over the quadrilateral faces of the subface and
707  ! compute the viscous contribution to the force and
708  ! moment and update the maximum value of y+.
709 
710  !$AD II-LOOP
711  do ii = 0, (bcdata(mm)%jnEnd - bcdata(mm)%jnBeg) * (bcdata(mm)%inEnd - bcdata(mm)%inBeg) - 1
712  i = mod(ii, (bcdata(mm)%inEnd - bcdata(mm)%inBeg)) + bcdata(mm)%inBeg + 1
713  j = ii / (bcdata(mm)%inEnd - bcdata(mm)%inBeg) + bcdata(mm)%jnBeg + 1
714 
715  ! Store the viscous stress tensor a bit easier.
716  blk = max(bcdata(mm)%iblank(i, j), 0)
717 
718  tauxx = viscsubface(mm)%tau(i, j, 1)
719  tauyy = viscsubface(mm)%tau(i, j, 2)
720  tauzz = viscsubface(mm)%tau(i, j, 3)
721  tauxy = viscsubface(mm)%tau(i, j, 4)
722  tauxz = viscsubface(mm)%tau(i, j, 5)
723  tauyz = viscsubface(mm)%tau(i, j, 6)
724 
725  ! Compute the viscous force on the face. A minus sign
726  ! is now present, due to the definition of this force.
727 
728  fx = -fact * (tauxx * ssi(i, j, 1) + tauxy * ssi(i, j, 2) &
729  + tauxz * ssi(i, j, 3)) * pref
730  fy = -fact * (tauxy * ssi(i, j, 1) + tauyy * ssi(i, j, 2) &
731  + tauyz * ssi(i, j, 3)) * pref
732  fz = -fact * (tauxz * ssi(i, j, 1) + tauyz * ssi(i, j, 2) &
733  + tauzz * ssi(i, j, 3)) * pref
734 
735  ! Compute the coordinates of the centroid of the face
736  ! relative from the moment reference point. Due to the
737  ! usage of pointers for xx and offset of 1 is present,
738  ! because x originally starts at 0.
739 
740  xc = fourth * (xx(i, j, 1) + xx(i + 1, j, 1) &
741  + xx(i, j + 1, 1) + xx(i + 1, j + 1, 1)) - refpoint(1)
742  yc = fourth * (xx(i, j, 2) + xx(i + 1, j, 2) &
743  + xx(i, j + 1, 2) + xx(i + 1, j + 1, 2)) - refpoint(2)
744  zc = fourth * (xx(i, j, 3) + xx(i + 1, j, 3) &
745  + xx(i, j + 1, 3) + xx(i + 1, j + 1, 3)) - refpoint(3)
746 
747  ! Update the viscous force and moment coefficients, blanking as we go.
748 
749  fv(1) = fv(1) + fx * blk
750  fv(2) = fv(2) + fy * blk
751  fv(3) = fv(3) + fz * blk
752 
753  mx = yc * fz - zc * fy
754  my = zc * fx - xc * fz
755  mz = xc * fy - yc * fx
756 
757  mv(1) = mv(1) + mx * blk
758  mv(2) = mv(2) + my * blk
759  mv(3) = mv(3) + mz * blk
760 
761  ! the force integral for the center of pressure computation.
762  ! We need the cell centers wrt origin
763  xco = fourth * (xx(i, j, 1) + xx(i + 1, j, 1) &
764  + xx(i, j + 1, 1) + xx(i + 1, j + 1, 1))
765  yco = fourth * (xx(i, j, 2) + xx(i + 1, j, 2) &
766  + xx(i, j + 1, 2) + xx(i + 1, j + 1, 2))
767  zco = fourth * (xx(i, j, 3) + xx(i + 1, j, 3) &
768  + xx(i, j + 1, 3) + xx(i + 1, j + 1, 3))
769 
770  ! accumulate in the sums. each force component is tracked separately
771 
772  ! Force-X
773  cofsumfx(1) = cofsumfx(1) + xco * fx * blk
774  cofsumfx(2) = cofsumfx(2) + yco * fx * blk
775  cofsumfx(3) = cofsumfx(3) + zco * fx * blk
776 
777  ! Force-Y
778  cofsumfy(1) = cofsumfy(1) + xco * fy * blk
779  cofsumfy(2) = cofsumfy(2) + yco * fy * blk
780  cofsumfy(3) = cofsumfy(3) + zco * fy * blk
781 
782  ! Force-Z
783  cofsumfz(1) = cofsumfz(1) + xco * fz * blk
784  cofsumfz(2) = cofsumfz(2) + yco * fz * blk
785  cofsumfz(3) = cofsumfz(3) + zco * fz * blk
786 
787  ! Compute the r and n vectors for the moment around an
788  ! axis computation where r is the distance from the
789  ! force to the first point on the axis and n is a unit
790  ! normal in the direction of the axis
791  r(1) = fourth * (xx(i, j, 1) + xx(i + 1, j, 1) &
792  + xx(i, j + 1, 1) + xx(i + 1, j + 1, 1)) - axispoints(1, 1)
793  r(2) = fourth * (xx(i, j, 2) + xx(i + 1, j, 2) &
794  + xx(i, j + 1, 2) + xx(i + 1, j + 1, 2)) - axispoints(2, 1)
795  r(3) = fourth * (xx(i, j, 3) + xx(i + 1, j, 3) &
796  + xx(i, j + 1, 3) + xx(i + 1, j + 1, 3)) - axispoints(3, 1)
797 
798  l = sqrt((axispoints(1, 2) - axispoints(1, 1))**2 &
799  + (axispoints(2, 2) - axispoints(2, 1))**2 &
800  + (axispoints(3, 2) - axispoints(3, 1))**2)
801 
802  n(1) = (axispoints(1, 2) - axispoints(1, 1)) / l
803  n(2) = (axispoints(2, 2) - axispoints(2, 1)) / l
804  n(3) = (axispoints(3, 2) - axispoints(3, 1)) / l
805 
806  ! Compute the moment of the force about the first point
807  ! used to define the axis, and then project that axis in
808  ! the n direction
809  m0x = r(2) * fz - r(3) * fy
810  m0y = r(3) * fx - r(1) * fz
811  m0z = r(1) * fy - r(2) * fx
812  mvaxis = mvaxis + (m0x * n(1) + m0y * n(2) + m0z * n(3)) * blk
813 
814  ! Save the face based forces for the slice operations
815  bcdata(mm)%Fv(i, j, 1) = fx
816  bcdata(mm)%Fv(i, j, 2) = fy
817  bcdata(mm)%Fv(i, j, 3) = fz
818 
819  ! Compute the tangential component of the stress tensor,
820  ! which is needed to monitor y+. The result is stored
821  ! in fx, fy, fz, although it is not really a force.
822  ! As later on only the magnitude of the tangential
823  ! component is important, there is no need to take the
824  ! sign into account (it should be a minus sign).
825 
826  fx = tauxx * bcdata(mm)%norm(i, j, 1) + tauxy * bcdata(mm)%norm(i, j, 2) &
827  + tauxz * bcdata(mm)%norm(i, j, 3)
828  fy = tauxy * bcdata(mm)%norm(i, j, 1) + tauyy * bcdata(mm)%norm(i, j, 2) &
829  + tauyz * bcdata(mm)%norm(i, j, 3)
830  fz = tauxz * bcdata(mm)%norm(i, j, 1) + tauyz * bcdata(mm)%norm(i, j, 2) &
831  + tauzz * bcdata(mm)%norm(i, j, 3)
832 
833  fn = fx * bcdata(mm)%norm(i, j, 1) + fy * bcdata(mm)%norm(i, j, 2) + fz * bcdata(mm)%norm(i, j, 3)
834 
835  fx = fx - fn * bcdata(mm)%norm(i, j, 1)
836  fy = fy - fn * bcdata(mm)%norm(i, j, 2)
837  fz = fz - fn * bcdata(mm)%norm(i, j, 3)
838 
839  ! Compute the local value of y+. Due to the usage
840  ! of pointers there is on offset of -1 in dd2Wall..
841 #ifndef USE_TAPENADE
842  if (equations == ransequations) then
843  dwall = dd2wall(i - 1, j - 1)
844  rho = half * (ww2(i, j, irho) + ww1(i, j, irho))
845  mul = half * (rlv2(i, j) + rlv1(i, j))
846  yplus = sqrt(rho * sqrt(fx * fx + fy * fy + fz * fz)) * dwall / mul
847 
848  ! Store this value if this value is larger than the
849  ! currently stored value. Blank non-active cells.
850 
851  yplusmax = max(yplusmax, yplus * blk)
852  end if
853 #endif
854  end do
855  else
856  ! If we had no viscous force, set the viscous component to zero
857  bcdata(mm)%Fv = zero
858  end if visforce
859 
860  ! Increment the local values array with the values we computed here.
861  localvalues(ifp:ifp + 2) = localvalues(ifp:ifp + 2) + fp
862  localvalues(ifv:ifv + 2) = localvalues(ifv:ifv + 2) + fv
863  localvalues(imp:imp + 2) = localvalues(imp:imp + 2) + mp
864  localvalues(imv:imv + 2) = localvalues(imv:imv + 2) + mv
865  localvalues(icoforcex:icoforcex + 2) = localvalues(icoforcex:icoforcex + 2) + cofsumfx
866  localvalues(icoforcey:icoforcey + 2) = localvalues(icoforcey:icoforcey + 2) + cofsumfy
867  localvalues(icoforcez:icoforcez + 2) = localvalues(icoforcez:icoforcez + 2) + cofsumfz
868  localvalues(isepsensor) = localvalues(isepsensor) + sepsensor
869  localvalues(isepsensorks) = localvalues(isepsensorks) + sepsensorks
870  localvalues(isepsensorksarea) = localvalues(isepsensorksarea) + sepsensorksarea
871  localvalues(isepsensorarea) = localvalues(isepsensorarea) + sepsensorarea
872  localvalues(icavitation) = localvalues(icavitation) + cavitation
873  localvalues(icpmin) = localvalues(icpmin) + cpmin_ks_sum
874  localvalues(isepavg:isepavg + 2) = localvalues(isepavg:isepavg + 2) + sepsensoravg
875  localvalues(iaxismoment) = localvalues(iaxismoment) + mpaxis + mvaxis
876  localvalues(icperror2) = localvalues(icperror2) + cperror2
877 
878 #ifndef USE_TAPENADE
879  localvalues(iyplus) = max(localvalues(iyplus), yplusmax)
880 #endif
881  end subroutine wallintegrationface
882 
883  subroutine ksaggregationfunction(g, max_g, g_rho, ks_g)
884 
885  use precision
886 
887  real(kind=realtype), intent(inout) :: ks_g
888  real(kind=realtype), intent(in) :: g, max_g, g_rho
889 
890  ks_g = exp(g_rho * (g - max_g))
891 
892  end subroutine ksaggregationfunction
893 
894  subroutine flowintegrationface(isInflow, localValues, mm)
895 
896  use constants
900  use flowutils, only: computeptot, computettot
901  use bcpointers, only: ssi, sface, ww1, ww2, pp1, pp2, xx, gamma1, gamma2
902  use utils, only: mynorm2
903  implicit none
904 
905  ! Input/Output variables
906  logical, intent(in) :: isInflow
907  real(kind=realtype), dimension(nLocalValues), intent(inout) :: localvalues
908  integer(kind=intType), intent(in) :: mm
909 
910  ! Local variables
911  real(kind=realtype) :: massflowrate, mass_ptot, mass_ttot, mass_ps, mass_mn, mass_a, mass_rho, &
912  mass_vx, mass_vy, mass_vz, mass_nx, mass_ny, mass_nz, mass_vi
913  real(kind=realtype) :: area_ptot, area_ps
914  real(kind=realtype) :: govgm1, gm1ovg, viconst, vilocal, pratio
915  real(kind=realtype) :: mredim
916  integer(kind=intType) :: i, j, ii, blk
917  real(kind=realtype) :: internalflowfact, inflowfact, fact, xc, xco, yc, yco, zc, zco, mx, my, mz
918  real(kind=realtype) :: sf, vmag, vnm, vnmfreestreamref, vxm, vym, vzm, fx, fy, fz, u, v, w
919  real(kind=realtype) :: pm, ptot, ttot, rhom, gammam, am
920  real(kind=realtype) :: area, cellarea, overcellarea
921  real(kind=realtype), dimension(3) :: fp, mp, fmom, mmom, refpoint, sfacecoordref
922  real(kind=realtype), dimension(3) :: cofsumfx, cofsumfy, cofsumfz
923  real(kind=realtype) :: mnm, massflowratelocal
924 
925  refpoint(1) = lref * pointref(1)
926  refpoint(2) = lref * pointref(2)
927  refpoint(3) = lref * pointref(3)
928 
929  ! Note that these are *opposite* of force integrations. The reason
930  ! is that we want positive mass flow into the domain and negative
931  ! mass flow out of the domain. Since the low faces have ssi
932  ! vectors pointining into the domain, this is correct. The high
933  ! end faces need to flip this.
934  select case (bcfaceid(mm))
935  case (imin, jmin, kmin)
936  fact = one
937  case (imax, jmax, kmax)
938  fact = -one
939  end select
940 
941  ! the sign of momentum forces are flipped for internal flows
942  internalflowfact = one
943  if (flowtype == internalflow) then
944  internalflowfact = -one
945  end if
946 
947  inflowfact = one
948  if (isinflow) then
949  inflowfact = -one
950  end if
951 
952  ! Loop over the quadrilateral faces of the subface. Note that
953  ! the nodal range of BCData must be used and not the cell
954  ! range, because the latter may include the halo's in i and
955  ! j-direction. The offset +1 is there, because inBeg and jnBeg
956  ! refer to nodal ranges and not to cell ranges. The loop
957  ! (without the AD stuff) would look like:
958  !
959  ! do j=(BCData(mm)%jnBeg+1),BCData(mm)%jnEnd
960  ! do i=(BCData(mm)%inBeg+1),BCData(mm)%inEnd
961 
962  mredim = sqrt(pref * rhoref)
963  fp = zero
964  mp = zero
965  fmom = zero
966  mmom = zero
967 
968  cofsumfx = zero
969  cofsumfy = zero
970  cofsumfz = zero
971 
972  massflowrate = zero
973  area = zero
974  mass_ptot = zero
975  mass_ttot = zero
976  mass_ps = zero
977  mass_mn = zero
978  mass_a = zero
979  mass_rho = zero
980 
981  mass_vx = zero
982  mass_vy = zero
983  mass_vz = zero
984  mass_nx = zero
985  mass_ny = zero
986  mass_nz = zero
987  mass_vi = zero
988 
989  area_ptot = zero
990  area_ps = zero
991 
992  !$AD II-LOOP
993  do ii = 0, (bcdata(mm)%jnEnd - bcdata(mm)%jnBeg) * (bcdata(mm)%inEnd - bcdata(mm)%inBeg) - 1
994  i = mod(ii, (bcdata(mm)%inEnd - bcdata(mm)%inBeg)) + bcdata(mm)%inBeg + 1
995  j = ii / (bcdata(mm)%inEnd - bcdata(mm)%inBeg) + bcdata(mm)%jnBeg + 1
996 
997  if (addgridvelocities) then
998  sf = sface(i, j)
999  else
1000  sf = zero
1001  end if
1002 
1003  ! Compute the force components.
1004  blk = max(bcdata(mm)%iblank(i, j), 0) ! iBlank forces for overset stuff
1005 
1006  vxm = half * (ww1(i, j, ivx) + ww2(i, j, ivx))
1007  vym = half * (ww1(i, j, ivy) + ww2(i, j, ivy))
1008  vzm = half * (ww1(i, j, ivz) + ww2(i, j, ivz))
1009  rhom = half * (ww1(i, j, irho) + ww2(i, j, irho))
1010  pm = half * (pp1(i, j) + pp2(i, j))
1011  gammam = half * (gamma1(i, j) + gamma2(i, j))
1012 
1013  vnm = vxm * ssi(i, j, 1) + vym * ssi(i, j, 2) + vzm * ssi(i, j, 3) - sf
1014  vmag = sqrt((vxm**2 + vym**2 + vzm**2)) - sf
1015  am = sqrt(gammam * pm / rhom)
1016  mnm = vmag / am
1017 
1018  cellarea = sqrt(ssi(i, j, 1)**2 + ssi(i, j, 2)**2 + ssi(i, j, 3)**2)
1019  area = area + cellarea * blk
1020  overcellarea = 1 / cellarea
1021 
1022  call computeptot(rhom, vxm, vym, vzm, pm, ptot)
1023  call computettot(rhom, vxm, vym, vzm, pm, ttot)
1024 
1025  massflowratelocal = rhom * vnm * blk * fact * mredim
1026 
1027  massflowrate = massflowrate + massflowratelocal
1028 
1029  ! re-dimentionalize quantities
1030  pm = pm * pref
1031 
1032  mass_ptot = mass_ptot + ptot * massflowratelocal * pref
1033  mass_ttot = mass_ttot + ttot * massflowratelocal * tref
1034  mass_rho = mass_rho + rhom * massflowratelocal * rhoref
1035  mass_a = mass_a + am * massflowratelocal * uref
1036 
1037  mass_ps = mass_ps + pm * massflowratelocal
1038  mass_mn = mass_mn + mnm * massflowratelocal
1039 
1040  area_ptot = area_ptot + ptot * pref * cellarea * blk
1041  area_ps = area_ps + pm * cellarea * blk
1042 
1043  sfacecoordref(1) = sf * ssi(i, j, 1) * overcellarea
1044  sfacecoordref(2) = sf * ssi(i, j, 2) * overcellarea
1045  sfacecoordref(3) = sf * ssi(i, j, 3) * overcellarea
1046 
1047  mass_vx = mass_vx + (vxm * uref - sfacecoordref(1)) * massflowratelocal
1048  mass_vy = mass_vy + (vym * uref - sfacecoordref(2)) * massflowratelocal
1049  mass_vz = mass_vz + (vzm * uref - sfacecoordref(3)) * massflowratelocal
1050 
1051  govgm1 = gammainf / (gammainf - one)
1052  gm1ovg = one / govgm1
1053  viconst = two * govgm1 * rgasdim
1054  ! the prefs in psinf / ptot cancel out so we can just take the ratio
1055  ! we need to clip the ratio to stay under one. right next to the wall,
1056  ! the pTot can go below the static free stream pressure. To prevent
1057  ! nans from the sqrt, we just clip this. This does not affect the computation
1058  ! because when pTot is this small, the velocities are also small, and the
1059  ! mdot is almost zero, so the cells in this area don't contribute much
1060  ! to the mass weighed sum.
1061  pratio = min(one, one / ptot)
1062  vilocal = sqrt(viconst * (one - (pratio)**gm1ovg) * ttot * tref)
1063  mass_vi = mass_vi + vilocal * massflowratelocal
1064 
1065  mass_nx = mass_nx + ssi(i, j, 1) * overcellarea * massflowratelocal
1066  mass_ny = mass_ny + ssi(i, j, 2) * overcellarea * massflowratelocal
1067  mass_nz = mass_nz + ssi(i, j, 3) * overcellarea * massflowratelocal
1068 
1069  xc = fourth * (xx(i, j, 1) + xx(i + 1, j, 1) &
1070  + xx(i, j + 1, 1) + xx(i + 1, j + 1, 1)) - refpoint(1)
1071  yc = fourth * (xx(i, j, 2) + xx(i + 1, j, 2) &
1072  + xx(i, j + 1, 2) + xx(i + 1, j + 1, 2)) - refpoint(2)
1073  zc = fourth * (xx(i, j, 3) + xx(i + 1, j, 3) &
1074  + xx(i, j + 1, 3) + xx(i + 1, j + 1, 3)) - refpoint(3)
1075 
1076  ! Pressure forces. Note that these need a *negative* and to subtract
1077  ! the reference pressure sign to be consistent with the force
1078  ! computation on the walls.
1079  pm = -(pm - pinf * pref) * fact * blk
1080 
1081  fx = pm * ssi(i, j, 1)
1082  fy = pm * ssi(i, j, 2)
1083  fz = pm * ssi(i, j, 3)
1084 
1085  ! Update the pressure force and moment coefficients.
1086  fp(1) = fp(1) + fx
1087  fp(2) = fp(2) + fy
1088  fp(3) = fp(3) + fz
1089 
1090  mx = yc * fz - zc * fy
1091  my = zc * fx - xc * fz
1092  mz = xc * fy - yc * fx
1093 
1094  mp(1) = mp(1) + mx
1095  mp(2) = mp(2) + my
1096  mp(3) = mp(3) + mz
1097 
1098  ! the force integral for the center of pressure computation.
1099  ! We need the cell centers wrt origin
1100  xco = fourth * (xx(i, j, 1) + xx(i + 1, j, 1) &
1101  + xx(i, j + 1, 1) + xx(i + 1, j + 1, 1))
1102  yco = fourth * (xx(i, j, 2) + xx(i + 1, j, 2) &
1103  + xx(i, j + 1, 2) + xx(i + 1, j + 1, 2))
1104  zco = fourth * (xx(i, j, 3) + xx(i + 1, j, 3) &
1105  + xx(i, j + 1, 3) + xx(i + 1, j + 1, 3))
1106 
1107  ! Center of force computations. Here we accumulate in the sums.
1108  ! accumulate in the sums. each force component is tracked separately
1109  ! blanking is included in the mdot multiplier for the force.
1110 
1111  ! Force-X
1112  cofsumfx(1) = cofsumfx(1) + xco * fx
1113  cofsumfx(2) = cofsumfx(2) + yco * fx
1114  cofsumfx(3) = cofsumfx(3) + zco * fx
1115 
1116  ! Force-Y
1117  cofsumfy(1) = cofsumfy(1) + xco * fy
1118  cofsumfy(2) = cofsumfy(2) + yco * fy
1119  cofsumfy(3) = cofsumfy(3) + zco * fy
1120 
1121  ! Force-Z
1122  cofsumfz(1) = cofsumfz(1) + xco * fz
1123  cofsumfz(2) = cofsumfz(2) + yco * fz
1124  cofsumfz(3) = cofsumfz(3) + zco * fz
1125 
1126  ! Momentum forces are a little tricky. We negate because
1127  ! have to re-apply fact to massFlowRateLocal to undoo it, because
1128  ! we need the signed behavior of ssi to get the momentum forces correct.
1129  ! Also, the sign is flipped between inflow and outflow types
1130 
1131  massflowratelocal = massflowratelocal * fact / timeref * blk / cellarea * internalflowfact * inflowfact
1132 
1133  fx = massflowratelocal * ssi(i, j, 1) * vxm
1134  fy = massflowratelocal * ssi(i, j, 2) * vym
1135  fz = massflowratelocal * ssi(i, j, 3) * vzm
1136 
1137  fmom(1) = fmom(1) + fx
1138  fmom(2) = fmom(2) + fy
1139  fmom(3) = fmom(3) + fz
1140 
1141  mx = yc * fz - zc * fy
1142  my = zc * fx - xc * fz
1143  mz = xc * fy - yc * fx
1144 
1145  mmom(1) = mmom(1) + mx
1146  mmom(2) = mmom(2) + my
1147  mmom(3) = mmom(3) + mz
1148 
1149  ! Center of force computations. Here we accumulate in the sums.
1150  ! each force component is tracked separately
1151  ! blanking is included in the mdot multiplier for the force.
1152 
1153  ! Force-X
1154  cofsumfx(1) = cofsumfx(1) + xco * fx
1155  cofsumfx(2) = cofsumfx(2) + yco * fx
1156  cofsumfx(3) = cofsumfx(3) + zco * fx
1157 
1158  ! Force-Y
1159  cofsumfy(1) = cofsumfy(1) + xco * fy
1160  cofsumfy(2) = cofsumfy(2) + yco * fy
1161  cofsumfy(3) = cofsumfy(3) + zco * fy
1162 
1163  ! Force-Z
1164  cofsumfz(1) = cofsumfz(1) + xco * fz
1165  cofsumfz(2) = cofsumfz(2) + yco * fz
1166  cofsumfz(3) = cofsumfz(3) + zco * fz
1167 
1168  end do
1169 
1170  ! Increment the local values array with what we computed here
1171  localvalues(imassflow) = localvalues(imassflow) + massflowrate
1172  localvalues(iarea) = localvalues(iarea) + area
1173  localvalues(imassrho) = localvalues(imassrho) + mass_rho
1174  localvalues(imassa) = localvalues(imassa) + mass_a
1175  localvalues(imassptot) = localvalues(imassptot) + mass_ptot
1176  localvalues(imassttot) = localvalues(imassttot) + mass_ttot
1177  localvalues(imassps) = localvalues(imassps) + mass_ps
1178  localvalues(imassmn) = localvalues(imassmn) + mass_mn
1179  localvalues(ifp:ifp + 2) = localvalues(ifp:ifp + 2) + fp
1180  localvalues(iflowfm:iflowfm + 2) = localvalues(iflowfm:iflowfm + 2) + fmom
1181  localvalues(iflowmp:iflowmp + 2) = localvalues(iflowmp:iflowmp + 2) + mp
1182  localvalues(iflowmm:iflowmm + 2) = localvalues(iflowmm:iflowmm + 2) + mmom
1183 
1184  localvalues(icoforcex:icoforcex + 2) = localvalues(icoforcex:icoforcex + 2) + cofsumfx
1185  localvalues(icoforcey:icoforcey + 2) = localvalues(icoforcey:icoforcey + 2) + cofsumfy
1186  localvalues(icoforcez:icoforcez + 2) = localvalues(icoforcez:icoforcez + 2) + cofsumfz
1187 
1188  localvalues(iareaptot) = localvalues(iareaptot) + area_ptot
1189  localvalues(iareaps) = localvalues(iareaps) + area_ps
1190 
1191  localvalues(imassvx) = localvalues(imassvx) + mass_vx
1192  localvalues(imassvy) = localvalues(imassvy) + mass_vy
1193  localvalues(imassvz) = localvalues(imassvz) + mass_vz
1194  localvalues(imassnx) = localvalues(imassnx) + mass_nx
1195  localvalues(imassny) = localvalues(imassny) + mass_ny
1196  localvalues(imassnz) = localvalues(imassnz) + mass_nz
1197 
1198  localvalues(imassvi) = localvalues(imassvi) + mass_vi
1199 
1200  end subroutine flowintegrationface
1201 
1202  ! ----------------------------------------------------------------------
1203  ! |
1204  ! No Tapenade Routine below this line |
1205  ! |
1206  ! ----------------------------------------------------------------------
1207 
1208 #ifndef USE_TAPENADE
1209 
1210  subroutine getsolutionwrap(famLists, funcValues, nCost, nGroups, nFamMax)
1211 
1212  use constants
1214  implicit none
1215  ! Input/output Variables
1216  integer(kind=intType) :: nGroups, nCost, nFamMax
1217  integer(kind=intType), dimension(nGroups, nFamMax) :: famLists
1218  real(kind=realtype), dimension(nCost, nGroups), intent(out) :: funcvalues
1219 
1220  ! Local variable
1221 
1222  call getsolution(famlists, funcvalues)
1223  end subroutine getsolutionwrap
1224 
1225  subroutine getsolution(famLists, funcValues, globalValues)
1226  !--------------------------------------------------------------
1227  ! Manual Differentiation Warning: Modifying this routine requires
1228  ! modifying the hand-written forward and reverse routines.
1229  ! --------------------------------------------------------------
1230 
1231  use constants
1233  use communication, only: adflow_comm_world
1234  use blockpointers, only: ndom
1235  use utils, only: setpointers, echk
1240  implicit none
1241 
1242  ! Input/Output Variables
1243  integer(kind=intType), dimension(:, :), intent(in), target :: famLists
1244  real(kind=realtype), dimension(:, :), intent(out) :: funcvalues
1245  real(kind=realtype), optional, intent(out), dimension(:, :, :) :: globalvalues
1246 
1247  ! Working
1248  real(kind=realtype), dimension(nLocalValues, nTimeIntervalsSpectral) :: localval, globalval
1249  integer(kind=intType) :: nn, sps, ierr, iGroup, nFam
1250  integer(kind=intType), dimension(:), pointer :: famList
1251  ! Master loop over the each of the groups we have
1252 
1253  grouploop: do igroup = 1, size(famlists, 1)
1254 
1255  ! Extract the current family list
1256  nfam = famlists(igroup, 1)
1257  famlist => famlists(igroup, 2:2 + nfam - 1)
1258  funcvalues(:, igroup) = zero
1259  localval = zero
1260 
1261  ! compute the current cp min value for the cavitation computation with KS aggregation
1262  if (computecavitation) then
1263  call computecpminfamily(famlist)
1264  end if
1265 
1266  ! compute the current sepsensor max value for the separation computation with KS aggregation
1267  if (computesepsensorks) then
1268  call computesepsenmaxfamily(famlist)
1269  end if
1270 
1271  do sps = 1, ntimeintervalsspectral
1272  ! Integrate the normal block surfaces.
1273  do nn = 1, ndom
1274  call setpointers(nn, 1, sps)
1275  call integratesurfaces(localval(:, sps), famlist)
1276  end do
1277 
1278  ! Integrate any zippers we have
1279  call integratezippers(localval(:, sps), famlist, sps)
1280 
1281  ! Integrate any user-supplied surfaces as have as well.
1282  call integrateusersurfaces(localval(:, sps), famlist, sps)
1283 
1284  ! Integrate any actuator regions we have
1285  call integrateactuatorregions(localval(:, sps), famlist, sps)
1286  end do
1287 
1288  ! Now we need to reduce all the cost functions
1289  call mpi_allreduce(localval, globalval, nlocalvalues * ntimeintervalsspectral, adflow_real, &
1290  mpi_sum, adflow_comm_world, ierr)
1291  call echk(ierr, __file__, __line__)
1292 
1293  ! Call the final routine that will comptue all of our functions of
1294  ! interest.
1295  call getcostfunctions(globalval, funcvalues(:, igroup))
1296 
1297  if (present(globalvalues)) then
1298  globalvalues(:, :, igroup) = globalval
1299  end if
1300  end do grouploop
1301  end subroutine getsolution
1302 
1303  subroutine integratesurfaces(localValues, famList)
1304  !--------------------------------------------------------------
1305  ! Manual Differentiation Warning: Modifying this routine requires
1306  ! modifying the hand-written forward and reverse routines.
1307  ! --------------------------------------------------------------
1308  !
1309  ! This is a shell routine that calls the specific surface
1310  ! integration routines. Currently we have have the forceAndMoment
1311  ! routine as well as the flow properties routine. This routine
1312  ! takes care of setting pointers, while the actual computational
1313  ! routine just acts on a specific fast pointed to by pointers.
1314 
1315  use constants
1316  use blockpointers, only: nbocos, bcdata, bctype, sk, sj, si, x, rlv, &
1318  use utils, only: setbcpointers, iswalltype
1319  use sorting, only: faminlist
1320  ! Tapenade needs to see these modules that the callees use.
1321  use bcpointers
1322  use flowvarrefstate
1323  use inputphysics
1324 
1325  implicit none
1326 
1327  ! Input/output Variables
1328  real(kind=realtype), dimension(nLocalValues), intent(inout) :: localvalues
1329  integer(kind=intType), dimension(:), intent(in) :: famList
1330 
1331  ! Working variables
1332  integer(kind=intType) :: mm
1333 
1334  ! Loop over all possible boundary conditions
1335  bocos: do mm = 1, nbocos
1336 
1337  ! Determine if this boundary condition is to be incldued in the
1338  ! currently active group
1339  faminclude: if (faminlist(bcdata(mm)%famID, famlist)) then
1340 
1341  ! Set a bunch of pointers depending on the face id to make
1342  ! a generic treatment possible.
1343  call setbcpointers(mm, .true.)
1344 
1345  ! no post gathered integrations currently
1346  iswall: if (iswalltype(bctype(mm))) then
1347  call wallintegrationface(localvalues, mm)
1348  end if iswall
1349 
1350  isinflowoutflow: if (bctype(mm) == subsonicinflow .or. &
1351  bctype(mm) == supersonicinflow) then
1352  call flowintegrationface(.true., localvalues, mm)
1353  else if (bctype(mm) == subsonicoutflow .or. &
1354  bctype(mm) == supersonicoutflow) then
1355  call flowintegrationface(.false., localvalues, mm)
1356  end if isinflowoutflow
1357 
1358  end if faminclude
1359  end do bocos
1360 
1361  end subroutine integratesurfaces
1362 
1363  subroutine computecpminfamily(famList)
1364 
1365  use constants
1368  use blockpointers, only: ndom
1369  use inputphysics, only: cpmin_family, machcoef
1370  use blockpointers
1371  use flowvarrefstate
1372  use bcpointers
1374  use sorting, only: faminlist
1375 
1376  implicit none
1377 
1378  integer(kind=intType), dimension(:), intent(in) :: famList
1379  integer(kind=intType) :: mm, nn, sps
1380  integer(kind=intType) :: i, j, ii, blk, ierr
1381  real(kind=realtype) :: cp, plocal, tmp, cpmin_local
1382 
1383  ! this routine loops over the surface cells in the given family
1384  ! and computes the true minimum Cp value.
1385  ! this is then used in the surface integration routine to compute
1386  ! the cpmin using KS aggregation.
1387  ! the goal is to get a differentiable cpmin output.
1388 
1389  ! loop over the TS instances and compute cpmin_family for each TS instance
1390  do sps = 1, ntimeintervalsspectral
1391  ! set the local cp min to a large value so that we get the actual min
1392  cpmin_local = 10000.0_realtype
1393  do nn = 1, ndom
1394  call setpointers(nn, 1, sps)
1395 
1396  ! Loop over all possible boundary conditions
1397  bocos: do mm = 1, nbocos
1398  ! Determine if this boundary condition is to be incldued in the
1399  ! currently active group
1400  faminclude: if (faminlist(bcdata(mm)%famID, famlist)) then
1401 
1402  ! Set a bunch of pointers depending on the face id to make
1403  ! a generic treatment possible.
1404  call setbcpointers(mm, .true.)
1405 
1406  ! no post gathered integrations currently
1407  iswall: if (iswalltype(bctype(mm))) then
1408 
1409  !$AD II-LOOP
1410  do ii = 0, (bcdata(mm)%jnEnd - bcdata(mm)%jnBeg) * (bcdata(mm)%inEnd - bcdata(mm)%inBeg) - 1
1411  i = mod(ii, (bcdata(mm)%inEnd - bcdata(mm)%inBeg)) + bcdata(mm)%inBeg + 1
1412  j = ii / (bcdata(mm)%inEnd - bcdata(mm)%inBeg) + bcdata(mm)%jnBeg + 1
1413 
1414  ! only take this if its a compute cell
1415  if (bcdata(mm)%iblank(i, j) .eq. one) then
1416 
1417  ! compute local CP
1418  plocal = pp2(i, j)
1419  tmp = two / (gammainf * machcoef * machcoef)
1420  cp = tmp * (plocal - pinf)
1421 
1422  ! compare it against the current value on this proc
1423  cpmin_local = min(cpmin_local, cp)
1424  end if
1425  end do
1426  end if iswall
1427 
1428  end if faminclude
1429  end do bocos
1430  end do
1431  ! finally communicate across all processors for this time spectral instance
1432  call mpi_allreduce(cpmin_local, cpmin_family(sps), 1, mpi_double, &
1433  mpi_min, adflow_comm_world, ierr)
1434  call echk(ierr, __file__, __line__)
1435  end do
1436 
1437  end subroutine computecpminfamily
1438 
1439  subroutine computesepsenmaxfamily(famList)
1440 
1441  use constants
1444  use blockpointers, only: ndom
1446  use blockpointers
1447  use flowvarrefstate
1449  use bcpointers
1451  use sorting, only: faminlist
1452 
1453  implicit none
1454 
1455  integer(kind=intType), dimension(:), intent(in) :: famList
1456  integer(kind=intType) :: mm, nn, sps
1457  integer(kind=intType) :: i, j, ii, blk, ierr
1458  real(kind=realtype) :: sepsensor_local
1459  real(kind=realtype) :: vecttangential(3), v(3)
1460  real(kind=realtype) :: vectdotproductfsnormal, sensor
1461 
1462  ! this routine loops over the surface cells in the given family
1463  ! and computes the true maximum sepsensor value.
1464  ! this is then used in the surface integration routine to compute
1465  ! the maximum sepsensor value using KS aggregation.
1466  ! the goal is to get a differentiable maximum sepsensor output.
1467 
1468  ! loop over the TS instances and compute sepSenMaxFamily for each TS instance
1469  do sps = 1, ntimeintervalsspectral
1470  ! set the local sepsensor to a smaller value so that we get the actual max
1471  sepsensor_local = -10000.0_realtype
1472  do nn = 1, ndom
1473  call setpointers(nn, 1, sps)
1474 
1475  ! Loop over all possible boundary conditions
1476  bocos: do mm = 1, nbocos
1477  ! Determine if this boundary condition is to be incldued in the
1478  ! currently active group
1479  faminclude: if (faminlist(bcdata(mm)%famID, famlist)) then
1480 
1481  ! Set a bunch of pointers depending on the face id to make
1482  ! a generic treatment possible.
1483  call setbcpointers(mm, .true.)
1484 
1485  ! no post gathered integrations currently
1486  iswall: if (iswalltype(bctype(mm))) then
1487 
1488  !$AD II-LOOP
1489  do ii = 0, (bcdata(mm)%jnEnd - bcdata(mm)%jnBeg) * (bcdata(mm)%inEnd - bcdata(mm)%inBeg) - 1
1490  i = mod(ii, (bcdata(mm)%inEnd - bcdata(mm)%inBeg)) + bcdata(mm)%inBeg + 1
1491  j = ii / (bcdata(mm)%inEnd - bcdata(mm)%inBeg) + bcdata(mm)%jnBeg + 1
1492 
1493  ! only take this if its a compute cell
1494  if (bcdata(mm)%iblank(i, j) .eq. one) then
1495  ! Get normalized surface velocity:
1496  v(1) = ww2(i, j, ivx)
1497  v(2) = ww2(i, j, ivy)
1498  v(3) = ww2(i, j, ivz)
1499  v = v / (sqrt(v(1)**2 + v(2)**2 + v(3)**2) + 1e-16)
1500 
1501  vectdotproductfsnormal = veldirfreestream(1) * bcdata(mm)%norm(i, j, 1) + &
1502  veldirfreestream(2) * bcdata(mm)%norm(i, j, 2) + &
1503  veldirfreestream(3) * bcdata(mm)%norm(i, j, 3)
1504  ! Tangential Vector on the surface, which is the freestream projected vector
1505  vecttangential(1) = veldirfreestream(1) - &
1506  vectdotproductfsnormal * bcdata(mm)%norm(i, j, 1)
1507  vecttangential(2) = veldirfreestream(2) - &
1508  vectdotproductfsnormal * bcdata(mm)%norm(i, j, 2)
1509  vecttangential(3) = veldirfreestream(3) - &
1510  vectdotproductfsnormal * bcdata(mm)%norm(i, j, 3)
1511 
1512  vecttangential = vecttangential / &
1513  (sqrt(vecttangential(1)**2 + vecttangential(2)**2 + &
1514  vecttangential(3)**2) + 1e-16)
1515 
1516  ! computing separation sensor
1517  ! velocity dot products
1518  sensor = (v(1) * vecttangential(1) + v(2) * vecttangential(2) + &
1519  v(3) * vecttangential(3))
1520 
1521  ! sepsensor value
1522  sensor = (cos(degtorad * sepsensorksphi) - sensor) / &
1523  (-cos(degtorad * sepsensorksphi) + cos(zero) + 1e-16)
1524 
1525  ! compare it against the current value on this proc
1526  sepsensor_local = max(sepsensor_local, sensor)
1527  end if
1528 
1529  ! end if
1530  end do
1531  end if iswall
1532 
1533  end if faminclude
1534  end do bocos
1535  end do
1536  ! finally communicate across all processors for this time spectral instance
1537  call mpi_allreduce(sepsensor_local, sepsenmaxfamily(sps), 1, mpi_double, &
1538  mpi_max, adflow_comm_world, ierr)
1539  call echk(ierr, __file__, __line__)
1540  end do
1541 
1542  end subroutine computesepsenmaxfamily
1543 
1544 #ifndef USE_COMPLEX
1545  subroutine integratesurfaces_d(localValues, localValuesd, famList)
1546  !------------------------------------------------------------------------
1547  ! Manual Differentiation Warning: This routine is differentiated by hand.
1548  ! -----------------------------------------------------------------------
1549 
1550  ! Forward mode linearization of integrateSurfaces
1551  use constants
1552  use blockpointers, only: nbocos, bcdata, bctype
1553  use utils, only: setbcpointers_d, iswalltype
1554  use sorting, only: faminlist
1556  implicit none
1557 
1558  ! Input/output Variables
1559  real(kind=realtype), dimension(nLocalValues), intent(inout) :: localvalues, localvaluesd
1560  integer(kind=intType), dimension(:), intent(in) :: famList
1561 
1562  ! Working variables
1563  integer(kind=intType) :: mm
1564 
1565  ! Loop over all possible boundary conditions
1566  do mm = 1, nbocos
1567  ! Determine if this boundary condition is to be incldued in the
1568  ! currently active group
1569  faminclude: if (faminlist(bcdata(mm)%famID, famlist)) then
1570 
1571  ! Set a bunch of pointers depending on the face id to make
1572  ! a generic treatment possible.
1573  call setbcpointers_d(mm, .true.)
1574 
1575  ! not post gathered integrations currently
1576  iswall: if (iswalltype(bctype(mm))) then
1577  call wallintegrationface_d(localvalues, localvaluesd, mm)
1578  end if iswall
1579 
1580  isinflowoutflow: if (bctype(mm) == subsonicinflow .or. &
1581  bctype(mm) == supersonicinflow) then
1582  call flowintegrationface_d(.true., localvalues, localvaluesd, mm)
1583  else if (bctype(mm) == subsonicoutflow .or. &
1584  bctype(mm) == supersonicoutflow) then
1585 
1586  call flowintegrationface_d(.false., localvalues, localvaluesd, mm)
1587 
1588  end if isinflowoutflow
1589  end if faminclude
1590  end do
1591  end subroutine integratesurfaces_d
1592 
1593  subroutine integratesurfaces_b(localValues, localValuesd, famList)
1594  !------------------------------------------------------------------------
1595  ! Manual Differentiation Warning: This routine is differentiated by hand.
1596  ! -----------------------------------------------------------------------
1597 
1598  ! Reverse mode linearization of integrateSurfaces
1599  use constants
1600  use blockpointers, only: nbocos, bcdata, bctype, bcdatad
1601  use utils, only: setbcpointers_d, iswalltype
1602  use sorting, only: faminlist
1604  implicit none
1605 
1606  ! Input/output Variables
1607  real(kind=realtype), dimension(nLocalValues), intent(inout) :: localvalues, localvaluesd
1608  integer(kind=intType), dimension(:), intent(in) :: famList
1609  ! Working variables
1610  integer(kind=intType) :: mm
1611 
1612  ! Call the individual integration routines.
1613  do mm = 1, nbocos
1614  ! Determine if this boundary condition is to be incldued in the
1615  ! currently active group
1616  faminclude: if (faminlist(bcdata(mm)%famID, famlist)) then
1617 
1618  ! Set a bunch of pointers depending on the face id to make
1619  ! a generic treatment possible.
1620  call setbcpointers_d(mm, .true.)
1621 
1622  ! not post gathered integrations currently
1623  iswall: if (iswalltype(bctype(mm))) then
1624  call wallintegrationface_b(localvalues, localvaluesd, mm)
1625  end if iswall
1626 
1627  isinflowoutflow: if (bctype(mm) == subsonicinflow .or. &
1628  bctype(mm) == supersonicinflow) then
1629  call flowintegrationface_b(.true., localvalues, localvaluesd, mm)
1630  else if (bctype(mm) == subsonicoutflow .or. &
1631  bctype(mm) == supersonicoutflow) then
1632  call flowintegrationface_b(.false., localvalues, localvaluesd, mm)
1633  end if isinflowoutflow
1634  end if faminclude
1635  end do
1636  end subroutine integratesurfaces_b
1637 
1638  subroutine getsolution_d(famLists, funcValues, funcValuesd)
1639  !------------------------------------------------------------------------
1640  ! Manual Differentiation Warning: This routine is differentiated by hand.
1641  ! -----------------------------------------------------------------------
1642 
1643  use constants
1644  use inputtsstabderiv, only: tsstability
1646  use communication, only: adflow_comm_world
1647  use blockpointers, only: ndom
1648  use utils, only: setpointers_d, echk
1654  implicit none
1655 
1656  ! Input/Output Variables
1657  integer(kind=intType), dimension(:, :), target, intent(in) :: famLists
1658  real(kind=realtype), dimension(:, :), intent(out) :: funcvalues, funcvaluesd
1659 
1660  ! Working
1661  real(kind=realtype), dimension(nLocalValues, nTimeIntervalsSpectral) :: localval, globalval
1662  real(kind=realtype), dimension(nLocalValues, nTimeIntervalsSpectral) :: localvald, globalvald
1663  integer(kind=intType) :: nn, sps, ierr, iGroup, nFam
1664  integer(kind=intType), dimension(:), pointer :: famList
1665 
1666  grouploop: do igroup = 1, size(famlists, 1)
1667 
1668  ! Extract the current family list
1669  nfam = famlists(igroup, 1)
1670  famlist => famlists(igroup, 2:2 + nfam - 1)
1671 
1672  ! compute the current cp min value for the cavitation computation with KS aggregation
1673  if (computecavitation) then
1674  call computecpminfamily(famlist)
1675  end if
1676 
1677  ! compute the current sepsensor max value for the separation computation with KS aggregation
1678  if (computesepsensorks) then
1679  call computesepsenmaxfamily(famlist)
1680  end if
1681 
1682  localval = zero
1683  localvald = zero
1684  do sps = 1, ntimeintervalsspectral
1685  ! Integrate the normal block surfaces.
1686  do nn = 1, ndom
1687  call setpointers_d(nn, 1, sps)
1688  call integratesurfaces_d(localval(:, sps), localvald(:, sps), famlist)
1689  end do
1690 
1691  ! Integrate any zippers we have
1692  call integratezippers_d(localval(:, sps), localvald(:, sps), famlist, sps)
1693 
1694  ! Integrate any user-supplied surface as have as well.
1695  call integrateusersurfaces_d(localval(:, sps), localvald(:, sps), famlist, sps)
1696 
1697  ! Integrate any actuator regions we have
1698  call integrateactuatorregions_d(localval(:, sps), localvald(:, sps), famlist, sps)
1699  end do
1700 
1701  ! Now we need to reduce all the cost functions
1702  call mpi_allreduce(localval, globalval, nlocalvalues * ntimeintervalsspectral, adflow_real, &
1703  mpi_sum, adflow_comm_world, ierr)
1704  call echk(ierr, __file__, __line__)
1705 
1706  ! Now we need to reduce all the cost functions
1707  call mpi_allreduce(localvald, globalvald, nlocalvalues * ntimeintervalsspectral, adflow_real, &
1708  mpi_sum, adflow_comm_world, ierr)
1709  call echk(ierr, __file__, __line__)
1710 
1711  ! Call the final routine that will comptue all of our functions of
1712  ! interest.
1713 
1714  call getcostfunctions_d(globalval, globalvald, funcvalues(:, igroup), funcvaluesd(:, igroup))
1715 
1716  ! if (present(globalValues)) then
1717  ! globalValues = globalVal
1718  ! globalValuesd = globalVald
1719  ! end if
1720  end do grouploop
1721 
1722  end subroutine getsolution_d
1723 
1724  subroutine getsolution_b(famLists, funcValues, funcValuesd)
1725  ! -----------------------------------------------------------------------
1726  ! Manual Differentiation Warning: This routine is differentiated by hand.
1727  ! -----------------------------------------------------------------------
1728 
1729  use constants
1730  use communication, only: myid
1731  use inputtsstabderiv, only: tsstability
1733  use communication, only: adflow_comm_world
1734  use blockpointers, only: ndom
1735  use utils, only: setpointers_b, echk, setpointers
1741  implicit none
1742 
1743  ! Input/Output Variables
1744  integer(kind=intType), dimension(:, :), target, intent(in) :: famLists
1745  real(kind=realtype), dimension(:, :) :: funcvalues, funcvaluesd
1746 
1747  ! Working
1748  real(kind=realtype), dimension(nLocalValues, nTimeIntervalsSpectral) :: localval, globalval
1749  real(kind=realtype), dimension(nLocalValues, nTimeIntervalsSpectral) :: localvald, globalvald
1750  real(kind=realtype), dimension(nLocalValues, nTimeIntervalsSpectral, size(famLists, 1)) :: globalvalues
1751  integer(kind=intType) :: nn, sps, ierr, iGroup, nFam
1752  integer(kind=intType), dimension(:), pointer :: famList
1753 
1754  call getsolution(famlists, funcvalues, globalvalues)
1755 
1756  grouploop: do igroup = 1, size(famlists, 1)
1757 
1758  ! Extract the current family list
1759  nfam = famlists(igroup, 1)
1760  famlist => famlists(igroup, 2:2 + nfam - 1)
1761 
1762  ! compute the current cp min value for the cavitation computation with KS aggregation
1763  if (computecavitation) then
1764  call computecpminfamily(famlist)
1765  end if
1766 
1767  ! compute the current sepsensor max value for the separation computation with KS aggregation
1768  if (computesepsensorks) then
1769  call computesepsenmaxfamily(famlist)
1770  end if
1771 
1772  localval = zero
1773  localvald = zero
1774 
1775  ! Retrive the forward pass values from getSolution
1776  globalval = globalvalues(:, :, igroup)
1777 
1778  if (myid == 0) then
1779  call getcostfunctions_b(globalval, globalvald, funcvalues(:, igroup), funcvaluesd(:, igroup))
1780  localvald = globalvald
1781  end if
1782 
1783  ! Now we need to bcast out the localValues to all procs.
1784  call mpi_bcast(localvald, nlocalvalues * ntimeintervalsspectral, &
1785  adflow_real, 0, adflow_comm_world, ierr)
1786  call echk(ierr, __file__, __line__)
1787 
1788  do sps = 1, ntimeintervalsspectral
1789 
1790  ! Integrate any actuator regions we have:
1791  call integrateactuatorregions_b(localval(:, sps), localvald(:, sps), famlist, sps)
1792 
1793  ! Integrate any user-supplied planes as have as well.
1794  call integrateusersurfaces_b(localval(:, sps), localvald(:, sps), famlist, sps)
1795 
1796  ! Integrate any zippers we have
1797  call integratezippers_b(localval(:, sps), localvald(:, sps), famlist, sps)
1798 
1799  ! Integrate the normal block surfaces.
1800  do nn = 1, ndom
1801  call setpointers_b(nn, 1, sps)
1802  call integratesurfaces_b(localval(:, sps), localvald(:, sps), famlist)
1803  end do
1804 
1805  end do
1806  end do grouploop
1807  end subroutine getsolution_b
1808 #endif
1809 #endif
1810 end module surfaceintegrations
subroutine integrateactuatorregions_d(localValues, localValuesd, famList, sps)
subroutine integrateactuatorregions_b(localValues, localValuesd, famList, sps)
subroutine integrateactuatorregions(localValues, famList, sps)
Definition: BCData.F90:1
real(kind=realtype), dimension(:, :), pointer rlv2
Definition: BCPointers.F90:12
real(kind=realtype), dimension(:, :), pointer gamma2
Definition: BCPointers.F90:14
real(kind=realtype), dimension(:, :), pointer dd2wall
Definition: BCPointers.F90:17
real(kind=realtype), dimension(:, :), pointer rlv1
Definition: BCPointers.F90:12
real(kind=realtype), dimension(:, :), pointer pp1
Definition: BCPointers.F90:11
real(kind=realtype), dimension(:, :), pointer sface
Definition: BCPointers.F90:17
real(kind=realtype), dimension(:, :, :), pointer ww1
Definition: BCPointers.F90:10
real(kind=realtype), dimension(:, :), pointer pp2
Definition: BCPointers.F90:11
real(kind=realtype), dimension(:, :, :), pointer xx
Definition: BCPointers.F90:16
real(kind=realtype), dimension(:, :), pointer gamma1
Definition: BCPointers.F90:14
real(kind=realtype), dimension(:, :, :), pointer ww2
Definition: BCPointers.F90:10
real(kind=realtype), dimension(:, :, :), pointer ssi
Definition: BCPointers.F90:15
real(kind=realtype), dimension(:, :, :), pointer sfacek
real(kind=realtype), dimension(:, :, :), pointer gamma
logical addgridvelocities
integer(kind=inttype) spectralsol
real(kind=realtype), dimension(:, :, :), pointer p
real(kind=realtype), dimension(:, :, :), pointer sfacei
type(viscsubfacetype), dimension(:), pointer viscsubface
type(bcdatatype), dimension(:), pointer bcdatad
real(kind=realtype), dimension(:, :, :), pointer rlv
integer(kind=inttype), dimension(:), pointer bcfaceid
real(kind=realtype), dimension(:, :, :, :), pointer si
integer(kind=inttype) nbocos
real(kind=realtype), dimension(:, :, :, :), pointer sj
real(kind=realtype), dimension(:, :, :), pointer rev
integer(kind=inttype), dimension(:), pointer bctype
real(kind=realtype), dimension(:, :, :, :), pointer sk
real(kind=realtype), dimension(:, :, :), pointer sfacej
real(kind=realtype), dimension(:, :, :, :), pointer x
integer adflow_comm_world
integer(kind=inttype), parameter costfuncaxismoment
Definition: constants.F90:348
integer(kind=inttype), parameter costfunccfyqdot
Definition: constants.F90:348
integer(kind=inttype), parameter costfuncmavgptot
Definition: constants.F90:348
integer(kind=inttype), parameter costfuncforceyviscous
Definition: constants.F90:348
integer(kind=inttype), parameter isepavg
Definition: constants.F90:455
integer(kind=inttype), parameter imassvz
Definition: constants.F90:455
integer(kind=inttype), parameter iareaps
Definition: constants.F90:455
real(kind=realtype), parameter degtorad
Definition: constants.F90:89
real(kind=realtype), parameter zero
Definition: constants.F90:71
integer(kind=inttype), parameter costfuncforceycoefviscous
Definition: constants.F90:348
integer(kind=inttype), parameter nlocalvalues
Definition: constants.F90:454
integer(kind=inttype), parameter costfunccmzqdot
Definition: constants.F90:348
integer(kind=inttype), parameter costfuncforceypressure
Definition: constants.F90:348
integer(kind=inttype), parameter costfunccoforcexx
Definition: constants.F90:348
integer(kind=inttype), parameter imax
Definition: constants.F90:293
integer(kind=inttype), parameter costfuncclalpha
Definition: constants.F90:348
integer(kind=inttype), parameter supersonicinflow
Definition: constants.F90:264
integer(kind=inttype), parameter costfuncforcexmomentum
Definition: constants.F90:348
integer(kind=inttype), parameter iflowmp
Definition: constants.F90:455
integer(kind=inttype), parameter imassnx
Definition: constants.F90:455
integer(kind=inttype), parameter kmin
Definition: constants.F90:296
integer(kind=inttype), parameter costfunccoforcexz
Definition: constants.F90:348
integer(kind=inttype), parameter costfuncdragviscous
Definition: constants.F90:348
integer(kind=inttype), parameter imassflow
Definition: constants.F90:455
integer(kind=inttype), parameter jmax
Definition: constants.F90:295
integer(kind=inttype), parameter costfuncforcexcoefpressure
Definition: constants.F90:348
integer(kind=inttype), parameter icoforcez
Definition: constants.F90:455
integer(kind=inttype), parameter costfuncliftcoefpressure
Definition: constants.F90:348
integer(kind=inttype), parameter costfuncdragcoefviscous
Definition: constants.F90:348
integer(kind=inttype), parameter costfunccmzalpha
Definition: constants.F90:348
integer(kind=inttype), parameter costfuncmdot
Definition: constants.F90:348
integer(kind=inttype), parameter costfuncdragcoef
Definition: constants.F90:348
integer(kind=inttype), parameter costfuncdragcoefmomentum
Definition: constants.F90:348
integer(kind=inttype), parameter supersonicoutflow
Definition: constants.F90:266
integer(kind=inttype), parameter costfunccd0
Definition: constants.F90:348
integer(kind=inttype), parameter costfuncarea
Definition: constants.F90:348
integer(kind=inttype), parameter costfuncforcexpressure
Definition: constants.F90:348
integer(kind=inttype), parameter costfunccoforceyy
Definition: constants.F90:348
integer(kind=inttype), parameter costfunccavitation
Definition: constants.F90:348
integer(kind=inttype), parameter costfuncmomzcoef
Definition: constants.F90:348
integer(kind=inttype), parameter imassptot
Definition: constants.F90:455
integer(kind=inttype), parameter costfuncmavga
Definition: constants.F90:348
integer(kind=inttype), parameter iflowfm
Definition: constants.F90:455
integer(kind=inttype), parameter icperror2
Definition: constants.F90:455
integer(kind=inttype), parameter costfunccperror2
Definition: constants.F90:348
integer(kind=inttype), parameter costfuncliftmomentum
Definition: constants.F90:348
integer(kind=inttype), parameter costfuncforcezcoefviscous
Definition: constants.F90:348
integer(kind=inttype), parameter costfuncaavgps
Definition: constants.F90:348
integer(kind=inttype), parameter costfuncforcexviscous
Definition: constants.F90:348
integer(kind=inttype), parameter costfuncaavgptot
Definition: constants.F90:348
integer(kind=inttype), parameter costfuncflowpower
Definition: constants.F90:348
integer(kind=inttype), parameter costfunccmzalphadot
Definition: constants.F90:348
integer(kind=inttype), parameter costfuncforceymomentum
Definition: constants.F90:348
integer, parameter irho
Definition: constants.F90:34
integer(kind=inttype), parameter costfuncliftviscous
Definition: constants.F90:348
integer(kind=inttype), parameter costfuncclalphadot
Definition: constants.F90:348
integer(kind=inttype), parameter costfuncforcex
Definition: constants.F90:348
integer(kind=inttype), parameter nswalladiabatic
Definition: constants.F90:260
integer(kind=inttype), parameter costfuncliftpressure
Definition: constants.F90:348
integer(kind=inttype), parameter imassnz
Definition: constants.F90:455
integer(kind=inttype), parameter costfuncforceycoefpressure
Definition: constants.F90:348
integer(kind=inttype), parameter costfuncmomxcoef
Definition: constants.F90:348
integer(kind=inttype), parameter costfuncforcezmomentum
Definition: constants.F90:348
integer(kind=inttype), parameter costfuncforcezcoefmomentum
Definition: constants.F90:348
integer(kind=inttype), parameter imp
Definition: constants.F90:455
integer, parameter ivx
Definition: constants.F90:35
integer(kind=inttype), parameter costfuncmomz
Definition: constants.F90:348
integer(kind=inttype), parameter imassa
Definition: constants.F90:455
integer(kind=inttype), parameter costfunccdalphadot
Definition: constants.F90:348
integer(kind=inttype), parameter ipower
Definition: constants.F90:455
integer(kind=inttype), parameter ifv
Definition: constants.F90:455
integer(kind=inttype), parameter costfuncsepsensorksarea
Definition: constants.F90:348
integer(kind=inttype), parameter costfunccdq
Definition: constants.F90:348
integer(kind=inttype), parameter subsonicoutflow
Definition: constants.F90:267
integer(kind=inttype), parameter iyplus
Definition: constants.F90:455
integer(kind=inttype), parameter imassny
Definition: constants.F90:455
integer(kind=inttype), parameter costfuncmomy
Definition: constants.F90:348
integer(kind=inttype), parameter costfuncmavgvy
Definition: constants.F90:348
integer(kind=inttype), parameter costfuncmomx
Definition: constants.F90:348
integer(kind=inttype), parameter costfuncforcez
Definition: constants.F90:348
integer(kind=inttype), parameter costfuncmavgvx
Definition: constants.F90:348
integer(kind=inttype), parameter costfunccoforcexy
Definition: constants.F90:348
integer(kind=inttype), parameter costfuncdragmomentum
Definition: constants.F90:348
integer(kind=inttype), parameter isepsensorarea
Definition: constants.F90:455
integer(kind=inttype), parameter costfuncforcexcoef
Definition: constants.F90:348
integer(kind=inttype), parameter costfuncmavgvi
Definition: constants.F90:348
integer(kind=inttype), parameter icoforcex
Definition: constants.F90:455
integer(kind=inttype), parameter costfunccoforceyx
Definition: constants.F90:348
real(kind=realtype), parameter one
Definition: constants.F90:72
integer(kind=inttype), parameter costfuncforcexcoefmomentum
Definition: constants.F90:348
integer(kind=inttype), parameter costfunccfyq
Definition: constants.F90:348
integer(kind=inttype), parameter costfuncmavgps
Definition: constants.F90:348
integer(kind=inttype), parameter costfunccm0
Definition: constants.F90:348
integer(kind=inttype), parameter iflowmm
Definition: constants.F90:455
integer(kind=inttype), parameter imassvy
Definition: constants.F90:455
integer(kind=inttype), parameter costfunccoforceyz
Definition: constants.F90:348
real(kind=realtype), parameter half
Definition: constants.F90:80
integer(kind=inttype), parameter costfunccofliftx
Definition: constants.F90:348
integer(kind=inttype), parameter costfunccoforcezz
Definition: constants.F90:348
integer(kind=inttype), parameter costfunccpmin
Definition: constants.F90:348
integer(kind=inttype), parameter imassvx
Definition: constants.F90:455
integer(kind=inttype), parameter imassrho
Definition: constants.F90:455
integer(kind=inttype), parameter imin
Definition: constants.F90:292
integer(kind=inttype), parameter costfunccdalpha
Definition: constants.F90:348
integer(kind=inttype), parameter costfunccoflifty
Definition: constants.F90:348
integer(kind=inttype), parameter imassmn
Definition: constants.F90:455
integer(kind=inttype), parameter costfuncforcezcoefpressure
Definition: constants.F90:348
integer(kind=inttype), parameter costfuncmavgmn
Definition: constants.F90:348
integer(kind=inttype), parameter costfuncforceycoef
Definition: constants.F90:348
integer(kind=inttype), parameter costfuncliftcoefmomentum
Definition: constants.F90:348
integer(kind=inttype), parameter costfuncforcey
Definition: constants.F90:348
integer(kind=inttype), parameter icoforcey
Definition: constants.F90:455
integer(kind=inttype), parameter costfunccfyalpha
Definition: constants.F90:348
integer(kind=inttype), parameter costfuncdrag
Definition: constants.F90:348
integer, parameter ivz
Definition: constants.F90:37
integer(kind=inttype), parameter iarea
Definition: constants.F90:455
integer(kind=inttype), parameter costfunccofliftz
Definition: constants.F90:348
integer(kind=inttype), parameter imassvi
Definition: constants.F90:455
integer(kind=inttype), parameter costfuncforcexcoefviscous
Definition: constants.F90:348
integer(kind=inttype), parameter iaxismoment
Definition: constants.F90:455
real(kind=realtype), parameter two
Definition: constants.F90:73
integer(kind=inttype), parameter costfuncsepsensoravgz
Definition: constants.F90:348
integer(kind=inttype), parameter costfunccl0
Definition: constants.F90:348
integer(kind=inttype), parameter imv
Definition: constants.F90:455
integer(kind=inttype), parameter costfuncdragcoefpressure
Definition: constants.F90:348
integer(kind=inttype), parameter isepsensorksarea
Definition: constants.F90:455
integer(kind=inttype), parameter imassps
Definition: constants.F90:455
real(kind=realtype), parameter fourth
Definition: constants.F90:82
integer(kind=inttype), parameter isepsensor
Definition: constants.F90:455
integer(kind=inttype), parameter nswallisothermal
Definition: constants.F90:261
integer(kind=inttype), parameter costfunccdqdot
Definition: constants.F90:348
integer(kind=inttype), parameter costfunccmzq
Definition: constants.F90:348
integer(kind=inttype), parameter costfunclift
Definition: constants.F90:348
integer(kind=inttype), parameter costfunccoforcezy
Definition: constants.F90:348
integer(kind=inttype), parameter costfuncmavgttot
Definition: constants.F90:348
integer(kind=inttype), parameter costfuncliftcoef
Definition: constants.F90:348
integer(kind=inttype), parameter costfunccfyalphadot
Definition: constants.F90:348
integer(kind=inttype), parameter subsonicinflow
Definition: constants.F90:265
integer(kind=inttype), parameter costfuncmomycoef
Definition: constants.F90:348
integer(kind=inttype), parameter costfuncsepsensoravgy
Definition: constants.F90:348
integer(kind=inttype), parameter costfuncmavgvz
Definition: constants.F90:348
integer(kind=inttype), parameter costfuncliftcoefviscous
Definition: constants.F90:348
integer(kind=inttype), parameter costfuncsepsensoravgx
Definition: constants.F90:348
integer(kind=inttype), parameter icpmin
Definition: constants.F90:455
integer(kind=inttype), parameter costfunccoforcezx
Definition: constants.F90:348
integer(kind=inttype), parameter costfuncforcezpressure
Definition: constants.F90:348
integer(kind=inttype), parameter costfuncforcezviscous
Definition: constants.F90:348
integer(kind=inttype), parameter costfuncmavgrho
Definition: constants.F90:348
integer(kind=inttype), parameter kmax
Definition: constants.F90:297
integer(kind=inttype), parameter costfuncclqdot
Definition: constants.F90:348
integer, parameter ivy
Definition: constants.F90:36
integer(kind=inttype), parameter costfuncsepsensor
Definition: constants.F90:348
integer(kind=inttype), parameter costfuncsepsensorks
Definition: constants.F90:348
integer(kind=inttype), parameter costfuncclq
Definition: constants.F90:348
integer(kind=inttype), parameter isepsensorks
Definition: constants.F90:455
integer(kind=inttype), parameter icavitation
Definition: constants.F90:455
integer(kind=inttype), parameter ransequations
Definition: constants.F90:110
integer(kind=inttype), parameter imassttot
Definition: constants.F90:455
integer(kind=inttype), parameter jmin
Definition: constants.F90:294
integer(kind=inttype), parameter costfuncforcezcoef
Definition: constants.F90:348
integer(kind=inttype), parameter costfunccfy0
Definition: constants.F90:348
integer(kind=inttype), parameter internalflow
Definition: constants.F90:120
integer(kind=inttype), parameter ifp
Definition: constants.F90:455
integer(kind=inttype), parameter costfuncdragpressure
Definition: constants.F90:348
integer(kind=inttype), parameter costfuncforceycoefmomentum
Definition: constants.F90:348
integer(kind=inttype), parameter iareaptot
Definition: constants.F90:455
subroutine getdirvector(refDirection, alpha, beta, windDirection, liftIndex)
Definition: flowUtils.F90:1533
subroutine computettot(rho, u, v, w, p, Ttot)
Definition: flowUtils.F90:5
subroutine computeptot(rho, u, v, w, p, ptot)
Definition: flowUtils.F90:171
real(kind=realtype) gammainf
real(kind=realtype) uinf
real(kind=realtype) pinf
real(kind=realtype) rgas
real(kind=realtype) uref
real(kind=realtype) rhoref
real(kind=realtype) tref
real(kind=realtype) lref
real(kind=realtype) rhoinf
real(kind=realtype) pref
real(kind=realtype) timeref
real(kind=realtype) sepsensorsharpness
Definition: inputParam.F90:307
real(kind=realtype) cavsensoroffset
Definition: inputParam.F90:309
real(kind=realtype) cavsensorsharpness
Definition: inputParam.F90:310
logical computesepsensorks
Definition: inputParam.F90:303
real(kind=realtype) sepsensoroffset
Definition: inputParam.F90:304
real(kind=realtype) sepsensorkssharpness
Definition: inputParam.F90:308
real(kind=realtype) sepsensorksphi
Definition: inputParam.F90:306
real(kind=realtype) sepsensorksoffset
Definition: inputParam.F90:305
integer(kind=inttype) cavexponent
Definition: inputParam.F90:311
logical computecavitation
Definition: inputParam.F90:312
real(kind=realtype) cpmin_rho
Definition: inputParam.F90:606
real(kind=realtype) sepsenmaxrho
Definition: inputParam.F90:608
integer(kind=inttype) equations
Definition: inputParam.F90:583
real(kind=realtype), dimension(:), allocatable sepsenmaxfamily
Definition: inputParam.F90:609
real(kind=realtype), dimension(3) pointref
Definition: inputParam.F90:602
real(kind=realtype), dimension(3, 2) momentaxis
Definition: inputParam.F90:603
integer(kind=inttype) liftindex
Definition: inputParam.F90:592
real(kind=realtype), dimension(3) dragdirection
Definition: inputParam.F90:601
real(kind=realtype) beta
Definition: inputParam.F90:591
real(kind=realtype), dimension(:), allocatable cpmin_family
Definition: inputParam.F90:607
real(kind=realtype) lengthref
Definition: inputParam.F90:598
real(kind=realtype) machcoef
Definition: inputParam.F90:593
real(kind=realtype) cavitationnumber
Definition: inputParam.F90:605
real(kind=realtype), dimension(3) liftdirection
Definition: inputParam.F90:600
integer(kind=inttype) flowtype
Definition: inputParam.F90:583
real(kind=realtype) surfaceref
Definition: inputParam.F90:598
real(kind=realtype) rgasdim
Definition: inputParam.F90:595
real(kind=realtype), dimension(3) veldirfreestream
Definition: inputParam.F90:599
real(kind=realtype) alpha
Definition: inputParam.F90:591
integer(kind=inttype) ntimeintervalsspectral
Definition: inputParam.F90:645
integer, parameter realtype
Definition: precision.F90:112
logical function faminlist(famID, famList)
Definition: sorting.F90:7
subroutine wallintegrationface_b(localvalues, localvaluesd, mm)
subroutine getcostfunctions_b(globalvals, globalvalsd, funcvalues, funcvaluesd)
subroutine flowintegrationface_b(isinflow, localvalues, localvaluesd, mm)
subroutine getcostfunctions_d(globalvals, globalvalsd, funcvalues, funcvaluesd)
subroutine wallintegrationface_d(localvalues, localvaluesd, mm)
subroutine flowintegrationface_d(isinflow, localvalues, localvaluesd, mm)
subroutine getsolution_b(famLists, funcValues, funcValuesd)
subroutine ksaggregationfunction(g, max_g, g_rho, ks_g)
subroutine getsolutionwrap(famLists, funcValues, nCost, nGroups, nFamMax)
subroutine integratesurfaces_b(localValues, localValuesd, famList)
subroutine getcostfunctions(globalVals, funcValues)
subroutine getsolution_d(famLists, funcValues, funcValuesd)
subroutine integratesurfaces_d(localValues, localValuesd, famList)
subroutine computecpminfamily(famList)
subroutine integratesurfaces(localValues, famList)
subroutine wallintegrationface(localValues, mm)
subroutine computesepsenmaxfamily(famList)
subroutine getsolution(famLists, funcValues, globalValues)
subroutine flowintegrationface(isInflow, localValues, mm)
subroutine integrateusersurfaces_d(localValues, localValuesd, famList, sps)
subroutine integrateusersurfaces(localValues, famList, sps)
subroutine integrateusersurfaces_b(localValues, localValuesd, famList, sps)
Definition: utils.F90:1
logical function iswalltype(bType)
Definition: utils.F90:1705
subroutine setbcpointers(nn, spatialPointers)
Definition: utils.F90:882
subroutine setpointers_d(nn, level, sps)
Definition: utils.F90:3564
real(kind=realtype) function mynorm2(x)
Definition: utils.F90:1697
subroutine computetsderivatives(force, moment, coef0, dcdalpha, dcdalphadot, dcdq, dcdqdot)
Definition: utils.F90:1254
subroutine setbcpointers_d(nn, spatialpointers)
Definition: utils.F90:2049
subroutine echk(errorcode, file, line)
Definition: utils.F90:5722
subroutine setpointers_b(nn, level, sps)
Definition: utils.F90:3553
subroutine setpointers(nn, mm, ll)
Definition: utils.F90:3237
subroutine integratezippers_b(localValues, localValuesd, famList, sps)
subroutine integratezippers_d(localValues, localValuesd, famList, sps)
subroutine integratezippers(localValues, famList, sps)