CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Mesh Generation & Pre-Processing (https://www.cfd-online.com/Forums/mesh-generation/)
-   -   Cylinder mesh in Fortran (https://www.cfd-online.com/Forums/mesh-generation/246781-cylinder-mesh-fortran.html)

niyas December 22, 2022 21:07

Cylinder mesh in Fortran
 
Hello everyone,
I am trying to create a simple cylinder mesh using Fortran (see the attached figure) and I think I did.
I want to make sure the cylindrical mesh I produced is correct and that is why I am here.
Please check and let me know if there are any changes.

Here is the code:

Code:

program cylinder_Grid
      parameter (mmx=601,nmx=21,omx=601)
      common/contr0/m,n,next,o
      common/coord /x(mmx,nmx,omx),y(mmx,nmx,omx),z(mmx,nmx,omx)

      m = 151; o = 11; n = 101
      dxy = 1.d0; rad = 1.d0

      dx = 3.d0/dble(m-1)
      dy = 0.2d0/dble(o-1)
      dz = 1.3d0/dble(n-1)     

      do k=1,n
      do j=1,o
      do i=1,m
            ang      = 0.4*(i-1)
            x(i,j,k) = dx*dble(rad*cos(ang))
            y(i,j,k) = dy*dble(rad*sin(ang))
            z(i,j,k) = dz*dble(k-1)       
      enddo
      enddo
      enddo
     
      print*,'z_end=',z(1,1,n)
     
      open(2,file='cylinder.grd',status='unknown')
      write(2,*) 'variables = x y z'
      write(2,*) 'zone t="", i=',m,'  j=',o,'  k=',n

      do k=1,n
      do j=1,o
      do i=1,m
        write(2,*) x(i,j,k), y(i,j,k), z(i,j,k)
      enddo
      enddo
      enddo

      close(2)

      stop
      end program cylinder_Grid

http://file:///Y:/Niyas/3DRDE/case_s...d/Cylinder.png


All times are GMT -4. The time now is 13:54.