[Nek5000-users] Smooth Restart feature in Nek

nek5000-users at lists.mcs.anl.gov nek5000-users at lists.mcs.anl.gov
Wed Aug 11 08:03:01 CDT 2010


Shriram,

Attached is a full-restart routine.   You need to update the repo
to use it.  It seems to work ok - hopefully the remarks in the attached
.usr file are clear.

Paul

On Mon, 9 Aug 2010, nek5000-users at lists.mcs.anl.gov wrote:

> Hi Paul,
>
> Thanks a lot. That would be very helpful.
>
> Regards
> Shriram
>
-------------- next part --------------
c-----------------------------------------------------------------------
c
c     .usr file with full-restart routines, called from userchk
c
c-----------------------------------------------------------------------
      subroutine my_full_restart_save    ! Call this from userchk

c     Saves files for next full restart


      include 'SIZE'
      include 'TOTAL'
      include 'RESTART'  ! max_rst

c     This is the full-restart save part:

      max_rst = 2*(nbdinp-1)    ! max # of rst files saved
      nps1 = 0
      if (ifheat) nps1 = 1 + npscal

      mostep = mod1(istep,iostep)
      if (istep.gt.iostep.and.mostep.lt.nbdinp) 
     $    call outpost2(vx,vy,vz,pr,t,nps1,'rst')


      return
      end
c-----------------------------------------------------------------------
      subroutine my_full_restart_load    ! Call this from userchk
      include 'SIZE'
      include 'TOTAL'

c     Typical file sequence for Torder=3
c                 :
c                 :
crw-r--r-- 1 fischer mcsz 135252 Aug 11 04:42 x.fld89
crw-r--r-- 1 fischer mcsz 135252 Aug 11 04:43 x.fld90
crw-r--r-- 1 fischer mcsz 135252 Aug 11 04:43 x.fld91
crw-r--r-- 1 fischer mcsz 135252 Aug 11 04:43 rstx.fld01
crw-r--r-- 1 fischer mcsz 135252 Aug 11 04:43 rstx.fld02
crw-r--r-- 1 fischer mcsz 135252 Aug 11 04:43 x.fld92
crw-r--r-- 1 fischer mcsz 135252 Aug 11 04:43 rstx.fld03
crw-r--r-- 1 fischer mcsz 135252 Aug 11 04:43 rstx.fld04
c
c    To restart from such a sequence, assuming you have specified x.fld92
c    in the .rea file, then you would use the following lines (uncommented):
c
c     if (istep.eq.1) s80 ='rstx.fld03'  ! This would be the case for Torder=3
c     if (istep.eq.2) s80 ='rstx.fld04'  ! using the second restart pair
c
c    If restarting from x.fld91, use
c
c     if (istep.eq.1) s80 ='rstx.fld01'  ! This would be the case for Torder=3
c     if (istep.eq.2) s80 ='rstx.fld02'  ! using the second restart pair
c
c    so that you get the two files (timesteps) immediately following x.fld91.
c
c    A similar procedure should hold for the 0.f0000n files.
c
c    For Torder=2, see comments below.
c

      character*80 s80

      call blank(s80,80)

      if (istep.eq.1) s80 ='rstx.fld01'  ! This would be the case for Torder=3
      if (istep.eq.2) s80 ='rstx.fld02'  ! using the first restart pair

c     if (istep.eq.1) s80 ='rstx.fld03'  ! This would be the case for Torder=3
c     if (istep.eq.2) s80 ='rstx.fld04'  ! using the second restart pair

c     if (istep.eq.1) s80 ='rstx.fld01'  ! This would be the case for Torder=2, file 1
c     if (istep.eq.1) s80 ='rstx.fld02'  ! This would be the case for Torder=2, file 2


      call bcast(s80,80)
      call chcopy(initc,s80,80)

c     time_curr = time

      nfiles = 1
      call restart(nfiles)  ! Note -- time is reset.

      if (nid.ne.0) time=0
      time = glmax(time,1)  ! Synchronize time across all processors

c     time = time_curr      ! Preserve current simulation time

      return
      end
c-----------------------------------------------------------------------
      subroutine uservp (ix,iy,iz,eg)
      include 'SIZE'
      include 'TOTAL'
      include 'NEKUSE'

      integer e,f,eg
c     e = gllel(eg)

      udiff =0.
      utrans=0.
      return
      end
c-----------------------------------------------------------------------
      subroutine userf  (ix,iy,iz,eg)
      include 'SIZE'
      include 'TOTAL'
      include 'NEKUSE'

      integer e,f,eg
c     e = gllel(eg)


c     Note: this is an acceleration term, NOT a force!
c     Thus, ffx will subsequently be multiplied by rho(x,t).


      ffx = 0.0
      ffy = 0.0
      ffz = 0.0

      return
      end
c-----------------------------------------------------------------------
      subroutine userq  (ix,iy,iz,eg)
      include 'SIZE'
      include 'TOTAL'
      include 'NEKUSE'

      integer e,f,eg
c     e = gllel(eg)

      qvol   = 0.0

      return
      end
c-----------------------------------------------------------------------
      subroutine userchk
      include 'SIZE'
      include 'TOTAL'

      logical if_drag_out,if_torq_out
      real x0(ldim)
      data x0 /ldim*0/

c     Comment out the line below if not restarting
      if (istep.gt.0.and.istep.lt.nbdinp) call my_full_restart_load

      call my_full_restart_save  ! save add'l files for full-restart


      scale = 1.
      if_drag_out = .true.
      if_torq_out = .false.
      call torque_calc(scale,x0,if_drag_out,if_torq_out)


      return
      end
c-----------------------------------------------------------------------
      subroutine userbc (ix,iy,iz,iside,ieg)
      include 'SIZE'
      include 'TOTAL'
      include 'NEKUSE'
      ux=1.0
      uy=0.0
      uz=0.0
      temp=0.0
      return
      end
c-----------------------------------------------------------------------
      subroutine useric (ix,iy,iz,ieg)
      include 'SIZE'
      include 'TOTAL'
      include 'NEKUSE'
      ux=1.0
      uy=0.0
      uz=0.0
      temp=0
      return
      end
c-----------------------------------------------------------------------
      subroutine usrdat
      include 'SIZE'
      include 'TOTAL'
c
      return
      end
c-----------------------------------------------------------------------
      subroutine usrdat2
      include 'SIZE'
      include 'TOTAL'

      param(66) = 4.   ! These give the std nek binary i/o and are 
      param(67) = 4.   ! good default values

      call set_obj     ! define objects for surface integrals

      return
      end
c-----------------------------------------------------------------------
      subroutine usrdat3
      include 'SIZE'
      include 'TOTAL'
c
      return
      end
c-----------------------------------------------------------------------
      subroutine set_obj  ! define objects for surface integrals
c
      include 'SIZE'
      include 'TOTAL'
c
      integer e,f
c
c     Define new objects

      nobj = 1
      iobj = 0
      do ii=nhis+1,nhis+nobj
         iobj = iobj+1
         hcode(10,ii) = 'I'
         hcode( 1,ii) = 'F' ! 'F'
         hcode( 2,ii) = 'F' ! 'F'
         hcode( 3,ii) = 'F' ! 'F'
         lochis(1,ii) = iobj
      enddo
      nhis = nhis + nobj

      if (maxobj.lt.nobj) write(6,*) 'increase maxobj in SIZE'
      if (maxobj.lt.nobj) call exitt

      do e=1,nelv
      do f=1,2*ndim
         if (cbc(f,e,1).eq.'W  ') then
            iobj = 0
c           if (f.eq.1) iobj=1  ! lower wall
c           if (f.eq.3) iobj=2  ! upper wall
            iobj=1              ! cylinder wall
            if (iobj.gt.0) then
               nmember(iobj) = nmember(iobj) + 1
               mem = nmember(iobj)
               ieg = lglel(e)
               object(iobj,mem,1) = ieg
               object(iobj,mem,2) = f
c              write(6,1) iobj,mem,f,ieg,e,nid,' OBJ'
    1          format(6i9,a4)
            endif
c
         endif
      enddo
      enddo
c     write(6,*) 'number',(nmember(k),k=1,4)
c
      return
      end
c-----------------------------------------------------------------------
c
c automatically added by makenek
      subroutine usrsetvert(glo_num,nel,nx,ny,nz) ! to modify glo_num
      integer*8 glo_num(1)
      return
      end


More information about the Nek5000-users mailing list