Nek5000
SEM for Incompressible NS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
navier1.F90
Go to the documentation of this file.
1 !-----------------------------------------------------------------------
3 subroutine ctolspl (tolspl,respr)
4  use kinds, only : dp
5  use size_m, only : lelv, lx2, ly2, lz2
6  use size_m, only : nx1, ny1, nz1, nelv, nid
7  use geom, only : binvm1, volvm1
8  use tstep, only : dt, tolpdf, tolps, prelax
9  use soln, only : pmask, vmult
10  implicit none
11 
12  real(DP) :: tolspl
13  REAL(DP) :: RESPR (lx2,ly2,lz2,lelv)
14 
15  real(DP), allocatable :: WORK(:,:,:,:)
16  integer :: ntot1
17  real(DP) :: rinit, tolmin, tolold
18  real(DP), external :: glsc23
19 
20  allocate(work(lx2,ly2,lz2,lelv))
21  ntot1 = nx1*ny1*nz1*nelv
22  work = respr
23  call dssum(work)
24  work = work * pmask
25  rinit = glsc23(work, binvm1, vmult, ntot1)
26  rinit = sqrt(rinit/volvm1)
27  IF (tolpdf > 0.) THEN
28  tolspl = tolpdf
29  tolmin = tolpdf
30  ELSE
31  tolspl = tolps/dt
32  tolmin = rinit*prelax
33  ENDIF
34  IF (tolspl < tolmin) THEN
35  tolold = tolspl
36  tolspl = tolmin
37  IF (nid == 0) &
38  WRITE (6,*) 'Relax the pressure tolerance ',tolspl,tolold
39  ENDIF
40 
41  return
42 end subroutine ctolspl
43 
44 !------------------------------------------------------------------------
47 subroutine ortho (respr)
48  use kinds, only : dp, i8, i4
49  use size_m, only : lx2, ly2, lz2, lelv, nx2, ny2, nz2, nelv
50  use geom, only : ifvcor, ifbcor
51  use input, only : ifldmhd
52  use parallel, only : nelgv
53  use tstep, only : ifield
54  implicit none
55 
56  real(DP) :: respr (lx2,ly2,lz2,lelv)
57  integer(i8) :: ntotg,nxyz2
58  integer :: ntot
59  real(DP) :: rlam
60  real(DP), external :: glsum
61 
62  nxyz2 = nx2*ny2*nz2
63  ntot = int(nxyz2*nelv, kind=i4)
64  ntotg = nxyz2*nelgv
65 
66  if (ifield == 1) then
67  if (ifvcor) then
68  rlam = glsum(respr,ntot)/ntotg
69  respr = respr - rlam
70  endif
71  elseif (ifield == ifldmhd) then
72  if (ifbcor) then
73  rlam = glsum(respr,ntot)/ntotg
74  respr = respr - rlam
75  endif
76  else
77  call exitti('ortho: unaccounted ifield = $',ifield)
78  endif
79 
80  return
81 end subroutine ortho
82 
83 !---------------------------------------------------------------------
87 !---------------------------------------------------------------------
88 subroutine opgrad (out1,out2,out3,inp)
89  use kinds, only : dp
90  use size_m, only : nx2, ny2, nz2, ndim, nelv
91  use size_m, only : lx1, ly1, lz1, lx2, ly2, lz2, nx1, ny1, nz1
92  use geom, only : rxm2, rym2, rzm2, sxm2, sym2, szm2, txm2, tym2, tzm2
93  use geom, only : bm1, jacmi
94  use input, only : ifsplit, ifaxis
95  use mesh, only : if_ortho
96  use dxyz, only : dxm12, dytm12, dztm12
97  use ixyz, only : ixm12, iytm12, iztm12
98  implicit none
99 
100  REAL(DP) :: OUT1 (lx2,ly2,lz2,nelv)
101  REAL(DP) :: OUT2 (lx2,ly2,lz2,nelv)
102  REAL(DP) :: OUT3 (lx2,ly2,lz2,nelv)
103  REAL(DP) :: INP (lx1,ly1,lz1,nelv)
104 
105  real(DP) :: ta1 (lx1*ly1*lz1) &
106  , ta2 (lx1*ly1*lz1) &
107  , ta3 (lx1*ly1*lz1)
108 
109  integer :: iflg, ntot2, i1, i2, e, iz, n1, n2, nxy2, nyz1
110  iflg = 0
111 
112  if (ifsplit .AND. .NOT. ifaxis) then
113  call wgradm1(out1,out2,out3,inp,nelv) ! weak grad on FLUID mesh
114  return
115  endif
116 
117  ntot2 = nx2*ny2*nz2*nelv
118  if (if_ortho) then
119  nxy2 = nx2*ny2
120  n1 = nx2*ny1
121  n2 = nx2*ny2
122  nyz1 = ny1*nz1
123 
124  do e=1,nelv
125  call mxm(dxm12,nx2,inp(:,:,:,e),nx1,ta1,nyz1)
126  i1=1
127  i2=1
128  do iz=1,nz1
129  call mxm(ta1(i1),nx2,iytm12,ny1,ta2(i2),ny2)
130  i1=i1+n1
131  i2=i2+n2
132  enddo
133  call mxm(ta2,nxy2,iztm12,nz1,out1(:,:,:,e),nz2)
134 
135  call mxm(ixm12,nx2,inp(:,:,:,e),nx1,ta3,nyz1) ! reuse ta3 below
136  i1=1
137  i2=1
138  do iz=1,nz1
139  call mxm(ta3(i1),nx2,dytm12,ny1,ta2(i2),ny2)
140  i1=i1+n1
141  i2=i2+n2
142  enddo
143  call mxm(ta2,nxy2,iztm12,nz1,out2(:,:,:,e),nz2)
144 
145  ! re-use ta3 from above
146  i1=1
147  i2=1
148  do iz=1,nz1
149  call mxm(ta3(i1),nx2,iytm12,ny1,ta2(i2),ny2)
150  i1=i1+n1
151  i2=i2+n2
152  enddo
153  call mxm(ta2,nxy2,dztm12,nz1,out3(:,:,:,e),nz2)
154  enddo
155 
156  out1 = out1 * rxm2 * bm1 * jacmi
157  out2 = out2 * sym2 * bm1 * jacmi
158  out3 = out3 * tzm2 * bm1 * jacmi
159 
160  else
161  CALL multd(out1,inp,rxm2,sxm2,txm2,1,iflg)
162  CALL multd(out2,inp,rym2,sym2,tym2,2,iflg)
163  IF (ndim == 3) &
164  CALL multd(out3,inp,rzm2,szm2,tzm2,3,iflg)
165  endif
166 
167  return
168 end subroutine opgrad
169 
170 !-------------------------------------------------------------
172 !-------------------------------------------------------------
173 subroutine cdtp (dtx,x,rm2,sm2,tm2,isd)
174  use kinds, only : dp
175  use size_m, only : lx1, ly1, lz1, lx2, ly2, lz2, lelv
176  use size_m, only : nx1, ny1, nz1, nx2, ny2, nz2, nelv, ndim
177  use ctimer, only : icalld, tcdtp, ncdtp, etime1, dnekclock
178  use dxyz, only : dym12, dam12, dcm12, dxtm12, dzm12
179  use geom, only : ifrzer, jacm2, ym2, jacm1
180  use input, only : ifaxis, ifsplit
181  use ixyz, only : iym12, iam12, icm12
182  use geom, only : bm1, bm2
183  use wz_m, only : w3m2, w2am2, w2cm2
184  implicit none
185 
186  integer :: isd
187  real(DP) :: dtx (lx1,ly1,lz1,lelv)
188  real(DP) :: x (lx2,ly2,lz2,lelv)
189  real(DP) :: rm2 (lx2,ly2,lz2,lelv)
190  real(DP) :: sm2 (lx2,ly2,lz2,lelv)
191  real(DP) :: tm2 (lx2,ly2,lz2,lelv)
192 
193  real(DP) :: wx (lx1,ly1,lz1) &
194  , ta1 (lx1,ly1,lz1) &
195  , ta2 (lx1,ly1,lz1)
196 
197  integer :: e
198  integer :: nxyz1, nxyz2, nxy1, nyz2, n1, n2, ny12, i1, i2, iz
199 
200 #ifndef NOTIMER
201  if (icalld == 0) tcdtp=0.0
202  icalld=icalld+1
203  ncdtp=icalld
204  etime1=dnekclock()
205 #endif
206 
207  nxyz1 = nx1*ny1*nz1
208  nxyz2 = nx2*ny2*nz2
209  nyz2 = ny2*nz2
210  nxy1 = nx1*ny1
211 
212  n1 = nx1*ny1
213  n2 = nx1*ny2
214 
215  do e=1,nelv
216 
217  ! Use the appropriate derivative- and interpolation operator in
218  ! the y-direction (= radial direction if axisymmetric).
219  if (ifaxis) then
220  ny12 = ny1*ny2
221  if (ifrzer(e)) then
222  call copy(iym12,iam12,ny12)
223  call copy(dym12,dam12,ny12)
224  call copy(w3m2,w2am2,nxyz2)
225  else
226  call copy(iym12,icm12,ny12)
227  call copy(dym12,dcm12,ny12)
228  call copy(w3m2,w2cm2,nxyz2)
229  endif
230  endif
231 
232  ! Collocate with weights
233 
234  if(ifsplit) then
235  wx = bm1(:,:,:,e) * x(:,:,:,e) / jacm1(:,:,:,e)
236  else
237  if (ifaxis) then
238  if (ifrzer(e)) then
239  wx = x(:,:,:,e) * bm2(:,:,:,e) / jacm2(:,:,:,e)
240  else
241  wx = w3m2 * x(:,:,:,e) * ym2(:,:,:,e)
242  endif
243  else
244  wx = w3m2 * x(:,:,:,e)
245  endif
246  endif
247 
248  if (ndim == 2) then
249  write(*,*) "Whoops! cdtp"
250 #if 0
251  if ( .NOT. ifdfrm(e) .AND. ifalgn(e)) then
252 
253  if ( ifrsxy(e) .AND. isd == 1 .OR. &
254  .NOT. ifrsxy(e) .AND. isd == 2) then
255 
256  call col3(ta1,wx,rm2(1,e),nxyz2)
257  call mxm(dxtm12,nx1,ta1,nx2,ta2,nyz2)
258  call mxm(ta2,nx1,iym12,ny2,dtx(1,e),ny1)
259  else
260  call col3(ta1,wx,sm2(1,e),nxyz2)
261  call mxm(ixtm12,nx1,ta1,nx2,ta2,nyz2)
262  call mxm(ta2,nx1,dym12,ny2,dtx(1,e),ny1)
263  endif
264  else
265  call col3(ta1,wx,rm2(1,e),nxyz2)
266  call mxm(dxtm12,nx1,ta1,nx2,ta2,nyz2)
267  call mxm(ta2,nx1,iym12,ny2,dtx(1,e),ny1)
268 
269  call col3(ta1,wx,sm2(1,e),nxyz2)
270  call mxm(ixtm12,nx1,ta1,nx2,ta2,nyz2)
271  call mxm(ta2,nx1,dym12,ny2,ta1,ny1)
272 
273  call add2(dtx(1,e),ta1,nxyz1)
274  endif
275 #endif
276  else
277  if (ifsplit) then
278  ta1 = wx * rm2(:,:,:,e)
279  call mxm(dxtm12,nx1,ta1,nx2,dtx(:,:,:,e),nyz2)
280  ta1 = wx * sm2(:,:,:,e)
281  i1 = 1
282  i2 = 1
283  do iz=1,nz2
284  call mxm(ta1(:,:,iz),nx1,dym12,ny2,ta2(:,:,iz),ny1)
285  i1 = i1 + n1
286  i2 = i2 + n2
287  enddo
288  dtx(:,:,:,e) = dtx(:,:,:,e) + ta2
289  ta1 = wx * tm2(:,:,:,e)
290  call mxm(ta1,nxy1,dzm12,nz2,ta2,nz1)
291  dtx(:,:,:,e) = dtx(:,:,:,e) + ta2
292  else
293  write(*,*) "Whoops! cdtp"
294 #if 0
295  call col3(ta1,wx,rm2(1,e),nxyz2)
296  call mxm(dxtm12,nx1,ta1,nx2,ta2,nyz2)
297  i1 = 1
298  i2 = 1
299  do iz=1,nz2
300  call mxm(ta2(i2),nx1,iym12,ny2,ta1(i1),ny1)
301  i1 = i1 + n1
302  i2 = i2 + n2
303  enddo
304  call mxm(ta1,nxy1,izm12,nz2,dtx(1,e),nz1)
305 
306  call col3(ta1,wx,sm2(1,e),nxyz2)
307  call mxm(ixtm12,nx1,ta1,nx2,ta2,nyz2)
308  i1 = 1
309  i2 = 1
310  do iz=1,nz2
311  call mxm(ta2(i2),nx1,dym12,ny2,ta1(i1),ny1)
312  i1 = i1 + n1
313  i2 = i2 + n2
314  enddo
315  call mxm(ta1,nxy1,izm12,nz2,ta2,nz1)
316  call add2(dtx(1,e),ta2,nxyz1)
317 
318  call col3(ta1,wx,tm2(1,e),nxyz2)
319  call mxm(ixtm12,nx1,ta1,nx2,ta2,nyz2)
320  i1 = 1
321  i2 = 1
322  do iz=1,nz2
323  call mxm(ta2(i2),nx1,iym12,ny2,ta1(i1),ny1)
324  i1 = i1 + n1
325  i2 = i2 + n2
326  enddo
327  call mxm(ta1,nxy1,dzm12,nz2,ta2,nz1)
328  call add2(dtx(1,e),ta2,nxyz1)
329 #endif
330  endif
331 
332  endif
333 
334  ! If axisymmetric, add an extra diagonal term in the radial
335  ! direction (only if solving the momentum equations and ISD=2)
336  ! NOTE: NZ1=NZ2=1
337  if (ifaxis) write(*,*) "Oops: ifaxis"
338 #if 0
339  if(ifsplit) then
340 
341  if (ifaxis .AND. (isd == 4)) then
342  call copy(ta1,x(1,e),nxyz1)
343  if (ifrzer(e)) THEN
344  call rzero(ta1, nx1)
345  call mxm(x(1,e),nx1,datm1,ny1,duax,1)
346  call copy(ta1,duax,nx1)
347  endif
348  call col2(ta1,baxm1(1,1,1,e),nxyz1)
349  call add2(dtx(1,e),ta1,nxyz1)
350  endif
351 
352  else
353 
354  if (ifaxis .AND. (isd == 2)) then
355  call col3(ta1,x(1,e),bm2(1,1,1,e),nxyz2)
356  ta = ta / ym2(:,:,:,e)
357  call mxm(ixtm12,nx1,ta1,nx2,ta2,ny2)
358  call mxm(ta2,nx1,iym12,ny2,ta1,ny1)
359  call add2(dtx(1,e),ta1,nxyz1)
360  endif
361 
362  endif
363 #endif
364  enddo
365 
366 #ifndef NOTIMER
367  tcdtp=tcdtp+(dnekclock()-etime1)
368 #endif
369  return
370 end subroutine cdtp
371 
372 !---------------------------------------------------------------------
381 !---------------------------------------------------------------------
382 subroutine multd (dx,x,rm2,sm2,tm2,isd,iflg)
383  use kinds, only : dp
384  use size_m, only : lx2, ly2, lz2, lx1, ly1, lz1, lelv
385  use size_m, only : nx1, ny1, nz1, nx2, ny2, nz2, nelv, ndim
386  use ctimer, only : icalld, tmltd, nmltd, etime1, dnekclock
387  use dxyz, only : dytm12, datm12, dctm12, dxm12, dztm12
388  use geom, only : ifrzer, jacm1
389  use input, only : ifaxis, ifsplit
390  use ixyz, only : iytm12, iatm12, ictm12, iztm12, ixm12
391  use geom, only : bm1
392  use wz_m, only : w3m2, w2am2, w2cm2
393  implicit none
394 
395  integer :: isd, iflg
396  real(DP) :: dx (lx2,ly2,lz2,lelv)
397  real(DP) :: x (lx1,ly1,lz1,lelv)
398  real(DP) :: rm2 (lx2,ly2,lz2,lelv)
399  real(DP) :: sm2 (lx2,ly2,lz2,lelv)
400  real(DP) :: tm2 (lx2,ly2,lz2,lelv)
401 
402  real(DP) :: ta1 (lx1*ly1*lz1) &
403  , ta2 (lx1*ly1*lz1) &
404  , ta3 (lx1*ly1*lz1)
405 
406  integer :: e
407  integer :: nxyz1, nxy2, nxyz2, n1, n2, ny12, i1, i2, iz, nyz1
408 
409 #ifndef NOTIMER
410  if (icalld == 0) tmltd=0.0
411  icalld=icalld+1
412  nmltd=icalld
413  etime1=dnekclock()
414 #endif
415 
416  nyz1 = ny1*nz1
417  nxy2 = nx2*ny2
418  nxyz1 = nx1*ny1*nz1
419  nxyz2 = nx2*ny2*nz2
420 
421  n1 = nx2*ny1
422  n2 = nx2*ny2
423 
424  do e=1,nelv
425 
426  ! Use the appropriate derivative- and interpolation operator in
427  ! the y-direction (= radial direction if axisymmetric).
428  if (ifaxis) then
429  ny12 = ny1*ny2
430  if (ifrzer(e)) then
431  call copy(iytm12,iatm12,ny12)
432  call copy(dytm12,datm12,ny12)
433  call copy(w3m2,w2am2,nxyz2)
434  else
435  call copy(iytm12,ictm12,ny12)
436  call copy(dytm12,dctm12,ny12)
437  call copy(w3m2,w2cm2,nxyz2)
438  endif
439  endif
440 
441  if (ndim == 2) then
442  write(*,*) "Whoops! multd"
443 #if 0
444  if ( .NOT. ifdfrm(e) .AND. ifalgn(e)) then
445 
446  if ( ifrsxy(e) .AND. isd == 1 .OR. &
447  .NOT. ifrsxy(e) .AND. isd == 2) then
448  call mxm(dxm12,nx2,x(1,e),nx1,ta1,nyz1)
449  call mxm(ta1,nx2,iytm12,ny1,dx(1,e),ny2)
450  call col2(dx(1,e),rm2(1,e),nxyz2)
451  else
452  call mxm(ixm12,nx2,x(1,e),nx1,ta1,nyz1)
453  call mxm(ta1,nx2,dytm12,ny1,dx(1,e),ny2)
454  call col2(dx(1,e),sm2(1,e),nxyz2)
455  endif
456  else
457  call mxm(dxm12,nx2,x(1,e),nx1,ta1,nyz1)
458  call mxm(ta1,nx2,iytm12,ny1,dx(1,e),ny2)
459  call col2(dx(1,e),rm2(1,e),nxyz2)
460  call mxm(ixm12,nx2,x(1,e),nx1,ta1,nyz1)
461  call mxm(ta1,nx2,dytm12,ny1,ta3,ny2)
462  call addcol3(dx(1,e),ta3,sm2(1,e),nxyz2)
463  endif
464 #endif
465  else ! 3D
466 
467  ! if (ifsplit) then
468 
469  ! call mxm (dxm12,nx2,x(1,e),nx1,dx(1,e),nyz1)
470  ! call col2 (dx(1,e),rm2(1,e),nxyz2)
471  ! i1=1
472  ! i2=1
473  ! do iz=1,nz1
474  ! call mxm (x(1,e),nx2,dytm12,ny1,ta1(i2),ny2)
475  ! i1=i1+n1
476  ! i2=i2+n2
477  ! enddo
478  ! call addcol3 (dx(1,e),ta1,sm2(1,e),nxyz2)
479  ! call mxm (x(1,e),nxy2,dztm12,nz1,ta1,nz2)
480  ! call addcol3 (dx(1,e),ta1,tm2(1,e),nxyz2)
481 
482  ! else ! PN - PN-2
483 
484  call mxm(dxm12,nx2,x(:,:,:,e),nx1,ta1,nyz1)
485  i1=1
486  i2=1
487  do iz=1,nz1
488  call mxm(ta1(i1),nx2,iytm12,ny1,ta2(i2),ny2)
489  i1=i1+n1
490  i2=i2+n2
491  enddo
492  call mxm(ta2,nxy2,iztm12,nz1,dx(:,:,:,e),nz2)
493  dx(:,:,:,e) = dx(:,:,:,e) * rm2(:,:,:,e)
494 
495  call mxm(ixm12,nx2,x(:,:,:,e),nx1,ta3,nyz1) ! reuse ta3 below
496  i1=1
497  i2=1
498  do iz=1,nz1
499  call mxm(ta3(i1),nx2,dytm12,ny1,ta2(i2),ny2)
500  i1=i1+n1
501  i2=i2+n2
502  enddo
503  call mxm(ta2,nxy2,iztm12,nz1,ta1,nz2)
504  dx(:,:,:,e) = dx(:,:,:,e) + reshape(ta1,(/lx2,ly2,lz2/)) * sm2(:,:,:,e)
505 
506  ! call mxm (ixm12,nx2,x(1,e),nx1,ta1,nyz1) ! reuse ta3 from above
507  i1=1
508  i2=1
509  do iz=1,nz1
510  call mxm(ta3(i1),nx2,iytm12,ny1,ta2(i2),ny2)
511  i1=i1+n1
512  i2=i2+n2
513  enddo
514  call mxm(ta2,nxy2,dztm12,nz1,ta3,nz2)
515  dx(:,:,:,e) = dx(:,:,:,e) + reshape(ta3,(/lx2,ly2,lz2/)) * tm2(:,:,:,e)
516  ! endif
517  endif
518 
519  ! Collocate with the weights on the pressure mesh
520 
521 
522  if(ifsplit) then
523  dx(:,:,:,e) = dx(:,:,:,e) * bm1(:,:,:,e)
524  dx(:,:,:,e) = dx(:,:,:,e) / jacm1(:,:,:,e)
525  else
526  write(*,*) "Whoops! multd"
527 #if 0
528  if ( .NOT. ifaxis) call col2(dx(1,e),w3m2,nxyz2)
529  if (ifaxis) then
530  if (ifrzer(e)) then
531  call col2(dx(1,e),bm2(1,1,1,e),nxyz2)
532  dx(:,e) = dx(:,e) / reshape(jacm2(:,:,:,e), (/nxyz2/))
533  else
534  call col2(dx(1,e),w3m2,nxyz2)
535  call col2(dx(1,e),ym2(1,1,1,e),nxyz2)
536  endif
537  endif
538 #endif
539  endif
540 
541  ! If axisymmetric, add an extra diagonal term in the radial
542  ! direction (ISD=2).
543  ! NOTE: NZ1=NZ2=1
544 
545  if(ifsplit) then
546 
547  if (ifaxis .AND. (isd == 2) .AND. iflg == 1) then
548  write(*,*) "Whoops! multd"
549 #if 0
550  call copy(ta3,x(1,e),nxyz1)
551  if (ifrzer(e)) then
552  call rzero(ta3, nx1)
553  call mxm(x(1,e),nx1,datm1,ny1,duax,1)
554  call copy(ta3,duax,nx1)
555  endif
556  call col2(ta3,baxm1(1,1,1,e),nxyz1)
557  call add2(dx(1,e),ta3,nxyz2)
558 #endif
559  endif
560 
561  else
562  write(*,*) "Whoops! multd"
563 #if 0
564  if (ifaxis .AND. (isd == 2)) then
565  call mxm(ixm12,nx2,x(1,e),nx1,ta1,ny1)
566  call mxm(ta1,nx2,iytm12,ny1,ta2,ny2)
567  call col3(ta3,bm2(1,1,1,e),ta2,nxyz2)
568  call invcol2(ta3,ym2(1,1,1,e),nxyz2)
569  call add2(dx(1,e),ta3,nxyz2)
570  endif
571 #endif
572  endif
573 
574  enddo
575 
576 #ifndef NOTIMER
577  tmltd=tmltd+(dnekclock()-etime1)
578 #endif
579  return
580 end subroutine multd
581 
582 !----------------------------------------------------------------------
584 !----------------------------------------------------------------------
585 subroutine ophx (out1,out2,out3,inp1,inp2,inp3,h1,h2)
586  use kinds, only : dp
587  use size_m, only : lx1, ly1, lz1, ndim
588  use input, only : ifstrs
589  implicit none
590 
591  REAL(DP) :: OUT1 (lx1,ly1,lz1,1)
592  REAL(DP) :: OUT2 (lx1,ly1,lz1,1)
593  REAL(DP) :: OUT3 (lx1,ly1,lz1,1)
594  REAL(DP) :: INP1 (lx1,ly1,lz1,1)
595  REAL(DP) :: INP2 (lx1,ly1,lz1,1)
596  REAL(DP) :: INP3 (lx1,ly1,lz1,1)
597  REAL(DP) :: H1 (lx1,ly1,lz1,1)
598  REAL(DP) :: H2 (lx1,ly1,lz1,1)
599 
600  integer :: imesh
601  imesh = 1
602 
603  IF (ifstrs) THEN
604 #if 0
605  matmod = 0
606  CALL axhmsf(out1,out2,out3,inp1,inp2,inp3,h1,h2,matmod)
607 #endif
608  ELSE
609  CALL axhelm(out1,inp1,h1,h2,imesh,1)
610  CALL axhelm(out2,inp2,h1,h2,imesh,2)
611  IF (ndim == 3) &
612  CALL axhelm(out3,inp3,h1,h2,imesh,3)
613  ENDIF
614 
615  return
616 end subroutine ophx
617 
618 !--------------------------------------------------------------
627 !--------------------------------------------------------------
628 subroutine dudxyz (du,u,rm1,sm1,tm1,jm1,imsh,isd)
629  use kinds, only : dp
630  use size_m, only : lx1, ly1, lz1
631  use size_m, only : nx1, ny1, nz1, nelv, nelt, ndim
632  use dxyz, only : dxm1, dytm1, dztm1
633  use geom, only : jacmi
634  implicit none
635 
636  integer :: imsh, isd
637  REAL(DP) :: DU (lx1,ly1,lz1,*)
638  REAL(DP) :: U (lx1,ly1,lz1,*)
639  REAL(DP) :: RM1 (lx1,ly1,lz1,*)
640  REAL(DP) :: SM1 (lx1,ly1,lz1,*)
641  REAL(DP) :: TM1 (lx1,ly1,lz1,*)
642  REAL(DP) :: JM1 (lx1,ly1,lz1,*)
643 
644  REAL(DP) :: DRST(lx1,ly1,lz1)
645  integer :: nel, nxy1, nyz1, nxyz1, ntot, iel, iz
646 
647  nel = -1
648  IF (imsh == 1) nel = nelv
649  IF (imsh == 2) nel = nelt
650  nxy1 = nx1*ny1
651  nyz1 = ny1*nz1
652  nxyz1 = nx1*ny1*nz1
653  ntot = nxyz1*nel
654 
656  DO 1000 iel=1,nel
657 
658 !max IF (IFAXIS) CALL SETAXDY (IFRZER(IEL) )
659 
660  IF (ndim == 2) THEN
661  CALL mxm(dxm1,nx1,u(1,1,1,iel),nx1,du(1,1,1,iel),nyz1)
662  du(:,:,:,iel) = du(:,:,:,iel) * rm1(:,:,:,iel)
663  CALL mxm(u(1,1,1,iel),nx1,dytm1,ny1,drst,ny1)
664  du(:,:,:,iel) = du(:,:,:,iel) + drst * sm1(:,:,:,iel)
665  ELSE
666  CALL mxm(dxm1,nx1,u(1,1,1,iel),nx1,du(1,1,1,iel),nyz1)
667  du(:,:,:,iel) = du(:,:,:,iel) * rm1(:,:,:,iel)
668  DO 20 iz=1,nz1
669  CALL mxm(u(1,1,iz,iel),nx1,dytm1,ny1,drst(1,1,iz),ny1)
670  20 END DO
671  du(:,:,:,iel) = du(:,:,:,iel) + drst * sm1(:,:,:,iel)
672  CALL mxm(u(1,1,1,iel),nxy1,dztm1,nz1,drst,nz1)
673  du(:,:,:,iel) = du(:,:,:,iel) + drst * tm1(:,:,:,iel)
674  ENDIF
675 
676  1000 END DO
677 
678 ! CALL INVCOL2 (DU,JM1,NTOT)
679  du(:,:,:,1:nel) = du(:,:,:,1:nel) * jacmi
680 
681  return
682 end subroutine dudxyz
683 
684 !---------------------------------------------------------------------
690 !----------------------------------------------------------------------
691 subroutine makef
692  use kinds, only : dp
693  use input, only : ifnav, ifchar, iftran
694  use ctimer, only : tmakef, nmakef, dnekclock
695  implicit none
696  real(DP) :: etime
697 
698  nmakef = nmakef + 1
699  etime = dnekclock()
700  call makeuf
701 ! if (ifnatc) call natconv
702 ! if (ifexplvis .AND. ifsplit) call explstrs
703  etime = etime - dnekclock()
704  if (ifnav .AND. ( .NOT. ifchar)) call advab
705  etime = etime + dnekclock()
706 ! if (ifmvbd) call admeshv
707  if (iftran) then
708  call makeabf
709  endif
710  if ((iftran .AND. .NOT. ifchar) .OR. &
711  (iftran .AND. .NOT. ifnav .AND. ifchar)) call makebdf
712 !max if (ifnav .AND. ifchar .AND. ( .NOT. ifmvbd)) call advchar
713 #if 0
714  if (ifmodel) call twallsh
715 #endif
716  tmakef = tmakef + (dnekclock() - etime)
717  return
718 end subroutine makef
719 
720 !---------------------------------------------------------------------
722 !----------------------------------------------------------------------
723 subroutine makeuf
724  use size_m, only : nelv
725  use geom, only : bm1
726  use soln, only : bfx, bfy, bfz
727  use tstep, only : time, dt
728  implicit none
729 
730  integer :: i
731  time = time-dt
732  CALL nekuf(bfx,bfy,bfz)
733  do i = 1, nelv
734  bfx(:,:,:,i) = bfx(:,:,:,i) * bm1(:,:,:,i)
735  bfy(:,:,:,i) = bfy(:,:,:,i) * bm1(:,:,:,i)
736  bfz(:,:,:,i) = bfz(:,:,:,i) * bm1(:,:,:,i)
737  enddo
738  time = time+dt
739 
740  return
741 end subroutine makeuf
742 
743 subroutine nekuf (f1,f2,f3)
744  use kinds, only : dp
745  use size_m, only : lx1, ly1, lz1, lelv, nx1, ny1, nz1, nelv
746  use nekuse, only : ffx, ffy, ffz
747  use parallel, only : lglel
748  implicit none
749 
750  REAL(DP) :: F1 (lx1,ly1,lz1,lelv)
751  REAL(DP) :: F2 (lx1,ly1,lz1,lelv)
752  REAL(DP) :: F3 (lx1,ly1,lz1,lelv)
753 
754  integer :: i, j, k, ielg, iel
755  f1 = 0._dp; f2 = 0._dp; f3=0._dp
756  DO iel=1,nelv
757  ielg = lglel(iel)
758  DO k=1,nz1
759  DO j=1,ny1
760  DO i=1,nx1
761  CALL nekasgn(i,j,k,iel)
762  CALL userf(i,j,k,ielg)
763  f1(i,j,k,iel) = ffx
764  f2(i,j,k,iel) = ffy
765  f3(i,j,k,iel) = ffz
766  enddo
767  enddo
768  enddo
769  END DO
770 
771  return
772 end subroutine nekuf
773 
774 !---------------------------------------------------------------
777 !---------------------------------------------------------------
778 subroutine advab()
779  use kinds, only : dp
780  use size_m, only : nx1, ny1, nz1, nelv, ndim
781  use geom, only : bm1
782  use soln, only : vx, vy, vz, bfx, bfy, bfz
783  implicit none
784 
785  real(DP), allocatable:: TA (:,:,:,:)
786 
787  integer :: ntot1
788 
789  allocate(ta(nx1,ny1,nz1,nelv))
790  ntot1 = nx1*ny1*nz1*nelv
791  CALL convop(ta,vx)
792  bfx = bfx - bm1*ta
793  CALL convop(ta,vy)
794  bfy = bfy - bm1*ta
795  IF (ndim /= 2) THEN
796  CALL convop(ta,vz)
797  bfz = bfz - bm1*ta
798  ENDIF
799 
800  return
801 end subroutine advab
802 
803 !-----------------------------------------------------------------------
805 subroutine makebdf()
806  use kinds, only : dp
807  use size_m, only : nx1, ny1, nz1, nelv
808  use geom, only : ifgeom
809  use geom, only : bm1, bm1lag
810  use soln, only : vx, vy, vz, vxlag, vylag, vzlag, bfx, bfy, bfz
811  use soln, only : vtrans
812  use tstep, only : dt, ifield, bd, nbd
813  implicit none
814 
815  real(DP), allocatable :: H2 (:,:,:)
816 
817  integer :: ilag, i
818 
819  allocate(h2(nx1,ny1,nz1))
820 
821  do i = 1, nelv
822  h2 = (1./dt) * vtrans(:,:,:,i,ifield)
823  DO ilag=2,nbd
824  IF (ifgeom) THEN
825  bfx(:,:,:,i) = bfx(:,:,:,i) + h2 * (vxlag(:,:,:,i,ilag-1) * bm1lag(:,:,:,i,ilag-1) * bd(ilag+1))
826  bfy(:,:,:,i) = bfy(:,:,:,i) + h2 * (vylag(:,:,:,i,ilag-1) * bm1lag(:,:,:,i,ilag-1) * bd(ilag+1))
827  bfz(:,:,:,i) = bfz(:,:,:,i) + h2 * (vzlag(:,:,:,i,ilag-1) * bm1lag(:,:,:,i,ilag-1) * bd(ilag+1))
828  ELSE
829  bfx(:,:,:,i) = bfx(:,:,:,i) + h2 * (vxlag(:,:,:,i,ilag-1) * bm1(:,:,:,i) * bd(ilag+1))
830  bfy(:,:,:,i) = bfy(:,:,:,i) + h2 * (vylag(:,:,:,i,ilag-1) * bm1(:,:,:,i) * bd(ilag+1))
831  bfz(:,:,:,i) = bfz(:,:,:,i) + h2 * (vzlag(:,:,:,i,ilag-1) * bm1(:,:,:,i) * bd(ilag+1))
832  ENDIF
833  END DO
834  bfx(:,:,:,i) = bfx(:,:,:,i) + h2*vx(:,:,:,i)*bm1(:,:,:,i)*bd(2)
835  bfy(:,:,:,i) = bfy(:,:,:,i) + h2*vy(:,:,:,i)*bm1(:,:,:,i)*bd(2)
836  bfz(:,:,:,i) = bfz(:,:,:,i) + h2*vz(:,:,:,i)*bm1(:,:,:,i)*bd(2)
837  enddo
838 
839  return
840 end subroutine makebdf
841 
842 !-----------------------------------------------------------------------
846 !-----------------------------------------------------------------------
847 subroutine makeabf
848  use kinds, only : dp
849  use size_m, only : nx1, ny1, nz1, nelv, ndim
850  use soln, only : abx1, aby1, abz1, abx2, aby2, abz2, bfx, bfy, bfz, vtrans
851  use tstep, only : ab
852  implicit none
853 
854  real(DP), allocatable :: TA (:,:,:,:)
855 
856  integer :: ntot1, iel
857  real(DP) :: ab0, ab1, ab2
858 
859  allocate(ta(nx1,ny1,nz1,nelv))
860 
861  ntot1 = nx1*ny1*nz1*nelv
862 
863  ab0 = ab(1)
864  ab1 = ab(2)
865  ab2 = ab(3)
866 
867 #if 0
868 ! 11*ntot mops
869 ! 6*ntot flops
870  ta = ab1 * abx1 + ab2 * abx2
871  CALL copy(abx2,abx1,ntot1)
872  CALL copy(abx1,bfx,ntot1)
873  bfx = (ab0 * bfx + ta) * vtrans(:,:,:,:,1) ! multiply by density
874 
875  ta = ab1 * aby1 + ab2 * aby2
876  CALL copy(aby2,aby1,ntot1)
877  CALL copy(aby1,bfy,ntot1)
878  bfy = (ab0 * bfy + ta) * vtrans(:,:,:,:,1) ! multiply by density
879 
880  IF (ndim == 3) THEN
881  ta = ab1 * abz1 + ab2 * abz2
882  CALL copy(abz2,abz1,ntot1)
883  CALL copy(abz1,bfz,ntot1)
884  bfz = (ab0 * bfz + ta) * vtrans(:,:,:,:,1) ! multiply by density
885  ENDIF
886 #else
887 ! 7*ntot mops
888 ! 6*ntot flops
889  do iel = 1, nelv
890  ta(:,:,:,1) = ab1 * abx1(:,:,:,iel) + ab2 * abx2(:,:,:,iel)
891  abx2(:,:,:,iel) = abx1(:,:,:,iel)
892  abx1(:,:,:,iel) = bfx(:,:,:,iel)
893  bfx(:,:,:,iel) = (ab0*bfx(:,:,:,iel) + ta(:,:,:,1)) * vtrans(:,:,:,iel,1)
894  enddo
895 
896  do iel = 1, nelv
897  ta(:,:,:,1) = ab1 * aby1(:,:,:,iel) + ab2 * aby2(:,:,:,iel)
898  aby2(:,:,:,iel) = aby1(:,:,:,iel)
899  aby1(:,:,:,iel) = bfy(:,:,:,iel)
900  bfy(:,:,:,iel) = (ab0*bfy(:,:,:,iel) + ta(:,:,:,1)) * vtrans(:,:,:,iel,1)
901  enddo
902 
903  do iel = 1, nelv
904  ta(:,:,:,1) = ab1 * abz1(:,:,:,iel) + ab2 * abz2(:,:,:,iel)
905  abz2(:,:,:,iel) = abz1(:,:,:,iel)
906  abz1(:,:,:,iel) = bfz(:,:,:,iel)
907  bfz(:,:,:,iel) = (ab0*bfz(:,:,:,iel) + ta(:,:,:,1)) * vtrans(:,:,:,iel,1)
908  enddo
909 #endif
910 
911  return
912 end subroutine makeabf
913 
914 !-----------------------------------------------------------------------
921 !-----------------------------------------------------------------------
922 subroutine setabbd (ab,dtlag,nab,nbd)
923  use kinds, only : dp
924  implicit none
925 
926  REAL(DP), intent(out) :: AB(nab) !>
927  real(DP), intent(in) :: DTLAG(nbd) !>
928  integer, intent(in) :: nab !>
929  integer, intent(in) :: nbd !>
930 
931  real(DP) :: dt0, dt1, dt2, dta, dts, dtb, dtc, dtd, dte
932 
933  IF ( nab == 1 ) THEN
934 
935  ab(1) = 1.0
936 
937  ELSEIF ( nab == 2 ) THEN
938  dt0 = dtlag(1)
939  dt1 = dtlag(2)
940 
941  dta = dt0/dt1
942 
943  IF ( nbd == 1 ) THEN
944 
945  ab(2) = -0.5*dta
946  ab(1) = 1.0 - ab(2)
947 
948  ELSEIF ( nbd == 2 ) THEN
949 
950  ab(2) = -dta
951  ab(1) = 1.0 - ab(2)
952 
953  ENDIF
954 
955  ELSEIF ( nab == 3 ) THEN
956  dt0 = dtlag(1)
957  dt1 = dtlag(2)
958  dt2 = dtlag(3)
959 
960  dts = dt1 + dt2
961  dta = dt0 / dt1
962  dtb = dt1 / dt2
963  dtc = dt0 / dt2
964  dtd = dts / dt1
965  dte = dt0 / dts
966 
967  IF ( nbd == 1 ) THEN
968 
969  ab(3) = dte*( 0.5*dtb + dtc/3. )
970  ab(2) = -0.5*dta - ab(3)*dtd
971  ab(1) = 1.0 - ab(2) - ab(3)
972 
973  ELSEIF ( nbd == 2 ) THEN
974 
975  ab(3) = 2./3.*dtc*(1./dtd + dte)
976  ab(2) = -dta - ab(3)*dtd
977  ab(1) = 1.0 - ab(2) - ab(3)
978 
979  ELSEIF ( nbd == 3 ) THEN
980 
981  ab(3) = dte*(dtb + dtc)
982  ab(2) = -dta*(1.0 + dtb + dtc)
983  ab(1) = 1.0 - ab(2) - ab(3)
984 
985  ENDIF
986 
987  ENDIF
988 
989  return
990 end subroutine setabbd
991 
992 !-----------------------------------------------------------------------
994 !-----------------------------------------------------------------------
995 subroutine setbd (bd,dtbd,nbd)
996  use kinds, only : dp
997  implicit none
998 
999  REAL(dp), intent(out) :: BD(*) !>
1000  real(dp), intent(in) :: DTBD(*) !>
1001  integer , intent(in) :: nbd !>
1002 
1003  integer, PARAMETER :: NDIM = 10
1004  REAL(DP) :: BDMAT(ndim,ndim),BDRHS(ndim), BDF
1005  INTEGER :: IR(ndim),IC(ndim)
1006  integer :: nsys, i, ibd
1007 
1008  bd(1:ndim) = 0._dp; bdf = -1
1009  ! BDF(1) is trivial
1010  IF (nbd == 1) THEN
1011  bd(1) = 1.
1012  bdf = 1.
1013  ! BDF(>1) computed using a linear system
1014  ELSEIF (nbd >= 2) THEN
1015  nsys = nbd+1
1016  CALL bdsys(bdmat,bdrhs,dtbd,nbd,ndim)
1017  CALL lu(bdmat,nsys,ndim,ir,ic)
1018  CALL solve(bdrhs,bdmat,1,nsys,ndim,ir,ic)
1019  DO 30 i=1,nbd
1020  bd(i) = bdrhs(i)
1021  30 END DO
1022  bdf = bdrhs(nbd+1)
1023  ENDIF
1024 
1025  ! Normalize
1026  DO ibd=nbd,1,-1
1027  bd(ibd+1) = bd(ibd)
1028  END DO
1029  bd(1) = 1.
1030  DO ibd=1,nbd+1
1031  bd(ibd) = bd(ibd)/bdf
1032  END DO
1033 ! write(6,1) (bd(k),k=1,nbd+1)
1034 ! 1 format('bd:',1p8e13.5)
1035 
1036  return
1037 end subroutine setbd
1038 
1040 subroutine bdsys (a,b,dt,nbd,ndim)
1041  use kinds, only : dp
1042  implicit none
1043 
1044  integer :: nbd, ndim
1045  REAL(DP) :: A(ndim,9),B(9),DT(9)
1046 
1047  integer :: n, j, k, i
1048  real(DP) :: sumdt
1049  a = 0._dp
1050  n = nbd+1
1051  DO j=1,nbd
1052  a(1,j) = 1.
1053  END DO
1054  a(1,nbd+1) = 0.
1055  b(1) = 1.
1056  DO j=1,nbd
1057  sumdt = 0.
1058  DO k=1,j
1059  sumdt = sumdt+dt(k)
1060  END DO
1061  a(2,j) = sumdt
1062  END DO
1063  a(2,nbd+1) = -dt(1)
1064  b(2) = 0.
1065  DO i=3,nbd+1
1066  DO j=1,nbd
1067  sumdt = 0.
1068  DO k=1,j
1069  sumdt = sumdt+dt(k)
1070  END DO
1071  a(i,j) = sumdt**(i-1)
1072  END DO
1073  a(i,nbd+1) = 0.
1074  b(i) = 0.
1075  END DO
1076  return
1077 end subroutine bdsys
1078 
1079 !-------------------------------------------------------------------
1081 !-------------------------------------------------------------------
1082 subroutine tauinit (tau,ilag)
1083  use kinds, only : dp
1084  use tstep, only : nbd, dtlag
1085  implicit none
1086 
1087  real(DP) :: tau
1088  integer :: ilag
1089  integer :: i
1090 
1091  tau = 0.
1092  DO 10 i=nbd,ilag+1,-1
1093  tau = tau+dtlag(i)
1094  10 END DO
1095  return
1096 end subroutine tauinit
1097 
1098 !-----------------------------------------------------------------------
1100 !-----------------------------------------------------------------------
1101 subroutine lagvel
1102  use size_m, only : nx1, ny1, nz1, nelv, ndim
1103  use soln, only : vxlag, vylag, vzlag, vx, vy, vz
1104  implicit none
1105 
1106  integer :: ntot1, ilag
1107  ntot1 = nx1*ny1*nz1*nelv
1108 
1109 ! DO 100 ILAG=NBDINP-1,2,-1
1110  DO 100 ilag=3-1,2,-1
1111  CALL copy(vxlag(1,1,1,1,ilag),vxlag(1,1,1,1,ilag-1),ntot1)
1112  CALL copy(vylag(1,1,1,1,ilag),vylag(1,1,1,1,ilag-1),ntot1)
1113  IF (ndim == 3) &
1114  CALL copy(vzlag(1,1,1,1,ilag),vzlag(1,1,1,1,ilag-1),ntot1)
1115  100 END DO
1116 
1117  CALL opcopy(vxlag,vylag,vzlag,vx,vy,vz)
1118 
1119  return
1120 end subroutine lagvel
1121 
1122 !----------------------------------------------------------------------
1124 !----------------------------------------------------------------------
1125 subroutine setordbd
1126  use tstep, only : nbdinp, nbd, istep
1127  implicit none
1128 
1129 ! IF (IFSPLIT .OR. NBDINP.EQ.0) THEN undid hardwire, 3/6/92 pff
1130  IF ( nbdinp < 1) THEN
1131  nbd = 1
1132  ELSE
1133  IF ((istep == 0) .OR. (istep == 1)) nbd = 1
1134  IF ((istep > 1) .AND. (istep <= nbdinp)) nbd = istep
1135  IF (istep > nbdinp) nbd = nbdinp
1136  ENDIF
1137 
1138  return
1139 end subroutine setordbd
1140 
1141 !---------------------------------------------------------------
1149 !---------------------------------------------------------------
1150 subroutine normsc (h1,semi,l2,linf,x,imesh)
1151  use kinds, only : dp
1152  use size_m, only : lx1, ly1, lz1, lelt
1153  use size_m, only : nx1, ny1, nz1, nelv, nelt, ndim
1154  use geom, only : bm1, voltm1, volvm1
1155  use ctimer, only : tnmsc, nnmsc, dnekclock
1156  implicit none
1157 
1158  real(DP) :: h1, semi, l2, linf
1159  real(DP), intent(in) :: X (lx1,ly1,lz1,*)
1160  integer :: imesh
1161 
1162  real(DP), allocatable, dimension(:,:,:,:) :: y, ta1, ta2
1163  REAL(DP) :: LENGTH, vol
1164  integer :: nel, nxyz1, ntot1
1165  real(DP), external :: glamax, glsum
1166  real(DP) :: etime
1167 
1168  nnmsc = nnmsc + 1
1169  etime = dnekclock()
1170 
1171  allocate(y(lx1,ly1,lz1,lelt), ta1(lx1,ly1,lz1,lelt), ta2(lx1,ly1,lz1,lelt))
1172 
1173  IF (imesh == 1) THEN
1174  nel = nelv
1175  vol = volvm1
1176  ELSEIF (imesh == 2) THEN
1177  nel = nelt
1178  vol = voltm1
1179  else
1180  nel = -1
1181  vol = -1.
1182  write(*,*) "IMESH \notin {1,2}"
1183  ENDIF
1184 
1185  length = vol**(1./(ndim))
1186  nxyz1 = nx1*ny1*nz1
1187  ntot1 = nxyz1*nel
1188 
1189  h1 = 0.
1190  semi = 0.
1191  l2 = 0.
1192  linf = 0.
1193 
1194  linf = glamax(x,ntot1)
1195 
1196  ta1 = x(:,:,:,1:nel)*x(:,:,:,1:nel) * bm1
1197  l2 = glsum(ta1,ntot1)
1198  IF (l2 < 0.0) l2 = 0.
1199 
1200  ta1 = 1._dp; ta2 = 0._dp
1201  etime = etime - dnekclock()
1202  CALL axhelm(y,x,ta1,ta2,imesh,1)
1203  etime = etime + dnekclock()
1204  ta1 = y * x(:,:,:,1:nel)
1205  semi = glsum(ta1,ntot1)
1206  IF (semi < 0.0) semi = 0.
1207 
1208  h1 = sqrt((semi*length**2+l2)/vol)
1209  semi = sqrt(semi/vol)
1210  l2 = sqrt(l2/vol)
1211  IF (h1 < 0.) h1 = 0.
1212  tnmsc = tnmsc + (dnekclock() - etime)
1213 
1214  return
1215 end subroutine normsc
1216 
1217 !---------------------------------------------------------------
1219 ! defined on mesh 1 (velocity mesh only !)
1220 ! The error norms are normalized with respect to the volume
1221 ! (except for Linf).
1222 !---------------------------------------------------------------
1223 subroutine normvc (h1,semi,l2,linf,x1,x2,x3)
1224  use kinds, only : dp
1225  use size_m, only : nx1, ny1, nz1, nelv, ndim
1226  use size_m, only : lx1, ly1, lz1, lelt
1227  use geom, only : volvm1, bm1
1228  use ctimer, only : tnmvc, nnmvc, dnekclock
1229  implicit none
1230 
1231  REAL(DP) :: H1,SEMI,L2,LINF
1232  REAL(DP) :: X1 (lx1,ly1,lz1,lelt)
1233  REAL(DP) :: X2 (lx1,ly1,lz1,lelt)
1234  REAL(DP) :: X3 (lx1,ly1,lz1,lelt)
1235 
1236  real(DP), allocatable, dimension(:,:,:,:) :: Y1, Y2, Y3, TA1, TA2
1237  REAL(DP) :: LENGTH
1238  integer :: imesh, nel, nxyz1, ntot1
1239  real(DP) :: vol
1240  real(DP), external :: glamax, glsum
1241  real(DP) :: etime
1242 
1243  nnmvc = nnmvc + 1
1244  etime = dnekclock()
1245 
1246  imesh = 1
1247  nel = nelv
1248  vol = volvm1
1249  length = vol**(1./(ndim))
1250  nxyz1 = nx1*ny1*nz1
1251  ntot1 = nxyz1*nel
1252 
1253  h1 = 0.
1254  semi = 0.
1255  l2 = 0.
1256  linf = 0.
1257 
1258  allocate(y1(lx1,ly1,lz1,lelt) &
1259  ,y2(lx1,ly1,lz1,lelt) &
1260  ,y3(lx1,ly1,lz1,lelt) &
1261  ,ta1(lx1,ly1,lz1,lelt) &
1262  ,ta2(lx1,ly1,lz1,lelt) )
1263 
1264 
1265  IF (ndim == 3) THEN
1266  ta1 = x1*x1 + x2*x2 + x3*x3
1267  else
1268  ta1 = x1*x1 + x2*x2
1269  ENDIF
1270  linf = glamax(ta1,ntot1)
1271  linf = sqrt( linf )
1272 
1273  ta1 = ta1 * bm1
1274  l2 = glsum(ta1,ntot1)
1275  IF (l2 < 0.0) l2 = 0.
1276 
1277  ta1 = 1._dp; ta2 = 0._dp
1278  etime = etime - dnekclock()
1279  CALL ophx(y1,y2,y3,x1,x2,x3,ta1,ta2)
1280  etime = etime + dnekclock()
1281  IF (ndim == 3) THEN
1282  ta1 = y1*x1 + y2*x2 + y3*x3
1283  else
1284  ta1 = y1*x1 + y2*x2
1285  ENDIF
1286 
1287  semi = glsum(ta1,ntot1)
1288  IF (semi < 0.0) semi = 0.
1289 
1290  h1 = sqrt((semi*length**2+l2)/vol)
1291  semi = sqrt(semi/vol)
1292  l2 = sqrt(l2 /vol)
1293  IF (h1 < 0.) h1 = 0.
1294 
1295  tnmvc = tnmvc + (dnekclock() - etime)
1296 
1297  return
1298 end subroutine normvc
1299 
1300 subroutine opcolv (a1,a2,a3,c)
1301  use kinds, only : dp
1302  use size_m, only : nx1, ny1, nz1, nelv, ndim
1303  use opctr, only : isclld, nrout, myrout, rname, dct, ncall, dcount
1304  implicit none
1305  REAL(DP) :: A1(1),A2(1),A3(1),C(1)
1306  integer :: ntot1, i, isbcnt
1307 
1308  ntot1=nx1*ny1*nz1*nelv
1309 
1310 #ifndef NOTIMER
1311  if (isclld == 0) then
1312  isclld=1
1313  nrout=nrout+1
1314  myrout=nrout
1315  rname(myrout) = 'opcolv'
1316  endif
1317 
1318  isbcnt = ntot1*ndim
1319  dct(myrout) = dct(myrout) + (isbcnt)
1320  ncall(myrout) = ncall(myrout) + 1
1321  dcount = dcount + (isbcnt)
1322 #endif
1323 
1324  IF (ndim == 3) THEN
1325  DO 100 i=1,ntot1
1326  a1(i)=a1(i)*c(i)
1327  a2(i)=a2(i)*c(i)
1328  a3(i)=a3(i)*c(i)
1329  100 END DO
1330  ELSE
1331  DO 200 i=1,ntot1
1332  a1(i)=a1(i)*c(i)
1333  a2(i)=a2(i)*c(i)
1334  200 END DO
1335  ENDIF
1336  return
1337 end subroutine opcolv
1338 
1339 subroutine opcopy (a1,a2,a3,b1,b2,b3)
1340  use kinds, only : dp
1341  use size_m
1342  implicit none
1343  REAL(DP) :: A1(1),A2(1),A3(1),B1(1),B2(1),B3(1)
1344  integer :: ntot1
1345  ntot1=nx1*ny1*nz1*nelv
1346  CALL copy(a1,b1,ntot1)
1347  CALL copy(a2,b2,ntot1)
1348  IF(ndim == 3)CALL copy(a3,b3,ntot1)
1349  return
1350 end subroutine opcopy
1351 
1352 !-----------------------------------------------------------------------
1353 subroutine opdssum (a,b,c)! NOTE: opdssum works on FLUID/MHD arrays only!
1354  use kinds, only : dp
1355  use input, only : ifcyclic
1356  implicit none
1357 
1358  real(DP) :: a(1),b(1),c(1)
1359 
1360  if (ifcyclic) then
1361  write(*,*) "Oops: ifcyclic"
1362 #if 0
1363  call rotate_cyc(a,b,c,1)
1364  call vec_dssum(a,b,c,nx1,ny1,nz1)
1365  call rotate_cyc(a,b,c,0)
1366 #endif
1367  else
1368  call vec_dssum(a,b,c)
1369  endif
1370 
1371  return
1372 end subroutine opdssum
1373 
1374 !-----------------------------------------------------------------------
1375 subroutine opdsop (a,b,c,op)! opdsop works on FLUID/MHD arrays only!
1376  use kinds, only : dp
1377  use input, only : ifcyclic
1378  implicit none
1379 
1380  real(DP) :: a(1),b(1),c(1)
1381  character(3) :: op
1382 
1383  if (ifcyclic) then
1384  if (op == '* ' .OR. op == 'mul' .OR. op == 'MUL') then
1385  call vec_dsop(a,b,c,op)
1386  else
1387  write(*,*) "Oops: op"
1388 #if 0
1389  call rotate_cyc(a,b,c,1)
1390  call vec_dsop(a,b,c,nx1,ny1,nz1,op)
1391  call rotate_cyc(a,b,c,0)
1392 #endif
1393  endif
1394  else
1395  call vec_dsop(a,b,c,op)
1396  endif
1397 
1398  return
1399 end subroutine opdsop
1400 
1401 !-----------------------------------------------------------------------
1402 subroutine transpose(a,lda,b,ldb)
1403  use kinds, only : dp
1404  implicit none
1405  integer :: lda, ldb
1406  real(DP) :: a(lda,*),b(ldb,*)
1407  integer :: i, j
1408 
1409  do j=1,ldb
1410  do i=1,lda
1411  a(i,j) = b(j,i)
1412  enddo
1413  enddo
1414  return
1415 end subroutine transpose
1416 
1417 !-----------------------------------------------------------------------
1419 ! using the skew-symmetric formulation.
1420 ! The field variable FI is defined on mesh M1 (GLL) and
1421 ! the velocity field is assumed given.
1422 subroutine convop(conv,fi)
1423  use kinds, only : dp
1424  use ctimer, only : icalld, tadvc, nadvc, etime1, dnekclock
1425  use size_m, only : lx1, ly1, lz1
1426  use size_m, only : nx1, ny1, nz1, nelv
1427  use dealias, only : vxd, vyd, vzd
1428  use input, only : param, ifpert
1429  use geom, only : bm1
1430  use soln, only : vx, vy, vz
1431  use tstep, only : nelfld, ifield
1432  implicit none
1433 
1434 ! Arrays in parameter list
1435  REAL(DP) :: CONV (lx1,ly1,lz1,*)
1436  REAL(DP) :: FI (lx1,ly1,lz1,*)
1437 
1438  integer :: nxyz1, ntot1, ntotz
1439 
1440 #ifndef NOTIMER
1441  nadvc=nadvc + 1
1442  etime1=dnekclock()
1443 #endif
1444 
1445  nxyz1 = nx1*ny1*nz1
1446  ntot1 = nx1*ny1*nz1*nelv
1447  ntotz = nx1*ny1*nz1*nelfld(ifield)
1448 
1449  conv(:,:,:,1:nelfld(ifield)) = 0._dp
1450 
1451  if (param(86) /= 0.0) then ! skew-symmetric form
1452 !max call convopo(conv,fi)
1453  goto 100
1454  endif
1455 
1456 ! write(6,*) istep,param(99),' CONVOP',ifpert
1457 ! ip99 = param(99)
1458 ! if (istep.gt.5) call exitti(' CONVOP dbg: $',ip99)
1459 
1460  if (param(99) == 2 .OR. param(99) == 3) then
1461 !max call conv1d(conv,fi) ! use dealiased form
1462  elseif (param(99) == 4) then
1463  if (ifpert) then
1464  etime1 = etime1 - dnekclock()
1465  call convect_new(conv,fi, .false. ,vx,vy,vz, .false. )
1466  etime1 = etime1 + dnekclock()
1467  else
1468  etime1 = etime1 - dnekclock()
1469  call convect_new(conv,fi, .false. ,vxd,vyd,vzd, .true. )
1470  etime1 = etime1 + dnekclock()
1471  endif
1472  conv(:,:,:,1:nelv) = conv(:,:,:,1:nelv) / bm1 ! local mass inverse
1473  elseif (param(99) == 5) then
1474 !max call convect_cons(conv,fi, .FALSE. ,vx,vy,vz, .FALSE. )
1475  conv(:,:,:,1:nelv) = conv(:,:,:,1:nelv) / bm1 ! local mass inverse
1476  else
1477 !max call conv1 (conv,fi) ! use the convective form
1478  endif
1479 
1480  100 continue
1481 
1482 #ifndef NOTIMER
1483  tadvc=tadvc+(dnekclock()-etime1)
1484 #endif
1485 
1486  return
1487 end subroutine convop
1488 
1489 !-----------------------------------------------------------------------
1492 !---------------------------------------------------------------------
1493 subroutine opdiv(outfld,inpx,inpy,inpz)
1494  use kinds, only : dp
1495  use size_m, only : lx1, ly1, lz1, lx2, ly2, lz2, lelv
1496  use size_m, only : nx2, ny2, nz2, nelv, ndim, nx1, ny1, nz1
1497  use geom, only : rxm2, rym2, rzm2, sxm2, sym2, szm2, txm2, tym2, tzm2
1498  use mesh, only : if_ortho
1499  use geom, only : bm1, jacmi
1500  use dxyz, only : dxm12, dytm12, dztm12
1501  use ixyz, only : ixm12, iytm12, iztm12
1502 
1503  implicit none
1504 
1505  real(DP) :: outfld (lx2,ly2,lz2,nelv)
1506  real(DP) :: inpx (lx1,ly1,lz1,nelv)
1507  real(DP) :: inpy (lx1,ly1,lz1,nelv)
1508  real(DP) :: inpz (lx1,ly1,lz1,nelv)
1509 
1510  real(DP), allocatable :: work (:,:,:,:)
1511 
1512  real(DP) :: ta1 (lx1*ly1*lz1) &
1513  , ta2 (lx1*ly1*lz1) &
1514  , ta3 (lx1*ly1*lz1)
1515  integer :: iflg, ntot2, i1, i2, e, iz, n1, n2, nxy2, nyz1
1516 
1517  allocate(work(lx2,ly2,lz2,lelv))
1518 
1519  iflg = 1
1520 
1521  ntot2 = nx2*ny2*nz2*nelv
1522  if (if_ortho) then
1523  nxy2 = nx2*ny2
1524  n1 = nx2*ny1
1525  n2 = nx2*ny2
1526  nyz1 = ny1*nz1
1527  do e=1,nelv
1528  call mxm(dxm12,nx2,inpx(:,:,:,e),nx1,ta1,nyz1)
1529  i1=1
1530  i2=1
1531  do iz=1,nz1
1532  call mxm(ta1(i1),nx2,iytm12,ny1,ta2(i2),ny2)
1533  i1=i1+n1
1534  i2=i2+n2
1535  enddo
1536  call mxm(ta2,nxy2,iztm12,nz1,outfld(:,:,:,e),nz2)
1537  outfld(:,:,:,e) = outfld(:,:,:,e) * rxm2(:,:,:,e)
1538 
1539  call mxm(ixm12,nx2,inpy(:,:,:,e),nx1,ta3,nyz1) ! reuse ta3 below
1540  i1=1
1541  i2=1
1542  do iz=1,nz1
1543  call mxm(ta3(i1),nx2,dytm12,ny1,ta2(i2),ny2)
1544  i1=i1+n1
1545  i2=i2+n2
1546  enddo
1547  call mxm(ta2,nxy2,iztm12,nz1,ta1,nz2)
1548  outfld(:,:,:,e) = outfld(:,:,:,e) + reshape(ta1,(/lx2,ly2,lz2/)) * sym2(:,:,:,e)
1549 
1550  call mxm(ixm12,nx2,inpz(:,:,:,e),nx1,ta1,nyz1)
1551  i1=1
1552  i2=1
1553  do iz=1,nz1
1554  call mxm(ta3(i1),nx2,iytm12,ny1,ta2(i2),ny2)
1555  i1=i1+n1
1556  i2=i2+n2
1557  enddo
1558  call mxm(ta2,nxy2,dztm12,nz1,ta3,nz2)
1559  outfld(:,:,:,e) = outfld(:,:,:,e) + reshape(ta3,(/lx2,ly2,lz2/)) * tzm2(:,:,:,e)
1560  enddo
1561  outfld = outfld * bm1 * jacmi
1562 
1563  else
1564  call multd(work,inpx,rxm2,sxm2,txm2,1,iflg)
1565  call copy(outfld,work,ntot2)
1566  call multd(work,inpy,rym2,sym2,tym2,2,iflg)
1567  outfld = outfld + work
1568  if (ndim == 3) then
1569  call multd(work,inpz,rzm2,szm2,tzm2,3,iflg)
1570  outfld = outfld + work
1571  endif
1572  endif
1573 
1574  return
1575 end subroutine opdiv
1576 
1577 !-----------------------------------------------------------------------
1579 subroutine wgradm1(ux,uy,uz,u,nel) ! weak form of grad
1580  use kinds, only : dp
1581  use size_m, only : lx1, ly1, lz1, nx1
1582  use dxyz, only : dxm1, dxtm1
1583  use geom, only : rxm1, sxm1, txm1, rym1, sym1, tym1, rzm1, szm1, tzm1
1584  use input, only : if3d
1585  use wz_m, only : w3m1
1586  use mesh, only : if_ortho
1587  implicit none
1588 
1589  integer, parameter :: lxyz=lx1*ly1*lz1
1590  real(DP) :: ux(lx1,ly1,lz1,*),uy(lx1,ly1,lz1,*),uz(lx1,ly1,lz1,*),u(lxyz,*)
1591 
1592  real(DP) :: ur(lx1,ly1,lz1),us(lx1,ly1,lz1),ut(lx1,ly1,lz1)
1593 
1594  integer :: e, n, nel
1595 
1596  n = nx1-1
1597  do e=1,nel
1598  if (if3d) then
1599  call local_grad3(ur,us,ut,u,n,e,dxm1,dxtm1)
1600  if (if_ortho) then
1601  ux(:,:,:,e) = w3m1*(ur*rxm1(:,:,:,e))
1602  uy(:,:,:,e) = w3m1*(us*sym1(:,:,:,e))
1603  uz(:,:,:,e) = w3m1*(ut*tzm1(:,:,:,e))
1604  else
1605  ux(:,:,:,e) = w3m1*(ur*rxm1(:,:,:,e) + us*sxm1(:,:,:,e) + ut*txm1(:,:,:,e))
1606  uy(:,:,:,e) = w3m1*(ur*rym1(:,:,:,e) + us*sym1(:,:,:,e) + ut*tym1(:,:,:,e))
1607  uz(:,:,:,e) = w3m1*(ur*rzm1(:,:,:,e) + us*szm1(:,:,:,e) + ut*tzm1(:,:,:,e))
1608  endif
1609  else
1610 #if 0
1611  if (ifaxis) then
1612  call setaxdy(ifrzer(e)) ! reset dytm1
1613  call setaxw1(ifrzer(e)) ! reset w3m1
1614  endif
1615 
1616  call local_grad2(ur,us,u,n,e,dxm1,dytm1)
1617 
1618  do i=1,lxyz
1619  ux(i,e) =w3m1(i,1,1)*(ur(i)*rxm1(i,1,1,e) &
1620  + us(i)*sxm1(i,1,1,e) )
1621  uy(i,e) =w3m1(i,1,1)*(ur(i)*rym1(i,1,1,e) &
1622  + us(i)*sym1(i,1,1,e) )
1623  enddo
1624 #endif
1625  endif
1626  enddo
1627 
1628  return
1629 end subroutine wgradm1
1630 
1631 !-----------------------------------------------------------------------
1634 subroutine wlaplacian(out,a,diff,ifld)
1635  use kinds, only : dp
1636  use size_m, only : lx1, ly1, lz1, lelt, nx1, ny1, nz1
1637  use input, only : iftmsh
1638  use tstep, only : ifield, nelfld, imesh
1639  implicit none
1640 
1641  real(DP) :: out(lx1,ly1,lz1,*),a(*),diff(*)
1642  real(DP), allocatable :: wrk(:,:,:,:)
1643  real(DP), allocatable :: h2(:,:,:,:)
1644  integer :: ifld
1645 
1646  integer :: ntot, ifield_
1647 
1648  ntot = nx1*ny1*nz1*nelfld(ifld)
1649  if ( .NOT. iftmsh(ifld)) imesh = 1
1650  if ( iftmsh(ifld)) imesh = 2
1651 
1652 
1653  allocate(wrk(nx1,ny1,nz1,nelfld(ifld)), h2(lx1,ly1,lz1,lelt))
1654  h2 = 0._dp
1655 
1656  ifield_ = ifield
1657  ifield = ifld
1658 
1659  call bcneusc(out,1)
1660  call axhelm(wrk,a,diff,h2,imesh,1)
1661  out(:,:,:,1:nelfld(ifld)) = out(:,:,:,1:nelfld(ifld)) - wrk
1662 
1663  ifield = ifield_
1664 
1665  return
1666 end subroutine wlaplacian
1667 
1668 !-----------------------------------------------------------------------
subroutine dssum(u)
Direct stiffness sum.
Definition: dssum.F90:54
subroutine lu(A, N, NDIM, IR, IC)
the first subroutine to compute the matrix inverse
Definition: gauss.F90:6
cleaned
Definition: tstep_mod.F90:2
Input parameters from preprocessors.
Definition: input_mod.F90:11
subroutine bcneusc(S, ITYPE)
Apply Neumann boundary conditions to surface of scalar, S. Use IFIELD as a guide to which boundary co...
Definition: bdry.F90:840
Definition: soln_mod.F90:1
cleaned
Definition: wz_mod.F90:2
subroutine mxm(a, n1, b, n2, c, n3)
Compute matrix-matrix product C = A*B.
Definition: mxm_wrapper.F90:7
subroutine vec_dsop(u, v, w, op)
Direct stiffness summation of the face data, for field U. Boundary condition data corresponds to comp...
Definition: dssum.F90:228
Definition: dxyz_mod.F90:3
subroutine axhelm(au, u, helm1, helm2, imesh, isd)
Compute the (Helmholtz) matrix-vector product, AU = helm1*[A]u + helm2*[B]u, for NEL elements...
Definition: hmholtz.F90:79
cleaned
Definition: mesh_mod.F90:2
real(dp) function dnekclock()
Definition: ctimer_mod.F90:103
integer function lglel(iel)
subroutine copy(a, b, n)
Definition: math.F90:52
subroutine convect_new(bdu, u, ifuf, cx, cy, cz, ifcf)
Compute dealiased form: J^T Bf *JC .grad Ju w/ correct Jacobians.
Definition: convect.F90:50
cleaned
Definition: parallel_mod.F90:2
subroutine solve(F, A, K, N, NDIM, IR, IC)
second part of the matrix inverse
Definition: gauss.F90:79
for i
Definition: xxt_test.m:74
Geometry arrays.
Definition: geom_mod.F90:2
subroutine nekasgn(IX, IY, IZ, IEL)
Assign NEKTON variables for definition (by user) of boundary conditions at collocation point (IX...
Definition: bdry.F90:1014
subroutine vec_dssum(u, v, w)
Direct stiffness summation of the face data, for field U.
Definition: dssum.F90:180
cleaned
Definition: nekuse_mod.F90:2
subroutine exitti(stringi, idata)
Definition: comm_mpi.F90:328
Definition: ixyz_mod.F90:2