GROUP 1. Run title and other preliminaries
    *** Q1 created by V. Semin for WUA-95/96
  DISPLAY
 
     This case considers the laminar or turbulent flow in
     a tank with four baffles, stirred by a four-bladed
     paddle. By symmetry only 1/4 of the tank has to be
     modelled.
 
     In the default laminar case the paddle rotates at 100 r.p.m.
 
     The case is as defined for WUA-95.
 
     The Q1 is set for a steady-state calculation, which will
     produce the time-averaged flow field.
 
     If it is required to calculate the instantaneous flow field,
     it is more efficient to calculate the steady flow field,and
     use this as the initial condition for a transient restart.
 
  ENDDIS
  
TEXT(Stirred reactor with baffles
  
  **************************************************************
BOOLEAN(LTURB,LSLD); LTURB = F; LSLD=T
  **************************************************************
INTEGER(NX1,NX2,NXI,NZ1,NZ2,NZI,NZDI)
INTEGER(II1,JJ1,IFF,ILL,JFF,JLL,KFF,KLL,IZC,IXC,IYC)
INTEGER(NY11,NY12,NY13,NY14,NY1,NY21,NY22,NY23,NY2)
REAL(UIMP,OMEGA,ROMED,VIMED,REYNO,DTHYD)
REAL(LREAC,HIMPB,HIMP,WIMP,TIMP,DTIM,DZIM,TBAF,XAR,YAR,ZAR,DZC)
REAL(XCUR,YCUR,ZCUR,RCUR,UCUR,VCUR,PWR)
REAL(R11,R12,R13,R14,R15,AL11,AL12,AL21,AL22,PI,PI4,PI8,PI38,SQT)
REAL(R21,R22,R23,R24,XI4,YI4,XI5,YI5,XI8,YI8,XI9,YI9)
REAL(Z0,Z1,Z2,Z3,Z4,Z5,PWZ)
REAL(TKEIN,EPSIN,FRIC,LMIX,KTDKP,COEF)
IF(LTURB) THEN
+ COEF= GRND2
ELSE
+ COEF= 1.0
ENDIF
NX1 = 8;  NX2 =NX1; NXI = 1;         NX =NX1+NX2+NXI
NY11= 2;  NY12=8;  NY13=8; NY14=2; NY1=NY11+NY12+NY13+NY14
NY21= 2;  NY22=8;  NY23=6;          NY2=NY21+NY22+NY23
NZ1 = 12; NZ2=NZ1;  NZI= 4; NZDI=2;  NZ =NZ1+NZ2+NZI+NZDI*2
PWZ = 1.4
PI = 3.1415; SQT=SQRT(2.0)
PI4=PI/4.0; PI8=PI/10.0; PI38=2*PI4-PI8
   * Impeller cylinder.[m]
R11= 0.008/2.0; R12= 0.0168/2.0; R13= 0.0508/2.0; R14=0.145/3.5
R15= R14+(R14-R13)/NY13*2
   * Baffle cylinder.[m]
R21= R14; R22= R15; R24= 0.145/2.0; R23= R24-0.0125
TBAF=0.003
   * Reactor height.
LREAC = 0.145
   * Impeller parameters.
HIMPB= 0.011
TIMP = 0.001; WIMP=0.009; HIMP = WIMP/SQT; DTIM=TIMP/SQT
DZIM = (HIMPB-HIMP-DTIM)/2.0
Z0=0.0; Z1=0.0667-DZIM; Z2 = Z1+DZIM;
Z3= Z2+HIMP+DTIM;  Z4=Z3+DZIM;  Z5=LREAC
   * Rotation speed.[r.p.m.]
IF(LTURB) THEN
+ OMEGA = 500.
ELSE
+ OMEGA = 100.
ENDIF
OMEGA = OMEGA * 3.1415*2.0/60.0
   * Impeller surface velocity.[m/s]
UIMP  = OMEGA*R13
   * Medium density.
ROMED = 1000.
IF(LTURB) THEN
+ VIMED =1.0E-6
ELSE
     REYNO = 183.0
     VIMED  = UIMP*R24*2.0/REYNO
+ VIMED = 0.211/ROMED
ENDIF
REYNO = UIMP*R24*2.0/VIMED
REYNO
   ** Turbulence parameters.
FRIC = 0.018;       TKEIN = 0.25*UIMP*UIMP*FRIC
LMIX = 0.09*R13;    EPSIN = 0.1643*TKEIN**1.5/LMIX
    GROUP 2. Transience; time-step specification
STEADY= t; GRDPWR(T,8*NX+1,1.0,1.0)
    GROUP 3. X-direction grid specification
    GROUP 4. Y-direction grid specification
    GROUP 5. Z-direction grid specification
    GROUP 6. Body-fitted coordinates or grid distortion
BFC = T
GSET(D,NX,NY1,NZ,R11,R11,LREAC)
  ** Plane-1
AL11=(WIMP-TIMP)/(2.0*SQT*R12); AL11=PI4-ASIN(AL11)
AL12=(WIMP+TIMP)/(2.0*SQT*R12); AL12=PI4-ASIN(AL12)
XI4 =R12*COS(AL11); YI4=R12*SIN(AL11)
XI5 =R12*COS(AL12); YI5=R12*SIN(AL12)
AL21=(WIMP-TIMP)/(2.0*SQT*R13); AL21=PI4-ASIN(AL21)
AL22=(WIMP+TIMP)/(2.0*SQT*R13); AL22=PI4-ASIN(AL22)
XI9 =R13*COS(AL21); YI9=R13*SIN(AL21)
XI8 =R13*COS(AL22); YI8=R13*SIN(AL22)
ZCUR = Z3; IZC = NZ1+NZI+NZDI+1
  ** Points.
GSET(P,P1 ,0.0,R11,ZCUR     );  GSET(P,P3 ,R12,0.0,ZCUR     )
GSET(P,P2 ,R11,0.0,ZCUR     );  GSET(P,P4 ,XI4,YI4,ZCUR     )
GSET(P,P5 ,XI5,YI5,ZCUR-DTIM);  GSET(P,P6 ,0.0,R12,ZCUR     )
GSET(P,P7 ,0.0,R13,ZCUR     );  GSET(P,P8 ,XI8,YI8,ZCUR-DTIM)
GSET(P,P9 ,XI9,YI9,ZCUR     );  GSET(P,P10,R13,0.0,ZCUR     )
GSET(P,P11,R14,0.0,ZCUR     );  GSET(P,P12,0.0,R14,ZCUR     )
GSET(P,P14,R15,0.0,ZCUR     );  GSET(P,P13,0.0,R15,ZCUR     )
  ** Lines.
GSET(L,L16,P1 ,P6 ,NY11,1.0); GSET(L,L23,P2 ,P3 ,NY11,1.0)
GSET(L,L45,P4 ,P5 ,NXI ,1.0); GSET(L,L98,P9 ,P8 ,NXI ,1.0)
GSET(L,L67,P6 ,P7 ,NY12,1.0); GSET(L,L58,P5 ,P8 ,NY12,1.0)
GSET(L,L49,P4 ,P9 ,NY12,1.0); GSET(L,N31,P3 ,P10,NY12,1.0)
GSET(L,N71,P7 ,P12,NY13,1.0); GSET(L,N11,P10,P11,NY13,1.0)
GSET(L,N23,P12,P13,NY14,1.0); GSET(L,N14,P11,P14,NY14,1.0)
XAR= R11*COS(PI4); YAR=R11*SIN(PI4);   ZAR = ZCUR
GSET(L,L12,P1,P2,NX,ARC,XAR,YAR,ZAR)
XAR= R12*COS(PI8); YAR=R12*SIN(PI8);   ZAR = ZCUR-DTIM*0.95
GSET(L,L35,P3,P5,NX2,ARC,XAR,YAR,ZAR)
XAR= R12*COS(PI38); YAR=R12*SIN(PI38); ZAR = ZCUR
GSET(L,L46,P4,P6,NX1,ARC,XAR,YAR,ZAR)
XAR= R13*COS(PI8); YAR=R13*SIN(PI8);   ZAR = ZCUR-DTIM*0.95
GSET(L,N18,P10,P8,NX2,ARC,XAR,YAR,ZAR)
XAR= R13*COS(PI38); YAR=R13*SIN(PI38); ZAR = ZCUR
GSET(L,L97,P9,P7,NX1,ARC,XAR,YAR,ZAR)
XAR= R14*COS(PI4); YAR=R14*SIN(PI4);   ZAR = ZCUR
GSET(L,N12,P11,P12,NX,ARC,XAR,YAR,ZAR)
XAR= R15*COS(PI4); YAR=R15*SIN(PI4);   ZAR = ZCUR
GSET(L,N34,P13,P14,NX,ARC,XAR,YAR,ZAR)
GSET(F,F1,P1 ,-    ,P2 ,-,P3 ,P5.P4,P6 ,-)
GSET(F,F2,P6 ,P4.P5,P3 ,-,P10,P8.P9,P7 ,-)
GSET(F,F3,P7 ,P9.P8,P10,-,P11,-    ,P12,-)
GSET(F,F4,P12,-    ,P11,-,P14,-    ,P13,-)
GSET(M,F1,+I+J,1,               1,IZC)
GSET(M,F2,+I+J,1,          NY11+1,IZC)
GSET(M,F3,+I+J,1,     NY11+NY12+1,IZC)
GSET(M,F4,+I+J,1,NY11+NY12+NY13+1,IZC)
gset(i)
  ** Plane-2
ZCUR = Z4; IZC = IZC+NZDI
  ** Points.
GSET(P,P1 ,0.0,R11,ZCUR     );  GSET(P,P3 ,R12,0.0,ZCUR     )
GSET(P,P2 ,R11,0.0,ZCUR     );  GSET(P,P4 ,XI4,YI4,ZCUR     )
GSET(P,P6 ,0.0,R12,ZCUR     );  GSET(P,P7 ,0.0,R13,ZCUR     )
GSET(P,P9 ,XI9,YI9,ZCUR     );  GSET(P,P10,R13,0.0,ZCUR     )
GSET(P,P11,R14,0.0,ZCUR     );  GSET(P,P12,0.0,R14,ZCUR     )
GSET(P,P14,R15,0.0,ZCUR     );  GSET(P,P13,0.0,R15,ZCUR     )
  ** Lines.
GSET(L,L16,P1 ,P6 ,NY11,1.0); GSET(L,L23,P2 ,P3 ,NY11,1.0)
GSET(L,L67,P6 ,P7 ,NY12,1.0); GSET(L,N31,P3 ,P10,NY12,1.0)
GSET(L,N71,P7 ,P12,NY13,1.0); GSET(L,N11,P10,P11,NY13,1.0)
GSET(L,N23,P12,P13,NY14,1.0); GSET(L,N14,P11,P14,NY14,1.0)
XAR= R11*COS(PI4); YAR=R11*SIN(PI4);   ZAR = ZCUR
GSET(L,L12,P1,P2,NX,ARC,XAR,YAR,ZAR)
XAR= R12*COS(PI8); YAR=R12*SIN(PI8);   ZAR = ZCUR
GSET(L,L34,P3,P4,NX2+NXI,ARC,XAR,YAR,ZAR)
XAR= R12*COS(PI38); YAR=R12*SIN(PI38); ZAR = ZCUR
GSET(L,L56,P4,P6,NX1,ARC,XAR,YAR,ZAR)
XAR= R13*COS(PI8); YAR=R13*SIN(PI8);   ZAR = ZCUR
GSET(L,N18,P10,P9,NX2+NXI,ARC,XAR,YAR,ZAR)
XAR= R13*COS(PI38); YAR=R13*SIN(PI38); ZAR = ZCUR
GSET(L,L97,P9,P7,NX1,ARC,XAR,YAR,ZAR)
XAR= R14*COS(PI4); YAR=R14*SIN(PI4);   ZAR = ZCUR
GSET(L,N12,P11,P12,NX,ARC,XAR,YAR,ZAR)
XAR= R15*COS(PI4); YAR=R15*SIN(PI4);   ZAR = ZCUR
GSET(L,N34,P13,P14,NX,ARC,XAR,YAR,ZAR)
GSET(F,F1,P1 ,- ,P2 ,-,P3 ,P4,P6 ,-)
GSET(F,F2,P6 ,P4,P3 ,-,P10,P9,P7 ,-)
GSET(F,F3,P7 ,P9,P10,-,P11,- ,P12,-)
GSET(F,F4,P12,- ,P11,-,P14,- ,P13,-)
GSET(M,F1,+I+J,1,               1,IZC)
GSET(M,F2,+I+J,1,          NY11+1,IZC)
GSET(M,F3,+I+J,1,     NY11+NY12+1,IZC)
GSET(M,F4,+I+J,1,NY11+NY12+NY13+1,IZC)
gset(i)
  ** Plane-3
AL11=(WIMP-TIMP)/(2.0*SQT*R12); AL11=PI4+ASIN(AL11)
AL12=(WIMP+TIMP)/(2.0*SQT*R12); AL12=PI4+ASIN(AL12)
XI4 =R12*COS(AL11); YI4=R12*SIN(AL11)
XI5 =R12*COS(AL12); YI5=R12*SIN(AL12)
AL21=(WIMP-TIMP)/(2.0*SQT*R13); AL21=PI4+ASIN(AL21)
AL22=(WIMP+TIMP)/(2.0*SQT*R13); AL22=PI4+ASIN(AL22)
XI9 =R13*COS(AL21); YI9=R13*SIN(AL21)
XI8 =R13*COS(AL22); YI8=R13*SIN(AL22)
ZCUR = Z2; IZC = NZ1+NZDI+1
  ** Points.
GSET(P,P1 ,0.0,R11,ZCUR     );  GSET(P,P3 ,R12,0.0,ZCUR     )
GSET(P,P2 ,R11,0.0,ZCUR     );  GSET(P,P4 ,XI4,YI4,ZCUR     )
GSET(P,P5 ,XI5,YI5,ZCUR+DTIM);  GSET(P,P6 ,0.0,R12,ZCUR     )
GSET(P,P7 ,0.0,R13,ZCUR     );  GSET(P,P8 ,XI8,YI8,ZCUR+DTIM)
GSET(P,P9 ,XI9,YI9,ZCUR     );  GSET(P,P10,R13,0.0,ZCUR     )
GSET(P,P11,R14,0.0,ZCUR     );  GSET(P,P12,0.0,R14,ZCUR     )
GSET(P,P14,R15,0.0,ZCUR     );  GSET(P,P13,0.0,R15,ZCUR     )
  ** Lines.
GSET(L,L16,P1 ,P6 ,NY11,1.0); GSET(L,L23,P2 ,P3 ,NY11,1.0)
GSET(L,L45,P4 ,P5 ,NXI ,1.0); GSET(L,L98,P9 ,P8 ,NXI ,1.0)
GSET(L,L67,P6 ,P7 ,NY12,1.0); GSET(L,L58,P5 ,P8 ,NY12,1.0)
GSET(L,L49,P4 ,P9 ,NY12,1.0); GSET(L,N31,P3 ,P10,NY12,1.0)
GSET(L,N71,P7 ,P12,NY13,1.0); GSET(L,N11,P10,P11,NY13,1.0)
GSET(L,N23,P12,P13,NY14,1.0); GSET(L,N14,P11,P14,NY14,1.0)
XAR= R11*COS(PI4); YAR=R11*SIN(PI4);   ZAR = ZCUR
GSET(L,L12,P1,P2,NX,ARC,XAR,YAR,ZAR)
XAR= R12*COS(PI8); YAR=R12*SIN(PI8);   ZAR = ZCUR
GSET(L,L34,P3,P4,NX2,ARC,XAR,YAR,ZAR)
XAR= R12*COS(PI38); YAR=R12*SIN(PI38); ZAR = ZCUR+DTIM*0.95
GSET(L,L56,P5,P6,NX1,ARC,XAR,YAR,ZAR)
XAR= R13*COS(PI8); YAR=R13*SIN(PI8);   ZAR = ZCUR
GSET(L,N18,P10,P9,NX2,ARC,XAR,YAR,ZAR)
XAR= R13*COS(PI38); YAR=R13*SIN(PI38); ZAR = ZCUR+DTIM*0.95
GSET(L,L97,P8,P7,NX1,ARC,XAR,YAR,ZAR)
XAR= R14*COS(PI4); YAR=R14*SIN(PI4);   ZAR = ZCUR
GSET(L,N12,P11,P12,NX,ARC,XAR,YAR,ZAR)
XAR= R15*COS(PI4); YAR=R15*SIN(PI4);   ZAR = ZCUR
GSET(L,N34,P13,P14,NX,ARC,XAR,YAR,ZAR)
GSET(F,F1,P1 ,-    ,P2 ,-,P3 ,P4.P5,P6 ,-)
GSET(F,F2,P6 ,P5.P4,P3 ,-,P10,P9.P8,P7 ,-)
GSET(F,F3,P7 ,P8.P9,P10,-,P11,-    ,P12,-)
GSET(F,F4,P12,-    ,P11,-,P14,-    ,P13,-)
GSET(M,F1,+I+J,1,               1,IZC)
GSET(M,F2,+I+J,1,          NY11+1,IZC)
GSET(M,F3,+I+J,1,     NY11+NY12+1,IZC)
GSET(M,F4,+I+J,1,NY11+NY12+NY13+1,IZC)
gset(i)
  ** Plane-2
ZCUR = Z1; IZC = NZ1+1
  ** Points.
GSET(P,P1 ,0.0,R11,ZCUR     );  GSET(P,P3 ,R12,0.0,ZCUR     )
GSET(P,P2 ,R11,0.0,ZCUR     );  GSET(P,P4 ,XI4,YI4,ZCUR     )
GSET(P,P6 ,0.0,R12,ZCUR     );  GSET(P,P7 ,0.0,R13,ZCUR     )
GSET(P,P9 ,XI9,YI9,ZCUR     );  GSET(P,P10,R13,0.0,ZCUR     )
GSET(P,P11,R14,0.0,ZCUR     );  GSET(P,P12,0.0,R14,ZCUR     )
GSET(P,P14,R15,0.0,ZCUR     );  GSET(P,P13,0.0,R15,ZCUR     )
  ** Lines.
GSET(L,L16,P1 ,P6 ,NY11,1.0); GSET(L,L23,P2 ,P3 ,NY11,1.0)
GSET(L,L67,P6 ,P7 ,NY12,1.0); GSET(L,N31,P3 ,P10,NY12,1.0)
GSET(L,N71,P7 ,P12,NY13,1.0); GSET(L,N11,P10,P11,NY13,1.0)
GSET(L,N23,P12,P13,NY14,1.0); GSET(L,N14,P11,P14,NY14,1.0)
XAR= R11*COS(PI4); YAR=R11*SIN(PI4);   ZAR = ZCUR
GSET(L,L12,P1,P2,NX,ARC,XAR,YAR,ZAR)
XAR= R12*COS(PI8); YAR=R12*SIN(PI8);   ZAR = ZCUR
GSET(L,L34,P3,P4,NX2,ARC,XAR,YAR,ZAR)
XAR= R12*COS(PI38); YAR=R12*SIN(PI38); ZAR = ZCUR
GSET(L,L46,P4,P6,NX1+NXI,ARC,XAR,YAR,ZAR)
XAR= R13*COS(PI8); YAR=R13*SIN(PI8);   ZAR = ZCUR
GSET(L,N19,P10,P9,NX2,ARC,XAR,YAR,ZAR)
XAR= R13*COS(PI38); YAR=R13*SIN(PI38); ZAR = ZCUR
GSET(L,L97,P9,P7,NX1+NXI,ARC,XAR,YAR,ZAR)
XAR= R14*COS(PI4); YAR=R14*SIN(PI4);   ZAR = ZCUR
GSET(L,N12,P11,P12,NX,ARC,XAR,YAR,ZAR)
XAR= R15*COS(PI4); YAR=R15*SIN(PI4);   ZAR = ZCUR
GSET(L,N34,P13,P14,NX,ARC,XAR,YAR,ZAR)
GSET(F,F1,P1 ,- ,P2 ,-,P3 ,P4,P6 ,-)
GSET(F,F2,P6 ,P4,P3 ,-,P10,P9,P7 ,-)
GSET(F,F3,P7 ,P9,P10,-,P11,- ,P12,-)
GSET(F,F4,P12,- ,P11,-,P14,- ,P13,-)
GSET(M,F1,+I+J,1,               1,IZC)
GSET(M,F2,+I+J,1,          NY11+1,IZC)
GSET(M,F3,+I+J,1,     NY11+NY12+1,IZC)
GSET(M,F4,+I+J,1,NY11+NY12+NY13+1,IZC)
gset(i)
DO II = 1,2
IF(II.EQ.1) THEN
+ ZCUR= 0.0;   IZC = 1
ELSE
+ ZCUR= LREAC; IZC = NZ+1
ENDIF
  ** Points.
GSET(P,P1 ,0.0,R11,ZCUR     );  GSET(P,P3 ,R12,0.0,ZCUR     )
GSET(P,P2 ,R11,0.0,ZCUR     )
GSET(P,P6 ,0.0,R12,ZCUR     );  GSET(P,P7 ,0.0,R13,ZCUR     )
GSET(P,P10,R13,0.0,ZCUR     )
GSET(P,P11,R14,0.0,ZCUR     );  GSET(P,P12,0.0,R14,ZCUR     )
GSET(P,P14,R15,0.0,ZCUR     );  GSET(P,P13,0.0,R15,ZCUR     )
  ** Lines.
GSET(L,L16,P1 ,P6 ,NY11,1.0); GSET(L,L23,P2 ,P3 ,NY11,1.0)
GSET(L,L67,P6 ,P7 ,NY12,1.0); GSET(L,N31,P3 ,P10,NY12,1.0)
GSET(L,N71,P7 ,P12,NY13,1.0); GSET(L,N11,P10,P11,NY13,1.0)
GSET(L,N23,P12,P13,NY14,1.0); GSET(L,N14,P11,P14,NY14,1.0)
XAR= R11*COS(PI4); YAR=R11*SIN(PI4);   ZAR = ZCUR
GSET(L,L12,P1,P2,NX,ARC,XAR,YAR,ZAR)
XAR= R12*COS(PI4); YAR=R12*SIN(PI4);   ZAR = ZCUR
GSET(L,L36,P3,P6,NX,ARC,XAR,YAR,ZAR)
XAR= R13*COS(PI4); YAR=R13*SIN(PI4);   ZAR = ZCUR
GSET(L,N17,P10,P7,NX,ARC,XAR,YAR,ZAR)
XAR= R14*COS(PI4); YAR=R14*SIN(PI4);   ZAR = ZCUR
GSET(L,N12,P11,P12,NX,ARC,XAR,YAR,ZAR)
XAR= R15*COS(PI4); YAR=R15*SIN(PI4);   ZAR = ZCUR
GSET(L,N34,P13,P14,NX,ARC,XAR,YAR,ZAR)
GSET(F,F1,P1 ,-,P2 ,-,P3 ,-,P6 ,-)
GSET(F,F2,P6 ,-,P3 ,-,P10,-,P7 ,-)
GSET(F,F3,P7 ,-,P10,-,P11,-,P12,-)
GSET(F,F4,P12,-,P11,-,P14,-,P13,-)
GSET(M,F1,+I+J,1,               1,IZC)
GSET(M,F2,+I+J,1,          NY11+1,IZC)
GSET(M,F3,+I+J,1,     NY11+NY12+1,IZC)
GSET(M,F4,+I+J,1,NY11+NY12+NY13+1,IZC)
gset(i)
ENDDO
    ** Interpolation.
KFF = 1;   KLL= KFF+NZ1
GSET(T,K:KLL:,F,K:KFF:,1,NX,1,NY,-:PWZ:)
KFF = KLL; KLL= KFF+NZDI
GSET(T,K:KLL:,F,K:KFF:,1,NX,1,NY,1.0)
KFF = KLL; KLL= KFF+NZI
GSET(T,K:KLL:,F,K:KFF:,1,NX,1,NY,1.0)
KFF = KLL; KLL= KFF+NZDI
GSET(T,K:KLL:,F,K:KFF:,1,NX,1,NY,1.0)
KFF = KLL; KLL= KFF+NZ2
GSET(T,K:KLL:,F,K:KFF:,1,NX,1,NY, :PWZ:)
DUMPC(MRGR1)
gset(i)
   ** Second domain.
GSET(D,NX,NY2,NZ,R11,R11,LREAC)
  ** Plane-1
AL11=TBAF/(2.0*R23); AL11=PI4+ASIN(AL11)
AL12=TBAF/(2.0*R23); AL12=PI4-ASIN(AL12)
XI4 =R23*COS(AL11); YI4=R23*SIN(AL11)
XI5 =R23*COS(AL12); YI5=R23*SIN(AL12)
AL21=TBAF/(2.0*R24); AL21=PI4+ASIN(AL21)
AL22=TBAF/(2.0*R24); AL22=PI4-ASIN(AL22)
XI9 =R24*COS(AL21); YI9=R24*SIN(AL21)
XI8 =R24*COS(AL22); YI8=R24*SIN(AL22)
ZCUR = 0.0; IZC = 1
  ** Points.
GSET(P,P1 ,0.0,R21,ZCUR);  GSET(P,P3 ,R22,0.0,ZCUR)
GSET(P,P2 ,R21,0.0,ZCUR);  GSET(P,P4 ,XI4,YI4,ZCUR)
GSET(P,P5 ,XI5,YI5,ZCUR);  GSET(P,P6 ,0.0,R22,ZCUR)
GSET(P,P7 ,R23,0.0,ZCUR);  GSET(P,P8 ,XI8,YI8,ZCUR)
GSET(P,P9 ,XI9,YI9,ZCUR);  GSET(P,P10,0.0,R23,ZCUR)
GSET(P,P11,0.0,R24,ZCUR);  GSET(P,P12,R24,0.0,ZCUR)
  ** Lines.
GSET(L,L16,P1 ,P6 ,NY21,1.0); GSET(L,L23,P2 ,P3 ,NY21,1.0)
GSET(L,L45,P4 ,P5 ,NXI ,1.0); GSET(L,L98,P9 ,P8 ,NXI ,1.0)
GSET(L,N61,P6 ,P10,NY22,1.0); GSET(L,L58,P5 ,P8 ,NY23,1.0)
GSET(L,L49,P4 ,P9 ,NY23,1.0); GSET(L,L37,P3 ,P7 ,NY22,1.0)
GSET(L,N71,P7 ,P12,NY23,1.0); GSET(L,N11,P10,P11,NY23,1.0)
XAR= R21*COS(PI4); YAR=R21*SIN(PI4);   ZAR = ZCUR
GSET(L,L12,P1,P2,NX,ARC,XAR,YAR,ZAR)
XAR= R22*COS(PI8); YAR=R22*SIN(PI8);   ZAR = ZCUR
GSET(L,L34,P3,P6,NX,ARC,XAR,YAR,ZAR)
XAR= R23*COS(PI38); YAR=R23*SIN(PI38); ZAR = ZCUR
GSET(L,N41,P4,P10,NX1,ARC,XAR,YAR,ZAR)
XAR= R23*COS(PI8); YAR=R23*SIN(PI8);   ZAR = ZCUR
GSET(L,L75,P7,P5,NX2,ARC,XAR,YAR,ZAR)
XAR= R24*COS(PI8); YAR=R24*SIN(PI8);   ZAR = ZCUR
GSET(L,N18,P12,P8,NX2,ARC,XAR,YAR,ZAR)
XAR= R24*COS(PI38); YAR=R24*SIN(PI38); ZAR = ZCUR
GSET(L,N91,P9,P11,NX1,ARC,XAR,YAR,ZAR)
GSET(F,F1,P1 ,-,P2,-,P3 ,-    ,P6 ,-)
GSET(F,F2,P6 ,-,P3,-,P7,P5.P4 ,P10,-)
GSET(F,F3,P10,-,P4,-,P9 ,-    ,P11,-)
GSET(F,F4,P4 ,-,P5,-,P8 ,-    ,P9 ,-)
GSET(F,F5,P5 ,-,P7,-,P12,-    ,P8 ,-)
GSET(M,F1,+I+J,1,                  1,IZC)
GSET(M,F2,+I+J,1,             NY21+1,IZC)
GSET(M,F3,+I+J,        1,NY21+NY22+1,IZC)
GSET(M,F4,+I+J,    NX1+1,NY21+NY22+1,IZC)
GSET(M,F5,+I+J,NX1+NXI+1,NY21+NY22+1,IZC)
KFF = 1;   KLL= KFF+NZ1;    DZC= Z1-Z0
GSET(C,K:KLL:,F,K:KFF:,1,NX,1,NY,+,0.0,0.0,DZC,INC,-:PWZ:)
KFF = KLL;   KLL= KFF+NZDI; DZC= Z2-Z1
GSET(C,K:KLL:,F,K:KFF:,1,NX,1,NY,+,0.0,0.0,DZC,INC)
KFF = KLL;   KLL= KFF+NZI;  DZC= Z3-Z2
GSET(C,K:KLL:,F,K:KFF:,1,NX,1,NY,+,0.0,0.0,DZC,INC)
KFF = KLL;   KLL= KFF+NZDI; DZC= Z4-Z3
GSET(C,K:KLL:,F,K:KFF:,1,NX,1,NY,+,0.0,0.0,DZC,INC)
KFF = KLL;   KLL= KFF+NZ2;  DZC= Z5-Z4
GSET(C,K:KLL:,F,K:KFF:,1,NX,1,NY,+,0.0,0.0,DZC,INC, :PWZ:)
DUMPC(MRGR2)
  ** Assemble blocks:
NUMBLK = 2
READCO(MRGR+Y)
readco(viewonly)
gset(i); gclear; gview(p,.2,.9,.4);gview(up,0,0,1)
gdom(1,nx+1,1,ny+1,1,nz+1,1,0)
gdom(1,nx+1,1,ny1+1,1,nz+1,1,0)
  ** Set links:
MPATCH(1,MBL1,NORTH,1,NX,NY-1,NY-1,1,NZ,1,LSTEP)
MPATCH(2,MBL2,SOUTH,1,NX,   2,   2,1,NZ,1,LSTEP)
IF(LSLD) THEN
+ MPATCH(1,MBS1,CELL,1,NX,1,NY,1,NZ,1,LSTEP)
+ RSG2=-OMEGA
ENDIF
    GROUP 7. Variables stored, solved & named
store(VRCM)
SOLVE(P1,U1,V1,W1); SOLUTN(P1,Y,Y,Y,N,N,N)
IF(LTURB) THEN
+ TURMOD(KEMODL);  STORE(ENUT,GENK)
+ FIINIT(KE)= TKEIN;  FIINIT(EP)= EPSIN
ENDIF
GCV=T; LSG2=T; RSG1  =0.5
    GROUP 9. Properties of the medium (or media)
ENUL= VIMED; RHO1= ROMED
    GROUP 11. Initialization of variable or porosity fields
INIADD=F; FIINIT(U1)=1.E-5; FIINIT(V1)=1.E-5; FIINIT(W1)=1.E-5
    GROUP 13. Boundary conditions and special sources
XCYCLE= T
IF(LTURB) THEN
+ RELAX(KE,linrlx,0.5);  RELAX(EP,linrlx,0.5)
 
+ KELIN = 3
ENDIF
   ** Impeller region.
   ** Porosity patches.
STORE(PRPS)
IFF=1;     ILL=NX
JFF=1;     JLL=NY11
KFF=NZ1+1; KLL=KFF+NZI+2*NZDI-1
PATCH(IMP1,INIVAL,IFF,ILL,JFF,JLL,KFF,KLL,1,LSTEP)
COVAL(IMP1,PRPS,0.0,199)
gdom(iff,ill+1,jff,jll+1,kff,kll+1,4,0)
IFF=NX1 +1;     ILL=IFF+NXI -1
JFF=NY11+1;     JLL=JFF+NY12-1
KFF=NZ1+NZDI+1; KLL=KFF+NZI -1
PATCH(IMP2,INIVAL,IFF,ILL,JFF,JLL,KFF,KLL,1,LSTEP)
COVAL(IMP2,PRPS,0.0,199)
gdom(iff,ill+1,jff,jll+1,kff,kll+1,5,0)
IFF=NX1 +1;      ILL=IFF+NXI -1
JFF=NY21+NY22+1; JLL=JFF+NY23-1
KFF=1;           KLL=NZ
MPATCH(2,BAF1,INIVAL,IFF,ILL,JFF,JLL,KFF,KLL,1,LSTEP)
COVAL(BAF1,PRPS,0.0,199)
MESG(Show grid? (N/y)
READVDU(ANS,CHAR,N)
IF(:ANS:.EQ.Y) THEN
gdraw
ENDIF
   ** Wall patches.
IFF = NX1;        ILL=IFF
JFF = NY11+1;     JLL=JFF+NY12-1
KFF = NZ1+NZDI+1; KLL=KFF+NZI -1
IF(LTURB) THEN
+ MPATCH(1,RTPE,EWALL,IFF,ILL,JFF,JLL,KFF,KLL,1,LSTEP)
+ COVAL(RTPE,KE,:COEF:,:COEF:); COVAL(RTPE,EP,:COEF:,:COEF:)
ELSE
+ MPATCH(1,ROTE,EWALL,IFF,ILL,JFF,JLL,KFF,KLL,1,LSTEP)
ENDIF
IFF = NX1+NXI+1;  ILL=IFF
JFF = NY11+1;     JLL=JFF+NY12-1
KFF = NZ1+NZDI+1; KLL=KFF+NZI -1
IF(LTURB) THEN
+ MPATCH(1,RTPW,WWALL,IFF,ILL,JFF,JLL,KFF,KLL,1,LSTEP)
+ COVAL(RTPW,KE,:COEF:,:COEF:); COVAL(RTPW,EP,:COEF:,:COEF:)
ELSE
+ MPATCH(1,ROTW,WWALL,IFF,ILL,JFF,JLL,KFF,KLL,1,LSTEP)
ENDIF
IFF = NX1+1;          ILL=IFF+NXI -1
JFF = NY11+1;         JLL=JFF+NY12-1
KFF = NZ1+NZDI+NZI+1; KLL=KFF
IF(LTURB) THEN
+MPATCH(1,RTPL,LWALL,IFF,ILL,JFF,JLL,KFF,KLL,1,LSTEP)
+COVAL(RTPL,KE,:COEF:,:COEF:); COVAL(RTPL,EP,:COEF:,:COEF:)
ELSE
+MPATCH(1,ROTL,LWALL,IFF,ILL,JFF,JLL,KFF,KLL,1,LSTEP)
ENDIF
 
IFF = NX1+1;          ILL=IFF+NXI-1
JFF = NY11+1;         JLL=JFF+NY12-1
KFF = NZ1+NZDI;       KLL=KFF
IF(LTURB) THEN
+MPATCH(1,RTPH,HWALL,IFF,ILL,JFF,JLL,KFF,KLL,1,LSTEP)
+COVAL(RTPH,KE,:COEF:,:COEF:); COVAL(RTPH,EP,:COEF:,:COEF:)
ELSE
+MPATCH(1,ROTH,HWALL,IFF,ILL,JFF,JLL,KFF,KLL,1,LSTEP)
ENDIF
IFF = NX1+1;       ILL=IFF+NXI -1
JFF = NY11+NY12+1; JLL=JFF
KFF = NZ1+NZDI+1;  KLL=KFF+NZI -1
IF(LTURB) THEN
+MPATCH(1,RTPS,SWALL,IFF,ILL,JFF,JLL,KFF,KLL,1,LSTEP)
+COVAL(RTPS,KE,:COEF:,:COEF:); COVAL(RTPS,EP,:COEF:,:COEF:)
ELSE
+MPATCH(1,ROTS1,SWALL,IFF,ILL,JFF,JLL,KFF,KLL,1,LSTEP)
ENDIF
IFF = 1;    ILL= NX
JFF = 1;    JLL= 1
KFF = 1;    KLL= NZ
IF(LTURB) THEN
+MPATCH(1,RTCS,SWALL,IFF,ILL,JFF,JLL,KFF,KLL,1,LSTEP)
+COVAL(RTCS,KE,:COEF:,:COEF:); COVAL(RTCS,EP,:COEF:,:COEF:)
ELSE
+MPATCH(1,ROTS2,SWALL,IFF,ILL,JFF,JLL,KFF,KLL,1,LSTEP)
ENDIF
IFF = 1;                   ILL= NX
JFF = 1;                   JLL= NY11
KFF = NZ1+NZDI*2+NZI+1;    KLL= KFF
IF(LTURB) THEN
+MPATCH(1,RTCL,LWALL,IFF,ILL,JFF,JLL,KFF,KLL,1,LSTEP)
+COVAL(RTCL,KE,:COEF:,:COEF:); COVAL(RTCL,EP,:COEF:,:COEF:)
ELSE
+MPATCH(1,ROTL2,LWALL,IFF,ILL,JFF,JLL,KFF,KLL,1,LSTEP)
ENDIF
IFF = 1;      ILL= NX
JFF = 1;      JLL= NY11
KFF = NZ1;    KLL= KFF
IF(LTURB) THEN
+MPATCH(1,RTCH,HWALL,IFF,ILL,JFF,JLL,KFF,KLL,1,LSTEP)
+COVAL(RTCH,KE,:COEF:,:COEF:); COVAL(RTCH,EP,:COEF:,:COEF:)
ELSE
+MPATCH(1,ROTH2,HWALL,IFF,ILL,JFF,JLL,KFF,KLL,1,LSTEP)
ENDIF
IFF = 1;      ILL= NX
JFF = NY11+1; JLL= JFF
KFF = NZ1+1;  KLL= NZ1+NZI+2*NZDI
IF(LTURB) THEN
+MPATCH(1,RTCS2,SWALL,IFF,ILL,JFF,JLL,KFF,KLL,1,LSTEP)
+COVAL(RTCS2,KE,:COEF:,:COEF:); COVAL(RTCS2,EP,:COEF:,:COEF:)
ELSE
+MPATCH(1,ROTS3,SWALL,IFF,ILL,JFF,JLL,KFF,KLL,1,LSTEP)
ENDIF
   ** Baffle region.
MPATCH(2,RECN,NWALL,1,NX,NY,NY,1,NZ,1,LSTEP)
COVAL(RECN,U1,:COEF:,0.0); COVAL(RECN,V1,:COEF:,0.0)
COVAL(RECN,W1,:COEF:,0.0)
IF(LTURB) THEN
+COVAL(RECN,KE,:COEF:,:COEF:); COVAL(RECN,EP,:COEF:,:COEF:)
ENDIF
IFF = NX1+1;       ILL= NX1+NXI
JFF = NY21+NY22;   JLL= JFF
KFF = 1;           KLL= NZ
MPATCH(2,BFLN,NWALL,IFF,ILL,JFF,JLL,KFF,KLL,1,LSTEP)
COVAL(BFLN,U1,:COEF:,0.0); COVAL(BFLN,V1,:COEF:,0.0)
COVAL(BFLN,W1,:COEF:,0.0)
IF(LTURB) THEN
+COVAL(BFLN,KE,:COEF:,:COEF:); COVAL(BFLN,EP,:COEF:,:COEF:)
ENDIF
IFF = NX1;          ILL= IFF
JFF = NY21+NY22+1;  JLL= JFF+NY23-1
KFF = 1;            KLL= NZ
MPATCH(2,BFLE,EWALL,IFF,ILL,JFF,JLL,KFF,KLL,1,LSTEP)
COVAL(BFLE,U1,:COEF:,0.0); COVAL(BFLE,V1,:COEF:,0.0)
COVAL(BFLE,W1,:COEF:,0.0)
IF(LTURB) THEN
+COVAL(BFLE,KE,:COEF:,:COEF:); COVAL(BFLE,EP,:COEF:,:COEF:)
ENDIF
IFF = NX1+NXI+1;    ILL= IFF
JFF = NY21+NY22+1;  JLL= JFF+NY23-1
KFF = 1;            KLL= NZ
MPATCH(2,BFLW,WWALL,IFF,ILL,JFF,JLL,KFF,KLL,1,LSTEP)
COVAL(BFLW,U1,:COEF:,0.0); COVAL(BFLW,V1,:COEF:,0.0)
COVAL(BFLW,W1,:COEF:,0.0)
IF(LTURB) THEN
+COVAL(BFLW,KE,:COEF:,:COEF:); COVAL(BFLW,EP,:COEF:,:COEF:)
ENDIF
MPATCH(2,PRSREL,CELL,NX,NX,NY,NY,2,2,1,LSTEP)
COVAL(PRSREL,P1,1.E5,0.0)
    GROUP 15. Termination of sweeps
LSWEEP = 200; TSTSWP = -1
    GROUP 16. Termination of iterations
SELREF = T; RESFAC = 1.E-6
    GROUP 22. Spot-value print-out
IXMON = NX/2+1; IYMON = NY1/2+1; IZMON = 1
    GROUP 23. Field print-out and plot control
NXPRIN= 1; NYPRIN= 1
    GROUP 24. Dumps for restarts