ADflow  v1.0
ADflow is a finite volume RANS solver tailored for gradient-based aerodynamic design optimization.
wallDistance_fast_b.f90
Go to the documentation of this file.
1 ! generated by tapenade (inria, ecuador team)
2 ! tapenade 3.16 (develop) - 22 aug 2023 15:51
3 !
5  use constants, only : inttype, realtype
7  implicit none
8  save
9 
10 contains
11  subroutine updatewalldistancesquickly(nn, level, sps)
12 ! this is the actual update routine that uses xsurf. it is done on
13 ! block-level-sps basis. this is the used to update the wall
14 ! distance. most importantly, this routine is included in the
15 ! reverse mode ad routines, but not the forward mode. since it is
16 ! done on a per-block basis, it is assumed that the required block
17 ! pointers are already set.
18  use constants
19  use blockpointers, only : nx, ny, nz, il, jl, kl, x, flowdoms&
20 & , d2wall
21  implicit none
22 ! subroutine arguments
23  integer(kind=inttype) :: nn, level, sps
24 ! local variables
25  integer(kind=inttype) :: i, j, k, ii, ind(4)
26  real(kind=realtype) :: xp(3), xc(3), u, v
27  intrinsic mod
28  intrinsic sqrt
29 !$ad ii-loop
30  do ii=0,nx*ny*nz-1
31  i = mod(ii, nx) + 2
32  j = mod(ii/nx, ny) + 2
33  k = ii/(nx*ny) + 2
34  if (flowdoms(nn, level, sps)%surfnodeindices(1, i, j, k) .eq. 0) &
35 & then
36 ! this node is too far away and has no
37 ! association. set the distance to a large constant.
38  d2wall(i, j, k) = large
39  else
40 ! extract elemid and u-v position for the association of
41 ! this cell:
42  ind = flowdoms(nn, level, sps)%surfnodeindices(:, i, j, k)
43  u = flowdoms(nn, level, sps)%uv(1, i, j, k)
44  v = flowdoms(nn, level, sps)%uv(2, i, j, k)
45 ! now we have the 4 corners, use bi-linear shape
46 ! functions o to get target: (ccw ordering remember!)
47  xp(:) = (one-u)*(one-v)*xsurf(3*(ind(1)-1)+1:3*ind(1)) + u*(one-&
48 & v)*xsurf(3*(ind(2)-1)+1:3*ind(2)) + u*v*xsurf(3*(ind(3)-1)+1:3&
49 & *ind(3)) + (one-u)*v*xsurf(3*(ind(4)-1)+1:3*ind(4))
50 ! get the cell center
51  xc(1) = eighth*(x(i-1, j-1, k-1, 1)+x(i, j-1, k-1, 1)+x(i-1, j, &
52 & k-1, 1)+x(i, j, k-1, 1)+x(i-1, j-1, k, 1)+x(i, j-1, k, 1)+x(i-&
53 & 1, j, k, 1)+x(i, j, k, 1))
54  xc(2) = eighth*(x(i-1, j-1, k-1, 2)+x(i, j-1, k-1, 2)+x(i-1, j, &
55 & k-1, 2)+x(i, j, k-1, 2)+x(i-1, j-1, k, 2)+x(i, j-1, k, 2)+x(i-&
56 & 1, j, k, 2)+x(i, j, k, 2))
57  xc(3) = eighth*(x(i-1, j-1, k-1, 3)+x(i, j-1, k-1, 3)+x(i-1, j, &
58 & k-1, 3)+x(i, j, k-1, 3)+x(i-1, j-1, k, 3)+x(i, j-1, k, 3)+x(i-&
59 & 1, j, k, 3)+x(i, j, k, 3))
60 ! now we have the two points...just take the norm of the
61 ! distance between them
62  d2wall(i, j, k) = sqrt((xc(1)-xp(1))**2 + (xc(2)-xp(2))**2 + (xc&
63 & (3)-xp(3))**2)
64  end if
65  end do
66  end subroutine updatewalldistancesquickly
67 ! ----------------------------------------------------------------------
68 ! |
69 ! no tapenade routine below this line |
70 ! |
71 ! ----------------------------------------------------------------------
72 
73 end module walldistance_fast_b
74 
integer(kind=inttype) jl
integer(kind=inttype) nx
integer(kind=inttype) ny
real(kind=realtype), dimension(:, :, :), pointer d2wall
integer(kind=inttype) nz
real(kind=realtype), dimension(:, :, :, :), pointer x
integer(kind=inttype) kl
integer(kind=inttype) il
real(kind=realtype), parameter eighth
Definition: constants.F90:84
real(kind=realtype), parameter one
Definition: constants.F90:72
real(kind=realtype), parameter large
Definition: constants.F90:24
subroutine updatewalldistancesquickly(nn, level, sps)
real(kind=realtype), dimension(:), pointer xsurf