TALK=F;RUN( 1, 1)
CPVNAM=VDI;SPPNAM=Core
TEXT(USP. Conductivity task on divided grid)

title
  DISPLAY 
    This case solves a simple three-dimensional conductivity
    task on divided grid in cube.
    The exact solution is one-dimensional constant gradient 
    of temperature.
    User can change direction of gradient and coefficient of
    conductivity.
  ENDDIS
   
STEADY  =    T
RSET(M,64,64,64)
RSET(D,DOM,1.,1.,1.)
 
ONEPHS  =    T
NAME(148) =KOND; NAME(150) =TEM1
STORE(KOND)
SOLVE(TEM1)
SOLUTN(TEM1,Y,Y,Y,N,N,Y)

integer(idir)
idir = 1
mesg(Default direction of temperature gradient is X.
mesg(Do you want to change it? (y/n)
readvdu(ans,char,n)
if(:ans:.eq.y)then
 mesg(Please, enter direction of temperature gradient. (x/y/z)
 readvdu(ans,char,n)
 if(:ans:.eq.x)then
 idir = 1
 mesg(New direction of temperature gradient is X.
 endif
 if(:ans:.eq.y)then
 idir = 2
 mesg(New direction of temperature gradient is Y.
 endif
 if(:ans:.eq.z)then
 idir = 3
 mesg(New direction of temperature gradient is Z.
 endif
endif

real(MINT,MAXT,MINKOND,MAXKOND,KONDC,DK,MINGR)
MINKOND=1.e-2
MAXKOND=1.e-2
mesg(Default coefficient of conductivity is constant.
mesg(Conductivity is :MINKOND:
mesg(Do you want to change it? (y/n)
readvdu(ans,char,n)
if(:ans:.eq.y)then
 mesg(Enter coductivity at minimum temperature
 readvdu(MINKOND,real,MINKOND)
 mesg(New coductivity at minimum temperature is :MINKOND:
 mesg(Enter coductivity at maximum temperature
 readvdu(MAXKOND,real,MAXKOND)
 mesg(New coductivity at maximum temperature is :MAXKOND:
endif

MINT=0
MAXT=100

if(idir.eq.1)then
       MINGR = MINKOND*2*NX
 MINGR = MINKOND/0.125
 PATCH(LESS,WEST,1,1,1,NY,1,NZ,1,1)
      COVAL(LESS,TEM1,FIXVAL,MINT)
 COVAL(LESS,TEM1,MINGR,MINT)
 PATCH(MORE,EAST,NX,NX,1,NY,1,NZ,1,1)
      COVAL(MORE,TEM1,FIXVAL,MAXT)
 COVAL(MORE,TEM1,MINGR,MAXT)
DK = (MAXKOND-MINKOND)/NX
DO II=1,NX
+ KONDC = MINKOND+0.5*DK+(II-1)*DK
+ PATCH(IP:II:,INIVAL,:II:,:II:,1,NY,1,NZ,1,1)
+ INIT(IP:II:,KOND,0.0,KONDC)
ENDDO
endif
if(idir.eq.2)then
 PATCH(LESS,SOUTH,1,NX,1,1,1,NZ,1,1)
 COVAL(LESS,TEM1,FIXVAL,MINT)
 PATCH(MORE,NORTH,1,NX,NY,NY,1,NZ,1,1)
 COVAL(MORE,TEM1,FIXVAL,MAXT)
DK = (MAXKOND-MINKOND)/NY
DO JJ=1,NY
+ KONDC = MINKOND+0.5*DK+(JJ-1)*DK
+ PATCH(IP:JJ:,INIVAL,1,NX,:JJ:,:JJ:,1,NZ,1,1)
+ INIT(IP:JJ:,KOND,0.0,KONDC)
ENDDO
endif
if(idir.eq.3)then
 PATCH(LESS,LOW,1,NX,1,NY,1,1,1,1)
 COVAL(LESS,TEM1,FIXVAL,MINT)
 PATCH(MORE,HIGH,1,NX,1,NY,NZ,NZ,1,1)
 COVAL(MORE,TEM1,FIXVAL,MAXT)
DK = (MAXKOND-MINKOND)/NZ
DO KK=1,NZ
+ KONDC = MINKOND+0.5*DK+(KK-1)*DK
+ PATCH(IP:KK:,INIVAL,1,NX,1,NY,:KK:,:KK:,1,1)
+ INIT(IP:KK:,KOND,0.0,KONDC)
ENDDO
endif

INTEGER(LEVEL)
LEVEL = 4
mesg(Level of coarsening is :LEVEL:
mesg(Do you want to change it? (y/n)
readvdu(ans,char,n)
if(:ans:.eq.y)then
 mesg(Enter level of coarsening
 readvdu(LEVEL,int,LEVEL)
 mesg(New level of coarsening is :LEVEL:
endif

mesg(Do you want to view results in the centres of cells? (y/n)
readvdu(ans,char,n)
if(:ans:.eq.y)then
SPEDAT(SET,USPIO,VERTCENT,L,F)
endif


mesg(Do you want to solve task without calculation of gradients ? (y/n)
readvdu(ans,char,n)
if(:ans:.eq.y)then
SPEDAT(SET,USP,CALCGRAD,L,F)
endif
 
LSWEEP  =       100
RESFAC  = 1.000000E-07
 
PARSOL=F
ECHO=T
IXMON=2 ;IYMON=2 ;IZMON=2
NPRMON=100000
NPRMNT=1
TSTSWP=-1
NPRINT=100000
ISWPRF=1 ;ISWPRL=100000

  SAVE7BEGIN
 
    ******** Test In-Form ******
(STORED of EXT1 is 100.*XG)
(STORED of DTEM is EXT1-TEM1) 
 
  SAVE7END


      Usp related variables
USP    = T
UAUTO  = F
USPDBG = F
UTCPLT = T
USPIMB = F
MXLEV  = LEVEL 
MYLEV  = LEVEL
MZLEV  = LEVEL
DOMAT  = -1
MINPRP = -1
MAXPRP = 250
CELLST = 10
FACEST = 10

SPEDAT(SET,USPVTK,GRADOUT,C,TEM1)


> DOM,    SIZE,        1.000000E+00, 1.000000E+00, 1.000000E+00
> DOM,    MONIT,       4.250000E-01, 4.250000E-01, 4.454545E-01
> DOM,    SCALE,       1.000000E+00, 1.000000E+00, 1.000000E+00
> DOM,    SNAPSIZE,    1.000000E-02

if(LEVEL.gt.0)then 
> OBJ,    NAME,        B1
> OBJ,    POSITION,    0.468750E+00, 0.468750E+00, 0.468750E+00
> OBJ,    SIZE,        6.250000E-02, 6.250000E-02, 6.250000E-02
> OBJ,    GEOMETRY,    fine
> OBJ,    ROTATION24,        1
> OBJ,    TYPE,        FINE_GRID_VOL
> OBJ,    LEVELS,       0.000000E+00, 0.000000E+00, 0.000000E+00
> OBJ,    AXES,        OXYZ
endif

if(LEVEL.gt.1)then
> OBJ,    NAME,        B2
> OBJ,    POSITION,    0.437500E+00, 0.437500E+00, 0.437500E+00
> OBJ,    SIZE,        0.125000E+00, 0.125000E+00, 0.125000E+00
> OBJ,    GEOMETRY,    fine
> OBJ,    ROTATION24,        1
> OBJ,    TYPE,        FINE_GRID_VOL
> OBJ,    LEVELS,       1.000000E+00, 1.000000E+00, 1.000000E+00
> OBJ,    AXES,        OXYZ
endif

if(LEVEL.gt.2)then
> OBJ,    NAME,        B3
> OBJ,    POSITION,    0.375000E+00, 0.375000E+00, 0.375000E+00
> OBJ,    SIZE,        0.250000E+00, 0.250000E+00, 0.250000E+00
> OBJ,    GEOMETRY,    fine
> OBJ,    ROTATION24,        1
> OBJ,    TYPE,        FINE_GRID_VOL
> OBJ,    LEVELS,       2.000000E+00, 2.000000E+00, 2.000000E+00
> OBJ,    AXES,        OXYZ
endif

if(LEVEL.gt.3)then
> OBJ,    NAME,        E1
> OBJ,    POSITION,    0.250000E+00, 0.250000E+00, 0.250000E+00
> OBJ,    SIZE,        0.500000E+00, 0.500000E+00, 0.500000E+00
> OBJ,    GEOMETRY,    fine
> OBJ,    ROTATION24,        1
> OBJ,    TYPE,        FINE_GRID_VOL
> OBJ,    LEVELS,       3.000000E+00, 3.000000E+00, 3.000000E+00
> OBJ,    AXES,        OXYZ
endif

STOP