** MBFGE Test: 2D laminar two-phase flow.
                 The main computational domain (coarse grid)
                 includes embedded fine grid.
  **************************************************************
  DISPLAY
  ----------------------------------------------------------
  The main purpose of the case is to demonstrate two-phase
  option with fine grid embedding.
  ----------------------------------------------------------
  ENDDIS
  **************************************************************
BOOLEAN(LRHFL); CCM= T;  LRHFL= T
  **************************************************************
  PHOTON USE
   p ; ; ; ; ;
 
   msg Computational Domain:
   mgrid 1 k 1
   mgrid 2 k 1 col 4
   msg Press Any Key to Continue...
   pause
   cl
   set vec av off
   msg 1st Phase Velocity Vectors:
   mvec 1 k 1 sh
   mvec 2 k 1 sh
   msg Press Any Key to Continue...
   pause
   cl
   msg 2nd Phase Velocity Vectors:
   set vec ph 2
   mvec 1 k 1 sh
   mvec 2 k 1 sh
   msg Press Any Key to Continue...
   pause
   cl
   msg Contours of Pressure:
   mcon 1 p1 k 1 fi
   0.001
   mcon 2 p1 k 1 fi
   0.001
   pause
   cl
   msg Contours of R2:
   mcon 1 r2 k 1 fi
   0.001
   mcon 2 r2 k 1 fi
   0.001
   msg Press E  to exit PHOTON ...
   pause
  ENDUSE
  **************************************************************
    GROUP 1. Run title and other preliminaries
TEXT(MBFGE: 2 phase 2D X-flow (X-Y plane, Re=500).
TITLE
REAL(REYNO,UIN,DIAM,LPIP,R1IN,R2IN)
INTEGER(NX1,NY1,NZ1,NX2,NY2,NZ2,IC,JC)
INTEGER(IXFG1,NXFG1,IFCX1,IYFG1,NYFG1,IFCY1)
REAL(XE1,YE1,XE2,YE2,XE3,YE3,XE4,YE4)
  ** Problem definition:
REYNO= 500;       UIN  = 1.0;  DIAM = 0.03
LPIP = 10.*DIAM;  R1IN = 0.5;  R2IN = 1.0-R1IN
NX1  = 33;        NY1  = 8;    NZ1  = 1
IXFG1= 15;        NXFG1= 5;    IFCX1= 3
IYFG1= 4;         NYFG1= 2;    IFCY1= 2
NX2  = NXFG1*IFCX1;  NY2= NYFG1*IFCY1;   NZ2  = 1
    GROUP 6. Body-fitted coordinates or grid distortion
BFC = T; GSET(D,NX1,NY1,NZ1,LPIP,DIAM,DIAM/10.)
  ** Define grid points and lines for the first domain:
GSET(P,P1,0.0, 0.0, 0.0);  GSET(P,P2,LPIP,0.0, 0.0)
GSET(P,P3,LPIP,DIAM,0.0);  GSET(P,P4,0.0, DIAM,0.0)
GSET(L,L12,P1,P2,NX1,1.0); GSET(L,L23,P2,P3,NY1,1.0)
GSET(L,L34,P3,P4,NX1,1.0); GSET(L,L41,P4,P1,NY1,1.0)
GSET(F,F1,P1,-,P2,-,P3,-,P4,-); GSET(M,F1,+I+J,1,1,1)
  ** Define grid points and lines for the first embedded grid:
IC = IXFG1+NXFG1;            JC = IYFG1+NYFG1
XE1= XC(IXFG1,IYFG1,1);      YE1= YC(IXFG1,IYFG1,1)
XE2= XC(IC,   IYFG1,1);      YE2= YC(IC,   IYFG1,1)
XE3= XC(IC,   JC,   1);      YE3= YC(IC,   JC,   1)
XE4= XC(IXFG1,JC,   1);      YE4= YC(IXFG1,JC,   1)
GSET(P,E1,XE1,YE1,0.0);      GSET(P,E2,XE2,YE2,0.0)
GSET(P,E3,XE3,YE3,0.0);      GSET(P,E4,XE4,YE4,0.0)
GSET(L,LE12,E1,E2,NX2,1.0);  GSET(L,LE23,E2,E3,NY2,1.0)
GSET(L,LE34,E3,E4,NX2,1.0);  GSET(L,LE41,E4,E1,NY2,1.0)
  ** Create grid for the main domain:
GSET(C,K:NZ1+1:,F,K1,1,NX1,1,NY1,+,0.0,0.0,DIAM/10.,INC,1.0)
DUMPC(MBGR1)
GSET(D,NX2,NY2,NZ2,LPIP,DIAM,DIAM/10.)
GSET(F,F2,E1,-,E2,-,E3,-,E4,-); GSET(M,F2,+I+J,1,1,1)
GSET(C,K:NZ2+1:,F,K1,1,NX2,1,NY2,+,0.0,0.0,DIAM/10.,INC,1.0)
DUMPC(MBGR2)
  ** Assemble blocks:
NUMBLK = 2
READCO(MBGR+L); GVIEW(Z); VIEW
    GROUP 7. Variables stored, solved & named
ONEPHS = F
NAME(C1)= UC1; NAME(C2)= UC2; NAME(C3)= VC1; NAME(C4)= VC2
SOLVE(P1,U1,U2,V1,V2,R2,UC1,UC2,VC1,VC2); STORE(R1)
SOLUTN(R2,P,P,P,N,P,P)
    GROUP 9. Properties of the medium (or media)
ENUL= UIN*DIAM/REYNO;  RHO1= 1.0;  RHO2= 1.0
    GROUP 10. Inter-phase-transfer processes and properties
CFIPS= GRND2;  CFIPA= 1E-4; CFIPC= 10000.
    GROUP 11. Initialization of variable or porosity fields
INIADD= F;  FIINIT(R1)= R1IN;  FIINIT(R2)= R2IN
FIINIT(UC1)= UIN;  FIINIT(VC1)= 1.E-5
FIINIT(UC2)= UIN;  FIINIT(VC2)= 1.E-5
    GROUP 13. Boundary conditions and special sources
    ** Inlet.
IF(LRHFL) THEN
+ MPATCH(1,IN,WEST,1,  1,  1,NY1,1,1,1,LSTEP)
+  COVAL(IN,UC1,ONLYMS, UIN); COVAL(IN,UC2,ONLYMS, UIN)
ELSE
+ MPATCH(1,IN,EAST,NX1,NX1,1,NY1,1,1,1,1)
+  COVAL(IN,UC1,ONLYMS,-UIN); COVAL(IN,UC1,ONLYMS,-UIN)
ENDIF
COVAL(IN,P1,FIXFLU,R1IN*RHO1*UIN);COVAL(IN,P2,FIXFLU,R2IN*RHO2*UIN)
COVAL(IN,VC1,ONLYMS,0.0);COVAL(IN,VC1,ONLYMS,0.0)
    ** Walls.
MPATCH(1,WS1,SWALL,1,NX1,1,1,1,NZ1,1,LSTEP)
 COVAL(WS1,UC1,1.0,0.0); COVAL(WS1,VC1,1.0,0.0)
 COVAL(WS1,UC2,1.0,0.0); COVAL(WS1,VC2,1.0,0.0)
IF(IYFG1.EQ.1) THEN
+MPATCH(2,WS2,SWALL,1,NX2,1,1,1,NZ2,1,LSTEP)
+ COVAL(WS2,UC1,1.0,0.0); COVAL(WS2,VC1,1.0,0.0)
+ COVAL(WS2,UC2,1.0,0.0); COVAL(WS2,VC2,1.0,0.0)
ENDIF
MPATCH(1,WN1,NWALL,1,NX1,NY1,NY1,1,NZ1,1,LSTEP)
 COVAL(WN1,UC1,1.0,0.0); COVAL(WN1,VC1,1.0,0.0)
 COVAL(WN1,UC2,1.0,0.0); COVAL(WN1,VC2,1.0,0.0)
IF((IYFG1+NYFG1-1).EQ.NY1) THEN
+MPATCH(2,WN2,NWALL,1,NX2,NY2,NY2,1,NZ2,1,LSTEP)
+ COVAL(WN2,UC1,1.0,UIN); COVAL(WN2,VC1,1.0,0.0)
+ COVAL(WN2,UC2,1.0,UIN); COVAL(WN2,VC2,1.0,0.0)
ENDIF
    ** Outlet.
IF(LRHFL) THEN
+ MPATCH(1,OUT,EAST,NX1,NX1,1,NY1,1,NZ1,1,LSTEP)
ELSE
+ MPATCH(1,OUT,WEST,1,1,1,NY1,1,NZ1,1,LSTEP)
ENDIF
 COVAL(OUT,P1,1.E3,0.0); COVAL(OUT,P2,1.E3*RHO2/RHO1,0.0)
    GROUP 15. Termination of sweeps
LSWEEP= 150; TSTSWP= -1
    GROUP 16. Termination of iterations
SELREF= T;   RESFAC= 1.E-3
    GROUP 17. Under-relaxation devices
RELAX(P1,LINRLX,0.5)
    GROUP 22. Spot-value print-out
IXMON = IXFG1-1; IYMON = NY1/2+1; IZMON = 1