71 CHARACTER(CHRLEN) :: RCSIdentString = &
72 '$RCSfile: RFLU_ModStencilsUtils.F90,v $ $Revision: 1.14 $'
105 nbfacemembs,bfacemembs)
117 INTEGER,
INTENT(IN) :: nbfacemembsmaxtemp,ncellmembs
118 INTEGER,
INTENT(OUT) :: nbfacemembs
119 INTEGER,
INTENT(IN) :: cellmembs(ncellmembs)
120 INTEGER,
INTENT(OUT) :: bfacemembs(2,nbfacemembsmaxtemp)
121 TYPE(t_region
),
POINTER :: pregion
127 INTEGER :: errorflag,ifl,iloc,ipatch,isg,isl
129 TYPE(t_grid),
POINTER :: pgrid
130 TYPE(t_patch),
POINTER :: ppatch
136 global => pregion%global
138 pgrid => pregion%grid
145 'RFLU_ModStencilsUtils.F90')
151 DO ipatch = 1,pgrid%nPatches
152 ppatch => pregion%patches(ipatch)
154 IF ( (ppatch%bcType == bc_noslipwall_hflux) .OR. &
155 (ppatch%bcType == bc_noslipwall_temp ) .OR. &
156 (ppatch%bcType == bc_slipwall ) .OR. &
157 (ppatch%bcType == bc_injection ) )
THEN
158 IF ( ppatch%nBFaces > 0 )
THEN
159 ALLOCATE(ppatch%bf2cSorted(ppatch%nBFaces),stat=errorflag)
160 global%error = errorflag
161 IF ( global%error /= err_none )
THEN
162 CALL
errorstop(global,err_allocate,__line__,
'pPatch%bf2cSorted')
165 ALLOCATE(ppatch%bf2cSortedKeys(ppatch%nBFaces),stat=errorflag)
166 global%error = errorflag
167 IF ( global%error /= err_none )
THEN
168 CALL
errorstop(global,err_allocate,__line__,
'pPatch%bf2cSortedKeys')
171 DO ifl = 1,ppatch%nBFaces
172 ppatch%bf2cSorted(ifl) = ppatch%bf2c(ifl)
177 DO ifl = 1,ppatch%nBFaces
179 ppatch%bf2c(ifl),iloc)
181 IF ( iloc /= element_not_found )
THEN
182 ppatch%bf2cSortedKeys(iloc) = ifl
184 CALL
errorstop(global,err_binary_search,__line__)
197 DO isl = 1,nbfacemembsmaxtemp
198 bfacemembs(1,isl) = crazy_value_int
199 bfacemembs(2,isl) = crazy_value_int
206 islloop:
DO isl = 1,ncellmembs
209 DO ipatch = 1,pgrid%nPatches
210 ppatch => pregion%patches(ipatch)
212 IF ( (ppatch%bcType == bc_noslipwall_hflux) .OR. &
213 (ppatch%bcType == bc_noslipwall_temp ) .OR. &
214 (ppatch%bcType == bc_slipwall ) .OR. &
215 (ppatch%bcType == bc_injection ) )
THEN
216 IF ( ppatch%nBFaces > 0 )
THEN
220 IF ( iloc /= element_not_found )
THEN
221 IF ( nbfacemembs < nbfacemembsmaxtemp )
THEN
222 nbfacemembs = nbfacemembs + 1
224 bfacemembs(1,nbfacemembs) = ipatch
225 bfacemembs(2,nbfacemembs) = ppatch%bf2cSortedKeys(iloc)
239 DO ipatch = 1,pgrid%nPatches
240 ppatch => pregion%patches(ipatch)
242 IF ( (ppatch%bcType == bc_noslipwall_hflux) .OR. &
243 (ppatch%bcType == bc_noslipwall_temp ) .OR. &
244 (ppatch%bcType == bc_slipwall ) .OR. &
245 (ppatch%bcType == bc_injection ) )
THEN
246 IF ( ppatch%nBFaces > 0 )
THEN
247 DEALLOCATE(ppatch%bf2cSorted,stat=errorflag)
248 global%error = errorflag
249 IF ( global%error /= err_none )
THEN
250 CALL
errorstop(global,err_deallocate,__line__,
'pPatch%bf2cSorted')
253 DEALLOCATE(ppatch%bf2cSortedKeys,stat=errorflag)
254 global%error = errorflag
255 IF ( global%error /= err_none )
THEN
256 CALL
errorstop(global,err_deallocate,__line__, &
257 'pPatch%bf2cSortedKeys')
307 x2csbeg,x2csend,x2cs,fndir)
319 INTEGER,
INTENT(IN) :: fndir,ixg,stencilsizemax,x2csbeg,x2csend
320 INTEGER,
INTENT(INOUT) :: degr
321 INTEGER,
INTENT(INOUT) :: x2cs(stencilsizemax)
323 TYPE(t_grid),
POINTER :: pgrid
329 INTEGER :: c1,c2,degrhelp,icg,icg2,icl,ifg,ifl,iloc,ipatch,isl,iv2c,ivg, &
331 INTEGER :: x2cshelp(stencilsizemax),x2cssort(stencilsizemax)
339 'RFLU_ModStencilsUtils.F90')
351 DO isl = 1,stencilsizemax
357 x2cssort(isl) = x2cs(isl)
366 outerloop:
DO isl = x2csbeg,x2csend
368 icl = pgrid%cellGlob2Loc(2,icg)
370 nfaces =
SIZE(pgrid%hex2f,2)
373 ipatch = pgrid%hex2f(1,ifl,icl)
374 ifg = pgrid%hex2f(2,ifl,icl)
376 IF ( ipatch == 0 )
THEN
377 c1 = pgrid%f2c(1,ifg)
378 c2 = pgrid%f2c(2,ifg)
380 IF ( c1 /= ixg .AND. c2 /= ixg )
THEN
381 IF ( c1 == icg )
THEN
382 fn = pgrid%fn(fndir,ifg)
383 ELSE IF ( c2 == icg )
THEN
384 fn = -pgrid%fn(fndir,ifg)
386 CALL
errorstop(global,err_reached_default,__line__)
389 IF ( abs(fn) >= 0.999_rfreal )
THEN
390 IF ( c1 == icg )
THEN
392 ELSE IF ( c2 == icg )
THEN
395 CALL
errorstop(global,err_reached_default,__line__)
400 IF ( iloc == element_not_found )
THEN
401 IF ( degrhelp > 0 )
THEN
404 IF ( iloc == element_not_found )
THEN
405 IF ( degrhelp < stencilsizemax )
THEN
406 degrhelp = degrhelp + 1
407 x2cshelp(degrhelp) = icg2
408 IF ( degrhelp > 1 )
THEN
416 degrhelp = degrhelp + 1
417 x2cshelp(degrhelp) = icg2
422 ELSE IF ( ipatch > 0 )
THEN
427 CALL
errorstop(global,err_reached_default,__line__)
437 IF ( degr < stencilsizemax )
THEN
439 x2cs(degr) = x2cshelp(isl)
486 x2csbeg,x2csend,x2cs,rc,
dir)
500 INTEGER,
INTENT(IN) ::
dir,ixg,stencilsizemax,x2csbeg,x2csend
501 INTEGER,
INTENT(INOUT) :: degr
502 INTEGER,
INTENT(INOUT) :: x2cs(stencilsizemax)
503 REAL(RFREAL),
INTENT(IN) :: rc(xcoord:zcoord)
505 TYPE(t_grid),
POINTER :: pgrid
512 INTEGER :: degrhelp,icg,icg2,icl,ict,iloc,isl,ivg,ivl,iv2c
513 INTEGER :: x2cshelp(stencilsizemax),x2cssort(stencilsizemax)
514 REAL(RFREAL) :: dr(xcoord:zcoord)
521 'RFLU_ModStencilsUtils.F90')
533 DO isl = 1,stencilsizemax
539 x2cssort(isl) = x2cs(isl)
548 outerloop:
DO isl = x2csbeg,x2csend
551 icl = pgrid%cellGlob2Loc(2,icg)
559 CASE ( cell_type_hex )
561 ivg = pgrid%hex2v(ivl,icl)
563 DO iv2c = pgrid%v2cInfo(v2c_beg,ivg),pgrid%v2cInfo(v2c_end,ivg)
564 icg2 = pgrid%v2c(iv2c)
566 IF ( icg2 /= ixg )
THEN
569 IF ( iloc == element_not_found )
THEN
570 IF ( degrhelp > 0 )
THEN
573 IF ( iloc == element_not_found )
THEN
574 IF ( degrhelp < stencilsizemax )
THEN
575 dr(xcoord) = pgrid%cofg(xcoord,icg2) - rc(xcoord)
576 dr(ycoord) = pgrid%cofg(ycoord,icg2) - rc(ycoord)
577 dr(zcoord) = pgrid%cofg(zcoord,icg2) - rc(zcoord)
581 IF ( alignflag .EQV. .true. )
THEN
582 degrhelp = degrhelp + 1
583 x2cshelp(degrhelp) = icg2
585 IF ( degrhelp > 1 )
THEN
594 dr(xcoord) = pgrid%cofg(xcoord,icg2) - rc(xcoord)
595 dr(ycoord) = pgrid%cofg(ycoord,icg2) - rc(ycoord)
596 dr(zcoord) = pgrid%cofg(zcoord,icg2) - rc(zcoord)
600 IF ( alignflag .EQV. .true. )
THEN
601 degrhelp = degrhelp + 1
602 x2cshelp(degrhelp) = icg2
616 CALL
errorstop(global,err_reached_default,__line__)
625 IF ( degr < stencilsizemax )
THEN
627 x2cs(degr) = x2cshelp(isl)
682 INTEGER,
INTENT(IN) :: ixg,stencilsizemax,x2csbeg,x2csend
683 INTEGER,
INTENT(INOUT) :: degr
684 INTEGER,
INTENT(INOUT) :: x2cs(stencilsizemax)
686 TYPE(t_grid),
POINTER :: pgrid
692 INTEGER :: degrhelp,icg,icg2,icl,ict,iloc,isl,ivg,ivl,iv2c
693 INTEGER :: x2cshelp(stencilsizemax),x2cssort(stencilsizemax)
700 'RFLU_ModStencilsUtils.F90')
712 DO isl = 1,stencilsizemax
718 x2cssort(isl) = x2cs(isl)
727 outerloop:
DO isl = x2csbeg,x2csend
730 icl = pgrid%cellGlob2Loc(2,icg)
738 CASE ( cell_type_tet )
740 ivg = pgrid%tet2v(ivl,icl)
742 DO iv2c = pgrid%v2cInfo(v2c_beg,ivg),pgrid%v2cInfo(v2c_end,ivg)
743 icg2 = pgrid%v2c(iv2c)
745 IF ( icg2 /= ixg )
THEN
748 IF ( iloc == element_not_found )
THEN
749 IF ( degrhelp > 0 )
THEN
753 IF ( iloc == element_not_found )
THEN
754 IF ( degrhelp < stencilsizemax )
THEN
755 degrhelp = degrhelp + 1
756 x2cshelp(degrhelp) = icg2
758 IF ( degrhelp > 1 )
THEN
766 degrhelp = degrhelp + 1
767 x2cshelp(degrhelp) = icg2
779 CASE ( cell_type_hex )
781 ivg = pgrid%hex2v(ivl,icl)
783 DO iv2c = pgrid%v2cInfo(v2c_beg,ivg),pgrid%v2cInfo(v2c_end,ivg)
784 icg2 = pgrid%v2c(iv2c)
786 IF ( icg2 /= ixg )
THEN
789 IF ( iloc == element_not_found )
THEN
790 IF ( degrhelp > 0 )
THEN
793 IF ( iloc == element_not_found )
THEN
794 IF ( degrhelp < stencilsizemax )
THEN
795 degrhelp = degrhelp + 1
796 x2cshelp(degrhelp) = icg2
798 IF ( degrhelp > 1 )
THEN
806 degrhelp = degrhelp + 1
807 x2cshelp(degrhelp) = icg2
819 CASE ( cell_type_pri )
821 ivg = pgrid%pri2v(ivl,icl)
823 DO iv2c = pgrid%v2cInfo(v2c_beg,ivg),pgrid%v2cInfo(v2c_end,ivg)
824 icg2 = pgrid%v2c(iv2c)
826 IF ( icg2 /= ixg )
THEN
829 IF ( iloc == element_not_found )
THEN
830 IF ( degrhelp > 0 )
THEN
834 IF ( iloc == element_not_found )
THEN
835 IF ( degrhelp < stencilsizemax )
THEN
836 degrhelp = degrhelp + 1
837 x2cshelp(degrhelp) = icg2
839 IF ( degrhelp > 1 )
THEN
847 degrhelp = degrhelp + 1
848 x2cshelp(degrhelp) = icg2
860 CASE ( cell_type_pyr )
862 ivg = pgrid%pyr2v(ivl,icl)
864 DO iv2c = pgrid%v2cInfo(v2c_beg,ivg),pgrid%v2cInfo(v2c_end,ivg)
865 icg2 = pgrid%v2c(iv2c)
867 IF ( icg2 /= ixg )
THEN
870 IF ( iloc == element_not_found )
THEN
871 IF ( degrhelp > 0 )
THEN
875 IF ( iloc == element_not_found )
THEN
876 IF ( degrhelp < stencilsizemax )
THEN
877 degrhelp = degrhelp + 1
878 x2cshelp(degrhelp) = icg2
880 IF ( degrhelp > 1 )
THEN
888 degrhelp = degrhelp + 1
889 x2cshelp(degrhelp) = icg2
902 CALL
errorstop(global,err_reached_default,__line__)
911 IF ( degr < stencilsizemax )
THEN
913 x2cs(degr) = x2cshelp(isl)
966 INTEGER,
INTENT(IN) :: stencilsizemax
967 INTEGER,
INTENT(IN) :: f2v(4)
968 INTEGER,
INTENT(INOUT) :: degr
969 INTEGER,
INTENT(INOUT) :: x2cs(stencilsizemax)
971 TYPE(t_grid),
POINTER :: pgrid
977 INTEGER :: icg,iloc,ivg,ivl,ivl2
984 'RFLU_ModStencilsUtils.F90')
1000 outerloop:
DO ivl = 1,4
1003 IF ( ivg /= vert_none )
THEN
1005 DO ivl2 = pgrid%v2cInfo(v2c_beg,ivg),pgrid%v2cInfo(v2c_end,ivg)
1006 icg = pgrid%v2c(ivl2)
1008 IF ( degr /= 0 )
THEN
1011 IF ( iloc == element_not_found )
THEN
1012 IF ( degr < stencilsizemax )
THEN
1016 IF ( degr > 1 )
THEN
1080 INTEGER,
INTENT(IN) :: dimens,factor,
order
1087 CHARACTER(CHRLEN) :: rcsidentstring
1094 'RFLU_ModStencilsUtils.F90')
1100 IF (
order > 0 )
THEN
1101 SELECT CASE ( dimens )
1107 CALL
errorstop(global,err_dimens_invalid,__line__)
1166 derivdegree,ordernominal,nrows,dr, &
1183 INTEGER,
INTENT(IN) :: derivdegree,dimens,nrows,scalmode,wtsmode
1184 INTEGER,
INTENT(IN) :: ordernominal
1185 INTEGER,
INTENT(OUT),
OPTIONAL :: scount
1186 REAL(RFREAL),
INTENT(IN) :: dr(xcoord:zcoord,nrows)
1187 REAL(RFREAL),
INTENT(OUT) :: wts(:,:)
1194 CHARACTER(CHRLEN) :: rcsidentstring
1195 INTEGER :: errorflag,isl,
j,ncols,
order,p,
q,
r
1196 REAL(RFREAL) :: colscal,
term,wtsnorm,wtsnormmax,wtsnormmin
1197 REAL(RFREAL) :: rowscal(nrows)
1198 REAL(RFREAL) :: drcopy(xcoord:zcoord,nrows)
1199 REAL(RFREAL),
DIMENSION(:,:),
ALLOCATABLE ::
a,
ainv
1206 'RFLU_ModStencilsUtils.F90')
1208 wtsnormmin = 1.0_rfreal
1209 wtsnormmax = 10.0_rfreal
1216 SELECT CASE ( dimens )
1218 SELECT CASE ( nrows )
1228 CALL
errorstop(global,err_reached_default,__line__)
1231 SELECT CASE ( nrows )
1241 CALL
errorstop(global,err_reached_default,__line__)
1244 CALL
errorstop(global,err_reached_default,__line__)
1247 order = ordernominal
1254 IF ( scalmode == compwts_scal_none )
THEN
1256 rowscal(isl) = 1.0_rfreal
1258 ELSE IF ( scalmode == compwts_scal_invdist )
THEN
1260 rowscal(isl) = 1.0_rfreal/
sqrt(dr(xcoord,isl)*dr(xcoord,isl) &
1261 + dr(ycoord,isl)*dr(ycoord,isl) &
1262 + dr(zcoord,isl)*dr(zcoord,isl))
1265 CALL
errorstop(global,err_reached_default,__line__)
1272 colscal = maxval(abs(dr(xcoord:zcoord,1:nrows)))
1275 drcopy(xcoord,isl) = dr(xcoord,isl)/colscal
1276 drcopy(ycoord,isl) = dr(ycoord,isl)/colscal
1277 drcopy(zcoord,isl) = dr(zcoord,isl)/colscal
1290 IF (
order > 0 )
THEN
1297 ALLOCATE(
a(nrows,ncols),stat=errorflag)
1298 global%error = errorflag
1299 IF ( global%error /= err_none )
THEN
1300 CALL
errorstop(global,err_allocate,__line__,
'a')
1303 ALLOCATE(
ainv(ncols,nrows),stat=errorflag)
1304 global%error = errorflag
1305 IF ( global%error /= err_none )
THEN
1306 CALL
errorstop(global,err_allocate,__line__,
'aInv')
1313 SELECT CASE ( dimens )
1316 a(isl,1) = rowscal(isl)
1323 a(isl,
j) =
term*drcopy(xcoord,isl)**(p-
q) &
1324 *drcopy(ycoord,isl)**
q
1331 a(isl,1) = rowscal(isl)
1339 a(isl,
j) =
term*drcopy(xcoord,isl)**(p-
q) &
1340 *drcopy(ycoord,isl)**(
q-
r) &
1341 *drcopy(zcoord,isl)**
r
1348 CALL
errorstop(global,err_reached_default,__line__)
1361 IF ( derivdegree == deriv_degree_0 )
THEN
1363 wts(1,isl) = rowscal(isl)*
ainv(1,isl)
1365 ELSE IF ( derivdegree == deriv_degree_1 )
THEN
1366 SELECT CASE ( dimens )
1369 wts(xcoord,isl) = rowscal(isl)*
ainv(2,isl)/colscal
1370 wts(ycoord,isl) = rowscal(isl)*
ainv(3,isl)/colscal
1371 wts(zcoord,isl) = 0.0_rfreal
1375 wts(xcoord,isl) = rowscal(isl)*
ainv(2,isl)/colscal
1376 wts(ycoord,isl) = rowscal(isl)*
ainv(3,isl)/colscal
1377 wts(zcoord,isl) = rowscal(isl)*
ainv(4,isl)/colscal
1380 CALL
errorstop(global,err_reached_default,__line__)
1383 CALL
errorstop(global,err_reached_default,__line__)
1390 wtsnorm = 0.0_rfreal
1393 wtsnorm = wtsnorm + abs(
ainv(1,isl))
1400 DEALLOCATE(
a,stat=errorflag)
1401 global%error = errorflag
1402 IF ( global%error /= err_none )
THEN
1403 CALL
errorstop(global,err_deallocate,__line__,
'a')
1406 DEALLOCATE(
ainv,stat=errorflag)
1407 global%error = errorflag
1408 IF ( global%error /= err_none )
THEN
1409 CALL
errorstop(global,err_deallocate,__line__,
'aInv')
1416 IF ( scount == 0 .AND. &
1417 wtsnorm > wtsnormmin .AND. wtsnorm < wtsnormmax )
THEN
1420 IF ( wtsmode == compwts_mode_adapt )
THEN
1432 IF ( derivdegree == deriv_degree_0 )
THEN
1434 wts(1,isl) = 1.0_rfreal/
REAL(nRows,KIND=RFREAL)
1436 ELSE IF ( derivdegree == deriv_degree_1 )
THEN
1438 wts(xcoord,isl) = 0.0_rfreal
1439 wts(ycoord,isl) = 0.0_rfreal
1440 wts(zcoord,isl) = 0.0_rfreal
1443 CALL
errorstop(global,err_reached_default,__line__)
1496 INTEGER,
INTENT(IN) :: nbfacemembs
1497 INTEGER,
INTENT(INOUT) :: bfacemembs(2,nbfacemembs)
1498 REAL(RFREAL),
INTENT(IN) :: xyz(xcoord:zcoord)
1499 TYPE(t_region
),
POINTER :: pregion
1505 INTEGER :: ifl,ipatch,isl
1506 INTEGER ::
key(nbfacemembs)
1507 INTEGER :: bfacemembsbak(2,nbfacemembs)
1508 REAL(RFREAL) ::
dist(nbfacemembs)
1510 TYPE(t_grid),
POINTER :: pgrid
1511 TYPE(t_patch),
POINTER :: ppatch
1517 global => pregion%global
1518 pgrid => pregion%grid
1525 'RFLU_ModStencilsUtils.F90')
1531 DO isl = 1,nbfacemembs
1532 bfacemembsbak(1,isl) = bfacemembs(1,isl)
1533 bfacemembsbak(2,isl) = bfacemembs(2,isl)
1540 DO isl = 1,nbfacemembs
1541 ipatch = bfacemembs(1,isl)
1542 ifl = bfacemembs(2,isl)
1544 ppatch => pregion%patches(ipatch)
1547 dist(isl) = (ppatch%fc(xcoord,ifl) - xyz(xcoord))**2 &
1548 + (ppatch%fc(ycoord,ifl) - xyz(ycoord))**2 &
1549 + (ppatch%fc(zcoord,ifl) - xyz(zcoord))**2
1558 DO isl = 1,nbfacemembs
1559 bfacemembs(1,isl) = bfacemembsbak(1,
key(isl))
1560 bfacemembs(2,isl) = bfacemembsbak(2,
key(isl))
subroutine, public rflu_computestencilweights(global, dimens, wtsMode, scalMode, derivDegree, orderNominal, nRows, dr, wts, sCount)
subroutine, public rflu_addcelllayer(global, pGrid, stencilSizeMax, ixg, degr, x2csBeg, x2csEnd, x2cs)
subroutine, public rflu_addcelllayer_1d(global, pGrid, stencilSizeMax, ixg, degr, x2csBeg, x2csEnd, x2cs, fnDir)
subroutine ainv(ajac, ajacin, det, ndim)
Size order() const
Degree of the element. 1 for linear and 2 for quadratic.
subroutine rflu_invertmatrixsvd(global, nRows, nCols, a, aInv, sCount)
subroutine registerfunction(global, funName, fileName)
subroutine quicksortinteger(a, n)
subroutine binarysearchinteger(a, n, v, i, j)
subroutine, public rflu_addfacevertneighbs(global, pGrid, stencilSizeMax, f2v, degr, x2cs)
subroutine, public rflu_addbfaces(pRegion, nBFaceMembsMaxTemp, nCellMembs, cellMembs, nBFaceMembs, bFaceMembs)
INTEGER function rflu_computestencilsize(global, factor, order)
subroutine quicksortrfrealinteger(a, b, n)
subroutine, public rflu_addcelllayer_1d_g(global, pGrid, stencilSizeMax, ixg, degr, x2csBeg, x2csEnd, x2cs, rc, dir)
subroutine, public rflu_sortbfaces(pRegion, xyz, nBFaceMembs, bFaceMembs)
subroutine errorstop(global, errorCode, errorLine, addMessage)
long double dist(long double *coord1, long double *coord2, int size)
subroutine deregisterfunction(global)
INTEGER function, public rflu_getglobalcelltype(global, pGrid, icg)