<div dir="ltr"><div><div><div>Hi all,<br><br></div><div>I have a question on how to read in information from external files as an inflow boundary condition when running in parallel.<br></div><div>Similar problem to this: <a href="http://lists.mcs.anl.gov/pipermail/nek5000-users/2010-December/001151.html" target="_blank">http://lists.mcs.anl.gov/pipermail/nek5000-users/2010-December/001151.html</a></div><div><br></div><div>My geometry is a simple 3D rectangle prism with the inlet on the Y-Z plane @ x=0.<br></div><div><br></div>I
 have developed some code that reads in a 2D plane of velocity data from
 another simulation (in this case fluent) as the boundary condition in 
userbc(). I am happy to share the process and the code (Fortran 
input/output from NEK, and MATLAB to do interpolation) however here I am
 primarily focused on getting it working in parallel.<br><br></div><div>The
 process works fine in serial - it reads in 3 files (01.dat, 02.dat, 
03.dat) that hold the x,y,z velocity (respectively) for each node on the
 inlet.<br><br></div><div>However it does not work correctly when 
running in parallel - looking at the results after a few iterations 
shows that the velocities are being mapped to nodes that are not all on 
the inlet. It does compile and run though.<br></div><div><br></div><div>I'd sincerely appreciate any the help in making it work.<br></div><div><br></div><div>Warm regards,<br><br>Tom<br></div><div><br></div>I have included my .usr file below.<br></div><div><br>C-----------------------------<div>------------------------------------------<br>C  nek5000 user-file template<br>C<br>C  user specified routines:<br>C     - userbc : boundary conditions<br>C     - useric : initial conditions<br>C     - uservp : variable properties<br>C     - userf  : local acceleration term for fluid<br>C     - userq  : local source term for scalars<br>C     - userchk: general purpose routine for checking errors etc.<br>C<br>C-----------------------------------------------------------------------<br>      subroutine uservp(ix,iy,iz,eg) ! set variable properties<br>      include 'SIZE'<br>      include 'TOTAL'<br>      include 'NEKUSE'<br><br>      integer e,f,eg<br>c     e = gllel(eg)<br><br>      udiff  = 0.0<br>      utrans = 0.0<br><br>      return<br>      end<br>c-----------------------------------------------------------------------<br>      subroutine userf(ix,iy,iz,eg) ! set acceleration term<br>c<br>c     Note: this is an acceleration term, NOT a force!<br>c     Thus, ffx will subsequently be multiplied by rho(x,t).<br>c<br>      include 'SIZE'<br>      include 'TOTAL'<br>      include 'NEKUSE'<br><br>      integer e,f,eg<br><br>      ffx=0<br>      ffy=0<br>      ffz=0<br><br><br>      return<br>      end<br>c-----------------------------------------------------------------------<br>      subroutine userq(ix,iy,iz,eg) ! set source term<br>      include 'SIZE'<br>      include 'TOTAL'<br>      include 'NEKUSE'<br><br>      integer e,f,eg<br>c     e = gllel(eg)<br><br>      qvol   = 0.0<br>      source = 0.0<br><br>      return<br>      end<br>c-----------------------------------------------------------------------<br>      subroutine userbc(ix,iy,iz,iside,eg) ! set up boundary conditions<br><br>c     NOTE: This routine may or may not be called by every processor<br><br>      include 'SIZE'<br>      include 'TOTAL'<br>      include 'NEKUSE'<br>      integer e,eg,ix,iy,iz,NELY,NELZ,egs<br><br>      common /myinlet/ Arrangedu(ly1,lz1,lelt),<br>     >                 Arrangedv(ly1,lz1,lelt),<br>     >                 Arrangedw(ly1,lz1,lelt)<br><br>      e  = gllel(eg)<br>      ux   = Arrangedu(iy,iz,eg)<br>      uy   = Arrangedv(iy,iz,eg)<br>      uz   = Arrangedw(iy,iz,eg)<br>      temp = 0.0<br><br>      return<br>      end<br>c-----------------------------------------------------------------------<br>      subroutine useric(ix,iy,iz,eg) ! set up initial conditions<br>      include 'SIZE'<br>      include 'TOTAL'<br>      include 'NEKUSE'<br>      integer e,eg<br><br>      ux   = 7.235<br>      uy   = 0.0<br>      uz   = 0.0<br>      temp = 0.0<br><br>      return<br>      end<br>c-----------------------------------------------------------------------<br>      subroutine userchk()<br>      include 'SIZE'<br>      include 'TOTAL'<br><br>      return<br>      end<br>c-----------------------------------------------------------------------<br>      subroutine usrdat()   ! This routine to modify element vertices<br>      include 'SIZE'<br>      include 'TOTAL'<br><br>      return<br>      end<br>c-----------------------------------------------------------------------<br>      subroutine usrdat2()  ! This routine to modify mesh coordinates<br>      include 'SIZE'<br>      include 'TOTAL'<br><br>      common /myinlet/ Arrangedu(ly1,lz1,lelt),<br>     >                 Arrangedv(ly1,lz1,lelt),<br>     >                 Arrangedw(ly1,lz1,lelt)<br><br>      call read_inlet(Arrangedu,Arrangedv,Arrangedw) ! Read in inlet data for BCs<br><br>      return<br>      end<br>c-----------------------------------------------------------------------<br>      subroutine usrdat3()<br>      include 'SIZE'<br>      include 'TOTAL'<br><br>      return<br>      end<br>C-------------------------------------------------------------------------------<br>      subroutine read_inlet(Arrangedu,Arrangedv,Arrangedw) ! Read in the inlet data<br><br>      include 'SIZE'<br>      include 'TOTAL'<br><br>      Integer    Max_Nodes,          Lun_Dat<br>      Parameter( Max_Nodes = 200000, Lun_Dat = 3)<br><br>      real Var_1( Max_Nodes,lx1), Var_2( Max_Nodes), Var_3( Max_Nodes)<br>      real Var_4( Max_Nodes), Var_5( Max_Nodes), Var_6( Max_Nodes)<br>      real Arrangedu(ly1,lz1,lelt)<br>      real Arrangedv(ly1,lz1,lelt)<br>      real Arrangedw(ly1,lz1,lelt)<br><br>      integer i_row( Max_Nodes), i_eg( Max_Nodes), i_y( Max_Nodes)<br><br>      real junk<br><br>      integer i, j, k, l, m, n, imin, imax, N_Nodes,ze, iyz, egs,egz<br>      integer fcount<br><br>      Character Line* 72<br><br>      Character  Directory* 57<br>      Parameter( Directory=<br>     >   '/home/tom/NEK/meshControl/MultiBox/MultiBox_10/NewInlet4/')<br>c         1234567890123456789012345678901234567890123456789012345678<br><br>      Character  Filename* 4<br>      Parameter( Filename= '.dat')<br>c                           12345<br>      character(2) fc<br><br>C     +-----------+<br>C     | Execution |<br>C     +-----------+<br><br>1       format( 1x, a)<br><br>      do fcount=1,3 !for each file 01=u;02=v;03=w.<br><br>37    format (I2.2)<br>      write (fc,37) fcount ! converting integer to string<br>      print *,'Readining file #: ',fc<br><br>      open( unit = Lun_Dat, status = 'old', form='formatted', err = 2, <br>     >      file = Directory//trim(fc)//Filename)<br>      go to 3<br>2     write( 6, 1) 'Error Opening file - EXIT'<br><br><br>3     read( Lun_Dat, 1)  Line<br><br>      N_Nodes = 0<br>      do i = 1, Max_Nodes<br>         read( Lun_Dat, 11, end=5) i_row(i),  i_eg(i),  i_y(i), <br>     >                      Var_1(i,1), Var_1(i,2), Var_1(i,3), <br>     >                      Var_1(i,4), Var_1(i,5), Var_1(i,6),<br>     >                      Var_1(i,7), Var_1(i,8), Var_1(i,9) <br>11       format( i6, 1x, i5, 1x, i4, 9( 1x, 1P E16.9))<br>         N_Nodes = N_Nodes + 1<br>         <br>       if( fcount .EQ. 1) THEN<br>         iyz=i_y(i)<br>         egz=i_eg(i)<br>         do ze=1,lx1<br>         Arrangedu(iyz,ze,egz)= Var_1(i,ze)<br>         end do<br>       else if( fcount .EQ. 2) THEN<br>         iyz=i_y(i)<br>         egz=i_eg(i)<br>         do ze=1,lx1<br>         Arrangedv(iyz,ze,egz)= Var_1(i,ze)<br>         end do<br>      else if( fcount .EQ. 3) THEN<br>         iyz=i_y(i)<br>         egz=i_eg(i)<br>         do ze=1,lx1<br>         Arrangedw(iyz,ze,egz)= Var_1(i,ze)<br>         end do<br>      end if<br><br>      end do<br>      write( 6, 1) ' '<br>      write( 6, 1) ' WARNING - Max nodes exceeeded'<br>      write( 6, 1) ' '<br>5     write( 6, 6) N_Nodes<br>6     format( ' Number of nodes read = ', I8)<br><br>      end do<br><br>      end<br>C-------------------------------------------------------------------------------</div></div></div>