Writing Interpolated Field in Binary Format

334 views
Skip to first unread message

tonyz...@gmail.com

unread,
Mar 13, 2021, 9:18:54 PM3/13/21
to Nek5000

Hi,

 

                Using the following subroutine, I am able to interpolate the velocity field used by Nek5000 to a regular grid.

 

                                call interp_nfld()

 

                I am wondering if its possible to then write the resulting interpolated field in binary format?

 

                I am presently writing this interpolated field with the following code snippet, it is ascii and thus takes up a fair amount of disk space.

 

                                        fmt = '(I7.7)'

        write (x1,fmt) istep

        open(unit=64, file='slice_visual'//trim(x1))

        if (nid .eq. 0) then

                write(64,*) 'TOTP', INTP_TOTP,INTP_NUMX,

     &           INTP_NUMY,'x, y, u',pts(1,:),pts(2,:),fpts

        endif

 

               

 

Kind regards,

 

Tony

YuHsiang Lan

unread,
Mar 13, 2021, 10:35:14 PM3/13/21
to Nek5000
Hi Tony,

It depends on what you are going to do next.
Otherwise, you can always create your own writer/reader.

  if (nid.eq.0) then
    call byte_open(fname,ierr)
    call byte_write / byte_read  ! write/read in unit of byte
    call byte_close(ierr)
  endif


If you want to store them in Nek5000 format and use Nek5000's parallel I/O, then you can try

Way 1. Run Nek5000 on a box mesh. Then, call gfldr to load a restart file and interpolate the solution onto the box mesh.
      call gfldr('restart.fld') 
    You can use ifreguo = .true. to let outpost interpolate the solution onto the uniform grid, or simply use lx1=3.

Way 2: You can actually hijack the xm1, ym1, zm1 for the output file.

    For example, build your own box, partition it into each processors and store the coordinates into
      my_xm1(lx1,ly1,lz1,lelt)
      my_ym1(lx1,ly1,lz1,lelt)
      my_zm1(lx1,ly1,lz1,lelt)

    Use those coordinates to interpolate the solution into same data structure
      my_sol(lx1,ly1,lz1,lelt)

    Then do something like this:

    call opcopy(xm1_bak,ym1_bak,zm1_bak,xm1,ym1,zm1) ! backup, only need once
   
    call opcopy(xm1,ym1,zm1,my_xm1,my_ym1,my_zm1)    ! overwrite
    call outpost(my_sol,vy,vz,pr,t,'box')
    call opcopy(xm1,ym1,zm1,xm1_bak,ym1_bak,zm1_bak) ! recover
  
    It's easier to use the same amount of elements and grid points, but you can always store an id list, like
    tmp(i) = 0
    if (the grid point has your data) tmp(i) = 1
    and then outpost tmp as well so you can do isovolume in paraview.


Way 1 is used as a post-processing mode after you finish your simulation.
Way 2 can be used along with the simulation.


Hope this helps,
Yu-Hsiang
--


Reply all
Reply to author
Forward
0 new messages