CFX-4
Introductory Training (Dec 1999)
9 -1
CFX-4.3 V4.3.1H
Lecture 9
User FORTRAN
CFX-4
Introductory Training (Dec 1999)
9 -2
CFX-4.3 V4.3.1H
User FORTRAN
? The user FORTRAN routines are used for
Complex features not available through the
command language
> Non-uniform velocity profiles,variable material
properties,moving grid,etc…
Convenience
Flexibility.
? User FORTRAN greatly enhances CFX-4
capabilities.
? CFX-4 comes with 32 FORTRAN templates.
? CFX-Environment provides access to user
FORTRAN routines.
CFX-4
Introductory Training (Dec 1999)
9 -3
CFX-4.3 V4.3.1H
Commonly Used Routines
? USRBCS
> To allow users to specify real information at walls,inlets,
mass flow boundaries and other 2D patches,called at
the start of a run and on each iteration or time step.
? USRBF
> To allow users to specify body forces,resistances.
? USRCND
> To allow users to specify conductivity.
? USRCVG
> To allow users to monitor the solution at every non-linear
iteration,and test for convergence.
CFX-4
Introductory Training (Dec 1999)
9 -4
CFX-4.3 V4.3.1H
Commonly Used Routines
? USRDEN
> To allow users to specify density and the partial
derivatives of density with respect to pressure.
? USRGRD
> To allow users to generate a user grid or update grid as
a function of time.
? USRINT
> To allow users to specify an initial guess.
? USRPBC
> To allow users to specify particle boundary conditions.
CFX-4
Introductory Training (Dec 1999)
9 -5
CFX-4.3 V4.3.1H
Commonly Used Routines
? USRSRC
> To allow users to add source or modify source terms.
? USRTRN
> To allow users to monitor the solution as a function of
time and to specify next time step.
? USRVIS
> To allow users to specify viscosity.
CFX-4
Introductory Training (Dec 1999)
9 -6
CFX-4.3 V4.3.1H
Commonly Used Routines
? There are also 22 utility routines which can be
called directly:
GETVAR
> To allow users to find equation number for a variable.
IPALL
> To allow users to obtain the addresses for all the centers /
vertices of selected blocks / patches.
IPREC
> To allow users to obtain the addresses for all the centers /
vertices on a single block / patch (covering a single face).
SETWRK,DELWRK
> To allow users to allocate and delete work space for a
temporary array.
CFX-4
Introductory Training (Dec 1999)
9 -7
CFX-4.3 V4.3.1H
How to Use FORTRAN
? To use a user
FORTRAN routine
Obtain the template by
clicking on User Fortran
within the Environment,
and Get Fortran.
Edit the FORTRAN
routine and ensure the
IUSED flag is set to 1.
Include the routine in the
command file
? OPTIONS
...,..
? USER FORTRAN
USRSRC
Specify the user
FORTRAN file when
running the solver.
CFX-4
Introductory Training (Dec 1999)
9 -8
CFX-4.3 V4.3.1H
? The solver stops if any of the last three steps
are missing.
? The FORTRAN routine is compiled and linked
at the beginning of a CFX run.
? Facility to save executable in local directory
(under Advanced Options of the solve menu).
How to Use FORTRAN
CFX-4
Introductory Training (Dec 1999)
9 -9
CFX-4.3 V4.3.1H
Structure of a Template
? Variables,constants are passed through the
argument list and common blocks
SUBROUTINE USRSRC(IEQN,ICALL,CNAME,CALIAS,AM,SP,SU,CONV
+,U,V,W,P,VFRAC,DEN,VIS,TE,ED,RS,T,H,RF,SCAL
+,XP,YP,ZP,VOL,AREA,VPOR,ARPOR,WFACT,IPT
+,IBLK,IPVERT,IPNODN,IPFACN,IPNODF,IPNODB,IPFACB
+,WORK,IWORK,CWORK)
U,V,W,P,VFRAC,DEN,…,T,H are dimensioned
(NNODE,NPHASE)
SCAL is dimensioned (NNODE,NPHASE,NSCAL)
XP,YP,ZP are dimensioned (NNODE).
CFX-4
Introductory Training (Dec 1999)
9 -10
CFX-4.3 V4.3.1H
Structure of a Template
? Variables not in the subroutine argument list
can be accessed through work space stacks.
WORK,IWORK,CWORK.
? User areas are available for defining user
variables,common blocks,etc.
? Each template contains several examples
which can be uncommented and modified by
the user.
CFX-4
Introductory Training (Dec 1999)
9 -11
CFX-4.3 V4.3.1H
Rules You Should Follow
? Only make changes within user areas.
? Do not modify the version number IVERS and
precision number ICHKPR.
? Start user common block with UC and user
array with USR.
CFX-4
Introductory Training (Dec 1999)
9 -12
CFX-4.3 V4.3.1H
Case Study - Adding a Source
? In the command file
>>OPTIONS
…
>>USER FORTRAN
USRSRC
…
? In the fortran
file IUSED=1.
? Run the solver.
CFX-4
Introductory Training (Dec 1999)
9 -13
CFX-4.3 V4.3.1H
Adding a Heat Source
? Numerical consideration
> the source terms can be linearized in different ways
> Sp, contribution of the source terms to the diagonal of
the coefficient matrix
> Su, remaining source terms.
To retain diagonal dominance of the linear
equation system (for numerical stability &
accuracy)
> Sp, should be negative,otherwise put into Su.
A A S Sp p nb
nb nb u p p
? ? ?- ? ??
CFX-4
Introductory Training (Dec 1999)
9 -14
CFX-4.3 V4.3.1H
Adding a Heat Source
User FORTRAN:
SUBROUTINE USRSRC(IEQN,ICALL,CNAME,CALIAS,AM,SP,SU,CONV
+,U,V,W,P,VFRAC,DEN,VIS,TE,ED,RS,T,H,RF,SCAL
+,XP,YP,ZP,VOL,AREA,VPOR,ARPOR,WFACT,IPT
+,IBLK,IPVERT,IPNODN,IPFACN,IPNODF,IPNODB,IPFACB
+,WORK,IWORK,CWORK)
C
C**********************************************************************
C
C UTILITY SUBROUTINE FOR USER-SUPPLIED SOURCES
C
C >>> IMPORTANT <<<
C >>> <<<
C >>> USERS MAY ONLY ADD OR ALTER PARTS OF THE SUBROUTINE WITHIN <<<
C >>> THE DESIGNATED USER AREAS <<<
C
C**********************************************************************
C
C THIS SUBROUTINE IS CALLED BY THE FOLLOWING SUBROUTINES
C CUSR SCDF SCDS SCED SCENRG SCHF SCMOM SCPCE SCSCAL
C SCTE SCVF
C
C***********************************************************************
CFX-4
Introductory Training (Dec 1999)
9 -15
CFX-4.3 V4.3.1H
Adding a Heat Source
C***********************************************************************
C CREATED
C 08/03/90 ADB
C MODIFIED
C 04/03/91 ADB ALTERED ARGUMENT LIST.
C 28/08/91 IRH NEW STRUCTURE
C 28/09/91 IRH CHANGE EXAMPLE + ADD COMMON BLOCKS
C 10/02/92 PHA UPDATE CALLED BY COMMENT,ADD RF ARGUMENT,
C CHANGE LAST DIMENSION OF RS TO 6 AND IVERS TO 2
C 03/06/92 PHA ADD PRECISION FLAG AND CHANGE IVERS TO 3
C 23/11/93 CSH EXPLICITLY DIMENSION IPVERT ETC.
C 07/12/93 NSW INCLUDE CONV IN ARGUMENT LIST AND CHANGE IVERS
C TO 4
C 03/02/94 PHA CHANGE FLOW3D TO CFDS-FLOW3D
C 03/03/94 FHW CORRECTION OF SPELLING MISTAKE
C 08/03/94 NSW CORRECT SPELLING
C 09/08/94 NSW CORRECT SPELLING.
C MOVE 'IF(IUSED.EQ.0) RETURN' OUT OF USER AREA.
C INCLUDE COMMENT ON MASS SOURCES.
C 19/12/94 NSW CHANGE FOR CFX-F3D
C
C***********************************************************************
CFX-4
Introductory Training (Dec 1999)
9 -16
CFX-4.3 V4.3.1H
Adding a Heat Source
C***********************************************************************
C
C SUBROUTINE ARGUMENTS
C
C IEQN - EQUATION NUMBER
C ICALL - SUBROUTINE CALL
C CNAME - EQUATION NAME
C CALIAS - ALIAS OF EQUATION NAME
C AM - OFF DIAGONAL MATRIX COEFFICIENTS
C SU - SU IN LINEARISATION OF SOURCE TERM
C SP - SP IN LINEARISATION OF SOURCE TERM
C CONV - CONVECTION COEFFICIENTS
C U - U COMPONENT OF VELOCITY
C V - V COMPONENT OF VELOCITY
C W - W COMPONENT OF VELOCITY
C P - PRESSURE
C VFRAC - VOLUME FRACTION
C DEN - DENSITY OF FLUID
C VIS - VISCOSITY OF FLUID
C TE - TURBULENT KINETIC ENERGY
C ED - EPSILON
C RS - REYNOLD STRESSES
C T - TEMPERATURE
C H - ENTHALPY
CFX-4
Introductory Training (Dec 1999)
9 -17
CFX-4.3 V4.3.1H
Adding a Heat Source
C RF - REYNOLD FLUXES
C SCAL - SCALARS (THE FIRST 'NCONC' OF THESE ARE MASS FRACTIONS)
C XP - X COORDINATES OF CELL CENTRES
C YP - Y COORDINATES OF CELL CENTRES
C ZP - Z COORDINATES OF CELL CENTRES
C VOL - VOLUME OF CELLS
C AREA - AREA OF CELLS
C VPOR - POROUS VOLUME
C ARPOR - POROUS AREA
C WFACT - WEIGHT FACTORS
C
C IPT - 1D POINTER ARRAY
C IBLK - BLOCK SIZE INFORMATION
C IPVERT - POINTER FROM CELL CENTERS TO 8 NEIGHBOURING VERTICES
C IPNODN - POINTER FROM CELL CENTERS TO 6 NEIGHBOURING CELLS
C IPFACN - POINTER FROM CELL CENTERS TO 6 NEIGHBOURING FACES
C IPNODF - POINTER FROM CELL FACES TO 2 NEIGHBOURING CELL CENTERS
C IPNODB - POINTER FROM BOUNDARY CENTERS TO CELL CENTERS
C IPFACB - POINTER FROM BOUNDARY CENTERS TO BOUNDARY FACESS
C
C WORK - REAL WORKSPACE ARRAY
C IWORK - INTEGER WORKSPACE ARRAY
C CWORK - CHARACTER WORKSPACE ARRAY
C
CFX-4
Introductory Training (Dec 1999)
9 -18
CFX-4.3 V4.3.1H
Adding a Heat Source
C SUBROUTINE ARGUMENTS PRECEDED WITH A '*' ARE ARGUMENTS THAT MUST
C BE SET BY THE USER IN THIS ROUTINE.
C
C NOTE THAT WHEN USING MASS SOURCES,THE FLOWS THROUGH MASS FLOW
C BOUNDARIES ARE UNCHANGED,THE USER SHOULD THEREFORE INCLUDE AT
C LEAST ONE PRESSURE BOUNDARY FOR SUCH A CALCULATION.
C
C NOTE THAT OTHER DATA MAY BE OBTAINED FROM CFX-F3D USING THE
C ROUTINE GETADD,FOR FURTHER DETAILS SEE THE VERSION 4
C USER MANUAL.
C
C***********************************************************************
C
LOGICAL LDEN,LVIS,LTURB,LTEMP,LBUOY,LSCAL,LCOMP
+,LRECT,LCYN,LAXIS,LPOROS,LTRANS
C
CHARACTER*(*) CWORK
CHARACTER CNAME*6,CALIAS*24
C
C+++++++++++++++++ USER AREA 1 +++++++++++++++++++++++++++++++++++++++++
C---- AREA FOR USERS EXPLICITLY DECLARED VARIABLES
C
C+++++++++++++++++ END OF USER AREA 1 ++++++++++++++++++++++++++++++++++
CFX-4
Introductory Training (Dec 1999)
9 -19
CFX-4.3 V4.3.1H
Adding a Heat Source
C
COMMON
+ /ALL/ NBLOCK,NCELL,NBDRY,NNODE,NFACE,NVERT,NDIM
+ /ALLWRK/ NRWS,NIWS,NCWS,IWRFRE,IWIFRE,IWCFRE
+ /ADDIMS/ NPHASE,NSCAL,NVAR,NPROP
+,NDVAR,NDPROP,NDXNN,NDGEOM,NDCOEF,NILIST,NRLIST,NTOPOL
+ /CHKUSR/ IVERS,IUCALL,IUSED
+ /DEVICE/ NREAD,NWRITE,NRDISK,NWDISK
+ /IDUM/ ILEN,JLEN
+ /LOGIC/ LDEN,LVIS,LTURB,LTEMP,LBUOY,LSCAL,LCOMP
+,LRECT,LCYN,LAXIS,LPOROS,LTRANS
+ /MLTGRD/ MLEVEL,NLEVEL,ILEVEL
+ /SGLDBL/ IFLGPR,ICHKPR
+ /SPARM/ SMALL,SORMAX,NITER,INDPRI,MAXIT,NODREF,NODMON
+ /TRANSI/ NSTEP,KSTEP,MF,INCORE
+ /TRANSR/ TIME,DT,DTINVF,TPARM
C
C+++++++++++++++++ USER AREA 2 +++++++++++++++++++++++++++++++++++++++++
C---- AREA FOR USERS TO DECLARE THEIR OWN COMMON BLOCKS
C THESE SHOULD START WITH THE CHARACTERS 'UC' TO ENSURE
C NO CONFLICT WITH NON-USER COMMON BLOCKS
C
C+++++++++++++++++ END OF USER AREA 2 ++++++++++++++++++++++++++++++++++
C
CFX-4
Introductory Training (Dec 1999)
9 -20
CFX-4.3 V4.3.1H
Adding a Heat Source
DIMENSION AM(NCELL,6,NPHASE),SP(NCELL,NPHASE),SU(NCELL,NPHASE)
+,CONV(NFACE,NPHASE)
C
DIMENSION
+ U(NNODE,NPHASE),V(NNODE,NPHASE),W(NNODE,NPHASE),P(NNODE,NPHASE)
+,VFRAC(NNODE,NPHASE),DEN(NNODE,NPHASE),VIS(NNODE,NPHASE)
+,TE(NNODE,NPHASE),ED(NNODE,NPHASE),RS(NNODE,NPHASE,6)
+,T(NNODE,NPHASE),H(NNODE,NPHASE),RF(NNODE,NPHASE,4)
+,SCAL(NNODE,NPHASE,NSCAL)
C
DIMENSION
+ XP(NNODE),YP(NNODE),ZP(NNODE)
+,VOL(NCELL),AREA(NFACE,3),VPOR(NCELL),ARPOR(NFACE,3)
+,WFACT(NFACE)
+,IPT(*),IBLK(5,NBLOCK)
+,IPVERT(NCELL,8),IPNODN(NCELL,6),IPFACN(NCELL,6),IPNODF(NFACE,4)
+,IPNODB(NBDRY,4),IPFACB(NBDRY)
+,IWORK(*),WORK(*),CWORK(*)
C
C+++++++++++++++++ USER AREA 3 +++++++++++++++++++++++++++++++++++++++++
C---- AREA FOR USERS TO DIMENSION THEIR ARRAYS
C
C---- AREA FOR USERS TO DEFINE DATA STATEMENTS
C
C+++++++++++++++++ END OF USER AREA 3 ++++++++++++++++++++++++++++++++++
CFX-4
Introductory Training (Dec 1999)
9 -21
CFX-4.3 V4.3.1H
Adding a Heat Source
C
C---- STATEMENT FUNCTION FOR ADDRESSING
IP(I,J,K)=IPT((K-1)*ILEN*JLEN+(J-1)*ILEN+I)
C
C----VERSION NUMBER OF USER ROUTINE AND PRECISION FLAG
C
IVERS=4 !!! DO NOT MODIFY
ICHKPR = 1
C
C+++++++++++++++++ USER AREA 4 +++++++++++++++++++++++++++++++++++++++++
C---- TO USE THIS USER ROUTINE FIRST SET IUSED=1
C
IUSED=1 MODIFY
C
C+++++++++++++++++ END OF USER AREA 4 ++++++++++++++++++++++++++++++++++
C
IF (IUSED.EQ.0) RETURN
C
C---- FRONTEND CHECKING OF USER ROUTINE
IF (IUCALL.EQ.0) RETURN
C
C---- ADD TO SOURCE TERMS
IF (ICALL.EQ.1) THEN
C
CFX-4
Introductory Training (Dec 1999)
9 -22
CFX-4.3 V4.3.1H
Adding a Heat Source
C+++++++++++++++++ USER AREA 5 +++++++++++++++++++++++++++++++++++++++++
C
C---- EXAMPLE (HEAT SOURCE) ADD 100W PER UNIT VOLUME IN BLOCK
C 'BLOCK-NUMBER-2'
C
C USE IPREC TO FIND ADDRESSES
C
CALL IPREC('BLOCK-NUMBER-2','BLOCK','CENTRES',IPT,ILEN,JLEN,KLEN,
+ CWORK,IWORK)
C
C FIND VARIABLE NUMBER FOR ENTHALPY
CALL GETVAR('USRSRC','H ',IVAR)
C IF ENTHALPY EQUATION ADD SOURCE TERMS
IF (IVAR.EQ.IEQN) THEN
C LOOP OVER PATCH
DO 103 K = 1,KLEN
DO 102 J = 1,JLEN
DO 101 I = 1,ILEN
C USE STATEMENT FUNCTION IP TO GET ADDRESSES
INODE = IP(I,J,K)
C ADD HEAT SOURCE
SU(INODE,1)=SU(INODE,1)+100.0*VOL(INODE)
101 CONTINUE
102 CONTINUE
103 CONTINUE
MODIFY EXAMPLE
CODE TO LOOP
OVER CELLS AND
ADD HEAT SOURCE
CFX-4
Introductory Training (Dec 1999)
9 -23
CFX-4.3 V4.3.1H
Adding a Heat Source
ENDIF
C
C---- END OF EXAMPLE
C+++++++++++++++++ END OF USER AREA 5 ++++++++++++++++++++++++++++++++++
ENDIF
RETURN
END
Introductory Training (Dec 1999)
9 -1
CFX-4.3 V4.3.1H
Lecture 9
User FORTRAN
CFX-4
Introductory Training (Dec 1999)
9 -2
CFX-4.3 V4.3.1H
User FORTRAN
? The user FORTRAN routines are used for
Complex features not available through the
command language
> Non-uniform velocity profiles,variable material
properties,moving grid,etc…
Convenience
Flexibility.
? User FORTRAN greatly enhances CFX-4
capabilities.
? CFX-4 comes with 32 FORTRAN templates.
? CFX-Environment provides access to user
FORTRAN routines.
CFX-4
Introductory Training (Dec 1999)
9 -3
CFX-4.3 V4.3.1H
Commonly Used Routines
? USRBCS
> To allow users to specify real information at walls,inlets,
mass flow boundaries and other 2D patches,called at
the start of a run and on each iteration or time step.
? USRBF
> To allow users to specify body forces,resistances.
? USRCND
> To allow users to specify conductivity.
? USRCVG
> To allow users to monitor the solution at every non-linear
iteration,and test for convergence.
CFX-4
Introductory Training (Dec 1999)
9 -4
CFX-4.3 V4.3.1H
Commonly Used Routines
? USRDEN
> To allow users to specify density and the partial
derivatives of density with respect to pressure.
? USRGRD
> To allow users to generate a user grid or update grid as
a function of time.
? USRINT
> To allow users to specify an initial guess.
? USRPBC
> To allow users to specify particle boundary conditions.
CFX-4
Introductory Training (Dec 1999)
9 -5
CFX-4.3 V4.3.1H
Commonly Used Routines
? USRSRC
> To allow users to add source or modify source terms.
? USRTRN
> To allow users to monitor the solution as a function of
time and to specify next time step.
? USRVIS
> To allow users to specify viscosity.
CFX-4
Introductory Training (Dec 1999)
9 -6
CFX-4.3 V4.3.1H
Commonly Used Routines
? There are also 22 utility routines which can be
called directly:
GETVAR
> To allow users to find equation number for a variable.
IPALL
> To allow users to obtain the addresses for all the centers /
vertices of selected blocks / patches.
IPREC
> To allow users to obtain the addresses for all the centers /
vertices on a single block / patch (covering a single face).
SETWRK,DELWRK
> To allow users to allocate and delete work space for a
temporary array.
CFX-4
Introductory Training (Dec 1999)
9 -7
CFX-4.3 V4.3.1H
How to Use FORTRAN
? To use a user
FORTRAN routine
Obtain the template by
clicking on User Fortran
within the Environment,
and Get Fortran.
Edit the FORTRAN
routine and ensure the
IUSED flag is set to 1.
Include the routine in the
command file
? OPTIONS
...,..
? USER FORTRAN
USRSRC
Specify the user
FORTRAN file when
running the solver.
CFX-4
Introductory Training (Dec 1999)
9 -8
CFX-4.3 V4.3.1H
? The solver stops if any of the last three steps
are missing.
? The FORTRAN routine is compiled and linked
at the beginning of a CFX run.
? Facility to save executable in local directory
(under Advanced Options of the solve menu).
How to Use FORTRAN
CFX-4
Introductory Training (Dec 1999)
9 -9
CFX-4.3 V4.3.1H
Structure of a Template
? Variables,constants are passed through the
argument list and common blocks
SUBROUTINE USRSRC(IEQN,ICALL,CNAME,CALIAS,AM,SP,SU,CONV
+,U,V,W,P,VFRAC,DEN,VIS,TE,ED,RS,T,H,RF,SCAL
+,XP,YP,ZP,VOL,AREA,VPOR,ARPOR,WFACT,IPT
+,IBLK,IPVERT,IPNODN,IPFACN,IPNODF,IPNODB,IPFACB
+,WORK,IWORK,CWORK)
U,V,W,P,VFRAC,DEN,…,T,H are dimensioned
(NNODE,NPHASE)
SCAL is dimensioned (NNODE,NPHASE,NSCAL)
XP,YP,ZP are dimensioned (NNODE).
CFX-4
Introductory Training (Dec 1999)
9 -10
CFX-4.3 V4.3.1H
Structure of a Template
? Variables not in the subroutine argument list
can be accessed through work space stacks.
WORK,IWORK,CWORK.
? User areas are available for defining user
variables,common blocks,etc.
? Each template contains several examples
which can be uncommented and modified by
the user.
CFX-4
Introductory Training (Dec 1999)
9 -11
CFX-4.3 V4.3.1H
Rules You Should Follow
? Only make changes within user areas.
? Do not modify the version number IVERS and
precision number ICHKPR.
? Start user common block with UC and user
array with USR.
CFX-4
Introductory Training (Dec 1999)
9 -12
CFX-4.3 V4.3.1H
Case Study - Adding a Source
? In the command file
>>OPTIONS
…
>>USER FORTRAN
USRSRC
…
? In the fortran
file IUSED=1.
? Run the solver.
CFX-4
Introductory Training (Dec 1999)
9 -13
CFX-4.3 V4.3.1H
Adding a Heat Source
? Numerical consideration
> the source terms can be linearized in different ways
> Sp, contribution of the source terms to the diagonal of
the coefficient matrix
> Su, remaining source terms.
To retain diagonal dominance of the linear
equation system (for numerical stability &
accuracy)
> Sp, should be negative,otherwise put into Su.
A A S Sp p nb
nb nb u p p
? ? ?- ? ??
CFX-4
Introductory Training (Dec 1999)
9 -14
CFX-4.3 V4.3.1H
Adding a Heat Source
User FORTRAN:
SUBROUTINE USRSRC(IEQN,ICALL,CNAME,CALIAS,AM,SP,SU,CONV
+,U,V,W,P,VFRAC,DEN,VIS,TE,ED,RS,T,H,RF,SCAL
+,XP,YP,ZP,VOL,AREA,VPOR,ARPOR,WFACT,IPT
+,IBLK,IPVERT,IPNODN,IPFACN,IPNODF,IPNODB,IPFACB
+,WORK,IWORK,CWORK)
C
C**********************************************************************
C
C UTILITY SUBROUTINE FOR USER-SUPPLIED SOURCES
C
C >>> IMPORTANT <<<
C >>> <<<
C >>> USERS MAY ONLY ADD OR ALTER PARTS OF THE SUBROUTINE WITHIN <<<
C >>> THE DESIGNATED USER AREAS <<<
C
C**********************************************************************
C
C THIS SUBROUTINE IS CALLED BY THE FOLLOWING SUBROUTINES
C CUSR SCDF SCDS SCED SCENRG SCHF SCMOM SCPCE SCSCAL
C SCTE SCVF
C
C***********************************************************************
CFX-4
Introductory Training (Dec 1999)
9 -15
CFX-4.3 V4.3.1H
Adding a Heat Source
C***********************************************************************
C CREATED
C 08/03/90 ADB
C MODIFIED
C 04/03/91 ADB ALTERED ARGUMENT LIST.
C 28/08/91 IRH NEW STRUCTURE
C 28/09/91 IRH CHANGE EXAMPLE + ADD COMMON BLOCKS
C 10/02/92 PHA UPDATE CALLED BY COMMENT,ADD RF ARGUMENT,
C CHANGE LAST DIMENSION OF RS TO 6 AND IVERS TO 2
C 03/06/92 PHA ADD PRECISION FLAG AND CHANGE IVERS TO 3
C 23/11/93 CSH EXPLICITLY DIMENSION IPVERT ETC.
C 07/12/93 NSW INCLUDE CONV IN ARGUMENT LIST AND CHANGE IVERS
C TO 4
C 03/02/94 PHA CHANGE FLOW3D TO CFDS-FLOW3D
C 03/03/94 FHW CORRECTION OF SPELLING MISTAKE
C 08/03/94 NSW CORRECT SPELLING
C 09/08/94 NSW CORRECT SPELLING.
C MOVE 'IF(IUSED.EQ.0) RETURN' OUT OF USER AREA.
C INCLUDE COMMENT ON MASS SOURCES.
C 19/12/94 NSW CHANGE FOR CFX-F3D
C
C***********************************************************************
CFX-4
Introductory Training (Dec 1999)
9 -16
CFX-4.3 V4.3.1H
Adding a Heat Source
C***********************************************************************
C
C SUBROUTINE ARGUMENTS
C
C IEQN - EQUATION NUMBER
C ICALL - SUBROUTINE CALL
C CNAME - EQUATION NAME
C CALIAS - ALIAS OF EQUATION NAME
C AM - OFF DIAGONAL MATRIX COEFFICIENTS
C SU - SU IN LINEARISATION OF SOURCE TERM
C SP - SP IN LINEARISATION OF SOURCE TERM
C CONV - CONVECTION COEFFICIENTS
C U - U COMPONENT OF VELOCITY
C V - V COMPONENT OF VELOCITY
C W - W COMPONENT OF VELOCITY
C P - PRESSURE
C VFRAC - VOLUME FRACTION
C DEN - DENSITY OF FLUID
C VIS - VISCOSITY OF FLUID
C TE - TURBULENT KINETIC ENERGY
C ED - EPSILON
C RS - REYNOLD STRESSES
C T - TEMPERATURE
C H - ENTHALPY
CFX-4
Introductory Training (Dec 1999)
9 -17
CFX-4.3 V4.3.1H
Adding a Heat Source
C RF - REYNOLD FLUXES
C SCAL - SCALARS (THE FIRST 'NCONC' OF THESE ARE MASS FRACTIONS)
C XP - X COORDINATES OF CELL CENTRES
C YP - Y COORDINATES OF CELL CENTRES
C ZP - Z COORDINATES OF CELL CENTRES
C VOL - VOLUME OF CELLS
C AREA - AREA OF CELLS
C VPOR - POROUS VOLUME
C ARPOR - POROUS AREA
C WFACT - WEIGHT FACTORS
C
C IPT - 1D POINTER ARRAY
C IBLK - BLOCK SIZE INFORMATION
C IPVERT - POINTER FROM CELL CENTERS TO 8 NEIGHBOURING VERTICES
C IPNODN - POINTER FROM CELL CENTERS TO 6 NEIGHBOURING CELLS
C IPFACN - POINTER FROM CELL CENTERS TO 6 NEIGHBOURING FACES
C IPNODF - POINTER FROM CELL FACES TO 2 NEIGHBOURING CELL CENTERS
C IPNODB - POINTER FROM BOUNDARY CENTERS TO CELL CENTERS
C IPFACB - POINTER FROM BOUNDARY CENTERS TO BOUNDARY FACESS
C
C WORK - REAL WORKSPACE ARRAY
C IWORK - INTEGER WORKSPACE ARRAY
C CWORK - CHARACTER WORKSPACE ARRAY
C
CFX-4
Introductory Training (Dec 1999)
9 -18
CFX-4.3 V4.3.1H
Adding a Heat Source
C SUBROUTINE ARGUMENTS PRECEDED WITH A '*' ARE ARGUMENTS THAT MUST
C BE SET BY THE USER IN THIS ROUTINE.
C
C NOTE THAT WHEN USING MASS SOURCES,THE FLOWS THROUGH MASS FLOW
C BOUNDARIES ARE UNCHANGED,THE USER SHOULD THEREFORE INCLUDE AT
C LEAST ONE PRESSURE BOUNDARY FOR SUCH A CALCULATION.
C
C NOTE THAT OTHER DATA MAY BE OBTAINED FROM CFX-F3D USING THE
C ROUTINE GETADD,FOR FURTHER DETAILS SEE THE VERSION 4
C USER MANUAL.
C
C***********************************************************************
C
LOGICAL LDEN,LVIS,LTURB,LTEMP,LBUOY,LSCAL,LCOMP
+,LRECT,LCYN,LAXIS,LPOROS,LTRANS
C
CHARACTER*(*) CWORK
CHARACTER CNAME*6,CALIAS*24
C
C+++++++++++++++++ USER AREA 1 +++++++++++++++++++++++++++++++++++++++++
C---- AREA FOR USERS EXPLICITLY DECLARED VARIABLES
C
C+++++++++++++++++ END OF USER AREA 1 ++++++++++++++++++++++++++++++++++
CFX-4
Introductory Training (Dec 1999)
9 -19
CFX-4.3 V4.3.1H
Adding a Heat Source
C
COMMON
+ /ALL/ NBLOCK,NCELL,NBDRY,NNODE,NFACE,NVERT,NDIM
+ /ALLWRK/ NRWS,NIWS,NCWS,IWRFRE,IWIFRE,IWCFRE
+ /ADDIMS/ NPHASE,NSCAL,NVAR,NPROP
+,NDVAR,NDPROP,NDXNN,NDGEOM,NDCOEF,NILIST,NRLIST,NTOPOL
+ /CHKUSR/ IVERS,IUCALL,IUSED
+ /DEVICE/ NREAD,NWRITE,NRDISK,NWDISK
+ /IDUM/ ILEN,JLEN
+ /LOGIC/ LDEN,LVIS,LTURB,LTEMP,LBUOY,LSCAL,LCOMP
+,LRECT,LCYN,LAXIS,LPOROS,LTRANS
+ /MLTGRD/ MLEVEL,NLEVEL,ILEVEL
+ /SGLDBL/ IFLGPR,ICHKPR
+ /SPARM/ SMALL,SORMAX,NITER,INDPRI,MAXIT,NODREF,NODMON
+ /TRANSI/ NSTEP,KSTEP,MF,INCORE
+ /TRANSR/ TIME,DT,DTINVF,TPARM
C
C+++++++++++++++++ USER AREA 2 +++++++++++++++++++++++++++++++++++++++++
C---- AREA FOR USERS TO DECLARE THEIR OWN COMMON BLOCKS
C THESE SHOULD START WITH THE CHARACTERS 'UC' TO ENSURE
C NO CONFLICT WITH NON-USER COMMON BLOCKS
C
C+++++++++++++++++ END OF USER AREA 2 ++++++++++++++++++++++++++++++++++
C
CFX-4
Introductory Training (Dec 1999)
9 -20
CFX-4.3 V4.3.1H
Adding a Heat Source
DIMENSION AM(NCELL,6,NPHASE),SP(NCELL,NPHASE),SU(NCELL,NPHASE)
+,CONV(NFACE,NPHASE)
C
DIMENSION
+ U(NNODE,NPHASE),V(NNODE,NPHASE),W(NNODE,NPHASE),P(NNODE,NPHASE)
+,VFRAC(NNODE,NPHASE),DEN(NNODE,NPHASE),VIS(NNODE,NPHASE)
+,TE(NNODE,NPHASE),ED(NNODE,NPHASE),RS(NNODE,NPHASE,6)
+,T(NNODE,NPHASE),H(NNODE,NPHASE),RF(NNODE,NPHASE,4)
+,SCAL(NNODE,NPHASE,NSCAL)
C
DIMENSION
+ XP(NNODE),YP(NNODE),ZP(NNODE)
+,VOL(NCELL),AREA(NFACE,3),VPOR(NCELL),ARPOR(NFACE,3)
+,WFACT(NFACE)
+,IPT(*),IBLK(5,NBLOCK)
+,IPVERT(NCELL,8),IPNODN(NCELL,6),IPFACN(NCELL,6),IPNODF(NFACE,4)
+,IPNODB(NBDRY,4),IPFACB(NBDRY)
+,IWORK(*),WORK(*),CWORK(*)
C
C+++++++++++++++++ USER AREA 3 +++++++++++++++++++++++++++++++++++++++++
C---- AREA FOR USERS TO DIMENSION THEIR ARRAYS
C
C---- AREA FOR USERS TO DEFINE DATA STATEMENTS
C
C+++++++++++++++++ END OF USER AREA 3 ++++++++++++++++++++++++++++++++++
CFX-4
Introductory Training (Dec 1999)
9 -21
CFX-4.3 V4.3.1H
Adding a Heat Source
C
C---- STATEMENT FUNCTION FOR ADDRESSING
IP(I,J,K)=IPT((K-1)*ILEN*JLEN+(J-1)*ILEN+I)
C
C----VERSION NUMBER OF USER ROUTINE AND PRECISION FLAG
C
IVERS=4 !!! DO NOT MODIFY
ICHKPR = 1
C
C+++++++++++++++++ USER AREA 4 +++++++++++++++++++++++++++++++++++++++++
C---- TO USE THIS USER ROUTINE FIRST SET IUSED=1
C
IUSED=1 MODIFY
C
C+++++++++++++++++ END OF USER AREA 4 ++++++++++++++++++++++++++++++++++
C
IF (IUSED.EQ.0) RETURN
C
C---- FRONTEND CHECKING OF USER ROUTINE
IF (IUCALL.EQ.0) RETURN
C
C---- ADD TO SOURCE TERMS
IF (ICALL.EQ.1) THEN
C
CFX-4
Introductory Training (Dec 1999)
9 -22
CFX-4.3 V4.3.1H
Adding a Heat Source
C+++++++++++++++++ USER AREA 5 +++++++++++++++++++++++++++++++++++++++++
C
C---- EXAMPLE (HEAT SOURCE) ADD 100W PER UNIT VOLUME IN BLOCK
C 'BLOCK-NUMBER-2'
C
C USE IPREC TO FIND ADDRESSES
C
CALL IPREC('BLOCK-NUMBER-2','BLOCK','CENTRES',IPT,ILEN,JLEN,KLEN,
+ CWORK,IWORK)
C
C FIND VARIABLE NUMBER FOR ENTHALPY
CALL GETVAR('USRSRC','H ',IVAR)
C IF ENTHALPY EQUATION ADD SOURCE TERMS
IF (IVAR.EQ.IEQN) THEN
C LOOP OVER PATCH
DO 103 K = 1,KLEN
DO 102 J = 1,JLEN
DO 101 I = 1,ILEN
C USE STATEMENT FUNCTION IP TO GET ADDRESSES
INODE = IP(I,J,K)
C ADD HEAT SOURCE
SU(INODE,1)=SU(INODE,1)+100.0*VOL(INODE)
101 CONTINUE
102 CONTINUE
103 CONTINUE
MODIFY EXAMPLE
CODE TO LOOP
OVER CELLS AND
ADD HEAT SOURCE
CFX-4
Introductory Training (Dec 1999)
9 -23
CFX-4.3 V4.3.1H
Adding a Heat Source
ENDIF
C
C---- END OF EXAMPLE
C+++++++++++++++++ END OF USER AREA 5 ++++++++++++++++++++++++++++++++++
ENDIF
RETURN
END