Nek5000
SEM for Incompressible NS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
subs1.F90
Go to the documentation of this file.
1 !-----------------------------------------------------------------------
3 subroutine setdt
4  use kinds, only : dp
5  use size_m, only : nid
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
10  implicit none
11 
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.
17 
18  real(DP) :: dtcfl, dtfs, dtmin, dtmax
19  real(DP), external :: uglmin
20 
21  if (param(12) < 0 .OR. iffxdt) then
22  iffxdt = .true.
23  param(12) = abs(param(12))
24  dt = param(12)
25  dtopf = dt
26  call compute_cfl(umax,vx,vy,vz,1.0)
27  goto 200
28  else IF (param(84) /= 0.0) THEN
29  if (istep < 6) then
30  dt =param(84)
31  dtold=param(84)
32  dtopf=param(84)
33  return
34  else
35  dtold=dt
36  dtopf=dt
37  dt=dtopf*param(85)
38  dt=min(dt,param(12))
39  endif
40  endif
41 
42 ! Find DT=DTCFL based on CFL-condition (if applicable)
43 
44  CALL setdtc(umax, uxmax)
45  re_cell = uxmax / param(2)
46  dtcfl = dt
47 
48 ! Find DTFS based on surface tension (if applicable)
49 
50 ! CALL SETDTFS (DTFS)
51 
52 ! Select appropriate DT
53  dtfs = 0.
54  IF ((dt == 0.) .AND. (dtfs > 0.)) THEN
55  dt = dtfs
56  ELSEIF ((dt > 0.) .AND. (dtfs > 0.)) THEN
57  dt = min(dt,dtfs)
58  ELSEIF ((dt == 0.) .AND. (dtfs == 0.)) THEN
59  dt = 0.
60  IF (ifflow .AND. nid == 0 .AND. ifprint) THEN
61  WRITE (6,*) 'WARNING: CFL-condition & surface tension'
62  WRITE (6,*) ' are not applicable'
63  endif
64  ELSEIF ((dt > 0.) .AND. (dtfs == 0.)) THEN
65  dt = dt
66  ELSE
67  dt = 0.
68  IF (nid == 0) WRITE (6,*) 'WARNING: DT<0 or DTFS<0'
69  IF (nid == 0) WRITE (6,*) ' Reset DT '
70  endif
71 
72 ! Check DT against user-specified input, DTINIT=PARAM(12).
73 
74  IF ((dt > 0.) .AND. (dtinit > 0.)) THEN
75  dt = min(dt,dtinit)
76  ELSEIF ((dt == 0.) .AND. (dtinit > 0.)) THEN
77  dt = dtinit
78  ELSEIF ((dt > 0.) .AND. (dtinit == 0.)) THEN
79  dt = dt
80  ELSEIF ( .NOT. iffxdt) THEN
81  dt = 0.001
82  IF(nid == 0)WRITE (6,*) 'WARNING: Set DT=0.001 (arbitrarily)'
83  endif
84 
85 ! Check if final time (user specified) has been reached.
86 
87  200 IF (time+dt >= fintim .AND. fintim /= 0.0) THEN
88  ! Last step
89  lastep = 1
90  dt = fintim-time
91  IF (nid == 0) WRITE (6,*) 'Final time step = ',dt
92  endif
93 
94  courno = dt*umax
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)
98 
99  ! only change dt if its off by more than 10%
100  if (abs(dt - dtold)/dt < 0.1) dt = dtold
101 
102  ! Put limits on how much DT can change.
103  IF (dtold /= 0.0) THEN
104  dtmin=0.8*dtold
105  dtmax=1.2*dtold
106  dt = min(dtmax,dt)
107  dt = max(dtmin,dt)
108  endif
109  dtold=dt
110 
111 ! IF (PARAM(84).NE.0.0) THEN
112 ! dt=dtopf*param(85)
113 ! dt=min(dt,param(12))
114 ! endif
115 
116  if (iffxdt) dt=dtopf
117  courno = dt*umax
118 
119 ! synchronize time step for multiple sessions
120 !max if (ifneknek) dt=uglmin(dt,1)
121 
122  if (iffxdt .AND. abs(courno) > 10.*abs(ctarg)) then
123  if (nid == 0) write(6,*) 'CFL, Ctarg!',courno,ctarg
124 !max call emerxit
125  endif
126 
127  return
128 end subroutine setdt
129 
130 
131 !----------------------------------------------------------------------
134 !----------------------------------------------------------------------
135 subroutine cvgnlps (ifconv)
136  use kinds, only : dp
137  use input, only : ifnonl
138  use tstep, only : ifield, tnrmh1, tolnl
139  implicit none
140 
141  LOGICAL :: IFCONV
142  real(DP) :: tnorm1, tnorm2, eps
143 
144  IF (ifnonl(ifield)) THEN
145  ifconv = .false.
146  ELSE
147  ifconv = .true.
148  return
149  endif
150 
151  tnorm1 = tnrmh1(ifield-1)
152  CALL unorm
153  tnorm2 = tnrmh1(ifield-1)
154  eps = abs((tnorm2-tnorm1)/tnorm2)
155  IF (eps < tolnl) ifconv = .true.
156 
157  return
158 end subroutine cvgnlps
159 
160 !---------------------------------------------------------------------
162 !---------------------------------------------------------------------
163 subroutine unorm
164  use kinds, only : dp
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
168  implicit none
169 
170  real(DP) :: tden, arg
171 
172  IF (ifield == 1) THEN
173 
174  ! Compute norms of the velocity.
175  ! Compute time mean (L2) of the inverse of the time step.
176  ! Compute L2 in time, H1 in space of the velocity.
177 
178  CALL normvc(vnrmh1,vnrmsm,vnrml2,vnrml8,vx,vy,vz)
179  IF (istep == 0) return
180  IF (istep == 1) THEN
181  dtinvm = 1./dt
182  vmean = vnrml8
183  ELSE
184  tden = time
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)
190  endif
191  ELSE
192 
193  ! Compute norms of a passive scalar
194 
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)
198  tmean(ifield-1) = 0.
199  endif
200 
201  return
202 end subroutine unorm
203 
204 !--------------------------------------------------------------
206 !--------------------------------------------------------------
207 subroutine setdtc(umax, uxmax)
208  use kinds, only : dp
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
217  implicit none
218 
219  real(DP), intent(out) :: umax, uxmax
220  real(DP), allocatable :: u(:,:,:,:), v(:,:,:,:), w(:,:,:,:)
221 
222  REAL(DP), save :: VCOUR
223 
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
229 
230 ! Steady state => all done
231  IF ( .NOT. iftran) THEN
232  ifirst=1
233  lastep=1
234  return
235  endif
236 
237  irst = int(param(46))
238  if (irst > 0) ifirst=1
239 
240 ! First time around
241 
242  IF (ifirst == 0) THEN
243  dt = dtinit
244  IF (ifflow) THEN
245  ifield = 1
246  CALL bcdirvc(vx,vy,vz,v1mask,v2mask,v3mask)
247  endif
248  endif
249  ifirst=ifirst+1
250 
251  dtold = dt
252 
253 ! Convection ?
254 
255 ! Don't enforce Courant condition if there is no convection.
256 
257 
258  iconv=0
259  IF (ifflow .AND. ifnav) iconv=1
260  IF (ifwcno) iconv=1
261  IF (ifheat) THEN
262  DO 10 ipscal=0,npscal
263  IF (ifadvc(ipscal+2)) iconv=1
264  10 END DO
265  endif
266  IF (iconv == 0) THEN
267  dt=0.
268  return
269  endif
270 
271 
272 ! Find Courant and Umax
273 
274 
275  ntot = nx1*ny1*nz1*nelv
276  ntotl = lx1*ly1*lz1*lelv
277  ntotd = ntotl*ndim
278  cold = courno
279  cmax = 1.2*ctarg
280  cmin = 0.8*ctarg
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)
283 
284 ! Zero DT
285 
286  IF (dt == 0.0) THEN
287 
288  IF (umax /= 0.0) THEN
289  dt = ctarg/umax
290  vcour = umax
291  ELSEIF (ifflow) THEN
292 
293  ! We'll use the body force to predict max velocity
294 
295  CALL setprop
296  ifield = 1
297 
298  CALL makeuf
299  CALL opdssum(bfx,bfy,bfz)
300  bfx = bfx * binvm1; bfy = bfy * binvm1; bfz = bfz * binvm1
301  fmax=0.0
302  u = 0._dp
303  DO 600 i=1,ntot
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))
307  600 END DO
308  fmax = glmax(u,ntotd)
309  density = avtran(1)
310  amax = fmax/density
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)
315  IF (amax /= 0.) THEN
316  dt = sqrt(ctarg*dxchar/amax)
317  ELSE
318  IF (nid == 0) &
319  WRITE (6,*) 'CFL: Zero velocity and body force'
320  dt = 0.0
321  return
322  endif
323  ELSEIF (ifwcno) THEN
324  IF (nid == 0) &
325  WRITE (6,*) ' Stefan problem with no fluid flow'
326  dt = 0.0
327  return
328  endif
329 
330  ELSEIF ((dt > 0.0) .AND. (umax /= 0.0)) THEN
331 
332 
333  ! Nonzero DT & nonzero velocity
334 
335 
336  courno = dt*umax
337  vold = vcour
338  vcour = umax
339  IF (ifirst == 1) THEN
340  cold = courno
341  vold = vcour
342  endif
343  cpred = 2.*courno-cold
344 
345  ! Change DT if it is too big or if it is too small
346 
347  ! if (nid.eq.0)
348  ! $write(6,917) dt,umax,vold,vcour,cpred,cmax,courno,cmin
349  ! 917 format(' dt',4f9.5,4f10.6)
350  IF(courno > cmax .OR. cpred > cmax .OR. courno < cmin) THEN
351 
352  a=(vcour-vold)/dt
353  b=vcour
354  ! -C IS Target Courant number
355  c=-ctarg
356  discr=b**2-4*a*c
357  dtold=dt
358  IF(discr <= 0.0)THEN
359  if (nid == 0) &
360  print*,'Problem calculating new DT Discriminant=',discr
361  dt=dt*(ctarg/courno)
362  ! IF(DT.GT.DTOLD) DT=DTOLD
363  ELSE IF(abs((vcour-vold)/vcour) < 0.001)THEN
364  ! Easy: same v as before (LINEARIZED)
365  dt=dt*(ctarg/courno)
366  ! if (nid.eq.0)
367  ! $write(6,918) dt,dthi,dtlow,discr,a,b,c
368  ! 918 format(' d2',4f9.5,4f10.6)
369  ELSE
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
373  dt = min(dthi,dtlow)
374  ! if (nid.eq.0)
375  ! $write(6,919) dt,dthi,dtlow,discr,a,b,c
376  ! 919 format(' d3',4f9.5,4f10.6)
377  ELSE IF(dthi <= 0.0 .AND. dtlow <= 0.0)THEN
378  ! PRINT*,'DTLOW,DTHI',DTLOW,DTHI
379  ! PRINT*,'WARNING: Abnormal DT from CFL-condition'
380  ! PRINT*,' Keep going'
381  dt=dt*(ctarg/courno)
382  ELSE
383  ! Normal case; 1 positive root, one negative root
384  dt = max(dthi,dtlow)
385  ! if (nid.eq.0)
386  ! $write(6,929) dt,dthi,dtlow,discr,a,b,c
387  ! 929 format(' d4',4f9.5,4f10.6)
388  endif
389  endif
390  ! We'll increase gradually-- make it the geometric mean between
391  ! if (nid.eq.0)
392  ! $write(6,939) dt,dtold
393  ! 939 format(' d5',4f9.5,4f10.6)
394  IF (dtold/dt < 0.2) dt = dtold*5
395  endif
396 
397  endif
398 
399  return
400 end subroutine setdtc
401 
405 subroutine cumax (v1,v2,v3,u,v,w,umax, uxmax)
406  use kinds, only : dp
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
412  implicit none
413 
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) ! scratch
418  real(DP), intent(out) :: v(lx1,ly1,lz1,lelv) ! scratch
419  real(DP), intent(out) :: w(lx1,ly1,lz1,lelv) ! scratch
420  real(DP), intent(out) :: umax
421  real(DP), intent(out) :: uxmax
422 
423  real(DP), allocatable, dimension(:,:,:,:) :: &
424  xrm1, xsm1, xtm1, yrm1, ysm1, ytm1, zrm1, zsm1, ztm1
425 
426  real(DP), allocatable :: x(:,:,:,:), r(:,:,:,:)
427  real(DP), allocatable :: tmp(:,:,:,:)
428 
429  real(DP), save :: drst(lx1), drsti(lx1)
430 
431  real(DP) :: U3(3)
432  INTEGER, save :: ICALLD = 0
433 
434  integer :: ntot, ntotl, ntotd
435  integer :: i, ie, ix, iy, iz
436  real(DP), external :: glmax
437 
438 
439  ntot = nx1*ny1*nz1*nelv
440  ntotl = lx1*ly1*lz1*lelv
441  ntotd = ntotl*ndim
442 
443 ! Compute isoparametric partials.
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))
449  else
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))
453  endif
454  CALL xyzrst(xrm1,yrm1,zrm1,xsm1,ysm1,zsm1,xtm1,ytm1,ztm1, ifaxis)
455 
456 ! Compute maximum U/DX
457 
458  IF (icalld == 0) THEN
459  icalld=1
460  drst(1)=abs(zgm1(2,1)-zgm1(1,1))
461  drsti(1)=1.0/drst(1)
462  DO 400 i=2,nx1-1
463  drst(i)=abs(zgm1(i+1,1)-zgm1(i-1,1))/2.0
464  drsti(i)=1.0/drst(i)
465  400 END DO
466  drst(nx1)=drst(1)
467  drsti(nx1)=1.0/drst(nx1)
468  endif
469 
470 ! Zero out scratch arrays U,V,W for ALL declared elements...
471 
472  u = 0_dp; v = 0_dp; w = 0_dp
473 
474  allocate(x(lx1,ly1,lz1,lelv), r(lx1,ly1,lz1,lelv))
475 
476  IF (ndim == 2) THEN
477 #if 0
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)
481  r = r * x
482  r = sqrt(r)
483  u = u / r
484 
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)
488  r = r * x
489  r = sqrt(r)
490  v = v / r
491 #endif
492  ELSE
493 
494  if (if_ortho) then
495  u = v1 * rxm1
496  r = rxm1 * rxm1
497  x = xrm1 * xrm1
498  else
499  u = v1 * rxm1 + v2 * rym1 + v3 * rzm1
500  r = rxm1 * rxm1 + rym1 * rym1 + rzm1 * rzm1
501  x = xrm1 * xrm1 + yrm1 * yrm1 + zrm1 * zrm1
502  endif
503 
504  r = r * x
505  r = sqrt(r)
506  u = u / r
507 
508  if (if_ortho) then
509  v = v2*sym1
510  r = sym1 * sym1
511  x = ysm1 * ysm1
512  else
513  v = v1*sxm1 + v2*sym1 + v3*szm1
514  r = sxm1 * sxm1 + sym1 * sym1 + szm1 * szm1
515  x = xsm1 * xsm1 + ysm1 * ysm1 + zsm1 * zsm1
516  endif
517 
518  r = r * x
519  r = sqrt(r)
520  v = v / r
521 
522  if (if_ortho) then
523  w = v3*tzm1
524  r = tzm1 * tzm1
525  x = ztm1 * ztm1
526  else
527  w = v1*txm1 + v2*tym1 + v3*tzm1
528  r = tzm1 * tzm1
529  x = ztm1 * ztm1
530  endif
531 
532  r = r * x
533  r = sqrt(r)
534  w = w / r
535 
536  endif
537 
538  deallocate(xsm1, xtm1, yrm1, ytm1, zrm1, zsm1)
539  deallocate(x,r)
540 
541  allocate(tmp(lx1,ly1,lz1,lelv))
542 
543  DO ie=1,nelv
544  DO ix=1,nx1
545  DO iy=1,ny1
546  DO iz=1,nz1
547  tmp(ix,iy,iz,ie)=abs( v1(ix,iy,iz,ie)*xrm1(ix,iy,iz,ie)*drst(ix) )
548  enddo
549  enddo
550  enddo
551  END DO
552  u3(1) = maxval(tmp)
553 
554  DO ie=1,nelv
555  DO ix=1,nx1
556  DO iy=1,ny1
557  DO iz=1,nz1
558  tmp(ix,iy,iz,ie)=abs( v2(ix,iy,iz,ie)*ysm1(ix,iy,iz,ie)*drst(iy) )
559  enddo
560  enddo
561  enddo
562  END DO
563  u3(2) = maxval(tmp)
564 
565  DO ie=1,nelv
566  DO ix=1,nx1
567  DO iy=1,ny1
568  DO iz=1,nz1
569  tmp(ix,iy,iz,ie)=abs( v3(ix,iy,iz,ie)*ztm1(ix,iy,iz,ie)*drst(iz) )
570  enddo
571  enddo
572  enddo
573  END DO
574  u3(3) = maxval(tmp)
575  uxmax = glmax(u3,3)
576  deallocate(xrm1, ysm1, ztm1)
577 
578  DO ie=1,nelv
579  DO ix=1,nx1
580  DO iy=1,ny1
581  DO iz=1,nz1
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) )
585  enddo
586  enddo
587  enddo
588  END DO
589 
590  u3(1) = maxval(u)
591  u3(2) = maxval(v)
592  u3(3) = maxval(w)
593  umax = glmax(u3,3)
594 
595  return
596 end subroutine cumax
597 
604 subroutine faccl2(a,b,iface1)
605  use kinds, only : dp
606  use size_m, only : lx1, ly1, lz1, nx1, ny1, nz1
607  use topol, only : eface1, skpdat
608  implicit none
609 
610  real(DP) :: A(lx1,ly1,lz1),B(lx1,ly1)
611  real(DP) :: af(lx1*ly1*lz1), bf(lx1*ly1)
612  integer :: iface1
613 
614  integer :: j1, j2, i, jskip2, jf2, js2, jskip1, jf1, js1, iface
615 
616 ! Set up counters
617 
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)
626 
627  af = reshape(a, (/lx1*ly1*lz1/))
628  bf = reshape(b, (/lx1*ly1/))
629  i = 0
630  DO j2=js2,jf2,jskip2
631  DO j1=js1,jf1,jskip1
632  i = i+1
633  af(j1+lx1*(j2-1)) = af(j1+lx1*(j2-1))*bf(i)
634  enddo
635  END DO
636  a = reshape(af, (/lx1, ly1, lz1/))
637 
638  return
639 end subroutine faccl2
640 
641 subroutine faccl3(a,b,c,iface1)
642 !
643 ! Collocate B with A on the surface IFACE1 of element IE.
644 !
645 ! A is a (NX,NY,NZ) data structure
646 ! B is a (NX,NY,IFACE) data structure
647 ! IFACE1 is in the preprocessor notation
648 ! IFACE is the dssum notation.
649 ! 5 Jan 1989 15:12:22 PFF
650 
651  use kinds, only : dp
652  use size_m, only : lx1, ly1, lz1, nx1, ny1, nz1
653  use topol, only : eface1, skpdat
654 
655  real(DP) :: A(lx1,ly1,lz1),B(lx1,ly1,lz1),C(lx1,ly1)
656  integer :: iface1, iface, js1, jf1, jskip1, js2, jf2, jskip2
657  integer :: i, j2, j1
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/))
662 
663 !
664 ! Set up counters
665 !
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)
674 
675  i = 0
676  DO j2=js2,jf2,jskip2
677  DO j1=js1,jf1,jskip1
678  i = i+1
679  !A(J1,J2,1) = B(J1,J2,1)*C(I,1)
680  af(j1+lx1*(j2-1)) = bf(j1+lx1*(j2-1))*cf(i)
681  enddo
682  enddo
683  a = reshape(af, (/lx1, ly1, lz1/))
684 
685  return
686 end
687 
688 
689 !-----------------------------------------------------------------------
694 subroutine sethlm (h1,h2,intloc)
695  use kinds, only : dp
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
701  implicit none
702 
703  real(DP) :: h1(lx1,ly1,lz1,lelt),h2(lx1,ly1,lz1,lelt)
704  integer :: intloc
705 
706  integer :: nel, ntot1
707  real(DP) :: dtbd
708 
709  nel = nelfld(ifield)
710  ntot1 = nx1*ny1*nz1*nel
711 
712  if (iftran) then
713  dtbd = bd(1)/dt
714  h1 = vdiff(:,:,:,:,ifield)
715  if (intloc == 0) then
716  h2 = 0._dp
717  else
718  if (ifield == 1 .OR. param(107) == 0) then
719  h2 = vtrans(:,:,:,:,ifield) * dtbd
720  else ! unsteady reaction-diffusion type equation
721  h2 = vtrans(:,:,:,:,ifield) * dtbd + param(107)
722  endif
723 
724  endif
725 
726  ! if (ifield.eq.1 .and. ifanls) then ! this should be replaced
727  ! const = 2. ! with a correct stress
728  ! call cmult (h1,const,ntot1) ! formulation
729  ! endif
730 
731  ELSE
732  CALL copy(h1,vdiff(1,1,1,1,ifield),ntot1)
733  h2 = 0._dp
734  if (param(107) /= 0) then
735  write(6,*) 'SPECIAL SETHLM!!',param(107)
736  ! call cfill (h2,param(107),ntot1)
737  call copy(h2,vtrans(1,1,1,1,ifield),ntot1)
738  endif
739  endif
740 
741  return
742 end subroutine sethlm
743 
744 !-----------------------------------------------------------------------
749 !-----------------------------------------------------------------------
750 subroutine vprops
751  use kinds, only : dp
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
757  implicit none
758 
759  integer :: nxyz1, nel, ntot1, iel, igrp, itype, itest
760  real(DP) :: cdiff, ctrans
761  integer, external :: iglmax
762 
763  nxyz1 = nx1*ny1*nz1
764  nel = nelfld(ifield)
765  ntot1 = nxyz1*nel
766 
767  IF (istep == 0) THEN
768 
769  ! First time around, set defaults
770 
771  ifvarp(ifield) = .false.
772  if (iflomach) ifvarp(ifield) = .true.
773 
774  if ( .NOT. ifvarp(ifield)) then ! check all groups
775  do iel=1,nel
776  igrp = igroup(iel)
777  itype = matype(igrp,ifield)
778  if(itype /= 0) ifvarp(ifield) = .true.
779  enddo
780  endif
781 
782  itest = 0 ! test against all processors
783  if (ifvarp(ifield)) itest = 1
784  itest = iglmax((/itest/),1)
785  if (itest > 0) ifvarp(ifield) = .true.
786 
787  endif
788 
789 ! Fill up property arrays every time step
790 
791 ! First, check for turbulence models
792 
793 #if 0
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
799  endif
800 #endif
801 
802 !... No turbulence models, OR current field is not k or e.
803 
804  DO iel=1,nel
805 
806  igrp=igroup(iel)
807 
808  if (ifuservp) then
809 #if 0
810 
811  ! User specified fortran function (pff 2/13/01)
812  CALL nekuvp(iel)
813  difmin = vlmin(vdiff(1,1,1,iel,ifield),nxyz1)
814  IF (difmin <= 0.0) THEN
815  WRITE (6,100) difmin,ifield,igrp
816  CALL exitt
817  endif
818 #endif
819  ELSE IF(matype(igrp,ifield) == 1)THEN
820 
821  ! Constant property within groups of elements
822 
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 &
831  ,' element',i4,'.' &
832  ,/,'ABORTING in VPROPS',//)
833  CALL exitt
834  endif
835 
836  ELSE IF(matype(igrp,ifield) == 2)THEN
837  write(*,*) "Oops: matype"
838 #if 0
839  ! User specified fortran function
840 
841  CALL nekuvp(iel)
842 
843  difmin = vlmin(vdiff(1,1,1,iel,ifield),nxyz1)
844  IF (difmin <= 0.0) THEN
845  WRITE (6,100) difmin,ifield,igrp
846  CALL exitt
847  endif
848 #endif
849  ELSE IF(matype(igrp,ifield) == 0)THEN
850 
851  ! Default constant property
852 
853  cdiff = cpfld(ifield,1)
854  ctrans = cpfld(ifield,2)
855  ! write(6,*) 'vdiff:',ifield,cdiff,ctrans
856  vdiff(:,:,:,iel,ifield) = cdiff
857  vtrans(:,:,:,iel,ifield) = ctrans
858 
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',//)
864  CALL exitt
865  endif
866  endif
867 
868  END DO
869 
870 ! Turbulence models --- sum eddy viscosity/diffusivity
871 #if 0
872  IF (ifmodel .AND. (ifield == 1 .OR. ifield == 2)) &
873  CALL tviscos
874 #endif
875 
876  return
877 end subroutine vprops
878 
879 !-----------------------------------------------------------------------
881 subroutine setsolv
882  use mesh, only : ifsolv
883  implicit none
884 
885  ifsolv = .false.
886  return
887 end subroutine setsolv
888 
889 !-----------------------------------------------------------------------
890 subroutine flush_io
891  return
892 end subroutine flush_io
893 
894 !-----------------------------------------------------------------------
895 !! IOP = 0
896 !! Extract vector (A1,A2,A3) from (B1,B2,B3) on face IFACE1.
897 !! IOP = 1
898 !! Extract vector (B1,B2,B3) from (A1,A2,A3) on face IFACE1.
899 !! A1, A2, A3 have the (NX,NY,NFACE) data structure
900 !! B1, B2, B3 have the (NX,NY,NZ) data structure
901 !! IFACE1 is in the preprocessor notation
902 !! IFACE is the dssum notation.
903 SUBROUTINE facexv (A1,A2,A3,B1,B2,B3,IFACE1,IOP)
904  use kinds, only : dp
905  use size_m, only : nx1, ny1, nz1, lx1, ly1, lz1
906  use topol, only : eface1, skpdat
907  implicit none
908 
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
914 
915  integer :: j1, j2, i, jskip2, jf2, js2, jskip1, jf1, js1, iface
916 
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)
925  i = 0
926 
927  IF (iop == 0) THEN
928  b1f = reshape(b1, (/lx1*ly1*lz1/))
929  b2f = reshape(b2, (/lx1*ly1*lz1/))
930  b3f = reshape(b3, (/lx1*ly1*lz1/))
931  DO j2=js2,jf2,jskip2
932  DO j1=js1,jf1,jskip1
933  i = i+1
934  a1f(i) = b1f(j1+lx1*(j2-1))
935  a2f(i) = b2f(j1+lx1*(j2-1))
936  a3f(i) = b3f(j1+lx1*(j2-1))
937  enddo
938  END DO
939  a1 = reshape(a1f, (/lx1, ly1/))
940  a2 = reshape(a2f, (/lx1, ly1/))
941  a3 = reshape(a3f, (/lx1, ly1/))
942  ELSE
943  a1f = reshape(a1, (/lx1*ly1/))
944  a2f = reshape(a2, (/lx1*ly1/))
945  a3f = reshape(a3, (/lx1*ly1/))
946  DO j2=js2,jf2,jskip2
947  DO j1=js1,jf1,jskip1
948  i = i+1
949  b1f(j1+lx1*(j2-1)) = a1f(i)
950  b2f(j1+lx1*(j2-1)) = a2f(i)
951  b3f(j1+lx1*(j2-1)) = a3f(i)
952  enddo
953  END DO
954  b1 = reshape(b1f, (/lx1, ly1, lz1/))
955  b2 = reshape(b2f, (/lx1, ly1, lz1/))
956  b3 = reshape(b3f, (/lx1, ly1, lz1/))
957  ENDIF
958 
959  RETURN
960 END SUBROUTINE facexv
961 
962 SUBROUTINE updmsys (IFLD)
963  use size_m
964  use geom, only : iflmsf
965  implicit none
966 
967  integer, intent(in) :: ifld
968 
969  IF ( .NOT. iflmsf(ifld)) RETURN
970 #if 0
971  nel = nelfld(ifld)
972  CALL sethmsk(hvmask,hfmask,ifld,nel)
973  CALL setcsys(hvmask,hfmask,nel)
974 #endif
975 
976  RETURN
977 END SUBROUTINE updmsys
978 
979 SUBROUTINE setcdof
980  use size_m, only : ndim, nelt
981  use input, only : cbc, cdof
982  implicit none
983 
984  integer :: nface, ifc, iel
985  nface = 2*ndim
986 
987  DO iel=1,nelt
988  DO ifc=1,nface
989  cdof(ifc,iel)=cbc(ifc,iel,0)(1:1)
990  enddo
991  END DO
992 
993  RETURN
994 END SUBROUTINE setcdof
subroutine setdt
Set the new time step. All cases covered.
Definition: subs1.F90:3
subroutine compute_cfl(cfl, u, v, w, dt)
Given velocity field (u,v,w) and dt, compute current CFL number.
Definition: induct.F90:7
cleaned
Definition: tstep_mod.F90:2
Input parameters from preprocessors.
Definition: input_mod.F90:11
subroutine faccl3(a, b, c, iface1)
Definition: subs1.F90:641
Definition: soln_mod.F90:1
cleaned
Definition: wz_mod.F90:2
subroutine sethlm(h1, h2, intloc)
Set the variable property arrays H1 and H2 in the Helmholtz equation. (associated with variable IFIEL...
Definition: subs1.F90:694
subroutine dsset(nx, ny, nz)
Set up arrays IXCN,ESKIP,SKPDAT,NEDG,NOFFST for new NX,NY,NZ.
Definition: connect1.F90:549
subroutine cumax(v1, v2, v3, u, v, w, umax, uxmax)
compute max(U/dx) and max(U * dx)
Definition: subs1.F90:405
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...
Definition: bdry.F90:588
Arrays for direct stiffness summation. cleaned.
Definition: topol_mod.F90:3
void exitt()
Definition: comm_mpi.F90:411
subroutine setsolv
Set ifsolv = .FALSE.
Definition: subs1.F90:881
subroutine vprops
Set material properties Material type: 0 for default (PARAM and PCOND/PRHOCP) 1 for constant props; 2...
Definition: subs1.F90:750
subroutine xyzrst(xrm1, yrm1, zrm1, xsm1, ysm1, zsm1, XTM1, YTM1, ZTM1, IFAXIS)
Compute global-to-local derivatives on mesh 1.
Definition: coef.F90:820
cleaned
Definition: mesh_mod.F90:2
subroutine copy(a, b, n)
Definition: math.F90:52
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...
Definition: subs1.F90:604
subroutine setprop
Set variable property arrays.
Definition: setprop.F90:5
subroutine unorm
Norm calculation.
Definition: subs1.F90:163
subroutine updmsys(IFLD)
Definition: subs1.F90:962
subroutine cvgnlps(ifconv)
Check convergence for non-linear passisve scalar solver. Relevant for solving heat transport problems...
Definition: subs1.F90:135
subroutine facexv(A1, A2, A3, B1, B2, B3, IFACE1, IOP)
Definition: subs1.F90:903
subroutine setcdof
Definition: subs1.F90:979
Geometry arrays.
Definition: geom_mod.F90:2
subroutine flush_io
Definition: subs1.F90:890
subroutine setdtc(umax, uxmax)
Compute new timestep based on CFL-condition.
Definition: subs1.F90:207