You are on page 1of 12

PROGRAM shad

! This program is a simple computational fluid dynamics program that


! finds numerical solutions of the compressible single-component
! Navier-Stokes equations in two-dimensional Cartesian and cylindrical
! coordinates.
! The author may be reached at adastera47@yahoo.com. This e-mail address
! is for reporting bugs or improvements to the software. No technical
! support will be provided.
! Copyright (C) 2010 Lawrence D. Cloutman
! This file is part of the SHAD software package.
! SHAD is free software: you can redistribute it and/or modify it
! under the terms of the GNU General Public License as published by
! the Free Software Foundation, either version 3 of the License,
! or (at your option) any later version.
! SHAD is distributed in the hope that it will be useful, but
! WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
! You should have received a copy of the GNU General Public License
! along with this program in the file SHAD.readme.txt. If not, see
! <http://www.gnu.org/licenses/>.
implicit none
integer i, j, im1, jm1, imax, jmax, iter, ncyc
character*80 label
character*8 nab
real*8, allocatable :: xc(:), yc(:), beta(:,:)
real*8, allocatable :: u(:,:), un(:,:), v(:,:), vn(:,:)
real*8, allocatable :: p(:,:), ro(:,:), ron(:,:), q(:,:)
real*8, allocatable :: e(:,:), en(:,:)
integer ibar, jbar, kl, kr, kt, kb, nwprt, nwfin
double precision delx, dely, delt, xnu, cyl,
1 epsi, pr, gx, gy, ui, vi, omg, twl, twr, twb, twt,
2 alpha, gam1, roi, eamb, wtmol, rgas
namelist /shadin/ ibar, jbar, delx, dely, delt, xnu, cyl,
1 epsi, pr, gx, gy, ui, vi, nwfin, nwprt, omg,
2 alpha, kl, kr, kt, kb, gam1, roi, eamb, wtmol,
3 rgas, label, twl, twr, twb, twt
double precision a1, a2, csubp, csubv, delp, dt, et, f, flg,
1 ftd, fux, fuy, fvx, fvy, otd, pi, pt, pto, rdx, rdy, rdx2, rdy2,
2 rot, t, vk, visx, visy,xkap, xkapx, xkapy, d, fluxl, fluxr,
3 div, xmu, ur, ul, vt, vb, volc, vol, uave, vave, fluxb, fluxt,
4 vconv, omcyl, redp, redm
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
CCC SPECIAL INITIAL CONDITION FOR RAYLEIGH-TAYLOR INSTABILITY
double precision ypert, yfrac, ycent
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
c +++
c +++ read initial input data
c +++
OPEN (unit=12,file='tape12',form='formatted') ! OUTPUT FILE
OPEN (unit=5, file='itape', form='formatted') ! INPUT FILE
read (5, shadin)
CLOSE(5)
write (12,50) ibar, jbar, delx, dely, delt, xnu, cyl,
1 epsi, pr, gx, gy, ui, vi, nwfin, nwprt, omg,
2 alpha, kl, kr, kt, kb, gam1, roi, eamb, twl, twr, twb,
3 twt, wtmol, rgas
50 format(6x,'ibar= ',i10/6x,'jbar= ',i10/6x,'delx= ',1p,D12.5/
1 6x,'dely= ',D12.5/6x,'delt= ',D12.5/7x,'xnu= ',D12.5/7x,'cyl= ',
2 D12.5/6x,'epsi= ',D12.5/8x,'pr= ',D12.5/8x,'gx= ',D12.5/
3 8x,'gy= ',D12.5/8x,'ui= ',D12.5/8x,'vi= ',D12.5/
4 5x,'nwfin= ',i10/5x,'nwprt= ',i10/7x,
5 'omg= ',D12.5/5x,'alpha= ',D12.5/8x,'kl= ',i10/8x,'kr= ',i10/
6 8x,'kt= ',i10/8x,'kb= ',i10/6x,'gam1= ',D12.5/
7 7x,'roi= ',D12.5/5x,'t amb= ',D12.5/
8 ' twl, twr, twb, twt=',4d13.5/
9 4x,'mol wt= ',D12.5/6x,'rgas= ',D12.5)
c +++ compute constant terms + + + + + + + + + + + + + + + + + + + + +
pi = 3.1415927d+00
imax = ibar + 2
jmax = jbar + 2
im1 = imax - 1
jm1 = jmax - 1
rdx = 1.0D+00 / delx
rdy = 1.0D+00 / dely
rdx2 = rdx * rdx
rdy2 = rdy * rdy
otd = 1.D+00 / 3.D+00
ftd = 4.D+00 / 3.D+00
csubv = rgas / (wtmol * gam1)
csubp = (gam1 + 1.D+00) * csubv
eamb = eamb * csubv
xkap = xnu * csubp * roi / pr
xmu = xnu * roi
omcyl = 1.d+00 - cyl
c +++ allocate arrays + + + + + + + + + + + + + + + + + + + + + + + + +
allocate (xc(imax))
allocate (yc(jmax))
allocate (beta(imax,jmax))
allocate (u(imax,jmax))
allocate (un(imax,jmax))
allocate (v(imax,jmax))
allocate (vn(imax,jmax))
allocate (p(imax,jmax))
allocate (ro(imax,jmax))
allocate (ron(imax,jmax))
allocate (q(imax,jmax))
allocate (e(imax,jmax))
allocate (en(imax,jmax))
c +++ initialize the uniform mesh + + + + + + + + + + + + + + + + + + +
do 15 i = 1, imax
xc(i) = delx * (real(i) - 1.5D+00)
15 continue
do 20 j = 1, jmax
yc(j) = dely * (real(j)-1.5D+00)
20 continue
c *** initialize dependent variables + + + + + + + + + + + + + + + + +
t = 0.D+00
iter = 0
ncyc = 0
a1 = gy * dely * 0.5D+00
a2 = 1.D+00 / ( 1.D+00 - a1 / ( gam1 * eamb ) )
do j = 1, jmax
if (j .eq. 1) then
p(1,1) = gam1 * roi * eamb
ro (1,1) = roi
else
p(1,j) = (p(1,j-1) + a1 * ro (1,j-1)) * a2
ro (1,j) = p(1,j) / (gam1 * eamb)
endif
do i = 1, imax
u(i,j) = ui
v(i,j) = vi
e(i,j) = eamb
ro (i,j) = ro (1,j)
p(i,j) = p(1,j)
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
CCC SPECIAL INITIAL CONDITION FOR RAYLEIGH-TAYLOR INSTABILITY
ro(i,j) = roi
ycent = (real(j) - 1.5d+00) * dely
yfrac = 1.d+00
CCC Equation for the perturbed interface ypert(x)
ypert = 4.4d+00 + 0.2d+00 * dcos(2.d+00 * pi* xc(i) / 7.3d+00)
if ((ycent + 0.5d+00 * dely) .gt. ypert) then
if ((ycent - 0.5d+00 * dely) .gt. ypert) then
yfrac = 1.57d+00
else
yfrac = (ypert - (ycent - 0.5d+00 * dely)) / dely
yfrac = ((1.d+00 - yfrac) * 1.57d+00) + yfrac
endif
endif
ro(i,j) = ro(i,j) * yfrac
e(i,j) = e(i,j) / yfrac
p(i,j) = gam1 * ro(i,j) * e(i,j)
CCC if (j .ge. jmax/2) then
CCC ro(i,j) = ro(i,j) * 1.57d+00
CCC e(i,j) = e(i,j) / 1.57d+00
CCC if (j .eq. jmax/2 .and. i .le. imax/2) then
CCC ro(i,j) = ro(i,j) * 1.01d+00
CCC e(i,j) = e(i,j) / 1.01d+00
CCC endif
CCC endif
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
ron(i,j)=ro(i,j)
en(i,j)=e(i,j)
enddo
enddo
write (*,'(A)') ' End setup, begin fluid dynamics.'
go to 75
c +++ start cycle + + + + + + + + + + + + + + + + + + + + + + + + + + +
59 continue
iter=0
flg=1.D+00
c +++ compute temporary u and v + + + + + + + + + + + + + + + + + + +
do j = 2, jm1
do i = 2, im1
fux = 0.5D+00 * rdx * ( un(i,j) * (un(i+1,j) - un(i-1,j))
1 -alpha*abs(un(i,j))*(un(i+1,j)-2.0D+00 *un(i,j)+un(i-1,j)))
vconv = (vn(i,j) + vn(i+1,j) + vn(i,j-1) + vn(i+1,j-1))
1 * 0.25d+00
fuy = rdy * 0.5D+00 * ( (un(i,j+1) - un(i,j-1)) * vconv
1 - alpha * abs(vconv)
2 *(un(i,j+1) - 2.D+00 * un(i,j) + un(i,j-1)) )
vconv = (un(i-1,j+1) + un(i,j+1) + un(i-1,j) + un(i,j))
1 * 0.25d+00
fvx = rdx * 0.5D+00 * ( (vn(i+1,j) - vn(i-1,j)) * vconv
1 - alpha * abs(vconv)
2 * (vn(i+1,j) - 2.0D+00 * vn(i,j) + vn(i-1,j)))
fvy = 0.5D+00 * rdy * ( vn(i,j)*(vn(i,j+1)-vn(i,j-1))
1 -alpha*abs(vn(i,j))*(vn(i,j+1)- 2.0D+00 * vn(i,j)+vn(i,j-1)))
c +++ diffusion terms
vk = 2.D+00 * xmu / (ro(i,j) + ro(i+1,j))
visx = vk * (
1 (un(i+1,j) - 2.D+00 * un(i,j) + un(i-1,j)) * ftd * rdx2
1 + (un(i,j+1) - 2.D+00 * un(i,j) + un(i,j-1)) * rdy2
2 + (vn(i+1,j) - vn(i+1,j-1) - vn(i,j) + vn(i,j-1)) *otd*rdx*rdy
3 + ftd * cyl * ((un(i+1,j) - un(i-1,j))* 0.5D+00 * rdx
4 - un(i,j) / (xc(i) + 0.5D+00 * delx) )
5 / (xc(i) + 0.5D+00 * delx) )
vk = 2.D+00 * xmu / (ro(i,j) + ro(i,j+1))
visy = vk * (
1 (vn(i+1,j) - 2.D+00 * vn(i,j) + vn(i-1,j)) * rdx2
1 + (vn(i,j+1) - 2.D+00 * vn(i,j) + vn(i,j-1)) * rdy2 * ftd
2 + (un(i,j+1) - un(i,j) - un(i-1,j+1) + un(i-1,j)) * otd*rdx*rdy
3 + cyl * ((vn(i+1,j) - vn(i-1,j)) * 0.5D+00 * rdx
4 + otd * 0.5D+00 * rdy * (un(i,j+1)
5 + un(i-1,j+1) - un(i,j) - un(i-1,j))) / xc(i) )
u(i,j) = un(i,j) + delt*( 2.0D+00 *(p(i,j)-p(i+1,j))*rdx
1 / (ro(i,j) + ro(i+1,j)) + gx - fux - fuy + visx)
v(i,j) = vn(i,j) + delt*( 2.0D+00 *(p(i,j)-p(i,j+1))*rdy
1 / (ro(i,j) + ro(i,j+1)) + gy - fvx - fvy + visy)
enddo
enddo
c +++ set boundary conditions + + + + + + + + + + + + + + + + + + + + +
75 continue
do 140 j = 2, jm1
ro(1,j) = ro(2,j) ! left wall
ron(1,j) = ron(2,j)
if (twl .ge. 0.d+00) then ! if wall T > 0, use fixed-T bc
e(1,j) = 2.D+00 * (twl * csubv) - e(2,j)
en(1,j) = 2.D+00 * (twl * csubv) - en(2,j)
else ! otherwise, use an adiabatic condition
e(1,j) = e(2,j)
en(1,j) = en(2,j)
endif
ro(imax,j) = ro(im1,j) ! right wall
ron(imax,j) = ron(im1,j)
if (twr .ge. 0.d+00) then
e(imax,j) = 2.D+00 * (twr * csubv) - e(im1,j)
en(imax,j) = 2.D+00 * (twr * csubv) - en(im1,j)
else
e(imax,j) = e(im1,j)
en(imax,j) = en(im1,j)
endif
select case (kl)
case(1)
u(1,j) = 0.0D+00
v(1,j) = v(2,j)
case(2)
u(1,j) = 0.0D+00
v(1,j) = -v(2,j)
case(3)
if (iter .le. 0) then
u(1,j) = u(2,j)
v(1,j) = v(2,j)
endif
case(4)
u(1,j) = u(im1,j)
v(1,j) = v(im1,j)
ro(1,j) = ro(im1,j)
e(1,j) = e(im1,j)
ron(1,j) = ron(im1,j)
en(1,j) = en(im1,j)
end select
select case (kr)
case(1)
u(im1,j) = 0.0D+00
v(imax,j) = v(im1,j)
case(2)
u(im1,j) = 0.0D+00
v(imax,j) = -v(im1,j)
case(3)
if (iter .le. 0) then
u(im1,j) = u(ibar,j)
v(imax,j) = v(im1,j)
endif
case(4)
u(imax,j) = u(2,j)
v(imax,j) = v(2,j)
ro(imax,j) = ro(2,j)
ron(imax,j) = ron(2,j)
e(imax,j) = e(2,j)
en(imax,j) = en(2,j)
end select
140 continue
do 180 i=2,im1
ro(i,1) = ro(i,2)
ron(i,1) = ron(i,2)
if (twb .ge. 0.d+00) then
e(i,1) = 2.D+00 * (twb * csubv) - e(i,2)
en(i,1) = 2.D+00 * (twb * csubv) - en(i,2)
else
e(i,1) = e(i,2)
en(i,1) = en(i,2)
endif
ro(i,jmax) = ro(i,jm1)
ron(i,jmax) = ro(i,jm1)
if (twt .ge. 0.d+00) then
e(i,jmax) = 2.D+00 * (twt * csubv) - e(i,jm1)
en(i,jmax) = 2.D+00 * (twt * csubv) - en(i,jm1)
else
e(i,jmax) = e(i,jm1)
en(i,jmax) = en(i,jm1)
endif
select case (kt)
case(1)
v(i,jm1) = 0.0D+00
u(i,jmax) = u(i,jm1)
case(2)
v(i,jm1) = 0.0D+00
u(i,jmax) = -u(i,jm1)
case(3)
if (iter .le. 0) then
v(i,jm1) = v(i,jbar)
u(i,jmax) = u(i,jm1)
endif
case(4)
v(i,jmax) = v(i,2)
u(i,jmax) = u(i,2)
ro(i,jmax) = ro(i,2)
ron(i,jmax) = ron(i,2)
e(i,jmax) = e(i,2)
en(i,jmax) = en(i,2)
end select
select case (kb)
case(1)
v(i,1) = 0.0D+00
u(i,1) = u(i,2)
case(2)
v(i,1) = 0.0D+00
u(i,1) = -u(i,2)
case(3)
if (iter .le. 0) then
v(i,1) = v(i,2)
u(i,1) = u(i,2)
endif
case(4)
v(i,1) = v(i,jm1)
u(i,1) = u(i,jm1)
ro(i,1) = ro(i,jm1)
ron(i,1) = ron(i,jm1)
e(i,1) = e(i,jm1)
en(i,1) = en(i,jm1)
end select
180 continue
if (ncyc .eq. 0) go to 480
c +++ has convergence been reached + + + + + + + + + + + + + + + + + + +
if (flg .eq. 0.D+00) go to 400
iter = iter + 1
if (iter .lt. 2000) go to 255
if(ncyc .lt. 2) go to 400
t = 1.d+220
ncyc = 100000000
go to 502
c +++ compute updated cell velocities u, v + + + + + + + + + + + + + + +
255 continue
flg = 0.0D+00
do j = 2, jm1
do i = 2, im1
d = rdx * (u(i,j) - u(i-1,j)) + rdy * (v(i,j) - v(i,j-1))
1 + cyl * (u(i,j) + u(i-1,j)) / (2.D+00 * xc(i))
rot = ron(i,j) / (1.0D+00 + delt * d)
et = en(i,j) - p(i,j) * delt * d / ro(i,j)
pt = gam1 * rot * et
delp = -beta(i,j) * (p(i,j) - pt)
p(i,j) = p(i,j) + delp
if (abs(delp) .ge. (p(i,j) * epsi)) flg = 1.0D+00
u(i,j) = u(i,j) +2.0D+00*delt*rdx*delp/(ro(i,j)+ro(i+1,j))
u(i-1,j) = u(i-1,j)-2.0D+00*delt*rdx*delp/(ro(i-1,j)+ro(i,j))
v(i,j) = v(i,j) +2.0D+00*delt*rdy*delp/(ro(i,j)+ro(i,j+1))
v(i,j-1) = v(i,j-1)-2.0D+00*delt*rdy*delp/(ro(i,j-1)+ro(i,j))
c 300 continue
enddo
enddo
go to 75
400 continue
c +++ mass transport equation + + + + + + + + + + + + + + + + + + + + +
do j=2,jm1
do i=2,im1
fluxl = 0.5d+00 * ( u(i-1,j) * (ron(i-1,j) + ron(i,j))
1 + alpha * abs(u(i-1,j)) * (ron(i-1,j) - ron(i,j)) )
fluxr = 0.5d+00 * ( u(i,j) * (ron(i,j) + ron(i+1,j))
1 + alpha * abs(u(i,j)) * (ron(i,j) - ron(i+1,j)) )
fluxb = 0.5d+00 * ( v(i,j-1) * (ron(i,j-1) + ron(i,j))
1 + alpha * abs(v(i,j-1)) * (ron(i,j-1) - ron(i,j)) )
fluxt = 0.5d+00 * ( v(i,j) * (ron(i,j) + ron(i,j+1))
1 + alpha * abs(v(i,j)) * (ron(i,j) - ron(i,j+1)) )
ro(i,j) = ron(i,j) + delt * ( (fluxl - fluxr) / delx
1 + (fluxb - fluxt) / dely
2 - cyl * (fluxl + fluxr) / (2.D+00 * xc(i)) )
enddo
enddo
c +++
c +++ energy transport equation + + + + + + + + + + + + + + + + + + + +
c +++
xkapx = xkap * delt * rdx * rdx /csubv
xkapy = xkap * delt * rdy * rdy /csubv
do j = 2, jm1
do i = 2, im1
redp = omcyl + cyl * (xc(i) + 0.5d+00 * delx) / xc(i)
redm = omcyl + cyl * (xc(i) - 0.5d+00 * delx) / xc(i)
fluxl = ( u(i-1,j) * (ron(i-1,j) * en(i-1,j)
1 + ron(i,j) * en(i,j))
2 + alpha * abs(u(i-1,j))
3 * (ron(i-1,j) * en(i-1,j) - ron(i,j) * en(i,j)) )
4 * 0.5d+00
fluxr = ( u(i,j) * (ron(i,j) * en(i,j)
1 + ron(i+1,j) * en(i+1,j))
2 + alpha * abs(u(i,j))
3 * (ron(i,j) * en(i,j) - ron(i+1,j) * en(i+1,j)) )
4 * 0.5d+00
fluxb = ( v(i,j-1) * (ron(i,j-1) * en(i,j-1)
1 + ron(i,j) * en(i,j))
2 + alpha * abs(v(i,j-1))
3 * (ron(i,j-1) * en(i,j-1) - ron(i,j) * en(i,j)) )
4 * 0.5d+00
fluxt = ( v(i,j) * (ron(i,j) * en(i,j)
1 + ron(i,j+1) * en(i,j+1))
2 + alpha * abs(v(i,j))
3 * (ron(i,j) * en(i,j) - ron(i,j+1)* en(i,j+1)) )
4 * 0.5d+00
e(i,j) = ( ron(i,j) * en(i,j)
1 - delt * ( rdx * (redp * fluxr - redm * fluxl)
1 + rdy * (fluxt - fluxb) ) ) / ro(i,j)
div = rdx * (redp * u(i,j) - redm * u(i-1,j))
1 + rdy * (v(i,j) - v(i,j-1))
e(i,j) = e(i,j) - delt * p(i,j) * div / ro(i,j)
e(i,j) = e(i,j) + (xkapx *
1 ( redp * (en(i+1,j) - en(i,j))
2 - redm * (en(i,j) - en(i-1,j)) )
1 + xkapy * (en(i,j+1)-2.D+00 *en(i,j)+en(i,j-1))
2 ) / ro(i,j)
enddo
enddo
480 continue
c +++ compute relaxation factors + + + + + + + + + + + + + + + + + + + +
do i = 2, im1
do j = 2, jm1
pto = gam1 * ro(i,j) * e(i,j)
delp = 1.d-04 * pto
ur = 2.0D+00 * delt * rdx * delp / (ro(i,j) + ro(i+1,j))
ul = -2.0D+00 * delt * rdx * delp / (ro(i-1,j) + ro(i,j))
vt = 2.0D+00 * delt * rdy * delp / (ro(i,j) + ro(i,j+1))
vb = -2.0D+00 * delt * rdy * delp / (ro(i,j-1) + ro(i,j))
dt = delt * ( rdx * (ur - ul) + rdy * (vt - vb)
1 + cyl * (ur + ul) / (2.0D+00 * xc(i)) )
rot = ro(i,j) / (1.0D+00 + dt)
et = e(i,j) - p(i,j) / ro(i,j) * dt
pt = gam1 * rot * et
beta(i,j) = omg * delp / (delp - (pt - pto))
enddo
enddo
502 continue
c +++ print and plot + + + + + + + + + + + + + + + + + + + + + + + + + +
volc=delx*dely
f=0.D+00
do i = 2, im1
vol=volc
if (cyl .gt. 0.5D+00) vol = 2.D+00 * pi * xc(i) * volc
do j = 2, jm1
uave = u(i-1,j) + u(i,j)
vave = v(i,j-1) + v(i,j)
f = f + ro(i,j) * vol * (uave * uave + vave * vave)
enddo
enddo
f=0.125D+00 * f
if (mod(ncyc,10) .eq. 0) write (*,46) ncyc, iter, t, f
if (mod(ncyc,100) .eq. 0) write (12,46) ncyc, iter, t, f
46 format (1x,'ncyc=',i7,' iter=',i4,' t=',1p,d13.6,' ke=',d13.6)
if(mod(ncyc,nwprt) .ne. 0 .and. ncyc .gt. 1) go to 560
c +++ print and plot + + + + + + + + + + + + + + + + + + + + + + + + + +
write(12,49) iter, t, ncyc, f
49 format (//1x,'iter = ',i5,2x,'time = ',1p,D13.6,2x,'ncyc=',i9,2x,
1 'ke = ',D13.6/)
write(12,47)
47 format (6x,'i',5x,'j',8x,'u',13x,'v',13x,'p',12x,'ro',13x,'e',
$ 13x,'T')
write(12,48)
48 format (2x,i5,1x,i5,2x,1p,D12.5,5(2x,D12.5))
do j = 1, jmax
do i = 1, imax
q(i,j) = e(i,j) / csubv
p(i,j) = gam1 * ro(i,j) * e(i,j)
write(12,48) i, j, u(i,j), v(i,j), p(i,j), ro(i,j), e(i,j),
1 q(i,j)
enddo
enddo
C +++
c +++ contours plot starts
C +++
call prcon (ro,imax,jmax,im1,jm1)
nab='density'
write (12,280) nab,ncyc,t
call prcon (q,imax,jmax,im1,jm1)
nab='temp (K)'
write (12,280) nab,ncyc,t
c +++ Compute and plot the stream function (corner-centered).
c +++ Set stream function along bottom of mesh.
c +++ ro * v = -(1/r) df/dx (r = 1.0 Cartesian; r = x, cylindrical)
q(2,2) = 0.d+00
do i = 2, im1
q(i+1,2) = q(i,2) - ro(i,2) * v(i,1) * delx
1 * (omcyl + cyl * xc(i))
enddo
c +++ Now integrate upwards
c +++ ro * u = (1/r) df/dy
do i = 2, imax
do j = 2, jm1
q(i,j+1) = q(i,j) + 0.5d+00 * (ro(i,j) + ro(i-1,j))
1 * u(i-1,j) * dely
2 * (omcyl + cyl * (xc(i) - 0.5d+00 * delx))
enddo
enddo
c +++ Average corners to get cell center values
do i = 2, im1
do j = 2, jm1
q(i,j)= 0.25D+00 * (q(i,j) + q(i+1,j) + q(i,j+1) + q(i+1,j+1))
enddo
enddo
call prcon (q,imax,jmax,im1,jm1)
nab='stream f'
write (12,280) nab,ncyc,t
call prcon (p,imax,jmax,im1,jm1)
nab='pressure'
write (12,280) nab,ncyc,t
280 FORMAT (1X,A8,' ncyc =',I6,' t =',1P,D14.6///)
560 continue
c +++ set the advance time velocities u and v into the un and vn arrays
DO 600 j = 1, jmax
DO 600 i = 1, imax
un(i,j) = u(i,j)
vn(i,j) = v(i,j)
ron(i,j) = ro(i,j)
en(i,j) = e(i,j)
p(i,j) = gam1 * ro(i,j) * e(i,j)
600 CONTINUE
c +++ advance time t=t+delt + + + + + + + + + + + + + + + + + + + + + +
t = t + delt
ncyc = ncyc + 1
IF (ncyc .le. nwfin) GO TO 59
CLOSE(12)
STOP
END
C
C <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
C
SUBROUTINE prcon (q,nxp,nyp,nx,ny)
implicit none
C +++
C +++ this routine makes contour plots of q on the printer.
C +++ (nxp,nyp) are the dimensions of q. nx and ny are the maximum
C +++ i and j indices used.
C +++
integer nxp, nyp, nx, ny, i, j, jq, l
character*1, allocatable :: ip(:)
character*1 ic(10)
double precision q, con, dq
dimension q(nxp,nyp), con(11)
integer nlev, nlew
save
data nlev /10/
data (ic(i),i=1,10) /'0','1','2','3','4','5','6','7','8','9'/
nlew=nlev+1
c +++
c +++ set up the contour values.
c +++
con(1)=1.D+250
con(nlew)=-con(1)
do j = 2, ny
do i = 2, nx
con(1)=min(con(1),q(i,j))
con(nlew)=max(con(nlew),q(i,j))
enddo
enddo
dq=(con(nlew)-con(1))/real(nlev)
if (dq .le. max(abs(con(1)), abs(con(nlew)))*1.D-05) then
return
endif
allocate (ip(nxp))
do 30 l=2,nlev
con(l)=con(l-1)+dq
30 continue
write (12,90) con(1),con(nlew),dq
90 format (////5x,'min=',1p,D13.5,2x,'max=',D13.5,2x,'dq=',D13.5)
do 70 jq=2,ny
j=ny-jq+2
do 60 i=2,nx
do 40 l=2,nlew
ip(i)=ic(l-1)
if (con(l) .ge. q(i,j)) go to 50
40 continue
50 continue
60 continue
write (12,100) (ip(i), i = 2, nx)
100 format (1x,2000a1)
70 continue
c +++
c +++ the user may now put a label at the bottom of the plot.
c +++
deallocate (ip)
return
end

You might also like