15 integer(kind=intType),
intent(in) :: nn, iRegion
18 integer(kind=intType) :: iii
19 integer(kind=intType) :: i, j, k
41 thrust, torque, heat, relaxStart, relaxEnd, nPts, nConn)
56 integer(kind=intType),
intent(in) :: nPts, nConn, famID
57 real(kind=realtype),
dimension(3, nPts),
intent(in),
target :: pts
58 integer(kind=intType),
dimension(4, nConn),
intent(in),
target :: conn
59 real(kind=realtype),
intent(in),
dimension(3) :: axis1, axis2
60 character(len=*) :: famName
61 real(kind=realtype) :: thrust, torque, heat, relaxstart, relaxend
64 integer(kind=intType) :: i, j, k, nn, iDim, cellID, intInfo(3), sps, level, iii, ierr
65 real(kind=realtype) :: dstar, frac, vollocal
67 real(kind=realtype),
dimension(3) :: minx, maxx, v1, v2, v3, xcen, axisvec
69 real(kind=realtype) :: axisvecnorm
70 real(kind=realtype),
dimension(:, :),
allocatable :: norm
71 integer(kind=intType),
dimension(:),
allocatable :: normcount
72 integer(kind=intType),
dimension(:, :),
pointer :: tmp
75 integer(kind=intType),
dimension(:),
pointer :: frontleaves, frontleavesnew
77 real(kind=realtype) :: coor(4), uvw(5)
78 real(kind=realtype) :: dummy(3, 2)
82 print *,
"Error: Exceeded the maximum number of actuatorDiskRegions. "&
83 &
"Increase nActuatorDiskRegionsMax"
89 region%famName = famname
91 region%torque = torque
93 region%relaxStart = relaxstart
94 region%relaxEnd = relaxend
99 axisvec = axis2 - axis1
100 axisvecnorm = sqrt((axisvec(1)**2 + axisvec(2)**2 + axisvec(3)**2))
101 if (axisvecnorm < 1e-12)
then
102 print *,
"Error: Axis cannot be determined by the supplied points. They are too close"
106 axisvec = axisvec / axisvecnorm
108 region%force = axisvec * thrust
109 region%axisVec = axisvec
111 allocate (region%blkPtr(0:ndom))
127 minx(idim) = minval(pts(idim, :))
128 maxx(idim) = maxval(pts(idim, :))
132 dstar = (maxx(1) - minx(1))**2 + (maxx(2) - minx(2))**2 + (maxx(3) - minx(3))**2
138 allocate (norm(3,
size(pts, 2)), normcount(
size(pts, 2)))
143 do i = 1,
size(conn, 2)
146 v1 = pts(:, conn(3, i)) - pts(:, conn(1, i))
147 v2 = pts(:, conn(4, i)) - pts(:, conn(2, i))
149 v3(1) = (v1(2) * v2(3) - v1(3) * v2(2))
150 v3(2) = (v1(3) * v2(1) - v1(1) * v2(3))
151 v3(3) = (v1(1) * v2(2) - v1(2) * v2(1))
152 v3 = v3 / sqrt(v3(1)**2 + v3(2)**2 + v3(3)**2)
156 norm(:, conn(j, i)) = norm(:, conn(j, i)) + v3
157 normcount(conn(j, i)) = normcount(conn(j, i)) + 1
162 do i = 1,
size(pts, 2)
163 norm(:, i) = norm(:, i) / normcount(i)
167 deallocate (normcount)
170 allocate (
stack(100), bb(20), frontleaves(25), frontleavesnew(25))
186 if (
iblank(i, j, k) == 1)
then
188 xcen =
eighth * (
x(i - 1, j - 1, k - 1, :) +
x(i, j - 1, k - 1, :) &
189 +
x(i - 1, j, k - 1, :) +
x(i, j, k - 1, :) &
190 +
x(i - 1, j - 1, k, :) +
x(i, j - 1, k, :) &
191 +
x(i - 1, j, k, :) +
x(i, j, k, :))
199 uvw, dummy, 0, bb, frontleaves, frontleavesnew)
206 region%nCellIDs = region%nCellIDs + 1
207 region%cellIDs(:, region%nCellIDs) = (/i, j, k/)
217 region%blkPtr(nn) = region%nCellIDs
223 tmp => region%cellIDs
224 allocate (region%cellIDs(3, region%nCellIDs))
225 region%cellIDs = tmp(:, 1:region%nCellIDs)
235 do iii = region%blkPtr(nn - 1) + 1, region%blkPtr(nn)
236 i = region%cellIDs(1, iii)
237 j = region%cellIDs(2, iii)
238 k = region%cellIDs(3, iii)
239 vollocal = vollocal +
vol(i, j, k)
243 call mpi_allreduce(vollocal, region%volume, 1, adflow_real, &
245 call echk(ierr, __file__, __line__)
248 deallocate (
stack, norm, frontleaves, frontleavesnew, bb)
256 integer(kind=intType) :: jj
257 real(kind=realtype) :: shp(4), xp(3), normal(3), v1(3), dp
260 shp(1) = (
one - uvw(1)) * (
one - uvw(2))
261 shp(2) = (uvw(1)) * (
one - uvw(2))
262 shp(3) = (uvw(1)) * (uvw(2))
263 shp(4) = (
one - uvw(1)) * (uvw(2))
268 xp = xp + shp(jj) * pts(:, conn(jj, cellid))
269 normal = normal + shp(jj) * norm(:, conn(jj, cellid))
275 dp = normal(1) * v1(1) + normal(2) * v1(2) + normal(3) * v1(3)
301 character(len=*) :: fileName
304 integer(kind=intType) :: iRegion, nn, i, j, k, ii, jj, kk, iii, kkk, iDim
305 integer(kind=intType) :: level, sps, iProc, ierr, totalCount, offset, nUnique
306 integer(kind=intType),
dimension(:),
allocatable :: sizesProc, cumSizesProc
307 real(kind=realtype),
dimension(:),
allocatable :: pts, allpts
308 real(kind=realtype),
dimension(:, :),
allocatable :: tmp, uniquepts
309 real(kind=realtype),
parameter :: tol = 1e-8
310 integer(kind=intType),
dimension(:),
allocatable :: conn, allConn, link
311 character(80) :: zoneName
318 open (unit=101, file=trim(filename), form=
'formatted')
319 write (101, *)
'TITLE = "Actuator Regions"'
320 write (101, *)
'Variables = "CoordinateX", "CoordinateY", "CoordinateZ"'
334 allocate (sizesproc(
nproc), cumsizesproc(0:
nproc))
336 call mpi_allgather(region%nCellIDs, 1, adflow_integer, sizesproc, 1, &
338 call echk(ierr, __file__, __line__)
342 cumsizesproc(iproc) = cumsizesproc(iproc - 1) + sizesproc(iproc)
346 allocate (conn(8 * region%nCellIDs), pts(24 * region%nCellIDs))
352 do iii = region%blkPtr(nn - 1) + 1, region%blkPtr(nn)
355 offset = (iii - 1) * 8 + cumsizesproc(
myid) * 8
356 conn((iii - 1) * 8 + 1) = 1 + offset
357 conn((iii - 1) * 8 + 2) = 2 + offset
358 conn((iii - 1) * 8 + 3) = 4 + offset
359 conn((iii - 1) * 8 + 4) = 3 + offset
360 conn((iii - 1) * 8 + 5) = 5 + offset
361 conn((iii - 1) * 8 + 6) = 6 + offset
362 conn((iii - 1) * 8 + 7) = 8 + offset
363 conn((iii - 1) * 8 + 8) = 7 + offset
371 i = region%cellIDs(1, iii)
372 j = region%cellIDs(2, iii)
373 k = region%cellIDs(3, iii)
375 pts(kkk) =
x(i + ii, j + jj, k + kk, idim)
386 totalcount = sum(sizesproc)
387 allocate (allconn(8 * totalcount), allpts(24 * totalcount))
391 call mpi_gatherv(pts, region%nCellIDs * 24, adflow_real, &
392 allpts, 24 * sizesproc, 24 * cumsizesproc, adflow_real, &
394 call echk(ierr, __file__, __line__)
396 call mpi_gatherv(conn, region%nCellIDs * 8, adflow_integer, &
397 allconn, 8 * sizesproc, 8 * cumsizesproc, adflow_integer, &
399 call echk(ierr, __file__, __line__)
402 deallocate (sizesproc, cumsizesproc, pts, conn)
411 allocate (tmp(3, totalcount * 8))
412 do i = 1, totalcount * 8
414 tmp(idim, i) = allpts((i - 1) * 3 + idim)
418 allocate (uniquepts(3, totalcount * 8), link(totalcount * 8))
421 call pointreduce(tmp, totalcount * 8, tol, uniquepts, link, nunique)
423 write (zonename,
"(a,a,a)")
'Zone T="', trim(region%famName),
' Region"'
424 write (101, *) trim(zonename)
425 write (101, *)
"Nodes = ", nunique,
" Elements= ", totalcount,
" ZONETYPE=FEBRICK"
426 write (101, *)
"DATAPACKING=BLOCK, VARLOCATION=([1,2,3]=NODAL, [4]=CELLCENTERED)"
431 write (101,
sci12) uniquepts(idim, i)
438 write (101,
"(I8)", advance=
'no') link(allconn((i - 1) * 8 + j))
444 deallocate (allconn, link, tmp, uniquepts)
470 real(kind=realtype),
dimension(nLocalValues),
intent(inout) :: localvalues
471 integer(kind=intType),
dimension(:),
intent(in) :: famList
472 integer(kind=intType),
intent(in) :: sps
475 integer(kind=intType) :: nn, iRegion
476 real(kind=realtype) :: plocal, plocald
482 domainloop:
do nn = 1, ndom
519 real(kind=realtype),
dimension(nLocalValues),
intent(inout) :: localvalues, localvaluesd
520 integer(kind=intType),
dimension(:),
intent(in) :: famList
521 integer(kind=intType),
intent(in) :: sps
524 integer(kind=intType) :: nn, iRegion
525 real(kind=realtype) :: plocal, plocald
533 domainloop:
do nn = 1, ndom
571 real(kind=realtype),
dimension(nLocalValues),
intent(inout) :: localvalues, localvaluesd
572 integer(kind=intType),
dimension(:),
intent(in) :: famList
573 integer(kind=intType),
intent(in) :: sps
576 integer(kind=intType) :: nn, iRegion
577 real(kind=realtype) :: plocal, plocald
586 plocald = localvaluesd(
ipower)
588 domainloop:
do nn = 1, ndom
subroutine addactuatorregion(pts, conn, axis1, axis2, famName, famID, thrust, torque, heat, relaxStart, relaxEnd, nPts, nConn)
subroutine writeactuatorregions(fileName)
subroutine computeactuatorregionvolume(nn, iRegion)
subroutine integrateactuatorregions_d(localValues, localValuesd, famList, sps)
subroutine integrateactuatorregions_b(localValues, localValuesd, famList, sps)
subroutine integrateactuatorregions(localValues, famList, sps)
type(actuatorregiontype), dimension(nactuatorregionsmax), target actuatorregions
integer(kind=inttype), parameter nactuatorregionsmax
integer(kind=inttype) nactuatorregions
integer(kind=inttype), dimension(maxlevels) ncellslocal
subroutine destroyserialquad(ADT)
subroutine buildserialquad(nQuad, nNodes, coor, quadsConn, ADT)
subroutine mindistancetreesearchsinglepoint(ADT, coor, intInfo, uvw, arrDonor, nInterpol, BB, frontLeaves, frontLeavesNew)
integer(kind=inttype), dimension(:), pointer stack
real(kind=realtype), dimension(:, :, :, :), pointer w
integer(kind=inttype), dimension(:, :, :), pointer iblank
real(kind=realtype), dimension(:, :, :, :), pointer dw
real(kind=realtype), dimension(:, :, :), pointer vol
real(kind=realtype), dimension(:, :, :, :), pointer x
integer adflow_comm_world
real(kind=realtype), parameter zero
real(kind=realtype), parameter eighth
integer(kind=inttype), parameter ipower
real(kind=realtype), parameter one
subroutine sourceterms_block_b(nn, res, iregion, plocal, plocald)
subroutine sourceterms_block_d(nn, res, iregion, plocal, plocald)
subroutine sourceterms_block(nn, res, iRegion, pLocal)
logical function faminlist(famID, famList)
subroutine setpointers_d(nn, level, sps)
subroutine pointreduce(pts, N, tol, uniquePts, link, nUnique)
subroutine echk(errorcode, file, line)
subroutine setpointers_b(nn, level, sps)
subroutine setpointers(nn, mm, ll)