63 CHARACTER(CHRLEN) :: RCSIdentString = &
64 '$RCSfile: RFLU_ModDifferentiationFaces.F90,v $ $Revision: 1.9 $'
118 INTEGER,
INTENT(IN) :: ibegvar,iendvar,ibeggrad,iendgrad
119 REAL(RFREAL),
DIMENSION(:,:),
POINTER :: var
120 REAL(RFREAL),
DIMENSION(:,:,:),
POINTER :: grad
121 TYPE(t_region
),
POINTER :: pregion
127 INTEGER :: errorflag,icg,ifg,ifl,igrad,ipatch,isl,ivar
128 REAL(RFREAL) :: c11,c12,c13,c14,c22,c23,c24,c33,c34,c44,
dx,
dy,
dz,r11, &
129 r12,r13,r14,r22,r23,r24,r33,r34,r44,
term,term1,term2, &
131 REAL(RFREAL) :: fc(xcoord:zcoord)
133 TYPE(t_grid),
POINTER :: pgrid
134 TYPE(t_patch),
POINTER :: ppatch
140 global => pregion%global
143 'RFLU_ModDifferentiationFaces.F90')
146 CALL fprofiler_begins(
"RFLU::ComputeGradFaces")
149 IF ( (iendvar - ibegvar) /= (iendgrad - ibeggrad) )
THEN
150 CALL
errorstop(global,err_grad_mismatch,__line__)
157 pgrid => pregion%grid
179 SELECT CASE ( pregion%mixtInput%dimens )
186 DO ifg = 1,pgrid%nFaces
187 r11 = pgrid%f2cs(ifg)%xyzMoms(xyz_mom_11)
188 r12 = pgrid%f2cs(ifg)%xyzMoms(xyz_mom_12)
189 r22 = pgrid%f2cs(ifg)%xyzMoms(xyz_mom_22)
190 r13 = pgrid%f2cs(ifg)%xyzMoms(xyz_mom_13)
191 r23 = pgrid%f2cs(ifg)%xyzMoms(xyz_mom_23)
192 r33 = pgrid%f2cs(ifg)%xyzMoms(xyz_mom_33)
199 c13 = -(c11*r13 + c12*c22*r23)
203 fc(xcoord) = pgrid%fc(xcoord,ifg)
204 fc(ycoord) = pgrid%fc(ycoord,ifg)
206 DO igrad = ibeggrad,iendgrad
207 grad(xcoord,igrad,ifg) = 0.0_rfreal
208 grad(ycoord,igrad,ifg) = 0.0_rfreal
209 grad(zcoord,igrad,ifg) = 0.0_rfreal
212 DO isl = 1,pgrid%f2cs(ifg)%nCellMembs
213 icg = pgrid%f2cs(ifg)%cellMembs(isl)
215 dx = pgrid%cofg(xcoord,icg) - fc(xcoord)
216 dy = pgrid%cofg(ycoord,icg) - fc(ycoord)
223 term1 = c11*c11*(
dx)
224 term2 = c22*c22*(
dy + c12*
dx)
225 term3 = c33*c33*(
term + c23*
dy + c13*
dx)
227 wx =
term*(term1 + c12*term2 + c13*term3)
228 wy =
term*( term2 + c23*term3)
232 DO ivar = ibegvar,iendvar
233 grad(xcoord,igrad,ifg) = grad(xcoord,igrad,ifg) + wx*var(ivar,icg)
234 grad(ycoord,igrad,ifg) = grad(ycoord,igrad,ifg) + wy*var(ivar,icg)
246 DO ifg = 1,pgrid%nFaces
247 r11 = pgrid%f2cs(ifg)%xyzMoms(xyz_mom_11)
248 r12 = pgrid%f2cs(ifg)%xyzMoms(xyz_mom_12)
249 r22 = pgrid%f2cs(ifg)%xyzMoms(xyz_mom_22)
250 r13 = pgrid%f2cs(ifg)%xyzMoms(xyz_mom_13)
251 r23 = pgrid%f2cs(ifg)%xyzMoms(xyz_mom_23)
252 r33 = pgrid%f2cs(ifg)%xyzMoms(xyz_mom_33)
253 r14 = pgrid%f2cs(ifg)%xyzMoms(xyz_mom_14)
254 r24 = pgrid%f2cs(ifg)%xyzMoms(xyz_mom_24)
255 r34 = pgrid%f2cs(ifg)%xyzMoms(xyz_mom_34)
256 r44 = pgrid%f2cs(ifg)%xyzMoms(xyz_mom_44)
264 c13 = -(c11*r13 + c12*c22*r23)
265 c14 = -(c11*r14 + c12*c22*r24 + c13*c33*r34)
268 c24 = -(c22*r24 + c23*c33*r34)
272 fc(xcoord) = pgrid%fc(xcoord,ifg)
273 fc(ycoord) = pgrid%fc(ycoord,ifg)
274 fc(zcoord) = pgrid%fc(zcoord,ifg)
276 DO igrad = ibeggrad,iendgrad
277 grad(xcoord,igrad,ifg) = 0.0_rfreal
278 grad(ycoord,igrad,ifg) = 0.0_rfreal
279 grad(zcoord,igrad,ifg) = 0.0_rfreal
282 DO isl = 1,pgrid%f2cs(ifg)%nCellMembs
283 icg = pgrid%f2cs(ifg)%cellMembs(isl)
285 dx = pgrid%cofg(xcoord,icg) - fc(xcoord)
286 dy = pgrid%cofg(ycoord,icg) - fc(ycoord)
287 dz = pgrid%cofg(zcoord,icg) - fc(zcoord)
295 term1 = c11*c11*(
dx)
296 term2 = c22*c22*(
dy + c12*
dx)
297 term3 = c33*c33*(
dz + c23*
dy + c13*
dx)
298 term4 = c44*c44*(
term + c34*
dz + c24*
dy + c14*
dx)
300 wx =
term*(term1 + c12*term2 + c13*term3 + c14*term4)
301 wy =
term*( term2 + c23*term3 + c24*term4)
302 wz =
term*( term3 + c34*term4)
306 DO ivar = ibegvar,iendvar
307 grad(xcoord,igrad,ifg) = grad(xcoord,igrad,ifg) + wx*var(ivar,icg)
308 grad(ycoord,igrad,ifg) = grad(ycoord,igrad,ifg) + wy*var(ivar,icg)
309 grad(zcoord,igrad,ifg) = grad(zcoord,igrad,ifg) + wz*var(ivar,icg)
321 CALL
errorstop(global,err_reached_default,__line__)
340 CALL fprofiler_ends(
"RFLU::ComputeGradFaces")
383 iendgrad,varinfo,var,grad)
397 INTEGER,
INTENT(IN) :: ibegvar,iendvar,ibeggrad,iendgrad
398 INTEGER,
INTENT(IN) :: varinfo(ibegvar:iendvar)
399 REAL(RFREAL),
DIMENSION(:,:),
POINTER :: var
400 REAL(RFREAL),
DIMENSION(:,:,:),
POINTER :: grad
401 TYPE(t_region
),
POINTER :: pregion
407 INTEGER :: errorflag,icg,icol,ifg,ifl,ifl2,igrad,ipatch,isl,irow,ivar, &
408 ncols,nconstr,nrows,scount
409 INTEGER,
DIMENSION(:),
ALLOCATABLE :: constrtype
410 REAL(RFREAL) :: cwt,
dx,
dy,
dz,
term,varc,wtx,wty,wtz,gx,gy,gz
411 REAL(RFREAL) :: colmax(4)
412 REAL(RFREAL) :: fc(xcoord:zcoord)
413 REAL(RFREAL),
DIMENSION(:,:),
ALLOCATABLE ::
a,
ainv
415 TYPE(t_grid),
POINTER :: pgrid
416 TYPE(t_patch),
POINTER :: ppatch
422 global => pregion%global
425 'RFLU_ModDifferentiationFaces.F90')
428 CALL fprofiler_begins(
"RFLU::ComputeGradFacesConstr")
431 IF ( (iendvar - ibegvar) /= (iendgrad - ibeggrad) )
THEN
432 CALL
errorstop(global,err_grad_mismatch,__line__)
439 pgrid => pregion%grid
441 cwt = pregion%mixtInput%cReconstFacesWeight
459 DO ifl = 1,pgrid%nFacesConstr
460 ifg = pgrid%ifgConstr(ifl)
466 DO igrad = ibeggrad,iendgrad
467 grad(xcoord,igrad,ifg) = 0.0_rfreal
468 grad(ycoord,igrad,ifg) = 0.0_rfreal
469 grad(zcoord,igrad,ifg) = 0.0_rfreal
472 fc(xcoord) = pgrid%fc(xcoord,ifg)
473 fc(ycoord) = pgrid%fc(ycoord,ifg)
474 fc(zcoord) = pgrid%fc(zcoord,ifg)
476 ALLOCATE(constrtype(pgrid%f2cs(ifg)%nBFaceMembs),stat=errorflag)
477 global%error = errorflag
478 IF ( global%error /= err_none )
THEN
479 CALL
errorstop(global,err_allocate,__line__,
'constrType')
488 DO ivar = ibegvar,iendvar
496 DO isl = 1,pgrid%f2cs(ifg)%nBFaceMembs
497 ipatch = pgrid%f2cs(ifg)%bFaceMembs(1,isl)
498 ifl2 = pgrid%f2cs(ifg)%bFaceMembs(2,isl)
500 ppatch => pregion%patches(ipatch)
505 IF ( constrtype(isl) == constr_type_dirichlet )
THEN
506 nconstr = nconstr + 1
508 constrtype(isl) = constr_type_none
520 IF ( nconstr > 0 )
THEN
524 nrows = pgrid%f2cs(ifg)%nCellMembs + nconstr
525 ncols = pregion%mixtInput%dimens + 1
527 ALLOCATE(
a(nrows,ncols),stat=errorflag)
528 global%error = errorflag
529 IF ( global%error /= err_none )
THEN
530 CALL
errorstop(global,err_allocate,__line__,
'a')
533 ALLOCATE(
ainv(ncols,nrows),stat=errorflag)
534 global%error = errorflag
535 IF ( global%error /= err_none )
THEN
536 CALL
errorstop(global,err_allocate,__line__,
'aInv')
541 SELECT CASE ( pregion%mixtInput%dimens )
546 DO isl = 1,pgrid%f2cs(ifg)%nCellMembs
547 icg = pgrid%f2cs(ifg)%cellMembs(isl)
549 dx = pgrid%cofg(xcoord,icg) - fc(xcoord)
550 dy = pgrid%cofg(ycoord,icg) - fc(ycoord)
559 irow = pgrid%f2cs(ifg)%nCellMembs
561 DO isl = 1,pgrid%f2cs(ifg)%nBFaceMembs
562 IF ( constrtype(isl) == constr_type_dirichlet )
THEN
563 ipatch = pgrid%f2cs(ifg)%bFaceMembs(1,isl)
564 ifl2 = pgrid%f2cs(ifg)%bFaceMembs(2,isl)
566 ppatch => pregion%patches(ipatch)
568 dx = ppatch%fc(xcoord,ifl2) - fc(xcoord)
569 dy = ppatch%fc(ycoord,ifl2) - fc(ycoord)
584 DO isl = 1,pgrid%f2cs(ifg)%nCellMembs
585 icg = pgrid%f2cs(ifg)%cellMembs(isl)
587 dx = pgrid%cofg(xcoord,icg) - fc(xcoord)
588 dy = pgrid%cofg(ycoord,icg) - fc(ycoord)
589 dz = pgrid%cofg(zcoord,icg) - fc(zcoord)
599 irow = pgrid%f2cs(ifg)%nCellMembs
601 DO isl = 1,pgrid%f2cs(ifg)%nBFaceMembs
602 IF ( constrtype(isl) == constr_type_dirichlet )
THEN
603 ipatch = pgrid%f2cs(ifg)%bFaceMembs(1,isl)
604 ifl2 = pgrid%f2cs(ifg)%bFaceMembs(2,isl)
606 ppatch => pregion%patches(ipatch)
608 dx = ppatch%fc(xcoord,ifl2) - fc(xcoord)
609 dy = ppatch%fc(ycoord,ifl2) - fc(ycoord)
610 dz = ppatch%fc(zcoord,ifl2) - fc(zcoord)
623 CALL
errorstop(global,err_reached_default,__line__)
629 colmax(icol) = -huge(1.0_rfreal)
632 colmax(icol) =
max(colmax(icol),abs(
a(irow,icol)))
636 a(irow,icol) =
a(irow,icol)/colmax(icol)
644 ainv(icol,irow) =
ainv(icol,irow)/colmax(icol)
649 IF ( scount /= 0 )
THEN
650 WRITE(*,*)
'ERROR - Singular matrix in RFLU_ComputeGradFacesConstr!'
657 SELECT CASE ( pregion%mixtInput%dimens )
662 DO isl = 1,pgrid%f2cs(ifg)%nCellMembs
663 icg = pgrid%f2cs(ifg)%cellMembs(isl)
665 dx = pgrid%cofg(xcoord,icg) - fc(xcoord)
666 dy = pgrid%cofg(ycoord,icg) - fc(ycoord)
670 gx = gx +
term*
ainv(2,isl)*var(ivar,icg)
671 gy = gy +
term*
ainv(3,isl)*var(ivar,icg)
674 irow = pgrid%f2cs(ifg)%nCellMembs
676 DO isl = 1,pgrid%f2cs(ifg)%nBFaceMembs
677 IF ( constrtype(isl) == constr_type_dirichlet )
THEN
678 ipatch = pgrid%f2cs(ifg)%bFaceMembs(1,isl)
679 ifl2 = pgrid%f2cs(ifg)%bFaceMembs(2,isl)
681 ppatch => pregion%patches(ipatch)
683 dx = ppatch%fc(xcoord,ifl2) - fc(xcoord)
684 dy = ppatch%fc(ycoord,ifl2) - fc(ycoord)
697 grad(xcoord,igrad,ifg) = gx
698 grad(ycoord,igrad,ifg) = gy
699 grad(zcoord,igrad,ifg) = 0.0_rfreal
705 DO isl = 1,pgrid%f2cs(ifg)%nCellMembs
706 icg = pgrid%f2cs(ifg)%cellMembs(isl)
708 dx = pgrid%cofg(xcoord,icg) - fc(xcoord)
709 dy = pgrid%cofg(ycoord,icg) - fc(ycoord)
710 dz = pgrid%cofg(zcoord,icg) - fc(zcoord)
714 gx = gx +
term*
ainv(2,isl)*var(ivar,icg)
715 gy = gy +
term*
ainv(3,isl)*var(ivar,icg)
716 gz = gz +
term*
ainv(4,isl)*var(ivar,icg)
719 irow = pgrid%f2cs(ifg)%nCellMembs
721 DO isl = 1,pgrid%f2cs(ifg)%nBFaceMembs
722 IF ( constrtype(isl) == constr_type_dirichlet )
THEN
723 ipatch = pgrid%f2cs(ifg)%bFaceMembs(1,isl)
724 ifl2 = pgrid%f2cs(ifg)%bFaceMembs(2,isl)
726 ppatch => pregion%patches(ipatch)
728 dx = ppatch%fc(xcoord,ifl2) - fc(xcoord)
729 dy = ppatch%fc(ycoord,ifl2) - fc(ycoord)
730 dz = ppatch%fc(zcoord,ifl2) - fc(zcoord)
744 grad(xcoord,igrad,ifg) = gx
745 grad(ycoord,igrad,ifg) = gy
746 grad(zcoord,igrad,ifg) = gz
748 CALL
errorstop(global,err_reached_default,__line__)
753 DEALLOCATE(
a,stat=errorflag)
754 global%error = errorflag
755 IF ( global%error /= err_none )
THEN
756 CALL
errorstop(global,err_deallocate,__line__,
'a')
759 DEALLOCATE(
ainv,stat=errorflag)
760 global%error = errorflag
761 IF ( global%error /= err_none )
THEN
762 CALL
errorstop(global,err_deallocate,__line__,
'aInv')
769 DEALLOCATE(constrtype,stat=errorflag)
770 global%error = errorflag
771 IF ( global%error /= err_none )
THEN
772 CALL
errorstop(global,err_deallocate,__line__,
'constrType')
792 CALL fprofiler_ends(
"RFLU::ComputeGradFacesConstr")
840 INTEGER,
INTENT(IN) :: ibegvar,iendvar,ibeggrad,iendgrad
841 REAL(RFREAL),
DIMENSION(:,:),
POINTER :: var
842 REAL(RFREAL),
DIMENSION(:,:,:),
POINTER :: grad
843 TYPE(t_region
),
POINTER :: pregion
850 TYPE(t_grid),
POINTER :: pgrid
856 global => pregion%global
859 'RFLU_ModDifferentiationFaces.F90' )
865 SELECT CASE ( pregion%mixtInput%stencilDimensFaces )
873 CALL
errorstop(global,err_reached_default,__line__)
914 order,dra,drb,rhsa,rhsb,gradlocal)
929 INTEGER,
INTENT(IN) :: dimens
930 INTEGER :: nbfacemembs,ncellmembs,
order
931 REAL(RFREAL) :: gradlocal(xcoord:xyzmag),rhsa(ncellmembs),rhsb(nbfacemembs)
932 REAL(RFREAL) :: dra(xcoord:zcoord,ncellmembs),drb(xcoord:zcoord,nbfacemembs)
939 INTEGER :: errorflag,isl,
j,lda,ldb,ncols,p,
q,
r,
term,workarrayrealsize
940 REAL(RFREAL),
DIMENSION(:),
ALLOCATABLE :: workarrayreal
941 REAL(RFREAL),
DIMENSION(:,:),
ALLOCATABLE ::
a,
b
948 'RFLU_ModDifferentiationFaces.F90')
956 workarrayrealsize = nbfacemembs + ncols + 100*ncellmembs
962 ALLOCATE(
a(ncellmembs,ncols),stat=errorflag)
963 global%error = errorflag
964 IF ( global%error /= err_none )
THEN
965 CALL
errorstop(global,err_allocate,__line__,
'a')
968 ALLOCATE(
b(nbfacemembs,ncols),stat=errorflag)
969 global%error = errorflag
970 IF ( global%error /= err_none )
THEN
971 CALL
errorstop(global,err_allocate,__line__,
'b')
974 ALLOCATE(workarrayreal(workarrayrealsize),stat=errorflag)
975 global%error = errorflag
976 IF ( global%error /= err_none )
THEN
977 CALL
errorstop(global,err_allocate,__line__,
'workArrayReal')
988 DO isl = 1,ncellmembs
989 a(isl,ncols) = 1.0_rfreal
997 a(isl,
j) =
term*dra(xcoord,isl)**(p-
q) &
998 *dra(ycoord,isl)**(
q-
r) &
1010 DO isl = 1,nbfacemembs
1011 b(isl,ncols) = 1.0_rfreal
1019 b(isl,
j) =
term*drb(xcoord,isl)**(p-
q) &
1020 *drb(ycoord,isl)**(
q-
r) &
1032 lda =
max(1,ncellmembs)
1033 ldb =
max(1,nbfacemembs)
1035 CALL dgglse(ncellmembs,ncols,nbfacemembs,
a,lda,
b,ldb,rhsa,rhsb,gradlocal, &
1036 workarrayreal,workarrayrealsize,errorflag)
1037 global%error = errorflag
1038 IF ( global%error /= err_none )
THEN
1039 CALL
errorstop(global,err_lapack_output,__line__)
1046 DEALLOCATE(
a,stat=errorflag)
1047 global%error = errorflag
1048 IF ( global%error /= err_none )
THEN
1049 CALL
errorstop(global,err_deallocate,__line__,
'a')
1052 DEALLOCATE(
b,stat=errorflag)
1053 global%error = errorflag
1054 IF ( global%error /= err_none )
THEN
1055 CALL
errorstop(global,err_deallocate,__line__,
'b')
1058 DEALLOCATE(workarrayreal,stat=errorflag)
1059 global%error = errorflag
1060 IF ( global%error /= err_none )
THEN
1061 CALL
errorstop(global,err_deallocate,__line__,
'workArrayReal')
subroutine, public rflu_computegradfaceswrapper(pRegion, iBegVar, iEndVar, iBegGrad, iEndGrad, var, grad)
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
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, public rflu_computegradfacesconstr(pRegion, iBegVar, iEndVar, iBegGrad, iEndGrad, varInfo, var, grad)
INTEGER function, public rflu_getconstrtype(pRegion, pPatch, var, ifl)
INTEGER function rflu_computestencilsize(global, factor, order)
subroutine, public rflu_computegradconstrained(global, dimens, nCellMembs, nBFaceMembs, order, dra, drb, rhsa, rhsb, gradLocal)
real(rfreal) function, public rflu_getconstrvalue(pRegion, pPatch, var, ifl)
subroutine errorstop(global, errorCode, errorLine, addMessage)
subroutine deregisterfunction(global)
subroutine rflu_computegradfaces(pRegion, iBegVar, iEndVar, iBegGrad, iEndGrad, var, grad)