31 $
'module ['//trim(sfd_name)//
'] already registered')
40 $
'Parent module ['//
'FRAME'//
'] not registered')
45 $
'Selective Frequency Damping')
50 $
'SFD_TOT',
'SFD total time',.false.)
53 $
'SFD_INI',
'SFD initialisation time',.true.)
56 $
'SFD_EVL',
'SFD evolution time',.true.)
59 $
'SFD_CHP',
'SFD checkpoint saving time',.true.)
62 $
'SFD_END',
'SFD finalilsation time',.true.)
65 call rprm_sec_reg(sfd_sec_id,sfd_id,
'_'//adjustl(sfd_name),
66 $
'Runtime paramere section for SFD module')
70 call rprm_rp_reg(sfd_dlt_id,sfd_sec_id,
'FILTERWDTH',
71 $
'SFD filter width',rpar_real,0,1.0,.false.,
' ')
73 call rprm_rp_reg(sfd_chi_id,sfd_sec_id,
'CONTROLCFF',
74 $
'SFD control coefficient',rpar_real,0,1.0,.false.,
' ')
76 call rprm_rp_reg(sfd_tol_id,sfd_sec_id,
'RESIDUALTOL',
77 $
'SFD tolerance for residual',rpar_real,0,1.0,.false.,
' ')
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.,
' ')
83 call rprm_rp_reg(sfd_ifrst_id,sfd_sec_id,
'SFDREADCHKPT',
84 $
'SFD; restat from checkpoint',
85 $ rpar_log,0,1.0,.false.,
' ')
91 ltim = dnekclock() - ltim
116 character*200 lstring
119 integer ierr, lmid, lsid, lrpid
122 integer frame_get_master
128 $
'module ['//trim(sfd_name)//
'] already initiaised.')
136 call rprm_rp_get(itmp,rtmp,ltmp,ctmp,sfd_dlt_id,rpar_real)
138 if (sfd_dlt.gt.0.0)
then
139 sfd_dlt = 1.0/sfd_dlt
142 $
'sfd_init; Filter width must be positive.')
145 call rprm_rp_get(itmp,rtmp,ltmp,ctmp,sfd_chi_id,rpar_real)
148 $
'sfd_init; Forcing control must be positive.')
150 call rprm_rp_get(itmp,rtmp,ltmp,ctmp,sfd_tol_id,rpar_real)
153 $
'sfd_init; Residual tolerance must be positive.')
155 call rprm_rp_get(itmp,rtmp,ltmp,ctmp,sfd_cnv_id,rpar_int)
158 call rprm_rp_get(itmp,rtmp,ltmp,ctmp,sfd_ifrst_id,rpar_log)
170 call rprm_rp_get(itmp,rtmp,ltmp,ctmp,lrpid,rpar_log)
176 if (sfd_chifrst)
then
181 call rprm_rp_get(itmp,rtmp,ltmp,ctmp,lrpid,rpar_int)
199 $
'Error reading checkpoint parameters')
202 if (sfd_ifrst.and.(.not.sfd_chifrst))
call mntr_abort(sfd_id,
203 $
'sfd_init; Restart flagg missmatch.')
207 $
'sfd_init; SFD requres transient equations')
210 $
'sfd_init; SFD cannot be run in perturbation mode')
213 if (param(27).lt.0)
then
224 itmp = nx1*ny1*nz1*nelv
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)
231 call opcopy (sfd_vx,sfd_vy,sfd_vz,vx,vy,vz)
235 call opsub3(sfd_bfx,sfd_bfy,sfd_bfz,vx,vy,vz,sfd_vx,sfd_vy,sfd_vz)
239 if (nid.eq.frame_get_master())
then
242 open (unit=sfd_fid,
file=
'SFDconv.out',status=
'new',
243 $ action=
'write',iostat=ierr)
249 $
'Error opening convergence file.')
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)
263 ltim = dnekclock() - ltim
301 logical lifxyo, lifpo, lifvo, lifto, lifreguo, lifpso(LDIMT1)
304 integer frame_get_master
305 real dnekclock, gl2norm
311 ntot1 = nx1*ny1*nz1*nelv
314 ab0 = gl2norm(sfd_bfx,ntot1)
315 ab1 = gl2norm(sfd_bfy,ntot1)
316 if (if3d) ab2 = gl2norm(sfd_bfz,ntot1)
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')
336 lifpso(il)= ifpso(il)
340 call outpost2(sfd_bfx,sfd_bfy,sfd_bfz,pr,t,0,
'vdf')
347 ifpso(il) = lifpso(il)
351 if (nid.eq.frame_get_master())
close(sfd_fid)
354 ltim = dnekclock() - ltim
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)
416 real TA1 (LX1,LY1,LZ1,LELV), TA2 (LX1,LY1,LZ1,LELV),
417 $ TA3 (LX1,LY1,LZ1,LELV)
418 COMMON /scruz/ ta1, ta2, ta3
426 integer frame_get_master
427 real dnekclock, gl2norm
429 if (istep.eq.0)
return
435 ntot1 = nx1*ny1*nz1*nelv
443 call opcmult(sfd_bfx,sfd_bfy,sfd_bfz,sfd_dlt)
449 call add3s2(ta1,sfd_abx1,sfd_abx2,ab1,ab2,ntot1)
450 call add3s2(ta2,sfd_aby1,sfd_aby2,ab1,ab2,ntot1)
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)
457 call add2s1 (sfd_bfx,ta1,ab0,ntot1)
458 call add2s1 (sfd_bfy,ta2,ab0,ntot1)
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)
467 call opcmult(sfd_bfx,sfd_bfy,sfd_bfz,dt)
471 call opadd2cm(sfd_bfx,sfd_bfy,sfd_bfz,sfd_vx,sfd_vy,sfd_vz,ab0)
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)
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))
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))
492 call opcopy (sfd_vxlag,sfd_vylag,sfd_vzlag,sfd_vx,sfd_vy,sfd_vz)
496 if (sfd_ifrst.and.(istep.lt.sfd_nsnap))
then
497 call opcopy (sfd_vx,sfd_vy,sfd_vz,ta1,ta2,ta3)
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)
506 call opsub3(sfd_bfx,sfd_bfy,sfd_bfz,vx,vy,vz,sfd_vx,sfd_vy,sfd_vz)
509 ab0 = gl2norm(sfd_bfx,ntot1)
510 ab1 = gl2norm(sfd_bfy,ntot1)
511 if (if3d) ab2 = gl2norm(sfd_bfz,ntot1)
514 if (mod(istep,sfd_cnv).eq.0)
then
515 if (nid.eq.frame_get_master())
then
517 write(sfd_fid,
'(4e13.5)') time, ab0, ab1, ab2
519 write(sfd_fid,
'(3e13.5)') time, ab0, ab1
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)
532 if (istep.gt.sfd_nsnap)
then
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')
542 ltim = dnekclock() - ltim
561 integer step_cnt, set_out
564 integer ipert, il, ierr
565 logical lif_full_pres, lifxyo, lifpo, lifvo, lifto,
566 $ lifpsco(LDIMT1), ifreguol
568 character*132 fname, bname
577 if (istep.le.step_cnt)
return
583 if (step_cnt.eq.1)
then
586 call mntr_log(sfd_id,lp_inf,
'Writing checkpoint snapshot')
591 lif_full_pres = if_full_pres
592 if_full_pres = .false.
602 lifpsco(il)= ifpsco(il)
613 bname = trim(adjustl(session))
616 $
'sfd_rst_write; file name error')
617 write(str,
'(i5.5)') set_out + 1
618 fname=trim(fname)//trim(str(1:5))
625 if_full_pres = lif_full_pres
631 ifpsco(il) = lifpsco(il)
636 ltim = dnekclock() - ltim
655 real TA1 (LX1,LY1,LZ1,LELV), TA2 (LX1,LY1,LZ1,LELV),
656 $ TA3 (LX1,LY1,LZ1,LELV)
657 COMMON /scruz/ ta1, ta2, ta3
663 character*132 fname, bname
668 call mntr_log(sfd_id,lp_inf,
'Reading checkpoint')
679 bname = trim(adjustl(session))
682 write(str,
'(i5.5)') sfd_fnum
683 fname=trim(fname)//trim(str(1:5))
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))
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))
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)
728 integer il, ierr, ioflds, nout
731 real tiostart, tio, dnbyte
734 real dnekclock_sync, glsum
737 tiostart=dnekclock_sync()
753 offs = iheadersize + 4 + isize*nelgt
758 call io_mfov(offs,sfd_vx,sfd_vy,sfd_vz,nx1,ny1,nz1,nelt,
760 ioflds = ioflds + ndim
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
769 dnbyte = 1.*ioflds*nelt*wdsizo*nx1*ny1*nz1
776 tio = dnekclock_sync()-tiostart
779 dnbyte = glsum(dnbyte,1)
780 dnbyte = dnbyte + iheadersize + 4. +isize*nelgt
781 dnbyte = dnbyte/1024/1024
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) = ',
787 call mntr_logi(sfd_id,lp_vrb,
'io-nodes = ',nfileo)
814 integer il, ioflds, ierr
816 real tiostart, tio, dnbyte
821 parameter(lwkv = lx1*ly1*lz1*lelt)
822 real wkv1(lwkv),wkv2(lwkv),wkv3(lwkv)
823 common /scruz/ wkv1,wkv2,wkv3
826 real dnekclock_sync, glsum
829 tiostart=dnekclock_sync()
835 offs = iheadersize + 4 + isize*nelgr
841 if ((nxr.eq.lx1).and.(nyr.eq.ly1).and.(nzr.eq.lz1))
then
844 call io_mfiv(offs,sfd_vx,sfd_vy,sfd_vz,lx1,ly1,lz1,lelv,ifskip)
848 call io_mfiv(offs,wkv1,wkv2,wkv3,nxr,nyr,nzr,lelt,ifskip)
855 ioflds = ioflds + ndim
859 if ((nxr.eq.lx1).and.(nyr.eq.ly1).and.(nzr.eq.lz1))
then
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)
868 call io_mfiv(offs,wkv1,wkv2,wkv3,nxr,nyr,nzr,lelt,ifskip)
878 ioflds = ioflds + ndim
886 tio = dnekclock_sync()-tiostart
887 if (tio.le.0.0) tio=1.
889 if(nid.eq.pid0r)
then
890 dnbyte = 1.*ioflds*nelr*wdsizr*nxr*nyr*nzr
895 dnbyte = glsum(dnbyte,1)
896 dnbyte = dnbyte + iheadersize + 4. + isize*nelgt
897 dnbyte = dnbyte/1024/1024
899 call mntr_log(sfd_id,lp_prd,
'Checkpoint read:')
900 call mntr_logr(sfd_id,lp_vrb,
'avg data-throughput (MB/s) = ',
902 call mntr_logi(sfd_id,lp_vrb,
'io-nodes = ',nfileo)
905 $
'sfd_mfi; axisymmetric case not supported')
integer function gllel(ieg)
subroutine chkpt_get_fset(step_cnt, set_out)
Get step count to the checkpoint and a set number.
subroutine chkptms_map_gll(xf, yf, nxr, nzr, nel)
Interpolate input on velocity mesh.
subroutine mntr_logi(mid, priority, logs, ivar)
Write log message adding single integer.
subroutine mntr_tmr_is_name_reg(mid, mname)
Check if timer name is registered and return its id.
subroutine mntr_logr(mid, priority, logs, rvar)
Write log message adding single real.
subroutine mntr_warn(mid, logs)
Write warning message.
subroutine mntr_tmr_add(mid, icount, time)
Check if timer id is registered. This operation is performed locally.
subroutine mntr_mod_is_name_reg(mid, mname)
Check if module name is registered and return its id.
subroutine mntr_abort(mid, logs)
Abort simulation.
subroutine mntr_set_conv(ifconv)
Set convergence flag to shorten simulation.
subroutine mntr_log(mid, priority, logs)
Write log message.
subroutine mntr_mod_reg(mid, pmid, mname, mdscr)
Register new module.
subroutine mntr_get_step_delay(dstep)
Get step delay.
subroutine mntr_tmr_reg(mid, pmid, modid, mname, mdscr, ifsum)
Register new timer.
subroutine mntr_check_abort(mid, ierr, logs)
Abort simulation.
subroutine rprm_rp_is_name_reg(rpid, mid, pname, ptype)
Check if parameter name is registered and return its id. Check flags as well.
subroutine rprm_rp_get(ipval, rpval, lpval, cpval, rpid, ptype)
Get runtime parameter form active section. This operation is performed locally.
subroutine rprm_sec_is_name_reg(rpid, mid, pname)
Check if section name is registered and return its id. Check mid as well.
subroutine rprm_rp_reg(rpid, mid, pname, pdscr, ptype, ipval, rpval, lpval, cpval)
Register new runtime parameter.
subroutine rprm_sec_set_act(ifact, rpid)
Set section's activation flag. Master value is broadcasted.
subroutine rprm_sec_reg(rpid, mid, pname, pdscr)
Register new parameter section.
subroutine sfd_solve
Update filtered velocity field.
subroutine sfd_main
Main SFD interface.
logical function sfd_is_initialised()
Check if module was initialised.
subroutine sfd_register()
Register SFD module.
subroutine sfd_forcing(ffx, ffy, ffz, ix, iy, iz, ieg)
Calcualte SFD forcing.
subroutine sfd_rst_read
Read from checkpoint.
subroutine sfd_rst_write
Create checkpoint.
subroutine sfd_end
Finalise SFD.
subroutine sfd_mfo(fname)
Store SFD restart file.
subroutine sfd_mfi(fname)
Load SFD restart file.
subroutine sfd_init()
Initialise SFD module.
subroutine mfi_prepare(hname)
subroutine add3s2(a, b, c, c1, c2, n)
subroutine add2s1(a, b, c1, n)
subroutine opcmult(a, b, c, const)
subroutine opcopy(a1, a2, a3, b1, b2, b3)
subroutine opsub3(a1, a2, a3, b1, b2, b3, c1, c2, c3)
subroutine opadd2cm(a1, a2, a3, b1, b2, b3, c)
subroutine outpost2(v1, v2, v3, vp, vt, nfldt, name3)