6 use input, only : param, ifflow, ifprint
7 use soln, only : vx, vy, vz
8 use tstep, only : dt, dtinit, time, fintim, lastep, courno, ctarg, istep
9 use tstep, only : re_cell
12 real(DP),
save :: umax = 0._dp
13 real(DP),
save :: uxmax = 0._dp
14 REAL(DP),
save :: DTOLD = 0._dp
15 REAL(DP),
save :: DTOpf = 0._dp
16 logical,
save :: iffxdt = .FALSE.
18 real(DP) :: dtcfl, dtfs, dtmin, dtmax
19 real(DP),
external :: uglmin
21 if (param(12) < 0 .OR. iffxdt)
then
23 param(12) = abs(param(12))
28 else IF (param(84) /= 0.0)
THEN
45 re_cell = uxmax / param(2)
54 IF ((dt == 0.) .AND. (dtfs > 0.))
THEN
56 ELSEIF ((dt > 0.) .AND. (dtfs > 0.))
THEN
58 ELSEIF ((dt == 0.) .AND. (dtfs == 0.))
THEN
60 IF (ifflow .AND. nid == 0 .AND. ifprint)
THEN
61 WRITE (6,*)
'WARNING: CFL-condition & surface tension'
62 WRITE (6,*)
' are not applicable'
64 ELSEIF ((dt > 0.) .AND. (dtfs == 0.))
THEN
68 IF (nid == 0)
WRITE (6,*)
'WARNING: DT<0 or DTFS<0'
69 IF (nid == 0)
WRITE (6,*)
' Reset DT '
74 IF ((dt > 0.) .AND. (dtinit > 0.))
THEN
76 ELSEIF ((dt == 0.) .AND. (dtinit > 0.))
THEN
78 ELSEIF ((dt > 0.) .AND. (dtinit == 0.))
THEN
80 ELSEIF ( .NOT. iffxdt)
THEN
82 IF(nid == 0)
WRITE (6,*)
'WARNING: Set DT=0.001 (arbitrarily)'
87 200
IF (time+dt >= fintim .AND. fintim /= 0.0)
THEN
91 IF (nid == 0)
WRITE (6,*)
'Final time step = ',dt
95 IF (nid == 0 .AND. ifprint .AND. dt /= dtold) &
96 WRITE (6,100) dt,dtcfl,dtfs,dtinit
97 100
FORMAT(5x,
'DT/DTCFL/DTFS/DTINIT',4e12.3)
100 if (abs(dt - dtold)/dt < 0.1) dt = dtold
103 IF (dtold /= 0.0)
THEN
122 if (iffxdt .AND. abs(courno) > 10.*abs(ctarg))
then
123 if (nid == 0)
write(6,*)
'CFL, Ctarg!',courno,ctarg
137 use input, only : ifnonl
138 use tstep, only : ifield, tnrmh1, tolnl
142 real(DP) :: tnorm1, tnorm2, eps
144 IF (ifnonl(ifield))
THEN
151 tnorm1 = tnrmh1(ifield-1)
153 tnorm2 = tnrmh1(ifield-1)
154 eps = abs((tnorm2-tnorm1)/tnorm2)
155 IF (eps < tolnl) ifconv = .true.
165 use soln, only : vx, vy, vz, t
166 use tstep, only : ifield, imesh, tnrml8, tnrmsm, tnrmh1, time, dt, tnrml2
167 use tstep, only : vnrmh1, vnrmsm, vnrml2, vnrml8, istep, dtinvm, vmean, tmean
170 real(DP) :: tden, arg
172 IF (ifield == 1)
THEN
178 CALL
normvc(vnrmh1,vnrmsm,vnrml2,vnrml8,vx,vy,vz)
179 IF (istep == 0)
return
185 if (time <= 0) tden = abs(time)+1.e-9
186 arg = ((time-dt)*dtinvm**2+1./dt)/tden
187 if (arg > 0) dtinvm = sqrt(arg)
188 arg = ((time-dt)*vmean**2+dt*vnrmh1**2)/tden
189 if (arg > 0) vmean = sqrt(arg)
195 CALL
normsc(tnrmh1(ifield-1),tnrmsm(ifield-1), &
196 tnrml2(ifield-1),tnrml8(ifield-1), &
197 t(1,1,1,1,ifield-1),imesh)
209 use size_m
, only : lx1, ly1, lz1, lelv
210 use size_m
, only : nx1, ny1, nz1, nelv, ndim, nid
211 use geom, only : ifwcno, xm1, ym1, zm1
212 use input, only : param, iftran, ifflow, ifnav, ifheat, ifadvc
213 use input, only : ipscal, npscal
214 use geom, only : binvm1
215 use soln, only : vx, vy, vz, v1mask, v2mask, v3mask, bfx, bfy, bfz
216 use tstep, only : lastep, dt, ifield, courno, ctarg, avtran, dtinit
219 real(DP),
intent(out) :: umax, uxmax
220 real(DP),
allocatable :: u(:,:,:,:), v(:,:,:,:), w(:,:,:,:)
222 REAL(DP),
save :: VCOUR
224 INTEGER,
save :: IFIRST = 0
225 integer :: irst, iconv, ntot, ntotl, ntotd, i
226 real(DP) :: dtold, cold, cmax, cmin, fmax, density, amax, dxchar, vold, cpred
227 real(DP) :: a, b, c, discr, dtlow, dthi
228 real(DP),
external :: glmax, glmin
231 IF ( .NOT. iftran)
THEN
237 irst = int(param(46))
238 if (irst > 0) ifirst=1
242 IF (ifirst == 0)
THEN
246 CALL
bcdirvc(vx,vy,vz,v1mask,v2mask,v3mask)
259 IF (ifflow .AND. ifnav) iconv=1
262 DO 10 ipscal=0,npscal
263 IF (ifadvc(ipscal+2)) iconv=1
275 ntot = nx1*ny1*nz1*nelv
276 ntotl = lx1*ly1*lz1*lelv
281 allocate(u(lx1,ly1,lz1,lelv), v(lx1,ly1,lz1,lelv), w(lx1,ly1,lz1,lelv))
282 CALL
cumax(vx,vy,vz,u,v,w,umax, uxmax)
288 IF (umax /= 0.0)
THEN
300 bfx = bfx * binvm1; bfy = bfy * binvm1; bfz = bfz * binvm1
304 u(i,1,1,1) = abs(bfx(i,1,1,1))
305 v(i,1,1,1) = abs(bfy(i,1,1,1))
306 w(i,1,1,1) = abs(bfz(i,1,1,1))
308 fmax = glmax(u,ntotd)
311 dxchar = sqrt( (xm1(1,1,1,1)-xm1(2,1,1,1))**2 + &
312 (ym1(1,1,1,1)-ym1(2,1,1,1))**2 + &
313 (zm1(1,1,1,1)-zm1(2,1,1,1))**2 )
314 dxchar = glmin((/dxchar/),1)
316 dt = sqrt(ctarg*dxchar/amax)
319 WRITE (6,*)
'CFL: Zero velocity and body force'
325 WRITE (6,*)
' Stefan problem with no fluid flow'
330 ELSEIF ((dt > 0.0) .AND. (umax /= 0.0))
THEN
339 IF (ifirst == 1)
THEN
343 cpred = 2.*courno-cold
350 IF(courno > cmax .OR. cpred > cmax .OR. courno < cmin)
THEN
360 print*,
'Problem calculating new DT Discriminant=',discr
363 ELSE IF(abs((vcour-vold)/vcour) < 0.001)
THEN
370 dtlow=(-b+sqrt(discr) )/(2.0*a)
371 dthi =(-b-sqrt(discr) )/(2.0*a)
372 IF(dthi > 0.0 .AND. dtlow > 0.0)
THEN
377 ELSE IF(dthi <= 0.0 .AND. dtlow <= 0.0)
THEN
394 IF (dtold/dt < 0.2) dt = dtold*5
405 subroutine cumax (v1,v2,v3,u,v,w,umax, uxmax)
407 use size_m
, only : lx1, ly1, lz1, lelv, nx1, ny1, nz1, nelv, ndim
408 use geom, only : rxm1, rym1, sxm1, sym1, rzm1, szm1, txm1, tym1, tzm1
409 use input, only : ifaxis
410 use wz_m, only : zgm1
411 use mesh, only : if_ortho
414 real(DP),
intent(in) :: V1(lx1,ly1,lz1,lelv)
415 real(DP),
intent(in) :: V2(lx1,ly1,lz1,lelv)
416 real(DP),
intent(in) :: V3(lx1,ly1,lz1,lelv)
417 real(DP),
intent(out) :: u(lx1,ly1,lz1,lelv)
418 real(DP),
intent(out) :: v(lx1,ly1,lz1,lelv)
419 real(DP),
intent(out) :: w(lx1,ly1,lz1,lelv)
420 real(DP),
intent(out) :: umax
421 real(DP),
intent(out) :: uxmax
423 real(DP),
allocatable,
dimension(:,:,:,:) :: &
424 xrm1, xsm1, xtm1, yrm1, ysm1, ytm1, zrm1, zsm1, ztm1
426 real(DP),
allocatable :: x(:,:,:,:), r(:,:,:,:)
427 real(DP),
allocatable :: tmp(:,:,:,:)
429 real(DP),
save :: drst(lx1), drsti(lx1)
432 INTEGER,
save :: ICALLD = 0
434 integer :: ntot, ntotl, ntotd
435 integer :: i, ie, ix, iy, iz
436 real(DP),
external :: glmax
439 ntot = nx1*ny1*nz1*nelv
440 ntotl = lx1*ly1*lz1*lelv
444 allocate(xrm1(nx1,ny1,nz1,nelv), ysm1(nx1,ny1,nz1,nelv), ztm1(nx1,ny1,nz1,nelv))
445 if (.not. if_ortho)
then
446 allocate(xsm1(nx1,ny1,nz1,nelv), xtm1(nx1,ny1,nz1,nelv))
447 allocate(yrm1(nx1,ny1,nz1,nelv), ytm1(nx1,ny1,nz1,nelv))
448 allocate(zrm1(nx1,ny1,nz1,nelv), zsm1(nx1,ny1,nz1,nelv))
450 allocate(xsm1(nx1,ny1,nz1,1), xtm1(nx1,ny1,nz1,1))
451 allocate(yrm1(nx1,ny1,nz1,1), ytm1(nx1,ny1,nz1,1))
452 allocate(zrm1(nx1,ny1,nz1,1), zsm1(nx1,ny1,nz1,1))
454 CALL
xyzrst(xrm1,yrm1,zrm1,xsm1,ysm1,zsm1,xtm1,ytm1,ztm1, ifaxis)
458 IF (icalld == 0)
THEN
460 drst(1)=abs(zgm1(2,1)-zgm1(1,1))
463 drst(i)=abs(zgm1(i+1,1)-zgm1(i-1,1))/2.0
467 drsti(nx1)=1.0/drst(nx1)
472 u = 0_dp; v = 0_dp; w = 0_dp
474 allocate(x(lx1,ly1,lz1,lelv), r(lx1,ly1,lz1,lelv))
478 CALL vdot2(u,v1 ,v2 ,rxm1,rym1,ntot)
479 CALL vdot2(r,rxm1,rym1,rxm1,rym1,ntot)
480 CALL vdot2(x,xrm1,yrm1,xrm1,yrm1,ntot)
485 CALL vdot2(v,v1 ,v2 ,sxm1,sym1,ntot)
486 CALL vdot2(r,sxm1,sym1,sxm1,sym1,ntot)
487 CALL vdot2(x,xsm1,ysm1,xsm1,ysm1,ntot)
499 u = v1 * rxm1 + v2 * rym1 + v3 * rzm1
500 r = rxm1 * rxm1 + rym1 * rym1 + rzm1 * rzm1
501 x = xrm1 * xrm1 + yrm1 * yrm1 + zrm1 * zrm1
513 v = v1*sxm1 + v2*sym1 + v3*szm1
514 r = sxm1 * sxm1 + sym1 * sym1 + szm1 * szm1
515 x = xsm1 * xsm1 + ysm1 * ysm1 + zsm1 * zsm1
527 w = v1*txm1 + v2*tym1 + v3*tzm1
538 deallocate(xsm1, xtm1, yrm1, ytm1, zrm1, zsm1)
541 allocate(tmp(lx1,ly1,lz1,lelv))
547 tmp(ix,iy,iz,ie)=abs( v1(ix,iy,iz,ie)*xrm1(ix,iy,iz,ie)*drst(ix) )
558 tmp(ix,iy,iz,ie)=abs( v2(ix,iy,iz,ie)*ysm1(ix,iy,iz,ie)*drst(iy) )
569 tmp(ix,iy,iz,ie)=abs( v3(ix,iy,iz,ie)*ztm1(ix,iy,iz,ie)*drst(iz) )
576 deallocate(xrm1, ysm1, ztm1)
582 u(ix,iy,iz,ie)=abs( u(ix,iy,iz,ie)*drsti(ix) )
583 v(ix,iy,iz,ie)=abs( v(ix,iy,iz,ie)*drsti(iy) )
584 w(ix,iy,iz,ie)=abs( w(ix,iy,iz,ie)*drsti(iz) )
606 use size_m
, only : lx1, ly1, lz1, nx1, ny1, nz1
607 use topol, only : eface1, skpdat
610 real(DP) :: A(lx1,ly1,lz1),B(lx1,ly1)
611 real(DP) :: af(lx1*ly1*lz1), bf(lx1*ly1)
614 integer :: j1, j2, i, jskip2, jf2, js2, jskip1, jf1, js1, iface
618 CALL
dsset(nx1,ny1,nz1)
619 iface = eface1(iface1)
620 js1 = skpdat(1,iface)
621 jf1 = skpdat(2,iface)
622 jskip1 = skpdat(3,iface)
623 js2 = skpdat(4,iface)
624 jf2 = skpdat(5,iface)
625 jskip2 = skpdat(6,iface)
627 af = reshape(a, (/lx1*ly1*lz1/))
628 bf = reshape(b, (/lx1*ly1/))
633 af(j1+lx1*(j2-1)) = af(j1+lx1*(j2-1))*bf(i)
636 a = reshape(af, (/lx1, ly1, lz1/))
652 use size_m
, only : lx1, ly1, lz1, nx1, ny1, nz1
653 use topol, only : eface1, skpdat
655 real(DP) :: A(lx1,ly1,lz1),B(lx1,ly1,lz1),C(lx1,ly1)
656 integer :: iface1, iface, js1, jf1, jskip1, js2, jf2, jskip2
658 real(DP) :: af(lx1*ly1*lz1), bf(lx1*ly1*lz1), cf(lx1*ly1)
659 af = reshape(a, (/lx1*ly1*lz1/))
660 bf = reshape(b, (/lx1*ly1*lz1/))
661 cf = reshape(c, (/lx1*ly1/))
666 CALL
dsset(nx1,ny1,nz1)
667 iface = eface1(iface1)
668 js1 = skpdat(1,iface)
669 jf1 = skpdat(2,iface)
670 jskip1 = skpdat(3,iface)
671 js2 = skpdat(4,iface)
672 jf2 = skpdat(5,iface)
673 jskip2 = skpdat(6,iface)
680 af(j1+lx1*(j2-1)) = bf(j1+lx1*(j2-1))*cf(i)
683 a = reshape(af, (/lx1, ly1, lz1/))
696 use size_m
, only : nx1, ny1, nz1
697 use size_m
, only : lx1, ly1, lz1, lelt
698 use input, only : iftran, param
699 use soln, only : vdiff, vtrans
700 use tstep, only : ifield, nelfld, bd, dt
703 real(DP) :: h1(lx1,ly1,lz1,lelt),h2(lx1,ly1,lz1,lelt)
706 integer :: nel, ntot1
710 ntot1 = nx1*ny1*nz1*nel
714 h1 = vdiff(:,:,:,:,ifield)
715 if (intloc == 0)
then
718 if (ifield == 1 .OR. param(107) == 0)
then
719 h2 = vtrans(:,:,:,:,ifield) * dtbd
721 h2 = vtrans(:,:,:,:,ifield) * dtbd + param(107)
732 CALL
copy(h1,vdiff(1,1,1,1,ifield),ntot1)
734 if (param(107) /= 0)
then
735 write(6,*)
'SPECIAL SETHLM!!',param(107)
737 call
copy(h2,vtrans(1,1,1,1,ifield),ntot1)
752 use size_m
, only : nx1, ny1, nz1
753 use input, only : ifuservp, ifvarp, matype, igroup, iflomach
754 use input, only : cpfld, cpgrp
755 use soln, only : vdiff, vtrans
756 use tstep, only : ifield, nelfld, istep
759 integer :: nxyz1, nel, ntot1, iel, igrp, itype, itest
760 real(DP) :: cdiff, ctrans
761 integer,
external :: iglmax
771 ifvarp(ifield) = .false.
772 if (iflomach) ifvarp(ifield) = .true.
774 if ( .NOT. ifvarp(ifield))
then
777 itype = matype(igrp,ifield)
778 if(itype /= 0) ifvarp(ifield) = .true.
783 if (ifvarp(ifield)) itest = 1
784 itest = iglmax((/itest/),1)
785 if (itest > 0) ifvarp(ifield) = .true.
794 IF (ifmodel .AND. ifkeps)
THEN
795 CALL turbfld(ifkfld,ifefld)
796 IF (ifkfld) CALL tpropk
797 IF (ifefld) CALL tprope
798 IF (ifkfld .OR. ifefld)
return
813 difmin = vlmin(vdiff(1,1,1,iel,ifield),nxyz1)
814 IF (difmin <= 0.0)
THEN
815 WRITE (6,100) difmin,ifield,igrp
819 ELSE IF(matype(igrp,ifield) == 1)
THEN
823 cdiff = cpgrp(igrp,ifield,1)
824 ctrans = cpgrp(igrp,ifield,2)
825 vdiff(:,:,:,iel,ifield) = cdiff
826 vtrans(:,:,:,iel,ifield) = ctrans
827 IF (cdiff <= 0.0)
THEN
828 WRITE(6,100) cdiff,ifield,igrp
829 100
FORMAT(2x,
'ERROR: Non-positive diffusivity (' &
830 ,g12.3,
') specified for field',i2,
', group',i2 &
832 ,/,
'ABORTING in VPROPS',//)
836 ELSE IF(matype(igrp,ifield) == 2)
THEN
837 write(*,*)
"Oops: matype"
843 difmin = vlmin(vdiff(1,1,1,iel,ifield),nxyz1)
844 IF (difmin <= 0.0)
THEN
845 WRITE (6,100) difmin,ifield,igrp
849 ELSE IF(matype(igrp,ifield) == 0)
THEN
853 cdiff = cpfld(ifield,1)
854 ctrans = cpfld(ifield,2)
856 vdiff(:,:,:,iel,ifield) = cdiff
857 vtrans(:,:,:,iel,ifield) = ctrans
859 IF (cdiff <= 0.0)
THEN
860 WRITE(6,200) cdiff,ifield
861 200
FORMAT(2x,
'ERROR: Non-positive diffusivity (' &
862 ,g12.3,
') specified for field',i2,
'.',/ &
863 ,
'ABORTING in VPROPS',//)
872 IF (ifmodel .AND. (ifield == 1 .OR. ifield == 2)) &
882 use mesh, only : ifsolv
903 SUBROUTINE facexv (A1,A2,A3,B1,B2,B3,IFACE1,IOP)
905 use size_m
, only : nx1, ny1, nz1, lx1, ly1, lz1
906 use topol, only : eface1, skpdat
909 real(DP) :: A1(lx1,ly1), A2(lx1,ly1), A3(lx1,ly1)
910 real(DP) :: B1(lx1,ly1,lz1),B2(lx1,ly1,lz1),B3(lx1,ly1,lz1)
911 real(DP) :: A1f(lx1*ly1), A2f(lx1*ly1), A3f(lx1*ly1)
912 real(DP) :: B1f(lx1*ly1*lz1), b2f(lx1*ly1*lz1), b3f(lx1*ly1*lz1)
913 integer :: iface1, iop
915 integer :: j1, j2, i, jskip2, jf2, js2, jskip1, jf1, js1, iface
917 CALL
dsset(nx1,ny1,nz1)
918 iface = eface1(iface1)
919 js1 = skpdat(1,iface)
920 jf1 = skpdat(2,iface)
921 jskip1 = skpdat(3,iface)
922 js2 = skpdat(4,iface)
923 jf2 = skpdat(5,iface)
924 jskip2 = skpdat(6,iface)
928 b1f = reshape(b1, (/lx1*ly1*lz1/))
929 b2f = reshape(b2, (/lx1*ly1*lz1/))
930 b3f = reshape(b3, (/lx1*ly1*lz1/))
934 a1f(i) = b1f(j1+lx1*(j2-1))
935 a2f(i) = b2f(j1+lx1*(j2-1))
936 a3f(i) = b3f(j1+lx1*(j2-1))
939 a1 = reshape(a1f, (/lx1, ly1/))
940 a2 = reshape(a2f, (/lx1, ly1/))
941 a3 = reshape(a3f, (/lx1, ly1/))
943 a1f = reshape(a1, (/lx1*ly1/))
944 a2f = reshape(a2, (/lx1*ly1/))
945 a3f = reshape(a3, (/lx1*ly1/))
949 b1f(j1+lx1*(j2-1)) = a1f(i)
950 b2f(j1+lx1*(j2-1)) = a2f(i)
951 b3f(j1+lx1*(j2-1)) = a3f(i)
954 b1 = reshape(b1f, (/lx1, ly1, lz1/))
955 b2 = reshape(b2f, (/lx1, ly1, lz1/))
956 b3 = reshape(b3f, (/lx1, ly1, lz1/))
964 use geom, only : iflmsf
967 integer,
intent(in) :: ifld
969 IF ( .NOT. iflmsf(ifld))
RETURN
972 CALL sethmsk(hvmask,hfmask,ifld,nel)
973 CALL setcsys(hvmask,hfmask,nel)
980 use size_m
, only : ndim, nelt
981 use input, only : cbc, cdof
984 integer :: nface, ifc, iel
989 cdof(ifc,iel)=cbc(ifc,iel,0)(1:1)
subroutine setdt
Set the new time step. All cases covered.
subroutine compute_cfl(cfl, u, v, w, dt)
Given velocity field (u,v,w) and dt, compute current CFL number.
subroutine faccl3(a, b, c, iface1)
subroutine sethlm(h1, h2, intloc)
Set the variable property arrays H1 and H2 in the Helmholtz equation. (associated with variable IFIEL...
subroutine dsset(nx, ny, nz)
Set up arrays IXCN,ESKIP,SKPDAT,NEDG,NOFFST for new NX,NY,NZ.
subroutine cumax(v1, v2, v3, u, v, w, umax, uxmax)
compute max(U/dx) and max(U * dx)
subroutine bcdirvc(V1, V2, V3, mask1, mask2, mask3)
Apply Dirichlet boundary conditions to surface of vector (V1,V2,V3). Use IFIELD as a guide to which b...
Arrays for direct stiffness summation. cleaned.
subroutine setsolv
Set ifsolv = .FALSE.
subroutine normsc(h1, semi, l2, linf, x, imesh)
Compute error norms of a (scalar) field variable X defined on mesh 1 or mesh 2. The error norms are n...
subroutine vprops
Set material properties Material type: 0 for default (PARAM and PCOND/PRHOCP) 1 for constant props; 2...
subroutine makeuf
Compute and add: (1) user specified forcing function (FX,FY,FZ)
subroutine xyzrst(xrm1, yrm1, zrm1, xsm1, ysm1, zsm1, XTM1, YTM1, ZTM1, IFAXIS)
Compute global-to-local derivatives on mesh 1.
subroutine faccl2(a, b, iface1)
Collocate B with A on the surface IFACE1 of element IE. A is a (NX,NY,NZ) data structure B is a (NX...
subroutine setprop
Set variable property arrays.
subroutine unorm
Norm calculation.
subroutine cvgnlps(ifconv)
Check convergence for non-linear passisve scalar solver. Relevant for solving heat transport problems...
subroutine facexv(A1, A2, A3, B1, B2, B3, IFACE1, IOP)
subroutine opdssum(a, b, c)
subroutine setdtc(umax, uxmax)
Compute new timestep based on CFL-condition.
subroutine normvc(h1, semi, l2, linf, x1, x2, x3)
Compute error norms of a (vector) field variable (X1,X2,X3)