60 CHARACTER(CHRLEN),
PRIVATE :: &
61 RCSIdentString =
'$RCSfile: RFLU_ModPatchUtils.F90,v $ $Revision: 1.7 $'
122 TYPE(t_region
),
POINTER :: pregion
128 INTEGER :: errorflag,iloc,ipatch,ipatch2,ivg,ivl
130 TYPE(t_grid),
POINTER :: pgrid
131 TYPE(t_patch),
POINTER :: ppatch,ppatch2
137 global => pregion%global
140 'RFLU_ModPatchUtils.F90')
142 IF ( global%myProcid == masterproc .AND. &
143 global%verbLevel >= verbose_high )
THEN
144 WRITE(stdout,
'(A,1X,A)') solver_name,
'Building patch-neighbor maps...'
147 pgrid => pregion%grid
153 IF ( pgrid%nPatches > 0 )
THEN
154 DO ipatch = 1,pgrid%nPatches
155 ppatch => pregion%patches(ipatch)
157 DO ipatch2 = ipatch+1,pgrid%nPatches
158 ppatch2 => pregion%patches(ipatch2)
160 ivlloop:
DO ivl = 1,ppatch%nBVert
166 IF ( iloc /= element_not_found )
THEN
167 ppatch%nbMap(ppatch2%iPatchGlobal) = .true.
175 DO ipatch2 = 1,pgrid%nPatches
176 ppatch2 => pregion%patches(ipatch2)
178 DO ipatch = ipatch2+1,pgrid%nPatches
179 ppatch => pregion%patches(ipatch)
181 ppatch%nbMap(ppatch2%iPatchGlobal) = ppatch2%nbMap(ppatch%iPatchGlobal)
190 IF ( global%myProcid == masterproc .AND. &
191 global%verbLevel >= verbose_high )
THEN
192 WRITE(stdout,
'(A,1X,A)') solver_name,
'Building patch-neighbor maps done.'
234 TYPE(t_region
),
POINTER :: pregion
240 INTEGER :: errorflag,ipatch,ipatchrelated
241 REAL(RFREAL) :: anglesum,eqtol
243 TYPE(t_grid),
POINTER :: pgrid
244 TYPE(t_patch),
POINTER :: ppatch,ppatchrelated
250 global => pregion%global
253 'RFLU_ModPatchUtils.F90')
255 IF ( global%myProcid == masterproc .AND. &
256 global%verbLevel >= verbose_high )
THEN
257 WRITE(stdout,
'(A,1X,A)') solver_name,
'Checking patch/bc consistency...'
260 pgrid => pregion%grid
262 eqtol = 1.0e-12_rfreal
268 DO ipatch = 1,pgrid%nPatches
269 ppatch => pregion%patches(ipatch)
271 SELECT CASE ( ppatch%bcType )
273 ipatchrelated = ppatch%iPatchRelated
274 ppatchrelated => pregion%patches(ipatchrelated)
276 anglesum = ppatch%angleRelated+ppatchrelated%angleRelated
278 IF (
floatequal(anglesum,0.0_rfreal,eqtol) .EQV. .false. )
THEN
279 CALL
errorstop(global,err_patch_bc_inconsistent,__line__)
282 IF ( ppatch%axisRelated /= ppatchrelated%axisRelated )
THEN
283 CALL
errorstop(global,err_patch_bc_inconsistent,__line__)
286 IF ( ppatch%axisRelated /= 1 .AND. &
287 ppatch%axisRelated /= 2 .AND. &
288 ppatch%axisRelated /= 3 )
THEN
289 CALL
errorstop(global,err_patch_bc_inconsistent,__line__)
292 IF ( ppatch%flatFlag .EQV. .false. )
THEN
293 CALL
errorstop(global,err_patch_bc_inconsistent,__line__)
302 IF ( global%myProcid == masterproc .AND. &
303 global%verbLevel >= verbose_high )
THEN
304 WRITE(stdout,
'(A,1X,A)') solver_name,
'Checking patch/bc consistency done.'
342 TYPE(t_region
),
DIMENSION(:),
POINTER :: regions
348 LOGICAL :: xflatflag,yflatflag,zflatflag
349 LOGICAL,
DIMENSION(:),
ALLOCATABLE :: flatflag
350 INTEGER :: errorflag,ifl,ipatch,ireg
351 REAL(RFREAL) :: eqtol,nx,nxmax,nxmin,ny,nymax,nymin,nz,nzmax,nzmin
352 REAL(RFREAL),
DIMENSION(:,:),
ALLOCATABLE :: globalvals,localvals
353 REAL(RFREAL),
DIMENSION(:,:,:),
POINTER :: pfnext
355 TYPE(t_grid),
POINTER :: pgrid
356 TYPE(t_patch),
POINTER :: ppatch
357 TYPE(t_region
),
POINTER :: pregion
363 global => regions(1)%global
366 'RFLU_ModPatchUtils.F90')
368 IF ( global%myProcid == masterproc .AND. &
369 global%verbLevel >= verbose_high )
THEN
370 WRITE(stdout,
'(A,1X,A)') solver_name, &
371 'Computing global patch normal vectors...'
374 eqtol = 1.0e-5_rfreal
376 IF ( global%myProcid == masterproc .AND. &
377 global%verbLevel >= verbose_high)
THEN
378 WRITE(stdout,
'(A,3X,A,1X,E15.8)') solver_name,
'Tolerance:',eqtol
379 WRITE(stdout,
'(A,3X,A,2X,A,2X,A,2X,A)') solver_name,
'Local',
'Global', &
380 'Flat',
'Normal vector'
387 ALLOCATE(pfnext(min_val:max_val,xcoord:zcoord,global%nPatches), &
389 global%error = errorflag
390 IF ( global%error /= err_none )
THEN
391 CALL
errorstop(global,err_allocate,__line__,
'pfnExt')
394 DO ipatch = 1,global%nPatches
395 pfnext(min_val,xcoord,ipatch) = huge(1.0_rfreal)
396 pfnext(min_val,ycoord,ipatch) = huge(1.0_rfreal)
397 pfnext(min_val,zcoord,ipatch) = huge(1.0_rfreal)
399 pfnext(max_val,xcoord,ipatch) = -huge(1.0_rfreal)
400 pfnext(max_val,ycoord,ipatch) = -huge(1.0_rfreal)
401 pfnext(max_val,zcoord,ipatch) = -huge(1.0_rfreal)
404 ALLOCATE(flatflag(global%nPatches),stat=errorflag)
405 global%error = errorflag
406 IF ( global%error /= err_none )
THEN
407 CALL
errorstop(global,err_allocate,__line__,
'flatFlag')
414 DO ireg = 1,global%nRegionsLocal
415 pregion => regions(ireg)
416 pgrid => pregion%grid
418 DO ipatch = 1,pgrid%nPatches
419 ppatch => pregion%patches(ipatch)
421 nxmin = pfnext(min_val,xcoord,ppatch%iPatchGlobal)
422 nymin = pfnext(min_val,ycoord,ppatch%iPatchGlobal)
423 nzmin = pfnext(min_val,zcoord,ppatch%iPatchGlobal)
425 nxmax = pfnext(max_val,xcoord,ppatch%iPatchGlobal)
426 nymax = pfnext(max_val,ycoord,ppatch%iPatchGlobal)
427 nzmax = pfnext(max_val,zcoord,ppatch%iPatchGlobal)
429 DO ifl = 1,ppatch%nBFaces
430 nx = ppatch%fn(xcoord,ifl)
431 ny = ppatch%fn(ycoord,ifl)
432 nz = ppatch%fn(zcoord,ifl)
434 nxmax =
max(nx,nxmax)
435 nxmin =
min(nx,nxmin)
437 nymax =
max(ny,nymax)
438 nymin =
min(ny,nymin)
440 nzmax =
max(nz,nzmax)
441 nzmin =
min(nz,nzmin)
444 pfnext(min_val,xcoord,ppatch%iPatchGlobal) = nxmin
445 pfnext(min_val,ycoord,ppatch%iPatchGlobal) = nymin
446 pfnext(min_val,zcoord,ppatch%iPatchGlobal) = nzmin
448 pfnext(max_val,xcoord,ppatch%iPatchGlobal) = nxmax
449 pfnext(max_val,ycoord,ppatch%iPatchGlobal) = nymax
450 pfnext(max_val,zcoord,ppatch%iPatchGlobal) = nzmax
458 ALLOCATE(localvals(xcoord:zcoord,global%nPatches),stat=errorflag)
459 global%error = errorflag
460 IF ( global%error /= err_none )
THEN
461 CALL
errorstop(global,err_allocate,__line__,
'localVals')
464 ALLOCATE(globalvals(xcoord:zcoord,global%nPatches),stat=errorflag)
465 global%error = errorflag
466 IF ( global%error /= err_none )
THEN
467 CALL
errorstop(global,err_allocate,__line__,
'globalVals')
470 DO ipatch = 1,global%nPatches
471 localvals(xcoord,ipatch) = pfnext(min_val,xcoord,ipatch)
472 localvals(ycoord,ipatch) = pfnext(min_val,ycoord,ipatch)
473 localvals(zcoord,ipatch) = pfnext(min_val,zcoord,ipatch)
476 CALL mpi_allreduce(localvals,globalvals,(zcoord-xcoord+1)*global%nPatches, &
477 mpi_rfreal,mpi_min,global%mpiComm,errorflag)
478 global%error = errorflag
479 IF ( global%error /= err_none )
THEN
480 CALL
errorstop(global,err_mpi_trouble,__line__)
483 DO ipatch = 1,global%nPatches
484 pfnext(min_val,xcoord,ipatch) = globalvals(xcoord,ipatch)
485 pfnext(min_val,ycoord,ipatch) = globalvals(ycoord,ipatch)
486 pfnext(min_val,zcoord,ipatch) = globalvals(zcoord,ipatch)
488 localvals(xcoord,ipatch) = pfnext(max_val,xcoord,ipatch)
489 localvals(ycoord,ipatch) = pfnext(max_val,ycoord,ipatch)
490 localvals(zcoord,ipatch) = pfnext(max_val,zcoord,ipatch)
493 CALL mpi_allreduce(localvals,globalvals,(zcoord-xcoord+1)*global%nPatches, &
494 mpi_rfreal,mpi_max,global%mpiComm,errorflag)
495 global%error = errorflag
496 IF ( global%error /= err_none )
THEN
497 CALL
errorstop(global,err_mpi_trouble,__line__)
500 DO ipatch = 1,global%nPatches
501 pfnext(max_val,xcoord,ipatch) = globalvals(xcoord,ipatch)
502 pfnext(max_val,ycoord,ipatch) = globalvals(ycoord,ipatch)
503 pfnext(max_val,zcoord,ipatch) = globalvals(zcoord,ipatch)
506 DEALLOCATE(localvals,stat=errorflag)
507 global%error = errorflag
508 IF ( global%error /= err_none )
THEN
509 CALL
errorstop(global,err_deallocate,__line__,
'localVals')
512 DEALLOCATE(globalvals,stat=errorflag)
513 global%error = errorflag
514 IF ( global%error /= err_none )
THEN
515 CALL
errorstop(global,err_deallocate,__line__,
'globalVals')
522 DO ipatch = 1,global%nPatches
523 nxmin = pfnext(min_val,xcoord,ipatch)
524 nymin = pfnext(min_val,ycoord,ipatch)
525 nzmin = pfnext(min_val,zcoord,ipatch)
527 nxmax = pfnext(max_val,xcoord,ipatch)
528 nymax = pfnext(max_val,ycoord,ipatch)
529 nzmax = pfnext(max_val,zcoord,ipatch)
532 eqtol,xflatflag,yflatflag,zflatflag)
534 IF ( (xflatflag .EQV. .true.) .AND. &
535 (yflatflag .EQV. .true.) .AND. &
536 (zflatflag .EQV. .true.) )
THEN
537 flatflag(ipatch) = .true.
539 flatflag(ipatch) = .false.
547 DO ireg = 1,global%nRegionsLocal
548 pregion => regions(ireg)
549 pgrid => pregion%grid
551 DO ipatch = 1,pgrid%nPatches
552 ppatch => pregion%patches(ipatch)
554 IF ( flatflag(ppatch%iPatchGlobal) .EQV. .true. )
THEN
555 ppatch%flatFlag = .true.
557 ppatch%pn(xcoord) = pfnext(max_val,xcoord,ppatch%iPatchGlobal)
558 ppatch%pn(ycoord) = pfnext(max_val,ycoord,ppatch%iPatchGlobal)
559 ppatch%pn(zcoord) = pfnext(max_val,zcoord,ppatch%iPatchGlobal)
561 ppatch%flatFlag = .false.
563 ppatch%pn(xcoord) =
REAL(crazy_value_int,kind=rfreal)
564 ppatch%pn(ycoord) =
REAL(crazy_value_int,kind=rfreal)
565 ppatch%pn(zcoord) =
REAL(CRAZY_VALUE_INT,KIND=RFREAL)
568 IF ( global%myProcid == masterproc .AND. &
569 global%verbLevel >= verbose_high )
THEN
570 IF ( ppatch%flatFlag .EQV. .true. )
THEN
571 WRITE(stdout,
'(A,2X,I4,4X,I4,6X,L1,3(2X,E13.6))') &
572 solver_name,ipatch,ppatch%iPatchGlobal,ppatch%flatFlag, &
573 ppatch%pn(xcoord:zcoord)
575 WRITE(stdout,
'(A,2X,I4,4X,I4,6X,L1)') &
576 solver_name,ipatch,ppatch%iPatchGlobal,ppatch%flatFlag
586 DEALLOCATE(pfnext,stat=errorflag)
587 global%error = errorflag
588 IF ( global%error /= err_none )
THEN
589 CALL
errorstop(global,err_deallocate,__line__,
'pfnExt')
592 DEALLOCATE(flatflag,stat=errorflag)
593 global%error = errorflag
594 IF ( global%error /= err_none )
THEN
595 CALL
errorstop(global,err_deallocate,__line__,
'flatFlag')
602 IF ( global%myProcid == masterproc .AND. &
603 global%verbLevel >= verbose_high )
THEN
604 WRITE(stdout,
'(A,1X,A)') solver_name, &
605 'Computing global patch normal vectors done.'
645 TYPE(t_region
),
POINTER :: pregion
651 LOGICAL :: xflatflag,yflatflag,zflatflag
652 INTEGER :: errorflag,ifl,ipatch
653 REAL(RFREAL) :: eqtol,nx,nxmax,nxmin,ny,nymax,nymin,nz,nzmax,nzmin
655 TYPE(t_grid),
POINTER :: pgrid
656 TYPE(t_patch),
POINTER :: ppatch
662 global => pregion%global
665 'RFLU_ModPatchUtils.F90')
667 IF ( global%myProcid == masterproc .AND. &
668 global%verbLevel >= verbose_high )
THEN
669 WRITE(stdout,
'(A,1X,A)') solver_name, &
670 'Computing patch normal vectors...'
671 WRITE(stdout,
'(A,3X,A,1X,I5.5)') solver_name,
'Global region:', &
672 pregion%iRegionGlobal
675 eqtol = 1.0e-5_rfreal
677 IF ( global%myProcid == masterproc .AND. &
678 global%verbLevel >= verbose_high)
THEN
679 WRITE(stdout,
'(A,3X,A,1X,E15.8)') solver_name,
'Tolerance:',eqtol
680 WRITE(stdout,
'(A,3X,A,2X,A,2X,A,2X,A)') solver_name,
'Local',
'Global', &
681 'Flat',
'Normal vector'
684 pgrid => pregion%grid
690 DO ipatch = 1,pgrid%nPatches
691 ppatch => pregion%patches(ipatch)
693 nxmin = huge(1.0_rfreal)
694 nymin = huge(1.0_rfreal)
695 nzmin = huge(1.0_rfreal)
697 nxmax = -huge(1.0_rfreal)
698 nymax = -huge(1.0_rfreal)
699 nzmax = -huge(1.0_rfreal)
705 DO ifl = 1,ppatch%nBFaces
706 nx = ppatch%fn(xcoord,ifl)
707 ny = ppatch%fn(ycoord,ifl)
708 nz = ppatch%fn(zcoord,ifl)
710 nxmax =
max(nx,nxmax)
711 nxmin =
min(nx,nxmin)
713 nymax =
max(ny,nymax)
714 nymin =
min(ny,nymin)
716 nzmax =
max(nz,nzmax)
717 nzmin =
min(nz,nzmin)
725 eqtol,xflatflag,yflatflag,zflatflag)
731 IF ( (xflatflag .EQV. .true.) .AND. &
732 (yflatflag .EQV. .true.) .AND. &
733 (zflatflag .EQV. .true.) )
THEN
734 ppatch%flatFlag = .true.
736 ppatch%pn(xcoord) = nxmax
737 ppatch%pn(ycoord) = nymax
738 ppatch%pn(zcoord) = nzmax
740 ppatch%flatFlag = .false.
742 ppatch%pn(xcoord) =
REAL(crazy_value_int,kind=rfreal)
743 ppatch%pn(ycoord) =
REAL(crazy_value_int,kind=rfreal)
744 ppatch%pn(zcoord) =
REAL(CRAZY_VALUE_INT,KIND=RFREAL)
747 IF ( global%myProcid == masterproc .AND. &
748 global%verbLevel >= verbose_high )
THEN
749 IF ( ppatch%flatFlag .EQV. .true. )
THEN
750 WRITE(stdout,
'(A,2X,I4,4X,I4,6X,L1,3(2X,E13.6))') &
751 solver_name,ipatch,ppatch%iPatchGlobal,ppatch%flatFlag, &
752 ppatch%pn(xcoord:zcoord)
754 WRITE(stdout,
'(A,2X,I4,4X,I4,6X,L1)') &
755 solver_name,ipatch,ppatch%iPatchGlobal,ppatch%flatFlag
764 IF ( global%myProcid == masterproc .AND. &
765 global%verbLevel >= verbose_high )
THEN
766 WRITE(stdout,
'(A,1X,A)') solver_name, &
767 'Computing patch normal vectors done.'
806 TYPE(t_region
),
POINTER :: pregion
812 INTEGER :: errorflag,ipatch,ipatch2
814 TYPE(t_grid),
POINTER :: pgrid
815 TYPE(t_patch),
POINTER :: ppatch
821 global => pregion%global
824 'RFLU_ModPatchUtils.F90')
826 IF ( global%myProcid == masterproc .AND. &
827 global%verbLevel >= verbose_high )
THEN
828 WRITE(stdout,
'(A,1X,A)') solver_name,
'Creating patch-neighbor maps...'
831 pgrid => pregion%grid
837 DO ipatch = 1,pgrid%nPatches
838 ppatch => pregion%patches(ipatch)
840 ALLOCATE(ppatch%nbMap(global%nPatches),stat=errorflag)
841 global%error = errorflag
842 IF ( global%error /= err_none )
THEN
843 CALL
errorstop(global,err_allocate,__line__,
'pPatch%nbMap')
846 DO ipatch2 = 1,global%nPatches
847 ppatch%nbMap(ipatch2) = .false.
855 IF ( global%myProcid == masterproc .AND. &
856 global%verbLevel >= verbose_high )
THEN
857 WRITE(stdout,
'(A,1X,A)') solver_name,
'Creating patch-neighbor maps done.'
899 TYPE(t_region
),
POINTER :: pregion
905 INTEGER :: errorflag,ipatch
907 TYPE(t_grid),
POINTER :: pgrid
908 TYPE(t_patch),
POINTER :: ppatch
914 global => pregion%global
917 'RFLU_ModPatchUtils.F90')
919 IF ( global%myProcid == masterproc .AND. &
920 global%verbLevel >= verbose_high )
THEN
921 WRITE(stdout,
'(A,1X,A)') solver_name,
'Destroying patch-neighbor maps...'
924 pgrid => pregion%grid
930 DO ipatch = 1,pgrid%nPatches
931 ppatch => pregion%patches(ipatch)
933 DEALLOCATE(ppatch%nbMap,stat=errorflag)
934 global%error = errorflag
935 IF ( global%error /= err_none )
THEN
936 CALL
errorstop(global,err_deallocate,__line__,
'pPatch%nbMap')
944 IF ( global%myProcid == masterproc .AND. &
945 global%verbLevel >= verbose_high )
THEN
946 WRITE(stdout,
'(A,1X,A)') solver_name,
'Destroying patch-neighbor maps done.'
984 eqtol,xflatflag,yflatflag,zflatflag)
998 LOGICAL,
INTENT(OUT) :: xflatflag,yflatflag,zflatflag
999 REAL(RFREAL),
INTENT(IN) :: eqtol,nxmax,nxmin,nymax,nymin,nzmax,nzmin
1011 'RFLU_ModPatchUtils.F90')
1017 IF ( (
sign(1.0_rfreal,nxmin) ==
sign(1.0_rfreal,nxmax)) )
THEN
1018 IF (
floatequal(nxmin,nxmax,eqtol) .EQV. .true. )
THEN
1024 IF ( (
floatequal(abs(nxmin),epsilon(1.0_rfreal),eqtol)) .AND. &
1025 (
floatequal(abs(nxmax),epsilon(1.0_rfreal),eqtol)) )
THEN
1032 IF ( (
sign(1.0_rfreal,nymin) ==
sign(1.0_rfreal,nymax)) )
THEN
1033 IF (
floatequal(nymin,nymax,eqtol) .EQV. .true. )
THEN
1039 IF ( (
floatequal(abs(nymin),epsilon(1.0_rfreal),eqtol)) .AND. &
1040 (
floatequal(abs(nymax),epsilon(1.0_rfreal),eqtol)) )
THEN
1047 IF ( (
sign(1.0_rfreal,nzmin) ==
sign(1.0_rfreal,nzmax)) )
THEN
1048 IF (
floatequal(nzmin,nzmax,eqtol) .EQV. .true. )
THEN
1054 IF ( (
floatequal(abs(nzmin),epsilon(1.0_rfreal),eqtol)) .AND. &
1055 (
floatequal(abs(nzmax),epsilon(1.0_rfreal),eqtol)) )
THEN
1110 LOGICAL,
INTENT(OUT) :: pndirflag
1111 INTEGER,
INTENT(OUT) :: pndir
1113 TYPE(t_patch),
POINTER :: ppatch
1119 REAL(RFREAL) :: pndirtemp(1)
1126 'RFLU_ModPatchUtils.F90')
1132 IF ( ppatch%flatFlag .EQV. .false. )
THEN
1133 pndir = crazy_value_int
1136 pndirtemp = maxloc(abs(ppatch%pn(xcoord:zcoord)))
1137 pndir = nint(pndirtemp(1))
1138 pndirflag =
floatequal(abs(ppatch%pn(pndir)),1.0_rfreal,1.0e-6_rfreal)
static SURF_BEGIN_NAMESPACE double sign(double x)
subroutine, public rflu_checkpatchbcconsistency(pRegion)
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
subroutine registerfunction(global, funName, fileName)
subroutine, public rflu_getpatchnormaldirection(global, pPatch, pnDir, pnDirFlag)
subroutine binarysearchinteger(a, n, v, i, j)
subroutine rflu_setpatchflatflags(global, nxMin, nxMax, nyMin, nyMax, nzMin, nzMax, eqTol, xFlatFlag, yFlatFlag, zFlatFlag)
subroutine, public rflu_createpatchneighbormaps(pRegion)
subroutine, public rflu_computepatchnormalsglobal(regions)
subroutine, public rflu_destroypatchneighbormaps(pRegion)
Vector_n min(const Array_n_const &v1, const Array_n_const &v2)
subroutine, public rflu_buildpatchneighbormaps(pRegion)
subroutine errorstop(global, errorCode, errorLine, addMessage)
subroutine, public rflu_computepatchnormalslocal(pRegion)
subroutine deregisterfunction(global)