ADflow  v1.0
ADflow is a finite volume RANS solver tailored for gradient-based aerodynamic design optimization.
zipperIntegrations.F90
Go to the documentation of this file.
2 contains
3 
4  subroutine flowintegrationzipper(isInflow, conn, fams, vars, localValues, famList, sps, ptValid)
5 
6  ! Integrate over the trianges for the inflow/outflow conditions.
7 
8  use constants
9  use blockpointers, only: bctype
10  use sorting, only: faminlist
15  use utils, only: mynorm2, cross_prod
16  implicit none
17 
18  ! Input/output Variables
19  logical, intent(in) :: isInflow
20  integer(kind=intType), intent(in), dimension(:, :) :: conn
21  integer(kind=intType), intent(in), dimension(:) :: fams
22  real(kind=realtype), dimension(:, :), intent(in) :: vars
23  real(kind=realtype), dimension(nLocalValues), intent(inout) :: localvalues
24  integer(kind=intType), dimension(:), intent(in) :: famList
25  integer(kind=intType), intent(in) :: sps
26  logical(kind=intType), dimension(:), optional, intent(in) :: ptValid
27 
28  ! Working variables
29  integer(kind=intType) :: i, j
30  real(kind=realtype) :: sf, vmag, vnm, vxm, vym, vzm, fx, fy, fz, u, v, w, vnmfreestreamref
31  real(kind=realtype), dimension(3) :: fp, mp, fmom, mmom, refpoint, ss, x1, x2, x3, &
32  norm, sfacecoordref
33  real(kind=realtype) :: pm, ptot, ttot, rhom, gammam, mnm, massflowratelocal, am
34  real(kind=realtype) :: massflowrate, mass_ptot, mass_ttot, mass_ps, mass_mn, mass_a, mass_rho, &
35  mass_vx, mass_vy, mass_vz, mass_nx, mass_ny, mass_nz, mass_vi
36  real(kind=realtype) :: area, cellarea, overcellarea
37  real(kind=realtype) :: area_ptot, area_ps
38  real(kind=realtype) :: govgm1, gm1ovg, viconst, vilocal, pratio
39  real(kind=realtype) :: mredim
40  real(kind=realtype) :: internalflowfact, inflowfact, xc, xco, yc, yco, zc, zco, mx, my, mz
41  real(kind=realtype), dimension(3) :: cofsumfx, cofsumfy, cofsumfz
42 
43  logical :: triIsValid
44 
45  mredim = sqrt(pref * rhoref)
46  fp = zero
47  mp = zero
48  fmom = zero
49  mmom = zero
50 
51  cofsumfx = zero
52  cofsumfy = zero
53  cofsumfz = zero
54 
55  massflowrate = zero
56  area = zero
57  mass_ptot = zero
58  mass_ttot = zero
59  mass_ps = zero
60  mass_mn = zero
61  mass_a = zero
62  mass_rho = zero
63 
64  mass_vx = zero
65  mass_vy = zero
66  mass_vz = zero
67  mass_nx = zero
68  mass_ny = zero
69  mass_nz = zero
70  mass_vi = zero
71 
72  area_ptot = zero
73  area_ps = zero
74 
75  refpoint(1) = lref * pointref(1)
76  refpoint(2) = lref * pointref(2)
77  refpoint(3) = lref * pointref(3)
78 
79  internalflowfact = one
80  if (flowtype == internalflow) then
81  internalflowfact = -one
82  end if
83 
84  inflowfact = one
85  if (isinflow) then
86  inflowfact = -one
87  end if
88 
89  !$AD II-LOOP
90  do i = 1, size(conn, 2)
91  if (faminlist(fams(i), famlist)) then
92 
93  ! If the ptValid list is given, check if we should integrate
94  ! this triangle.
95  triisvalid = .true.
96  if (present(ptvalid)) then
97  ! Check if each of the three nodes are valid
98  if ((ptvalid(conn(1, i)) .eqv. .false.) .or. &
99  (ptvalid(conn(2, i)) .eqv. .false.) .or. &
100  (ptvalid(conn(3, i)) .eqv. .false.)) then
101  triisvalid = .false.
102  end if
103  end if
104 
105  validtrianlge: if (triisvalid) then
106 
107  ! Compute the averaged values for this triangle
108  vxm = zero; vym = zero; vzm = zero; rhom = zero; pm = zero; mnm = zero; gammam = zero;
109  sf = zero
110  do j = 1, 3
111  rhom = rhom + vars(conn(j, i), irho)
112  vxm = vxm + vars(conn(j, i), ivx)
113  vym = vym + vars(conn(j, i), ivy)
114  vzm = vzm + vars(conn(j, i), ivz)
115  pm = pm + vars(conn(j, i), irhoe)
116  gammam = gammam + vars(conn(j, i), izippflowgamma)
117  sf = sf + vars(conn(j, i), izippflowsface)
118  end do
119 
120  ! Divide by 3 due to the summation above:
121  rhom = third * rhom
122  vxm = third * vxm
123  vym = third * vym
124  vzm = third * vzm
125  pm = third * pm
126  gammam = third * gammam
127  sf = third * sf
128 
129  ! Get the nodes of triangle.
130  x1 = vars(conn(1, i), izippflowx:izippflowz)
131  x2 = vars(conn(2, i), izippflowx:izippflowz)
132  x3 = vars(conn(3, i), izippflowx:izippflowz)
133  call cross_prod(x2 - x1, x3 - x1, norm)
134  ss = half * norm
135 
136  call computeptot(rhom, vxm, vym, vzm, pm, ptot)
137  call computettot(rhom, vxm, vym, vzm, pm, ttot)
138 
139  vnm = vxm * ss(1) + vym * ss(2) + vzm * ss(3) - sf
140 
141  vmag = sqrt((vxm**2 + vym**2 + vzm**2)) - sf
142  am = sqrt(gammam * pm / rhom)
143  mnm = vmag / sqrt(gammam * pm / rhom)
144 
145  cellarea = sqrt(ss(1)**2 + ss(2)**2 + ss(3)**2)
146  area = area + cellarea
147  overcellarea = 1 / cellarea
148 
149  massflowratelocal = rhom * vnm * mredim
150  massflowrate = massflowrate + massflowratelocal
151 
152  pm = pm * pref
153 
154  mass_ptot = mass_ptot + ptot * massflowratelocal * pref
155  mass_ttot = mass_ttot + ttot * massflowratelocal * tref
156  mass_rho = mass_rho + rhom * massflowratelocal * rhoref
157  mass_a = mass_a + am * massflowratelocal * uref
158 
159  mass_ps = mass_ps + pm * massflowratelocal
160  mass_mn = mass_mn + mnm * massflowratelocal
161 
162  area_ptot = area_ptot + ptot * pref * cellarea
163  area_ps = area_ps + pm * cellarea
164 
165  sfacecoordref(1) = sf * ss(1) * overcellarea
166  sfacecoordref(2) = sf * ss(2) * overcellarea
167  sfacecoordref(3) = sf * ss(3) * overcellarea
168 
169  mass_vx = mass_vx + (vxm * uref - sfacecoordref(1)) * massflowratelocal
170  mass_vy = mass_vy + (vym * uref - sfacecoordref(2)) * massflowratelocal
171  mass_vz = mass_vz + (vzm * uref - sfacecoordref(3)) * massflowratelocal
172 
173  govgm1 = gammainf / (gammainf - one)
174  gm1ovg = one / govgm1
175  viconst = two * govgm1 * rgasdim
176  ! the prefs in psinf / ptot cancel out so we can just take the ratio
177  ! we need to clip the ratio to stay under one. right next to the wall,
178  ! the pTot can go below the static free stream pressure. To prevent
179  ! nans from the sqrt, we just clip this. This does not affect the computation
180  ! because when pTot is this small, the velocities are also small, and the
181  ! mdot is almost zero, so the cells in this area don't contribute much
182  ! to the mass weighed sum.
183  pratio = min(one, one / ptot)
184  vilocal = sqrt(viconst * (one - (pratio)**gm1ovg) * ttot * tref)
185  mass_vi = mass_vi + vilocal * massflowratelocal
186 
187  mass_nx = mass_nx + ss(1) * overcellarea * massflowratelocal
188  mass_ny = mass_ny + ss(2) * overcellarea * massflowratelocal
189  mass_nz = mass_nz + ss(3) * overcellarea * massflowratelocal
190 
191  ! Compute the average cell center.
192  xco = zero
193  yco = zero
194  zco = zero
195  do j = 1, 3
196  xco = xco + (vars(conn(1, i), izippflowx))
197  yco = yco + (vars(conn(2, i), izippflowy))
198  zco = zco + (vars(conn(3, i), izippflowz))
199  end do
200 
201  ! Finish average for cell center
202  xco = third * xco
203  yco = third * yco
204  zco = third * zco
205 
206  ! x-y-zco is the cell center w.r.t. the origin, x-y-zc is w.r.t. the reference point
207  xc = xco - refpoint(1)
208  yc = yco - refpoint(2)
209  zc = zco - refpoint(3)
210 
211  pm = -(pm - pinf * pref)
212  fx = pm * ss(1)
213  fy = pm * ss(2)
214  fz = pm * ss(3)
215 
216  ! Update the pressure force and moment coefficients.
217  fp(1) = fp(1) + fx
218  fp(2) = fp(2) + fy
219  fp(3) = fp(3) + fz
220 
221  mx = yc * fz - zc * fy
222  my = zc * fx - xc * fz
223  mz = xc * fy - yc * fx
224 
225  mp(1) = mp(1) + mx
226  mp(2) = mp(2) + my
227  mp(3) = mp(3) + mz
228 
229  ! Center of force computations. Here we accumulate in the sums.
230  ! Force-X
231  cofsumfx(1) = cofsumfx(1) + xco * fx
232  cofsumfx(2) = cofsumfx(2) + yco * fx
233  cofsumfx(3) = cofsumfx(3) + zco * fx
234 
235  ! Force-Y
236  cofsumfy(1) = cofsumfy(1) + xco * fy
237  cofsumfy(2) = cofsumfy(2) + yco * fy
238  cofsumfy(3) = cofsumfy(3) + zco * fy
239 
240  ! Force-Z
241  cofsumfz(1) = cofsumfz(1) + xco * fz
242  cofsumfz(2) = cofsumfz(2) + yco * fz
243  cofsumfz(3) = cofsumfz(3) + zco * fz
244 
245  ! Momentum forces
246 
247  ! Get unit normal vector.
248  ss = ss / cellarea
249  massflowratelocal = massflowratelocal / timeref * internalflowfact * inflowfact
250 
251  fx = massflowratelocal * ss(1) * vxm
252  fy = massflowratelocal * ss(2) * vym
253  fz = massflowratelocal * ss(3) * vzm
254 
255  fmom(1) = fmom(1) - fx
256  fmom(2) = fmom(2) - fy
257  fmom(3) = fmom(3) - fz
258 
259  mx = yc * fz - zc * fy
260  my = zc * fx - xc * fz
261  mz = xc * fy - yc * fx
262 
263  mmom(1) = mmom(1) + mx
264  mmom(2) = mmom(2) + my
265  mmom(3) = mmom(3) + mz
266 
267  ! Center of force computations. Here we accumulate in the sums.
268  ! Force-X
269  cofsumfx(1) = cofsumfx(1) + xco * fx
270  cofsumfx(2) = cofsumfx(2) + yco * fx
271  cofsumfx(3) = cofsumfx(3) + zco * fx
272 
273  ! Force-Y
274  cofsumfy(1) = cofsumfy(1) + xco * fy
275  cofsumfy(2) = cofsumfy(2) + yco * fy
276  cofsumfy(3) = cofsumfy(3) + zco * fy
277 
278  ! Force-Z
279  cofsumfz(1) = cofsumfz(1) + xco * fz
280  cofsumfz(2) = cofsumfz(2) + yco * fz
281  cofsumfz(3) = cofsumfz(3) + zco * fz
282  end if validtrianlge
283  end if
284  end do
285 
286  ! Increment the local values array with what we computed here
287  localvalues(imassflow) = localvalues(imassflow) + massflowrate
288  localvalues(iarea) = localvalues(iarea) + area
289  localvalues(imassrho) = localvalues(imassrho) + mass_rho
290  localvalues(imassa) = localvalues(imassa) + mass_a
291  localvalues(imassptot) = localvalues(imassptot) + mass_ptot
292  localvalues(imassttot) = localvalues(imassttot) + mass_ttot
293  localvalues(imassps) = localvalues(imassps) + mass_ps
294  localvalues(imassmn) = localvalues(imassmn) + mass_mn
295  localvalues(ifp:ifp + 2) = localvalues(ifp:ifp + 2) + fp
296  localvalues(iflowfm:iflowfm + 2) = localvalues(iflowfm:iflowfm + 2) + fmom
297  localvalues(iflowmp:iflowmp + 2) = localvalues(iflowmp:iflowmp + 2) + mp
298  localvalues(iflowmm:iflowmm + 2) = localvalues(iflowmm:iflowmm + 2) + mmom
299 
300  localvalues(icoforcex:icoforcex + 2) = localvalues(icoforcex:icoforcex + 2) + cofsumfx
301  localvalues(icoforcey:icoforcey + 2) = localvalues(icoforcey:icoforcey + 2) + cofsumfy
302  localvalues(icoforcez:icoforcez + 2) = localvalues(icoforcez:icoforcez + 2) + cofsumfz
303 
304  localvalues(iareaptot) = localvalues(iareaptot) + area_ptot
305  localvalues(iareaps) = localvalues(iareaps) + area_ps
306 
307  localvalues(imassvx) = localvalues(imassvx) + mass_vx
308  localvalues(imassvy) = localvalues(imassvy) + mass_vy
309  localvalues(imassvz) = localvalues(imassvz) + mass_vz
310  localvalues(imassnx) = localvalues(imassnx) + mass_nx
311  localvalues(imassny) = localvalues(imassny) + mass_ny
312  localvalues(imassnz) = localvalues(imassnz) + mass_nz
313  localvalues(imassvi) = localvalues(imassvi) + mass_vi
314 
315  end subroutine flowintegrationzipper
316 
317  subroutine wallintegrationzipper(conn, fams, vars, localValues, famList, sps)
318 
319  use constants
320  use sorting, only: faminlist
321  use flowvarrefstate, only: lref
322  use inputphysics, only: pointref
323  use utils, only: mynorm2, cross_prod
324  implicit none
325 
326  ! Input/Output
327  integer(kind=intType), intent(in), dimension(:, :) :: conn
328  integer(kind=intType), intent(in), dimension(:) :: fams
329  real(kind=realtype), intent(in), dimension(:, :) :: vars
330  real(kind=realtype), intent(inout) :: localvalues(nlocalvalues)
331  integer(kind=intType), dimension(:), intent(in) :: famList
332  integer(kind=intType), intent(in) :: sps
333 
334  ! Working
335  real(kind=realtype), dimension(3) :: fp, fv, mp, mv
336  real(kind=realtype), dimension(3) :: cofsumfx, cofsumfy, cofsumfz
337 
338  integer(kind=intType) :: i, j
339  real(kind=realtype), dimension(3) :: ss, norm, refpoint
340  real(kind=realtype), dimension(3) :: p1, p2, p3, v1, v2, v3, x1, x2, x3
341  real(kind=realtype) :: fact, triarea, fx, fy, fz, mx, my, mz, xc, xco, yc, yco, zc, zco
342 
343  ! Determine the reference point for the moment computation in
344  ! meters.
345  refpoint(1) = lref * pointref(1)
346  refpoint(2) = lref * pointref(2)
347  refpoint(3) = lref * pointref(3)
348  fp = zero
349  fv = zero
350  mp = zero
351  mv = zero
352  cofsumfx = zero
353  cofsumfy = zero
354  cofsumfz = zero
355 
356  !$AD II-LOOP
357  do i = 1, size(conn, 2)
358  if (faminlist(fams(i), famlist)) then
359 
360  ! Get the nodes of triangle.
361  x1 = vars(conn(1, i), izippwallx:izippwallz)
362  x2 = vars(conn(2, i), izippwallx:izippwallz)
363  x3 = vars(conn(3, i), izippwallx:izippwallz)
364  call cross_prod(x2 - x1, x3 - x1, norm)
365  ss = half * norm
366  ! The third here is to account for the summation of P1, p2
367  ! and P3
368  triarea = mynorm2(ss) * third
369 
370  ! Compute the average cell center.
371  xco = third * (x1(1) + x2(1) + x3(1))
372  yco = third * (x1(2) + x2(2) + x3(2))
373  zco = third * (x1(3) + x2(3) + x3(3))
374 
375  xc = xco - refpoint(1)
376  yc = yco - refpoint(2)
377  zc = zco - refpoint(3)
378 
379  ! Update the pressure force and moment coefficients.
380  p1 = vars(conn(1, i), izippwalltpx:izippwalltpz)
381  p2 = vars(conn(2, i), izippwalltpx:izippwalltpz)
382  p3 = vars(conn(3, i), izippwalltpx:izippwalltpz)
383 
384  fx = (p1(1) + p2(1) + p3(1)) * triarea
385  fy = (p1(2) + p2(2) + p3(2)) * triarea
386  fz = (p1(3) + p2(3) + p3(3)) * triarea
387 
388  fp(1) = fp(1) + fx
389  fp(2) = fp(2) + fy
390  fp(3) = fp(3) + fz
391 
392  mx = yc * fz - zc * fy
393  my = zc * fx - xc * fz
394  mz = xc * fy - yc * fx
395 
396  mp(1) = mp(1) + mx
397  mp(2) = mp(2) + my
398  mp(3) = mp(3) + mz
399 
400  ! accumulate in the sums. each force component is tracked separately
401 
402  ! Force-X
403  cofsumfx(1) = cofsumfx(1) + xco * fx
404  cofsumfx(2) = cofsumfx(2) + yco * fx
405  cofsumfx(3) = cofsumfx(3) + zco * fx
406 
407  ! Force-Y
408  cofsumfy(1) = cofsumfy(1) + xco * fy
409  cofsumfy(2) = cofsumfy(2) + yco * fy
410  cofsumfy(3) = cofsumfy(3) + zco * fy
411 
412  ! Force-Z
413  cofsumfz(1) = cofsumfz(1) + xco * fz
414  cofsumfz(2) = cofsumfz(2) + yco * fz
415  cofsumfz(3) = cofsumfz(3) + zco * fz
416 
417  ! Update the viscous force and moment coefficients
418  v1 = vars(conn(1, i), izippwalltvx:izippwalltvz)
419  v2 = vars(conn(2, i), izippwalltvx:izippwalltvz)
420  v3 = vars(conn(3, i), izippwalltvx:izippwalltvz)
421 
422  fx = (v1(1) + v2(1) + v3(1)) * triarea
423  fy = (v1(2) + v2(2) + v3(2)) * triarea
424  fz = (v1(3) + v2(3) + v3(3)) * triarea
425 
426  ! Note: momentum forces have opposite sign to pressure forces
427  fv(1) = fv(1) + fx
428  fv(2) = fv(2) + fy
429  fv(3) = fv(3) + fz
430 
431  mx = yc * fz - zc * fy
432  my = zc * fx - xc * fz
433  mz = xc * fy - yc * fx
434 
435  mv(1) = mv(1) + mx
436  mv(2) = mv(2) + my
437  mv(3) = mv(3) + mz
438 
439  ! accumulate in the sums. each force component is tracked separately
440 
441  ! Force-X
442  cofsumfx(1) = cofsumfx(1) + xco * fx
443  cofsumfx(2) = cofsumfx(2) + yco * fx
444  cofsumfx(3) = cofsumfx(3) + zco * fx
445 
446  ! Force-Y
447  cofsumfy(1) = cofsumfy(1) + xco * fy
448  cofsumfy(2) = cofsumfy(2) + yco * fy
449  cofsumfy(3) = cofsumfy(3) + zco * fy
450 
451  ! Force-Z
452  cofsumfz(1) = cofsumfz(1) + xco * fz
453  cofsumfz(2) = cofsumfz(2) + yco * fz
454  cofsumfz(3) = cofsumfz(3) + zco * fz
455  end if
456  end do
457 
458  ! Increment into the local vector
459  localvalues(ifp:ifp + 2) = localvalues(ifp:ifp + 2) + fp
460  localvalues(ifv:ifv + 2) = localvalues(ifv:ifv + 2) + fv
461  localvalues(imp:imp + 2) = localvalues(imp:imp + 2) + mp
462  localvalues(imv:imv + 2) = localvalues(imv:imv + 2) + mv
463  localvalues(icoforcex:icoforcex + 2) = localvalues(icoforcex:icoforcex + 2) + cofsumfx
464  localvalues(icoforcey:icoforcey + 2) = localvalues(icoforcey:icoforcey + 2) + cofsumfy
465  localvalues(icoforcez:icoforcez + 2) = localvalues(icoforcez:icoforcez + 2) + cofsumfz
466 
467  end subroutine wallintegrationzipper
468 
469 #ifndef USE_TAPENADE
470 
471  subroutine integratezippers(localValues, famList, sps)
472  !--------------------------------------------------------------
473  ! Manual Differentiation Warning: Modifying this routine requires
474  ! modifying the hand-written forward and reverse routines.
475  ! --------------------------------------------------------------
476 
477  ! Integrate over the triangles formed by the zipper mesh. This
478  ! will perform both all necesasry zipper integrations. Currently
479  ! this includes the wall force integrations as well as the
480  ! flow-though surface integration.
481 
482  use constants
485  implicit none
486 
487  ! Input Variables
488  real(kind=realtype), dimension(nLocalValues), intent(inout) :: localvalues
489  integer(kind=intType), dimension(:), intent(in) :: famList
490  integer(kind=intType), intent(in) :: sps
491  real(kind=realtype), dimension(:, :), allocatable :: vars
492  type(zippermesh), pointer :: zipper
493 
494  ! Determine if we have a wall Zipper:
495  zipper => zippermeshes(ibcgroupwalls)
496  if (zipper%allocated) then
497 
498  ! Allocate space necessary to store variables. Only non-zero on
499  ! root proc.
500  allocate (vars(size(zipper%indices), nzippwallcomm))
501 
502  ! Gather up the required variables in "vars" on the root
503  ! proc. This routine is differientated by hand.
504  call wallintegrationzippercomm(vars, sps)
505 
506  ! Perform actual integration. Tapenade ADs this routine.
507  call wallintegrationzipper(zipper%conn, zipper%fam, vars, localvalues, famlist, sps)
508 
509  ! Cleanup vars
510  deallocate (vars)
511  end if
512 
513  zipper => zippermeshes(ibcgroupinflow)
514  ! Determine if we have a flowthrough Zipper:
515  if (zipper%allocated) then
516 
517  ! Allocate space necessary to store variables. Only non-zero on
518  ! root proc.
519  allocate (vars(size(zipper%indices), nzippflowcomm))
520 
521  ! Gather up the required variables in "vars" on the root
522  ! proc. This routine is differientated by hand.
523  call flowintegrationzippercomm(.true., vars, sps)
524 
525  ! Perform actual integration. Tapenade ADs this routine.
526  call flowintegrationzipper(.true., zipper%conn, zipper%fam, vars, &
527  localvalues, famlist, sps)
528 
529  ! Cleanup vars
530  deallocate (vars)
531  end if
532 
533  zipper => zippermeshes(ibcgroupoutflow)
534  ! Determine if we have a flowthrough Zipper:
535  if (zipper%allocated) then
536 
537  ! Allocate space necessary to store variables. Only non-zero on
538  ! root proc.
539  allocate (vars(size(zipper%indices), nzippflowcomm))
540 
541  ! Gather up the required variables in "vars" on the root
542  ! proc. This routine is differientated by hand.
543  call flowintegrationzippercomm(.false., vars, sps)
544 
545  ! Perform actual integration. Tapenade ADs this routine.
546  call flowintegrationzipper(.false., zipper%conn, zipper%fam, vars, &
547  localvalues, famlist, sps)
548 
549  ! Cleanup vars
550  deallocate (vars)
551  end if
552  end subroutine integratezippers
553 
554 #ifndef USE_COMPLEX
555  subroutine integratezippers_d(localValues, localValuesd, famList, sps)
556  !------------------------------------------------------------------------
557  ! Manual Differentiation Warning: This routine is differentiated by hand.
558  ! -----------------------------------------------------------------------
559 
560  ! Forward mode linearization of the zipper integration.
561 
562  use constants
566  implicit none
567 
568  ! Input Variables
569  real(kind=realtype), dimension(nLocalValues), intent(inout) :: localvalues, localvaluesd
570  integer(kind=intType), dimension(:), intent(in) :: famlist
571  integer(kind=intType), intent(in) :: sps
572  real(kind=realtype), dimension(:, :), allocatable :: vars, varsd
573  type(zippermesh), pointer :: zipper
574 
575  zipper => zippermeshes(ibcgroupwalls)
576  if (zipper%allocated) then
577 
578  ! Allocate space necessary to store variables. Only non-zero on
579  ! root proc.
580  allocate (vars(size(zipper%indices), nzippwallcomm), varsd(size(zipper%indices), nzippwallcomm))
581 
582  ! Gather up the required variables in "vars" on the root
583  ! proc. This routine is differientated by hand.
584  call wallintegrationzippercomm_d(vars, varsd, sps)
585 
586  ! Perform actual integration. Tapenade ADs this routine.
587  call wallintegrationzipper_d(zipper%conn, zipper%fam, vars, varsd, &
588  localvalues, localvaluesd, famlist, sps)
589 
590  ! Cleanup vars
591  deallocate (vars, varsd)
592  end if
593 
594  zipper => zippermeshes(ibcgroupinflow)
595  ! Determine if we have a flowthrough Zipper:
596  if (zipper%allocated) then
597 
598  ! Allocate space necessary to store variables. Only non-zero on
599  ! root proc.
600  allocate (vars(size(zipper%indices), nzippflowcomm), varsd(size(zipper%indices), nzippflowcomm))
601 
602  ! Gather up the required variables in "vars" on the root
603  ! proc. This routine is differientated by hand.
604  call flowintegrationzippercomm_d(.true., vars, varsd, sps)
605 
606  ! Perform actual integration. Tapenade ADs this routine.
607  call flowintegrationzipper_d(.true., zipper%conn, zipper%fam, vars, varsd, &
608  localvalues, localvaluesd, famlist, sps)
609 
610  ! Cleanup vars
611  deallocate (vars, varsd)
612  end if
613 
614  zipper => zippermeshes(ibcgroupoutflow)
615  ! Determine if we have a flowthrough Zipper:
616  if (zipper%allocated) then
617 
618  ! Allocate space necessary to store variables. Only non-zero on
619  ! root proc.
620  allocate (vars(size(zipper%indices), nzippflowcomm), varsd(size(zipper%indices), nzippflowcomm))
621 
622  ! Gather up the required variables in "vars" on the root
623  ! proc. This routine is differientated by hand.
624  call flowintegrationzippercomm_d(.false., vars, varsd, sps)
625 
626  ! Perform actual integration. Tapenade ADs this routine.
627  call flowintegrationzipper_d(.false., zipper%conn, zipper%fam, vars, varsd, &
628  localvalues, localvaluesd, famlist, sps)
629 
630  ! Cleanup vars
631  deallocate (vars, varsd)
632  end if
633  end subroutine integratezippers_d
634 
635  subroutine integratezippers_b(localValues, localValuesd, famList, sps)
636  !------------------------------------------------------------------------
637  ! Manual Differentiation Warning: This routine is differentiated by hand.
638  ! -----------------------------------------------------------------------
639 
640  ! Reverse mode linearization of the zipper integration.
641 
642  use constants
647  implicit none
648 
649  ! Input Variables
650  real(kind=realtype), dimension(nLocalValues), intent(inout) :: localvalues, localvaluesd
651  integer(kind=intType), dimension(:), intent(in) :: famlist
652  integer(kind=intType), intent(in) :: sps
653  real(kind=realtype), dimension(:, :), allocatable :: vars, varsd
654  type(zippermesh), pointer :: zipper
655 
656  ! Determine if we have a wall Zipper:
657  zipper => zippermeshes(ibcgroupwalls)
658  if (zipper%allocated) then
659 
660  ! Allocate space necessary to store variables. Only non-zero on
661  ! root proc.
662  allocate (vars(size(zipper%indices), nzippwallcomm), varsd(size(zipper%indices), nzippwallcomm))
663 
664  ! Set the forward variables
665  call wallintegrationzippercomm(vars, sps)
666 
667  ! Perform actual integration. Tapenade ADs this routine.
668  varsd = zero
669  call wallintegrationzipper_b(zipper%conn, zipper%fam, vars, varsd, &
670  localvalues, localvaluesd, famlist, sps)
671 
672  ! Scatter (becuase we are reverse) the values from the root
673  ! back out to all necessary procs. This routine is
674  ! differientated by hand.
675  call wallintegrationzippercomm_b(vars, varsd, sps)
676 
677  ! Cleanup vars
678  deallocate (vars, varsd)
679  end if
680 
681  zipper => zippermeshes(ibcgroupinflow)
682  ! Determine if we have a flowthrough Zipper:
683  if (zipper%allocated) then
684 
685  ! Allocate space necessary to store variables. Only non-zero on
686  ! root proc.
687  allocate (vars(size(zipper%indices), nzippflowcomm), varsd(size(zipper%indices), nzippflowcomm))
688 
689  ! Set the forward variables
690  call flowintegrationzippercomm(.true., vars, sps)
691 
692  ! Perform actual integration. Tapenade ADs this routine.
693  varsd = zero
694  call flowintegrationzipper_b(.true., zipper%conn, zipper%fam, vars, varsd, &
695  localvalues, localvaluesd, famlist, sps)
696 
697  ! Scatter (becuase we are reverse) the values from the root
698  ! back out to all necessary procs. This routine is
699  ! differientated by hand.
700  call flowintegrationzippercomm_b(.true., vars, varsd, sps)
701 
702  ! Cleanup vars
703  deallocate (vars, varsd)
704  end if
705 
706  zipper => zippermeshes(ibcgroupoutflow)
707  ! Determine if we have a flowthrough Zipper:
708  if (zipper%allocated) then
709 
710  ! Allocate space necessary to store variables. Only non-zero on
711  ! root proc.
712  allocate (vars(size(zipper%indices), nzippflowcomm), varsd(size(zipper%indices), nzippflowcomm))
713 
714  ! Set the forward variables
715  call flowintegrationzippercomm(.false., vars, sps)
716 
717  ! Perform actual integration. Tapenade ADs this routine.
718  varsd = zero
719  call flowintegrationzipper_b(.false., zipper%conn, zipper%fam, vars, varsd, &
720  localvalues, localvaluesd, famlist, sps)
721 
722  ! Scatter (becuase we are reverse) the values from the root
723  ! back out to all necessary procs. This routine is
724  ! differientated by hand.
725  call flowintegrationzippercomm_b(.false., vars, varsd, sps)
726 
727  ! Cleanup vars
728  deallocate (vars, varsd)
729  end if
730  end subroutine integratezippers_b
731 #endif
732 #endif
733 
734 end module zipperintegrations
integer(kind=inttype), dimension(:), pointer bctype
integer(kind=inttype), parameter imassvz
Definition: constants.F90:455
integer(kind=inttype), parameter iareaps
Definition: constants.F90:455
real(kind=realtype), parameter zero
Definition: constants.F90:71
integer(kind=inttype), parameter nlocalvalues
Definition: constants.F90:454
integer(kind=inttype), parameter izippflowy
Definition: constants.F90:508
integer(kind=inttype), parameter iflowmp
Definition: constants.F90:455
integer(kind=inttype), parameter imassnx
Definition: constants.F90:455
integer(kind=inttype), parameter imassflow
Definition: constants.F90:455
real(kind=realtype), parameter third
Definition: constants.F90:81
integer(kind=inttype), parameter icoforcez
Definition: constants.F90:455
integer(kind=inttype), parameter imassptot
Definition: constants.F90:455
integer(kind=inttype), parameter iflowfm
Definition: constants.F90:455
integer(kind=inttype), parameter izippwallz
Definition: constants.F90:523
integer, parameter irho
Definition: constants.F90:34
integer(kind=inttype), parameter izippflowx
Definition: constants.F90:507
integer(kind=inttype), parameter imassnz
Definition: constants.F90:455
integer(kind=inttype), parameter imp
Definition: constants.F90:455
integer, parameter ivx
Definition: constants.F90:35
integer(kind=inttype), parameter imassa
Definition: constants.F90:455
integer, parameter irhoe
Definition: constants.F90:38
integer(kind=inttype), parameter ifv
Definition: constants.F90:455
integer(kind=inttype), parameter imassny
Definition: constants.F90:455
integer(kind=inttype), parameter ibcgroupoutflow
Definition: constants.F90:311
integer(kind=inttype), parameter izippflowsface
Definition: constants.F90:506
integer(kind=inttype), parameter icoforcex
Definition: constants.F90:455
real(kind=realtype), parameter one
Definition: constants.F90:72
integer(kind=inttype), parameter iflowmm
Definition: constants.F90:455
integer(kind=inttype), parameter imassvy
Definition: constants.F90:455
real(kind=realtype), parameter half
Definition: constants.F90:80
integer(kind=inttype), parameter imassvx
Definition: constants.F90:455
integer(kind=inttype), parameter imassrho
Definition: constants.F90:455
integer(kind=inttype), parameter izippwalltpz
Definition: constants.F90:516
integer(kind=inttype), parameter imassmn
Definition: constants.F90:455
integer(kind=inttype), parameter icoforcey
Definition: constants.F90:455
integer, parameter ivz
Definition: constants.F90:37
integer(kind=inttype), parameter ibcgroupinflow
Definition: constants.F90:310
integer(kind=inttype), parameter iarea
Definition: constants.F90:455
integer(kind=inttype), parameter imassvi
Definition: constants.F90:455
real(kind=realtype), parameter two
Definition: constants.F90:73
integer(kind=inttype), parameter imv
Definition: constants.F90:455
integer(kind=inttype), parameter imassps
Definition: constants.F90:455
integer(kind=inttype), parameter izippwalltvx
Definition: constants.F90:517
integer(kind=inttype), parameter izippflowgamma
Definition: constants.F90:505
integer(kind=inttype), parameter izippwalltvz
Definition: constants.F90:519
integer(kind=inttype), parameter nzippflowcomm
Definition: constants.F90:502
integer(kind=inttype), parameter ibcgroupwalls
Definition: constants.F90:309
integer(kind=inttype), parameter nzippwallcomm
Definition: constants.F90:512
integer, parameter ivy
Definition: constants.F90:36
integer(kind=inttype), parameter izippwalltpx
Definition: constants.F90:514
integer(kind=inttype), parameter imassttot
Definition: constants.F90:455
integer(kind=inttype), parameter izippwallx
Definition: constants.F90:521
integer(kind=inttype), parameter internalflow
Definition: constants.F90:120
integer(kind=inttype), parameter ifp
Definition: constants.F90:455
integer(kind=inttype), parameter iareaptot
Definition: constants.F90:455
integer(kind=inttype), parameter izippflowz
Definition: constants.F90:509
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
subroutine wallintegrationzippercomm(vars, sps)
subroutine wallintegrationzippercomm_b(vars, varsd, sps)
subroutine flowintegrationzippercomm_b(isInflow, vars, varsd, sps)
subroutine wallintegrationzippercomm_d(vars, varsd, sps)
subroutine flowintegrationzippercomm_d(isInflow, vars, varsd, sps)
subroutine flowintegrationzippercomm(isInflow, vars, sps)
real(kind=realtype), dimension(3) pointref
Definition: inputParam.F90:602
integer(kind=inttype) flowtype
Definition: inputParam.F90:583
real(kind=realtype) rgasdim
Definition: inputParam.F90:595
type(zippermesh), dimension(nfamexchange), target zippermeshes
Definition: overset.F90:376
logical function faminlist(famID, famList)
Definition: sorting.F90:7
type(familyexchange), dimension(:, :), allocatable, target bcfamexchange
Definition: utils.F90:1
subroutine cross_prod(a, b, c)
Definition: utils.F90:1721
real(kind=realtype) function mynorm2(x)
Definition: utils.F90:1697
subroutine flowintegrationzipper_b(isinflow, conn, fams, vars, varsd, localvalues, localvaluesd, famlist, sps, ptvalid)
subroutine wallintegrationzipper_b(conn, fams, vars, varsd, localvalues, localvaluesd, famlist, sps)
subroutine flowintegrationzipper_d(isinflow, conn, fams, vars, varsd, localvalues, localvaluesd, famlist, sps, ptvalid)
subroutine wallintegrationzipper_d(conn, fams, vars, varsd, localvalues, localvaluesd, famlist, sps)
subroutine integratezippers_b(localValues, localValuesd, famList, sps)
subroutine integratezippers_d(localValues, localValuesd, famList, sps)
subroutine integratezippers(localValues, famList, sps)
subroutine flowintegrationzipper(isInflow, conn, fams, vars, localValues, famList, sps, ptValid)
subroutine wallintegrationzipper(conn, fams, vars, localValues, famList, sps)
real(kind=realtype) function triarea(pt1, pt2, pt3)
Definition: stringOps.F90:1309