TALK=T;RUN(1,2) 855

    GROUP 1. Run title and other preliminaries                      
TEXT(Transfer objects; 1d diffusion; 1st run.                       
LIBREF=855                                                          
TITLE                                                               
  DISPLAY                                                           
  (Modified from the original by dbs on 27/01/15)                                                                  
  This example illustrates a use of In-Form transfer objects for a 
  z-direction heat-conduction problem of which the boundary
  conditions dictate that, although two geometrical dimensions are
  allowed for, namely y and z, in the solution the temperature 
  varies linearly with z and is independent of y.
                                         
  The wall at iz=0 is held at zero temperature while a fixed heat 
  flux is applied at the iz=high boundary.
  The heat flux, dimensions and conductivity are chosen so that, 
  when the z-direction grid is uniform with NZ=10, the exact 
  solution is:
         T=1.0, 3.0, 5.0, etc.    at successive cells.
  This facilitates checking the accuracy of the result.
                                                                    
  The domain is divided into two parts, as shown below                             
                         !                          
        /----------------+-----------------/        
   low  /                !                 / high   
   wall /    1st part    !    2nd part     / wall   
        /                !                 /        
        / ---------------+-----------------/        
              ^ y        !                          
              |-------> z-direction                                 
                                                                    
                                                                    
  The run(1,2) at the top of the Q1 file ensures that two runs are
  made in succession, for the two sets of data in the file separated 
  by the first STOP.      
  
  The TROB1 transfer object at the high boundary is formed at the   
  end of the first run by means of an '(export' In-Form statement.  
                                                                    
  The second run reads the information at the low boundary from the 
  TROB1 object by means of an '(import' In-Form statement.
  
  The y-direction grid intervals in the two parts can differ, as 
  shown by the differing NY and YPOWER below; and NZ and ZPOWER can
  also be varied.

  HOWEVER, the apparent success of the method has been achieved by
  means  of a subterfuge which disguises the fact that a two-consecutive-
  run process can NOT solve the postulated problem, because in the first
  solution for the lower-z half, nothing is known about the highest-z fixed-
  heat flux boundary condition.

  UNLESS, that is to say, it receives a little help; which the creator of the 
  original Q1has provided by telling the lower-z half also to receive  the same
  heat  flux at its high-z boundary.
  If this help is removed, by setting case=1, the first-run solution is tem1=0
  throughout;  then the second run-solution is certainly linear,  but with the 
  wrong left-hand value.
  
  To confirm this, set caseno=1
  What is then needed is a series of further runs, characterised by right-
  hand runs exporting information to subsequent left-hand runs; which, as 
  iterations of the process proceed, gradually acquire sufficient information
  about the extreme-right-hand boundary condition.

  Some things the 2-run-only procedure can accomplish very well, namely:
  * transfer information from left to right correctly, 
    when NYleft does not equal NYright.		
  * transfer information from left to right correctly, 
    when YPOWERleft does not equal YPOWERright
  * transfer information from left to right correctly, 
    when YVLASTleft >= VVLASTright.	(caseno=2)	                                               
 * transfer information from left to right correctly, 
    when YVLASTleft < VVLASTright,         (caseno=3)
    BUT with the perfectly correct consequence that the temperature 
    distribution in the right-hand domain is no longer one-dimensonal.	                                                                                                                                        
  ENDDIS                                                            
                                                            
integer(caseno)
caseno=1      
caseno=2      
caseno=3  
caseno                                                                 
    First run                                                       
    ---------                                                                    
  Problem data                                                      
REAL(TCOLD,HEATIN,YPOWER,ZPOWER) 
NY=4;YPOWER=1.5;ZPOWER=2.0
zpower=1.0 
yvlast=1.0
if(caseno.eq.2) then
yvlast=2.0
endif
yvlast
if(caseno.eq.3) then
yvlast=0.5
endif
yvlast
TCOLD=0.0     ! Temperature of cold wall   
  
HEATIN=1.0    ! Heat 
  GROUP 4. Y-direction grid specification                           
GRDPWR(Y,NY,yvlast,YPOWER)                                               
  GROUP 5. Z-direction grid specification                           
GRDPWR(Z,5,1.0,ZPOWER)                                              
    GROUP 7. Variables stored, solved & named                       
SOLVE(TEM1)                                                         
    GROUP 9. Properties of the medium (or media)                    
PRNDTL(TEM1) = - 1.0   ! i.e. conductivity                                  
    GROUP 13. Boundary conditions and special sources               
  Cold wall                                                         
PATCH(LW,LWALL,1,NX,1,NY,1,1,1,1)                                   
COVAL(LW,TEM1,1.0,TCOLD)                                              
  Heated end                                    
if(caseno.ne.1) then
PATCH(HW,HIGH,1,NX,1,NY,NZ,NZ,1,1)                                 
COVAL(HW,TEM1,FIXFLU,HEATIN)                                              
endif                                                                    
  INFORM13BEGIN                                                     
PATCH(PAT2,HIGH,1,NX,1,NY,NZ,NZ,1,1) ! transfer object at high end                              
(EXPORT to TROB1 at PAT2)       
write(>>log,trob1 written)                                   
  INFORM13END                                                       
                                                                    
    GROUP 15. Termination of sweeps                                 
LSWEEP=1 ; LITER(TEM1)=100;ENDIT(TEM1)=0.0;RESREF(TEM1)=0.0
RELAX(TEM1,LINRLX,1.0) ! settings allowing single-sweep solution                                         
lsweep=10
lsweep
isg21=lsweep
tstswp=-1
#endpause     
mesg(at end of run 1, lsweep=:lsweep: 
                                                
write(>log, run 1)
write(>>log,ny=:ny: yvlast=:yvlast: ypower=:ypower:)
write(>>log,nz=:nz: zpower=:zpower:)                                          
stop 
                                                                   
    Second run                                                      
    ----------                                                             
                                                     
                                                            
TEXT(Transfer objects; 1d diffusion; 2nd run.                       
  Problem data                                                      
REAL(HEATIN,YPOWER)                                                     
NY=5;YPOWER=0.5  
                                                
HEATIN=1.0    ! Heat input                       
GRDPWR(Y,NY,yvlast,YPOWER)                                               
  GROUP 5. Z-direction grid specification
real(zpower)
zpower=1.0                           
GRDPWR(Z,5,1.0,zpower)                                              
    GROUP 7. Variables stored, solved & named                       
SOLVE(TEM1)                                                         
    GROUP 9. Properties of the medium (or media)                    
PRNDTL(TEM1) = - 1.0   ! i.e. conductivity                                  
    GROUP 13. Boundary conditions and special sources               
  INFORM13BEGIN                                                     
PATCH(PAT1,LOW,1,NX,1,NY,1,1,1,1) ! transfer object at low end                                  
(IMPORT from TROB1 at PAT1)
write(>>log, pat1 imported)                                         
  INFORM13END                                                       
  Heated end                                                          
PATCH(HW,HIGH,1,NX,1,NY,NZ,NZ,1,1)                                 
COVAL(HW,TEM1,FIXFLU,HEATIN)                                              
LSWEEP=10; LITER(TEM1)=100;ENDIT(TEM1)=0.0;RESREF(TEM1)=0.0
RELAX(TEM1,LINRLX,1.0) ! settings allowing single-sweep solution                                         lsweep=10
lsweep
isg21=lsweep
tstswp=-1
#endpause     
mesg(at end of run 2, lsweep=:lsweep:                                    
write(>>log, run 2 started)
write(>>log,ny=:ny: yvlast=:yvlast: ypower=:ypower:)
write(>>log,nz=:nz: zpower=:zpower:)                                                  
         
STOP