KTH framework for Nek5000 toolboxes; testing version  0.0.1
sfd.f
Go to the documentation of this file.
1 
6 !=======================================================================
10  subroutine sfd_register()
11  implicit none
12 
13  include 'SIZE'
14  include 'FRAMELP'
15  include 'SFDD'
16 
17  ! local variables
18  integer lpmid
19  real ltim
20 
21  ! functions
22  real dnekclock
23 !-----------------------------------------------------------------------
24  ! timing
25  ltim = dnekclock()
26 
27  ! check if the current module was already registered
28  call mntr_mod_is_name_reg(lpmid,sfd_name)
29  if (lpmid.gt.0) then
30  call mntr_warn(lpmid,
31  $ 'module ['//trim(sfd_name)//'] already registered')
32  return
33  endif
34 
35  ! find parent module
36  call mntr_mod_is_name_reg(lpmid,'FRAME')
37  if (lpmid.le.0) then
38  lpmid = 1
39  call mntr_abort(lpmid,
40  $ 'Parent module ['//'FRAME'//'] not registered')
41  endif
42 
43  ! register module
44  call mntr_mod_reg(sfd_id,lpmid,sfd_name,
45  $ 'Selective Frequency Damping')
46 
47  ! register timer
48  call mntr_tmr_is_name_reg(lpmid,'FRM_TOT')
49  call mntr_tmr_reg(sfd_ttot_id,lpmid,sfd_id,
50  $ 'SFD_TOT','SFD total time',.false.)
51 
52  call mntr_tmr_reg(sfd_tini_id,sfd_ttot_id,sfd_id,
53  $ 'SFD_INI','SFD initialisation time',.true.)
54 
55  call mntr_tmr_reg(sfd_tevl_id,sfd_ttot_id,sfd_id,
56  $ 'SFD_EVL','SFD evolution time',.true.)
57 
58  call mntr_tmr_reg(sfd_tchp_id,sfd_ttot_id,sfd_id,
59  $ 'SFD_CHP','SFD checkpoint saving time',.true.)
60 
61  call mntr_tmr_reg(sfd_tend_id,sfd_ttot_id,sfd_id,
62  $ 'SFD_END','SFD finalilsation time',.true.)
63 
64  ! register and set active section
65  call rprm_sec_reg(sfd_sec_id,sfd_id,'_'//adjustl(sfd_name),
66  $ 'Runtime paramere section for SFD module')
67  call rprm_sec_set_act(.true.,sfd_sec_id)
68 
69  ! register parameters
70  call rprm_rp_reg(sfd_dlt_id,sfd_sec_id,'FILTERWDTH',
71  $ 'SFD filter width',rpar_real,0,1.0,.false.,' ')
72 
73  call rprm_rp_reg(sfd_chi_id,sfd_sec_id,'CONTROLCFF',
74  $ 'SFD control coefficient',rpar_real,0,1.0,.false.,' ')
75 
76  call rprm_rp_reg(sfd_tol_id,sfd_sec_id,'RESIDUALTOL',
77  $ 'SFD tolerance for residual',rpar_real,0,1.0,.false.,' ')
78 
79  call rprm_rp_reg(sfd_cnv_id,sfd_sec_id,'LOGINTERVAL',
80  $ 'SFD frequency for logging convegence data',
81  $ rpar_int,0,1.0,.false.,' ')
82 
83  call rprm_rp_reg(sfd_ifrst_id,sfd_sec_id,'SFDREADCHKPT',
84  $ 'SFD; restat from checkpoint',
85  $ rpar_log,0,1.0,.false.,' ')
86 
87  ! initialisation flag
88  sfd_ifinit = .false.
89 
90  ! timing
91  ltim = dnekclock() - ltim
92  call mntr_tmr_add(sfd_tini_id,1,ltim)
93 
94  return
95  end subroutine
96 !=======================================================================
100  subroutine sfd_init()
101  implicit none
102 
103  include 'SIZE'
104  include 'SOLN'
105  include 'INPUT'
106  include 'TSTEP'
107  include 'FRAMELP'
108  include 'SFDD'
109 
110  ! local variables
111  integer itmp, il
112  real rtmp, ltim
113  logical ltmp
114  character*20 ctmp
115  character*2 str
116  character*200 lstring
117 
118  ! to get checkpoint runtime parameters
119  integer ierr, lmid, lsid, lrpid
120 
121  ! functions
122  integer frame_get_master
123  real dnekclock
124 !-----------------------------------------------------------------------
125  ! check if the module was already initialised
126  if (sfd_ifinit) then
127  call mntr_warn(sfd_id,
128  $ 'module ['//trim(sfd_name)//'] already initiaised.')
129  return
130  endif
131 
132  ! timing
133  ltim = dnekclock()
134 
135  ! get runtime parameters
136  call rprm_rp_get(itmp,rtmp,ltmp,ctmp,sfd_dlt_id,rpar_real)
137  sfd_dlt = abs(rtmp)
138  if (sfd_dlt.gt.0.0) then
139  sfd_dlt = 1.0/sfd_dlt
140  else
141  call mntr_abort(sfd_id,
142  $ 'sfd_init; Filter width must be positive.')
143  endif
144 
145  call rprm_rp_get(itmp,rtmp,ltmp,ctmp,sfd_chi_id,rpar_real)
146  sfd_chi = abs(rtmp)
147  if (sfd_chi.le.0.0) call mntr_abort(sfd_id,
148  $ 'sfd_init; Forcing control must be positive.')
149 
150  call rprm_rp_get(itmp,rtmp,ltmp,ctmp,sfd_tol_id,rpar_real)
151  sfd_tol = abs(rtmp)
152  if (sfd_tol.le.0.0) call mntr_abort(sfd_id,
153  $ 'sfd_init; Residual tolerance must be positive.')
154 
155  call rprm_rp_get(itmp,rtmp,ltmp,ctmp,sfd_cnv_id,rpar_int)
156  sfd_cnv = abs(itmp)
157 
158  call rprm_rp_get(itmp,rtmp,ltmp,ctmp,sfd_ifrst_id,rpar_log)
159  sfd_ifrst = ltmp
160 
161  ! check if checkpointing module was registered and take parameters
162  ierr = 0
163  call mntr_mod_is_name_reg(lmid,'CHKPT')
164  if (lmid.gt.0) then
165  call rprm_sec_is_name_reg(lsid,lmid,'_CHKPT')
166  if (lsid.gt.0) then
167  ! restart flag
168  call rprm_rp_is_name_reg(lrpid,lsid,'READCHKPT',rpar_log)
169  if (lrpid.gt.0) then
170  call rprm_rp_get(itmp,rtmp,ltmp,ctmp,lrpid,rpar_log)
171  sfd_chifrst = ltmp
172  else
173  ierr = 1
174  goto 30
175  endif
176  if (sfd_chifrst) then
177  ! checkpoint set number
178  call rprm_rp_is_name_reg(lrpid,lsid,'CHKPFNUMBER',
179  $ rpar_int)
180  if (lrpid.gt.0) then
181  call rprm_rp_get(itmp,rtmp,ltmp,ctmp,lrpid,rpar_int)
182  sfd_fnum = itmp
183  else
184  ierr = 1
185  goto 30
186  endif
187  endif
188  else
189  ierr = 1
190  endif
191  else
192  ierr = 1
193  endif
194 
195  30 continue
196 
197  ! check for errors
198  call mntr_check_abort(sfd_id,ierr,
199  $ 'Error reading checkpoint parameters')
200 
201  ! check restart flags
202  if (sfd_ifrst.and.(.not.sfd_chifrst)) call mntr_abort(sfd_id,
203  $ 'sfd_init; Restart flagg missmatch.')
204 
205  ! check simulation parameters
206  if (.not.iftran) call mntr_abort(sfd_id,
207  $ 'sfd_init; SFD requres transient equations')
208 
209  if (ifpert) call mntr_abort(sfd_id,
210  $ 'sfd_init; SFD cannot be run in perturbation mode')
211 
212  ! get number of snapshots in a set
213  if (param(27).lt.0) then
214  sfd_nsnap = nbdinp
215  else
216  sfd_nsnap = 3
217  endif
218 
219  ! initialise module arrays
220  if (sfd_ifrst) then
221  ! read checkpoint
222  call sfd_rst_read
223  else
224  itmp = nx1*ny1*nz1*nelv
225  do il=1,3
226  call rzero(sfd_vxlag(1,1,1,1,il),itmp)
227  call rzero(sfd_vylag(1,1,1,1,il),itmp)
228  if (if3d )call rzero(sfd_vzlag(1,1,1,1,il),itmp)
229  enddo
230 
231  call opcopy (sfd_vx,sfd_vy,sfd_vz,vx,vy,vz)
232  endif
233 
234  ! get the forcing (difference between v? and sfd_v?)
235  call opsub3(sfd_bfx,sfd_bfy,sfd_bfz,vx,vy,vz,sfd_vx,sfd_vy,sfd_vz)
236 
237  ! open the file for convergence history
238  ierr = 0
239  if (nid.eq.frame_get_master()) then
240  call io_file_freeid(sfd_fid, ierr)
241  if (ierr.eq.0) then
242  open (unit=sfd_fid,file='SFDconv.out',status='new',
243  $ action='write',iostat=ierr)
244  endif
245  endif
246 
247  ! check for errors
248  call mntr_check_abort(sfd_id,ierr,
249  $ 'Error opening convergence file.')
250 
251  ! initialise storage arrays
252  call rzero(sfd_abx1,itmp)
253  call rzero(sfd_abx2,itmp)
254  call rzero(sfd_aby1,itmp)
255  call rzero(sfd_aby2,itmp)
256  call rzero(sfd_abz1,itmp)
257  call rzero(sfd_abz2,itmp)
258 
259  ! initialisation flag
260  sfd_ifinit = .true.
261 
262  ! timing
263  ltim = dnekclock() - ltim
264  call mntr_tmr_add(sfd_tini_id,1,ltim)
265 
266  return
267  end subroutine
268 !=======================================================================
272  logical function sfd_is_initialised()
273  implicit none
274 
275  include 'SIZE'
276  include 'SFDD'
277 !-----------------------------------------------------------------------
278  sfd_is_initialised = sfd_ifinit
279 
280  return
281  end function
282 !=======================================================================
286  subroutine sfd_end
287  implicit none
288 
289  include 'SIZE' ! NID, NDIM, NPERT
290  include 'INPUT' ! IF3D
291  include 'RESTART'
292  include 'SOLN'
293  include 'FRAMELP'
294  include 'SFDD'
295 
296  ! local variables
297  integer ntot1, il
298  real ltim
299  real ab0, ab1, ab2
300 
301  logical lifxyo, lifpo, lifvo, lifto, lifreguo, lifpso(LDIMT1)
302 
303  ! functions
304  integer frame_get_master
305  real dnekclock, gl2norm
306 !-----------------------------------------------------------------------
307  ! timing
308  ltim = dnekclock()
309 
310  ! final convergence
311  ntot1 = nx1*ny1*nz1*nelv
312 
313  ! calculate L2 norms
314  ab0 = gl2norm(sfd_bfx,ntot1)
315  ab1 = gl2norm(sfd_bfy,ntot1)
316  if (if3d) ab2 = gl2norm(sfd_bfz,ntot1)
317 
318  ! stamp the log
319  call mntr_log(sfd_id,lp_prd,
320  $ 'Final convergence (L2 norm per grid point):')
321  call mntr_logr(sfd_id,lp_prd,'DVX = ',ab0)
322  call mntr_logr(sfd_id,lp_prd,'DVY = ',ab1)
323  if (if3d) call mntr_logr(sfd_id,lp_prd,'DVZ = ',ab2)
324  call mntr_log(sfd_id,lp_prd,'Saving velocity difference')
325 
326  ! save the velocity difference for inspection
327  lifxyo= ifxyo
328  ifxyo = .true.
329  lifpo= ifpo
330  ifpo = .false.
331  lifvo= ifvo
332  ifvo = .true.
333  lifto= ifto
334  ifto = .false.
335  do il=1,ldimt1
336  lifpso(il)= ifpso(il)
337  ifpso(il) = .false.
338  enddo
339 
340  call outpost2(sfd_bfx,sfd_bfy,sfd_bfz,pr,t,0,'vdf')
341 
342  ifxyo = lifxyo
343  ifpo = lifpo
344  ifvo = lifvo
345  ifto = lifto
346  do il=1,ldimt1
347  ifpso(il) = lifpso(il)
348  enddo
349 
350  ! close file with convergence history
351  if (nid.eq.frame_get_master()) close(sfd_fid)
352 
353  ! timing
354  ltim = dnekclock() - ltim
355  call mntr_tmr_add(sfd_tend_id,1,ltim)
356 
357  return
358  end subroutine
359 !=======================================================================
362  subroutine sfd_main
363  implicit none
364 !-----------------------------------------------------------------------
365  call sfd_solve
366  call sfd_rst_write
367 
368  return
369  end subroutine
370 !=======================================================================
376  subroutine sfd_forcing(ffx,ffy,ffz,ix,iy,iz,ieg)
377  implicit none
378 
379  include 'SIZE' !
380  include 'INPUT' ! IF3D
381  include 'PARALLEL' ! GLLEL
382  include 'SFDD'
383 
384  ! argument list
385  real ffx, ffy, ffz
386  integer ix,iy,iz,ieg
387 
388  ! local variables
389  integer iel
390 !-----------------------------------------------------------------------
391  iel=gllel(ieg)
392  ffx = ffx - sfd_chi*sfd_bfx(ix,iy,iz,iel)
393  ffy = ffy - sfd_chi*sfd_bfy(ix,iy,iz,iel)
394  if (if3d) ffz = ffz - sfd_chi*sfd_bfz(ix,iy,iz,iel)
395 
396  return
397  end subroutine
398 !=======================================================================
405  subroutine sfd_solve
406  implicit none
407 
408  include 'SIZE'
409  include 'SOLN'
410  include 'TSTEP' ! ISTEP, TIME, NSTEPS, LASTEP
411  include 'INPUT' ! IF3D
412  include 'FRAMELP'
413  include 'SFDD'
414 
415  ! temporary storage
416  real TA1 (LX1,LY1,LZ1,LELV), TA2 (LX1,LY1,LZ1,LELV),
417  $ TA3 (LX1,LY1,LZ1,LELV)
418  COMMON /scruz/ ta1, ta2, ta3
419 
420  ! local variables
421  integer ntot1, ilag
422  real ltim
423  real ab0, ab1, ab2
424 
425  ! functions
426  integer frame_get_master
427  real dnekclock, gl2norm
428 !-----------------------------------------------------------------------
429  if (istep.eq.0) return
430 
431  ! timing
432  ltim = dnekclock()
433 
434  ! active array length
435  ntot1 = nx1*ny1*nz1*nelv
436 
437  ! A-B part
438  ! current rhs
439  ! I use BFS? vectors generated during the convergence tests so skip this step
440 ! call opsub3(sfd_bfx,sfd_bfy,sfd_bfz,vxlag,vylag,vzlag,
441 ! $ sfd_vx,sfd_vy,sfd_vz)
442  ! finish rhs
443  call opcmult(sfd_bfx,sfd_bfy,sfd_bfz,sfd_dlt)
444 
445  ! old time steps
446  ab0 = ab(1)
447  ab1 = ab(2)
448  ab2 = ab(3)
449  call add3s2(ta1,sfd_abx1,sfd_abx2,ab1,ab2,ntot1)
450  call add3s2(ta2,sfd_aby1,sfd_aby2,ab1,ab2,ntot1)
451  ! save rhs
452  call copy(sfd_abx2,sfd_abx1,ntot1)
453  call copy(sfd_aby2,sfd_aby1,ntot1)
454  call copy(sfd_abx1,sfd_bfx,ntot1)
455  call copy(sfd_aby1,sfd_bfy,ntot1)
456  ! current
457  call add2s1 (sfd_bfx,ta1,ab0,ntot1)
458  call add2s1 (sfd_bfy,ta2,ab0,ntot1)
459  if (if3d) then
460  call add3s2 (ta3,sfd_abz1,sfd_abz2,ab1,ab2,ntot1)
461  call copy (sfd_abz2,sfd_abz1,ntot1)
462  call copy (sfd_abz1,sfd_bfz,ntot1)
463  call add2s1 (sfd_bfz,ta3,ab0,ntot1)
464  endif
465 
466  ! multiplication by time step
467  call opcmult(sfd_bfx,sfd_bfy,sfd_bfz,dt)
468 
469  ! BD part
470  ab0 = bd(2)
471  call opadd2cm(sfd_bfx,sfd_bfy,sfd_bfz,sfd_vx,sfd_vy,sfd_vz,ab0)
472 
473  do ilag=2,nbd
474  ab0 = bd(ilag+1)
475  call opadd2cm(sfd_bfx,sfd_bfy,sfd_bfz,
476  $ sfd_vxlag(1,1,1,1,ilag-1),sfd_vylag(1,1,1,1,ilag-1),
477  $ sfd_vzlag(1,1,1,1,ilag-1),ab0)
478  enddo
479 
480  ! take into account restart option
481  if (sfd_ifrst.and.(istep.lt.sfd_nsnap))
482  $ call opcopy (ta1,ta2,ta3,sfd_vxlag(1,1,1,1,sfd_nsnap-1),
483  $ sfd_vylag(1,1,1,1,sfd_nsnap-1),sfd_vzlag(1,1,1,1,sfd_nsnap-1))
484 
485  ! keep old filtered velocity fields
486  do ilag=3,2,-1
487  call opcopy(sfd_vxlag(1,1,1,1,ilag),sfd_vylag(1,1,1,1,ilag),
488  $ sfd_vzlag(1,1,1,1,ilag),sfd_vxlag(1,1,1,1,ilag-1),
489  $ sfd_vylag(1,1,1,1,ilag-1),sfd_vzlag(1,1,1,1,ilag-1))
490  enddo
491 
492  call opcopy (sfd_vxlag,sfd_vylag,sfd_vzlag,sfd_vx,sfd_vy,sfd_vz)
493 
494  ! calculate new filtered velocity field
495  ! take into account restart option
496  if (sfd_ifrst.and.(istep.lt.sfd_nsnap)) then
497  call opcopy (sfd_vx,sfd_vy,sfd_vz,ta1,ta2,ta3)
498  else
499  ab0 = 1.0/bd(1)
500  call opcopy (sfd_vx,sfd_vy,sfd_vz,sfd_bfx,sfd_bfy,sfd_bfz)
501  call opcmult(sfd_vx,sfd_vy,sfd_vz,ab0)
502  endif
503 
504  ! convergence test
505  ! find the difference between V? and VS?
506  call opsub3(sfd_bfx,sfd_bfy,sfd_bfz,vx,vy,vz,sfd_vx,sfd_vy,sfd_vz)
507 
508  ! calculate L2 norms
509  ab0 = gl2norm(sfd_bfx,ntot1)
510  ab1 = gl2norm(sfd_bfy,ntot1)
511  if (if3d) ab2 = gl2norm(sfd_bfz,ntot1)
512 
513  ! for tracking convergence
514  if (mod(istep,sfd_cnv).eq.0) then
515  if (nid.eq.frame_get_master()) then
516  if (if3d) then
517  write(sfd_fid,'(4e13.5)') time, ab0, ab1, ab2
518  else
519  write(sfd_fid,'(3e13.5)') time, ab0, ab1
520  endif
521  endif
522 
523  ! stamp the log
524  call mntr_log(sfd_id,lp_prd,
525  $ 'Convergence (L2 norm per grid point):')
526  call mntr_logr(sfd_id,lp_prd,'DVX = ',ab0)
527  call mntr_logr(sfd_id,lp_prd,'DVY = ',ab1)
528  if (if3d) call mntr_logr(sfd_id,lp_prd,'DVZ = ',ab2)
529  endif
530 
531  ! check stopping criteria
532  if (istep.gt.sfd_nsnap) then ! to ensure proper restart
533  ab0 = max(ab0,ab1)
534  if (if3d) ab0 = max(ab0,ab2)
535  if (ab0.lt.sfd_tol) then
536  call mntr_log(sfd_id,lp_ess,'Stopping criteria reached')
537  call mntr_set_conv(.true.)
538  endif
539  endif
540 
541  ! timing
542  ltim = dnekclock() - ltim
543  call mntr_tmr_add(sfd_tevl_id,1,ltim)
544 
545  return
546  end subroutine
547 !=======================================================================
550  subroutine sfd_rst_write
551  implicit none
552 
553  include 'SIZE'
554  include 'INPUT'
555  include 'RESTART'
556  include 'TSTEP'
557  include 'FRAMELP'
558  include 'SFDD'
559 
560  ! local variables
561  integer step_cnt, set_out
562  real ltim
563  integer lwdsizo
564  integer ipert, il, ierr
565  logical lif_full_pres, lifxyo, lifpo, lifvo, lifto,
566  $ lifpsco(LDIMT1), ifreguol
567 
568  character*132 fname, bname
569  character*3 prefix
570  character*6 str
571 
572  ! functions
573  real dnekclock
574 !-----------------------------------------------------------------------
575  ! avoid writing during possible restart reading
576  call mntr_get_step_delay(step_cnt)
577  if (istep.le.step_cnt) return
578 
579  ! get step count and file set number
580  call chkpt_get_fset(step_cnt, set_out)
581 
582  ! we write everything in single step
583  if (step_cnt.eq.1) then
584  ltim = dnekclock()
585 
586  call mntr_log(sfd_id,lp_inf,'Writing checkpoint snapshot')
587 
588  ! adjust I/O parameters
589  lwdsizo = wdsizo
590  wdsizo = 8
591  lif_full_pres = if_full_pres
592  if_full_pres = .false.
593  lifxyo = ifxyo
594  ifxyo = .false.
595  lifpo= ifpo
596  ifpo = .false.
597  lifvo= ifvo
598  ifvo = .true.
599  lifto= ifto
600  ifto = .false.
601  do il=1,npscal
602  lifpsco(il)= ifpsco(il)
603  ifpsco(il) = .true.
604  enddo
605  ifreguol= ifreguo
606  ifreguo = .false.
607 
608  ! initialise I/O data
609  call io_init
610 
611  ! get file name
612  prefix = 'SFD'
613  bname = trim(adjustl(session))
614  call io_mfo_fname(fname,bname,prefix,ierr)
615  call mntr_check_abort(sfd_id,ierr,
616  $ 'sfd_rst_write; file name error')
617  write(str,'(i5.5)') set_out + 1
618  fname=trim(fname)//trim(str(1:5))
619 
620  ! save filtered valocity field
621  call sfd_mfo(fname)
622 
623  ! put parameters back
624  wdsizo = lwdsizo
625  if_full_pres = lif_full_pres
626  ifxyo = lifxyo
627  ifpo = lifpo
628  ifvo = lifvo
629  ifto = lifto
630  do il=1,npscal
631  ifpsco(il) = lifpsco(il)
632  enddo
633  ifreguo = ifreguol
634 
635  ! timing
636  ltim = dnekclock() - ltim
637  call mntr_tmr_add(sfd_tchp_id,1,ltim)
638  endif
639 
640  return
641  end subroutine
642 !=======================================================================
646  subroutine sfd_rst_read
647  implicit none
648 
649  include 'SIZE' ! NID, NDIM, NPERT
650  include 'INPUT'
651  include 'FRAMELP'
652  include 'SFDD'
653 
654  ! temporary storage
655  real TA1 (LX1,LY1,LZ1,LELV), TA2 (LX1,LY1,LZ1,LELV),
656  $ TA3 (LX1,LY1,LZ1,LELV)
657  COMMON /scruz/ ta1, ta2, ta3
658 
659  ! local variables
660  integer ilag, ierr
661  logical ifreguol
662 
663  character*132 fname, bname
664  character*3 prefix
665  character*6 str
666 !-----------------------------------------------------------------------
667  ! stamp logs
668  call mntr_log(sfd_id,lp_inf,'Reading checkpoint')
669 
670  ! no regular mesh
671  ifreguol= ifreguo
672  ifreguo = .false.
673 
674  ! initialise I/O data
675  call io_init
676 
677  ! create file name
678  prefix = 'SFD'
679  bname = trim(adjustl(session))
680  call io_mfo_fname(fname,bname,prefix,ierr)
681  call mntr_check_abort(sfd_id,ierr,'sfd_rst_read; file name error')
682  write(str,'(i5.5)') sfd_fnum
683  fname=trim(fname)//trim(str(1:5))
684 
685  ! read filtered velocity field
686  call sfd_mfi(fname)
687 
688  ! put parameters back
689  ifreguo = ifreguol
690 
691  ! move velcity fields to sotre oldest one in VS?
692  call opcopy (ta1,ta2,ta3,sfd_vxlag(1,1,1,1,sfd_nsnap-1),
693  $ sfd_vylag(1,1,1,1,sfd_nsnap-1),sfd_vzlag(1,1,1,1,sfd_nsnap-1))
694 
695  do ilag=sfd_nsnap-1,2,-1
696  call opcopy(sfd_vxlag(1,1,1,1,ilag),sfd_vylag(1,1,1,1,ilag),
697  $ sfd_vzlag(1,1,1,1,ilag),sfd_vxlag(1,1,1,1,ilag-1),
698  $ sfd_vylag(1,1,1,1,ilag-1),sfd_vzlag(1,1,1,1,ilag-1))
699  enddo
700 
701  call opcopy (sfd_vxlag,sfd_vylag,sfd_vzlag,sfd_vx,sfd_vy,sfd_vz)
702  call opcopy (sfd_vx,sfd_vy,sfd_vz,ta1,ta2,ta3)
703 
704  return
705  end subroutine
706 !=======================================================================
714  subroutine sfd_mfo(fname)
715  implicit none
716 
717  include 'SIZE'
718  include 'RESTART'
719  include 'PARALLEL'
720  include 'INPUT'
721  include 'FRAMELP'
722  include 'SFDD'
723 
724  ! argument list
725  character*132 fname
726 
727  ! local variables
728  integer il, ierr, ioflds, nout
729  integer*8 offs
730 
731  real tiostart, tio, dnbyte
732 
733  ! functions
734  real dnekclock_sync, glsum
735 !-----------------------------------------------------------------------
736  ! simple timing
737  tiostart=dnekclock_sync()
738 
739  nout = nelt
740  nxo = nx1
741  nyo = ny1
742  nzo = nz1
743 
744  ! open file
745  ierr = 0
746  call io_mbyte_open(fname,ierr)
747  call mntr_check_abort(sfd_id,ierr,'sfd_mfo; file not opened.')
748 
749  ! write a header and create element mapping
750  call mfo_write_hdr
751 
752  ! set offset
753  offs = iheadersize + 4 + isize*nelgt
754  ioflds = 0
755 
756  ! write fields
757  ! current filtered velocity field
758  call io_mfov(offs,sfd_vx,sfd_vy,sfd_vz,nx1,ny1,nz1,nelt,
759  $ nelgt,ndim)
760  ioflds = ioflds + ndim
761 
762  ! history
763  do il=1,3
764  call io_mfov(offs,sfd_vxlag(1,1,1,1,il),sfd_vylag(1,1,1,1,il),
765  $ sfd_vzlag(1,1,1,1,il),nx1,ny1,nz1,nelt,nelgt,ndim)
766  ioflds = ioflds + ndim
767  enddo
768 
769  dnbyte = 1.*ioflds*nelt*wdsizo*nx1*ny1*nz1
770 
771  ! close file
772  call io_mbyte_close(ierr)
773  call mntr_check_abort(sfd_id,ierr,'sfd_mfo; file not closed.')
774 
775  ! stamp the log
776  tio = dnekclock_sync()-tiostart
777  if (tio.le.0) tio=1.
778 
779  dnbyte = glsum(dnbyte,1)
780  dnbyte = dnbyte + iheadersize + 4. +isize*nelgt
781  dnbyte = dnbyte/1024/1024
782 
783  call mntr_log(sfd_id,lp_prd,'Checkpoint written:')
784  call mntr_logr(sfd_id,lp_vrb,'file size (MB) = ',dnbyte)
785  call mntr_logr(sfd_id,lp_vrb,'avg data-throughput (MB/s) = ',
786  $ dnbyte/tio)
787  call mntr_logi(sfd_id,lp_vrb,'io-nodes = ',nfileo)
788 
789  return
790  end subroutine
791 !=======================================================================
800  subroutine sfd_mfi(fname)
801  implicit none
802 
803  include 'SIZE'
804  include 'INPUT'
805  include 'PARALLEL'
806  include 'RESTART'
807  include 'FRAMELP'
808  include 'SFDD'
809 
810  ! argument lilst
811  character*132 fname
812 
813  ! local variables
814  integer il, ioflds, ierr
815  integer*8 offs
816  real tiostart, tio, dnbyte
817  logical ifskip
818 
819  ! scratch arrays
820  integer lwkv
821  parameter(lwkv = lx1*ly1*lz1*lelt)
822  real wkv1(lwkv),wkv2(lwkv),wkv3(lwkv)
823  common /scruz/ wkv1,wkv2,wkv3
824 
825  ! functions
826  real dnekclock_sync, glsum
827 !-----------------------------------------------------------------------
828  ! simple timing
829  tiostart=dnekclock_sync()
830 
831  ! open file, get header information and read mesh data
832  call mfi_prepare(fname)
833 
834  ! set header offset
835  offs = iheadersize + 4 + isize*nelgr
836  ioflds = 0
837  ifskip = .false.
838 
839  ! read arrays
840  ! filtered velocity
841  if ((nxr.eq.lx1).and.(nyr.eq.ly1).and.(nzr.eq.lz1)) then
842  ! unchanged resolution
843  ! read field directly to the variables
844  call io_mfiv(offs,sfd_vx,sfd_vy,sfd_vz,lx1,ly1,lz1,lelv,ifskip)
845  else
846  ! modified resolution
847  ! read field to tmp array
848  call io_mfiv(offs,wkv1,wkv2,wkv3,nxr,nyr,nzr,lelt,ifskip)
849 
850  ! interpolate
851  call chkptms_map_gll(sfd_vx,wkv1,nxr,nzr,nelv)
852  call chkptms_map_gll(sfd_vy,wkv2,nxr,nzr,nelv)
853  if (if3d) call chkptms_map_gll(sfd_vz,wkv3,nxr,nzr,nelv)
854  endif
855  ioflds = ioflds + ndim
856 
857  ! history
858  do il=1,3
859  if ((nxr.eq.lx1).and.(nyr.eq.ly1).and.(nzr.eq.lz1)) then
860  ! unchanged resolution
861  ! read field directly to the variables
862  call io_mfiv(offs,sfd_vxlag(1,1,1,1,il),
863  $ sfd_vylag(1,1,1,1,il),sfd_vzlag(1,1,1,1,il),
864  $ lx1,ly1,lz1,lelv,ifskip)
865  else
866  ! modified resolution
867  ! read field to tmp array
868  call io_mfiv(offs,wkv1,wkv2,wkv3,nxr,nyr,nzr,lelt,ifskip)
869 
870  ! interpolate
871  call chkptms_map_gll(sfd_vxlag(1,1,1,1,il),wkv1,nxr,nzr,
872  $ nelv)
873  call chkptms_map_gll(sfd_vylag(1,1,1,1,il),wkv2,nxr,nzr,
874  $ nelv)
875  if (if3d) call chkptms_map_gll(sfd_vzlag(1,1,1,1,il),wkv3,
876  $ nxr,nzr,nelv)
877  endif
878  ioflds = ioflds + ndim
879  enddo
880 
881  ! close file
882  call io_mbyte_close(ierr)
883  call mntr_check_abort(sfd_id,ierr,'sfd_mfi; file not closed.')
884 
885  ! stamp the log
886  tio = dnekclock_sync()-tiostart
887  if (tio.le.0.0) tio=1.
888 
889  if(nid.eq.pid0r) then
890  dnbyte = 1.*ioflds*nelr*wdsizr*nxr*nyr*nzr
891  else
892  dnbyte = 0.0
893  endif
894 
895  dnbyte = glsum(dnbyte,1)
896  dnbyte = dnbyte + iheadersize + 4. + isize*nelgt
897  dnbyte = dnbyte/1024/1024
898 
899  call mntr_log(sfd_id,lp_prd,'Checkpoint read:')
900  call mntr_logr(sfd_id,lp_vrb,'avg data-throughput (MB/s) = ',
901  $ dnbyte/tio)
902  call mntr_logi(sfd_id,lp_vrb,'io-nodes = ',nfileo)
903 
904  if (ifaxis) call mntr_abort(sfd_id,
905  $ 'sfd_mfi; axisymmetric case not supported')
906 
907  return
908  end subroutine
909 !=======================================================================
integer function gllel(ieg)
Definition: dprocmap.f:183
subroutine chkpt_get_fset(step_cnt, set_out)
Get step count to the checkpoint and a set number.
Definition: chkpt.f:256
subroutine chkptms_map_gll(xf, yf, nxr, nzr, nel)
Interpolate input on velocity mesh.
Definition: chkptms.f:1210
subroutine io_mfov(offs, lvx, lvy, lvz, lnx, lny, lnz, lnel, lnelg, lndim)
Write single vector to the file.
Definition: io_tools.f:273
subroutine io_mbyte_open(hname, ierr)
Open field file.
Definition: io_tools.f:182
subroutine io_file_freeid(iunit, ierr)
Get free file unit number and store max unit value.
Definition: io_tools.f:47
subroutine io_mfo_fname(fname, bname, prefix, ierr)
Generate file name according to nek rulles without opening the file.
Definition: io_tools.f:109
subroutine io_mbyte_close(ierr)
Close field file.
Definition: io_tools.f:232
subroutine io_mfiv(offs, uf, vf, wf, lnx, lny, lnz, lnel, ifskip)
Read vector filed from the file.
Definition: io_tools.f:458
subroutine mntr_logi(mid, priority, logs, ivar)
Write log message adding single integer.
Definition: mntrlog.f:709
subroutine mntr_tmr_is_name_reg(mid, mname)
Check if timer name is registered and return its id.
Definition: mntrtmr.f:146
subroutine mntr_logr(mid, priority, logs, rvar)
Write log message adding single real.
Definition: mntrlog.f:731
subroutine mntr_warn(mid, logs)
Write warning message.
Definition: mntrlog.f:803
subroutine mntr_tmr_add(mid, icount, time)
Check if timer id is registered. This operation is performed locally.
Definition: mntrtmr.f:237
subroutine mntr_mod_is_name_reg(mid, mname)
Check if module name is registered and return its id.
Definition: mntrlog.f:459
subroutine mntr_abort(mid, logs)
Abort simulation.
Definition: mntrlog.f:837
subroutine mntr_set_conv(ifconv)
Set convergence flag to shorten simulation.
Definition: mntrlog.f:294
subroutine mntr_log(mid, priority, logs)
Write log message.
Definition: mntrlog.f:600
subroutine mntr_mod_reg(mid, pmid, mname, mdscr)
Register new module.
Definition: mntrlog.f:346
subroutine mntr_get_step_delay(dstep)
Get step delay.
Definition: mntrlog.f:277
subroutine mntr_tmr_reg(mid, pmid, modid, mname, mdscr, ifsum)
Register new timer.
Definition: mntrtmr.f:16
subroutine mntr_check_abort(mid, ierr, logs)
Abort simulation.
Definition: mntrlog.f:856
subroutine rprm_rp_is_name_reg(rpid, mid, pname, ptype)
Check if parameter name is registered and return its id. Check flags as well.
Definition: rprm.f:658
subroutine rprm_rp_get(ipval, rpval, lpval, cpval, rpid, ptype)
Get runtime parameter form active section. This operation is performed locally.
Definition: rprm.f:883
subroutine rprm_sec_is_name_reg(rpid, mid, pname)
Check if section name is registered and return its id. Check mid as well.
Definition: rprm.f:284
subroutine rprm_rp_reg(rpid, mid, pname, pdscr, ptype, ipval, rpval, lpval, cpval)
Register new runtime parameter.
Definition: rprm.f:484
subroutine rprm_sec_set_act(ifact, rpid)
Set section's activation flag. Master value is broadcasted.
Definition: rprm.f:422
subroutine rprm_sec_reg(rpid, mid, pname, pdscr)
Register new parameter section.
Definition: rprm.f:165
subroutine sfd_solve
Update filtered velocity field.
Definition: sfd.f:406
subroutine sfd_main
Main SFD interface.
Definition: sfd.f:363
logical function sfd_is_initialised()
Check if module was initialised.
Definition: sfd.f:273
subroutine sfd_register()
Register SFD module.
Definition: sfd.f:11
subroutine sfd_forcing(ffx, ffy, ffz, ix, iy, iz, ieg)
Calcualte SFD forcing.
Definition: sfd.f:377
subroutine sfd_rst_read
Read from checkpoint.
Definition: sfd.f:647
subroutine sfd_rst_write
Create checkpoint.
Definition: sfd.f:551
subroutine sfd_end
Finalise SFD.
Definition: sfd.f:287
subroutine sfd_mfo(fname)
Store SFD restart file.
Definition: sfd.f:715
subroutine sfd_mfi(fname)
Load SFD restart file.
Definition: sfd.f:801
subroutine sfd_init()
Initialise SFD module.
Definition: sfd.f:101
subroutine mfi_prepare(hname)
Definition: ic.f:2543
subroutine copy(a, b, n)
Definition: math.f:260
subroutine add3s2(a, b, c, c1, c2, n)
Definition: math.f:716
subroutine add2s1(a, b, c1, n)
Definition: math.f:678
subroutine rzero(a, n)
Definition: math.f:208
subroutine opcmult(a, b, c, const)
Definition: navier1.f:2663
subroutine opcopy(a1, a2, a3, b1, b2, b3)
Definition: navier1.f:2474
subroutine opsub3(a1, a2, a3, b1, b2, b3, c1, c2, c3)
Definition: navier1.f:2370
subroutine opadd2cm(a1, a2, a3, b1, b2, b3, c)
Definition: plan4.f:439
subroutine outpost2(v1, v2, v3, vp, vt, nfldt, name3)
Definition: prepost.f:1394
subroutine io_init
Definition: prepost.f:1024
subroutine mfo_write_hdr
Definition: prepost.f:1857