c
c
c =====================================================
subroutine rpn2meu(ixy,maxm,meqn,mwaves,mbc,mx,qlo,qro,
& maux,auxl,auxr,wave,s,amdq,apdq)
c =====================================================
c
c # Two-component Roe-solver for the Euler equations with quasi-stationary
c # source term balancing.
c
c # On input, ql contains the state vector at the left edge of each cell
c # qr contains the state vector at the right edge of each cell
c
c # This data is along a slice in the x-direction if ixy=1
c # or the y-direction if ixy=2.
c # On output, wave contains the waves, s the speeds,
c # and amdq, apdq the decomposition of the flux difference
c # f(qr(i-1)) - f(ql(i))
c # into leftgoing and rightgoing parts respectively.
c # With the Roe solver we have
c # amdq = A^- \Delta q and apdq = A^+ \Delta q
c # where A is the Roe matrix. An entropy fix can also be incorporated
c # into the flux differences.
c
c # Note that the i'th Riemann problem has left state qr(i-1,:)
c # and right state ql(i,:)
c # From the basic clawpack routines, this routine is called with ql = qr
c
c # Copyright (C) 2002 Ralf Deiterding
c # Brandenburgische Universitaet Cottbus
c
implicit double precision (a-h,o-z)
c
dimension wave(1-mbc:maxm+mbc, meqn, mwaves)
dimension s(1-mbc:maxm+mbc, mwaves)
dimension qlo(1-mbc:maxm+mbc, meqn)
dimension qro(1-mbc:maxm+mbc, meqn)
dimension apdq(1-mbc:maxm+mbc, meqn)
dimension amdq(1-mbc:maxm+mbc, meqn)
dimension auxl(1-mbc:maxm+mbc, maux)
dimension auxr(1-mbc:maxm+mbc, maux)
c
c local arrays -- common block comroe is passed to rpt2eu
c ------------
parameter (maxm2 = 10005) !# assumes at most 10000x10000 grid with mbc=5
parameter (minm2 = -4) !# assumes at most mbc=5
dimension delta(6), delh(6)
logical efix
common /comroe/ u2v2(minm2:maxm2),u(minm2:maxm2),
& v(minm2:maxm2),enth(minm2:maxm2),a(minm2:maxm2),
& g1a2(minm2:maxm2),euv(minm2:maxm2),p(minm2:maxm2)
dimension ql(minm2:maxm2,6),qr(minm2:maxm2,6)
c
data efix /.true./ !# use entropy fix for transonic rarefactions
c
if (minm2.gt.1-mbc .or. maxm2.lt.maxm+mbc) then
write(6,*) 'need to increase maxm2 in rpA'
stop
endif
c
c # set mu to point to the component of the system that corresponds
c # to momentum in the direction of this slice, mv to the orthogonal
c # momentum:
c
if (ixy.eq.1) then
mu = 2
mv = 3
ma = 1
else
mu = 3
mv = 2
ma = 2
endif
c
c # note that notation for u and v reflects assumption that the
c # Riemann problems are in the x-direction with u in the normal
c # direciton and v in the orthogonal direcion, but with the above
c # definitions of mu and mv the routine also works with ixy=2
c # and returns, for example, f0 as the Godunov flux g0 for the
c # Riemann problems u_t + g(u)_y = 0 in the y-direction.
c
c
c # Compute delh for left states
do 11 i=2-mbc,mx+mbc
gamma1 = 1.d0/qlo(i,5)
gamma = gamma1 + 1.d0
pinf = qlo(i,6) * gamma1/gamma
G = (gamma**2-gamma+2.)/gamma1
r = qlo(i,1)
ru = qlo(i,mu)
rv = qlo(i,mv)
e = qlo(i,4)
delh(1) = auxl(i,ma)/(gamma1*(2.*(e-pinf)*gamma/r-ru**2*G/r**2))
delh(4) = auxl(i,ma)*r/(2.*e*gamma1)*(1.+ru**2*(3.-gamma)/
& (gamma1*(2.*(e-pinf)*gamma*r-G*ru**2)))
ql(i,1) = r*(1.-delh(1))
ql(i,mu) = ru
ql(i,mv) = rv
ql(i,4) = e*(1.-delh(4))
ql(i,5) = qlo(i,5)
ql(i,6) = qlo(i,6)
11 continue
c # Compute delh for right states
do 12 i=1-mbc,mx+mbc-1
gamma1 = 1.d0/qro(i,5)
gamma = gamma1 + 1.d0
pinf = qro(i,6) * gamma1/gamma
G = (gamma**2-gamma+2.)/gamma1
r = qro(i,1)
ru = qro(i,mu)
rv = qro(i,mv)
e = qro(i,4)
G = (gamma**2-gamma+2.)/gamma1
delh(1) = auxr(i,ma)/(gamma1*(2.*(e-pinf)*gamma/r-ru**2*G/r**2))
delh(4) = auxr(i,ma)*r/(2.*e*gamma1)*(1.+ru**2*(3.-gamma)/
& (gamma1*(2.*(e-pinf)*gamma*r-G*ru**2)))
qr(i,1) = r*(1.+delh(1))
qr(i,mu) = ru
qr(i,mv) = rv
qr(i,4) = e*(1.+delh(4))
qr(i,5) = qro(i,5)
qr(i,6) = qro(i,6)
12 continue
c do 13 i=2-mbc,mx+mbc-1
c pr = (qr(i,4) - 0.5d0*(qr(i,2)**2 +
c & qr(i,3)**2)/qr(i,1) - qr(i,6) ) / qr(i,5)
c pl = (ql(i,4) - 0.5d0*(ql(i,2)**2 +
c & ql(i,3)**2)/ql(i,1) - ql(i,6) ) / ql(i,5)
c cm = qr(i,mu)**2/qr(i,1)+pr-ql(i,mu)**2/ql(i,1)-pl
c ce = (qr(i,4)+pr)*qr(i,mu)/qr(i,1)-
c & (ql(i,4)+pl)*ql(i,mu)/ql(i,1)
c write(6,*) 'cm ',cm,qlo(i,1)*auxl(i,ma),cm-qlo(i,1)*auxl(i,ma)
c write(6,*) 'ce ',ce,qlo(i,mu)*auxl(i,ma),ce-qlo(i,mu)*auxl(i,ma)
c
c write(6,*) 'new ',ql(i,1),qlo(i,1),qr(i,1),ql(i,4),qlo(i,4),qr(i,4)
c 13 continue
c # compute the Roe-averaged variables needed in the Roe solver.
c # These are stored in the common block comroe since they are
c # later used in routine rpt2eu to do the transverse wave splitting.
c
do 10 i = 2-mbc, mx+mbc
rhsqrtl = dsqrt(qr(i-1,1))
rhsqrtr = dsqrt(ql(i,1))
rhsq2 = rhsqrtl + rhsqrtr
*
pl = (qr(i-1,4) - 0.5d0*(qr(i-1,2)**2 +
& qr(i-1,3)**2)/qr(i-1,1) - qr(i-1,6) ) / qr(i-1,5)
pr = (ql(i,4) - 0.5d0*(ql(i,2)**2 +
& ql(i,3)**2)/ql(i,1) - ql(i,6) ) / ql(i,5)
*
gamma1 = rhsq2 / ( qr(i-1,5)*rhsqrtl + ql(i,5)*rhsqrtr )
xjota = ( pl*qr(i-1,5)*rhsqrtl + pr*ql(i,5)*rhsqrtr ) / rhsq2
p(i) = xjota*gamma1
*
u(i) = (qr(i-1,mu)/rhsqrtl + ql(i,mu)/rhsqrtr) / rhsq2
v(i) = (qr(i-1,mv)/rhsqrtl + ql(i,mv)/rhsqrtr) / rhsq2
u2v2(i) = u(i)**2 + v(i)**2
enth(i) = (((qr(i-1,4)+pl)/rhsqrtl
& + (ql(i,4)+pr)/rhsqrtr)) / rhsq2
*
a2 = gamma1*(enth(i) - .5d0*u2v2(i))
a(i) = dsqrt(a2)
g1a2(i) = gamma1 / a2
euv(i) = enth(i) - u2v2(i)
10 continue
c
c
c # now split the jump in q at each interface into waves
c
c # find a1 thru a6, the coefficients of the 6 eigenvectors:
do 20 i = 2-mbc, mx+mbc
delta(1) = ql(i,1) - qr(i-1,1)
delta(2) = ql(i,mu) - qr(i-1,mu)
delta(3) = ql(i,mv) - qr(i-1,mv)
delta(4) = ql(i,4) - qr(i-1,4)
delta(5) = ql(i,5) - qr(i-1,5)
delta(6) = ql(i,6) - qr(i-1,6)
a3 = g1a2(i) * (euv(i)*delta(1)
& + u(i)*delta(2) + v(i)*delta(3) - delta(4)
& + p(i)*delta(5) + delta(6))
a2 = delta(3) - v(i)*delta(1)
a4 = (delta(2) + (a(i)-u(i))*delta(1) - a(i)*a3) / (2.d0*a(i))
a1 = delta(1) - a3 - a4
a5 = delta(5)
a6 = delta(6)
c
c # Compute the waves.
c # Note that the 2-wave and 3-wave as well as the 5-wave and 6-wave
c # travel at the same speed and are lumped together in wave(.,.,2).
c # The 4-wave is then stored in wave(.,.,3).
c
wave(i,1 ,1) = a1
wave(i,mu,1) = a1*(u(i)-a(i))
wave(i,mv,1) = a1*v(i)
wave(i,4 ,1) = a1*(enth(i) - u(i)*a(i))
wave(i,5 ,1) = 0.d0
wave(i,6 ,1) = 0.d0
s(i,1) = u(i)-a(i)
c
wave(i,1 ,2) = a3
wave(i,mu,2) = a3*u(i)
wave(i,mv,2) = a3*v(i) + a2
wave(i,4 ,2) = a3*0.5d0*u2v2(i) + a2*v(i) + a5*p(i) + a6
wave(i,5 ,2) = a5
wave(i,6 ,2) = a6
s(i,2) = u(i)
c
wave(i,1 ,3) = a4
wave(i,mu,3) = a4*(u(i)+a(i))
wave(i,mv,3) = a4*v(i)
wave(i,4 ,3) = a4*(enth(i)+u(i)*a(i))
wave(i,5 ,3) = 0.d0
wave(i,6 ,3) = 0.d0
s(i,3) = u(i)+a(i)
20 continue
c
c
c # compute flux differences amdq and apdq.
c ---------------------------------------
c
if (efix) go to 110
c
c # no entropy fix
c ----------------
c
c # amdq = SUM s*wave over left-going waves
c # apdq = SUM s*wave over right-going waves
c
do 100 m=1,6
do 100 i=2-mbc, mx+mbc
amdq(i,m) = 0.d0
apdq(i,m) = 0.d0
do 90 mw=1,mwaves
if (s(i,mw) .lt. 0.d0) then
amdq(i,m) = amdq(i,m) + s(i,mw)*wave(i,m,mw)
else
apdq(i,m) = apdq(i,m) + s(i,mw)*wave(i,m,mw)
endif
90 continue
100 continue
go to 900
c
c-----------------------------------------------------
c
110 continue
c
c # With entropy fix
c ------------------
c
c # compute flux differences amdq and apdq.
c # First compute amdq as sum of s*wave for left going waves.
c # Incorporate entropy fix by adding a modified fraction of wave
c # if s should change sign.
c
do 200 i = 2-mbc, mx+mbc
c
c # check 1-wave:
c ---------------
c
rhoim1 = qr(i-1,1)
pim1 = (qr(i-1,4) - 0.5d0*(qr(i-1,mu)**2 +
& qr(i-1,mv)**2)/qr(i-1,1) - qr(i-1,6) ) / qr(i-1,5)
gamma1 = 1.d0/qr(i-1,5)
gamma = gamma1 + 1.d0
pinf = qr(i-1,6)*gamma1/gamma
cim1 = dsqrt(gamma*(pim1+pinf)/rhoim1)
s0 = qr(i-1,mu)/rhoim1 - cim1 !# u-c in left state (cell i-1)
c # check for fully supersonic case:
if (s0.ge.0.d0 .and. s(i,1).gt.0.d0) then
c # everything is right-going
do 60 m=1,6
amdq(i,m) = 0.d0
60 continue
go to 200
endif
c
rho1 = qr(i-1,1) + wave(i,1,1)
rhou1 = qr(i-1,mu) + wave(i,mu,1)
rhov1 = qr(i-1,mv) + wave(i,mv,1)
en1 = qr(i-1,4) + wave(i,4,1)
p1 = (en1 - 0.5d0*(rhou1**2 + rhov1**2)/rho1
& - qr(i-1,6) ) / qr(i-1,5)
c1 = dsqrt(gamma*(p1+pinf)/rho1)
s1 = rhou1/rho1 - c1 !# u-c to right of 1-wave
if (s0.lt.0.d0 .and. s1.gt.0.d0) then
c # transonic rarefaction in the 1-wave
sfract = s0 * (s1-s(i,1)) / (s1-s0)
else if (s(i,1) .lt. 0.d0) then
c # 1-wave is leftgoing
sfract = s(i,1)
else
c # 1-wave is rightgoing
sfract = 0.d0 !# this shouldn't happen since s0 < 0
endif
do 120 m=1,6
amdq(i,m) = sfract*wave(i,m,1)
120 continue
c
c # check 2-wave:
c ---------------
c
if (s(i,2) .ge. 0.d0) go to 200 !# 2- and 3- waves are rightgoing
do 140 m=1,6
amdq(i,m) = amdq(i,m) + s(i,2)*wave(i,m,2)
140 continue
c
c # check 3-wave:
c ---------------
c
rhoi = ql(i,1)
pi = (ql(i,4) - 0.5d0*(ql(i,mu)**2 +
& ql(i,mv)**2)/ql(i,1) - ql(i,6) ) / ql(i,5)
gamma1 = 1.d0/ql(i,5)
gamma = gamma1 + 1.d0
pinf = ql(i,6)*gamma1/gamma
ci = dsqrt(gamma*(pi+pinf)/rhoi)
s3 = ql(i,mu)/rhoi + ci !# u+c in right state (cell i)
c
rho2 = ql(i,1) - wave(i,1,3)
rhou2 = ql(i,mu) - wave(i,mu,3)
rhov2 = ql(i,mv) - wave(i,mv,3)
en2 = ql(i,4) - wave(i,4,3)
p2 = (en2 - 0.5d0*(rhou2**2+rhov2**2)/rho2 - ql(i,6)) / ql(i,5)
c2 = dsqrt(gamma*(p2+pinf)/rho2)
s2 = rhou2/rho2 + c2 !# u+c to left of 3-wave
if (s2 .lt. 0.d0 .and. s3.gt.0.d0) then
c # transonic rarefaction in the 3-wave
sfract = s2 * (s3-s(i,3)) / (s3-s2)
else if (s(i,3) .lt. 0.d0) then
c # 3-wave is leftgoing
sfract = s(i,3)
else
c # 3-wave is rightgoing
go to 200
endif
c
do 160 m=1,6
amdq(i,m) = amdq(i,m) + sfract*wave(i,m,3)
160 continue
200 continue
c
c # compute the rightgoing flux differences:
c # df = SUM s*wave is the total flux difference and apdq = df - amdq
c
do 220 m=1,6
do 220 i = 2-mbc, mx+mbc
df = 0.d0
do 210 mw=1,mwaves
df = df + s(i,mw)*wave(i,m,mw)
210 continue
apdq(i,m) = df - amdq(i,m)
220 continue
c
900 continue
return
end