CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   CFX (http://www.cfd-online.com/Forums/cfx/)
-   -   help me CFX call fortran (http://www.cfd-online.com/Forums/cfx/71718-help-me-cfx-call-fortran.html)

 zidanzm January 12, 2010 23:24

help me CFX call fortran

Hi,everyone
I am using user subroutine USRINT to give the initial conditions in CFX4.4,but when i read the followings:
VARBCS(IU,IPHS,INODE) = UVEL(J)
VARBCS(IK,IPHS,INODE) = STE(J)
VARBCS(IE,IPHS,INODE) = SED(J)
what's the meaning of UVEL(J),STE(J),SED(J),i can't find these in the manual,please give me a hand.

 kingjewel1 January 14, 2010 07:48

Quote:
 Originally Posted by zidanzm (Post 242367) Hi,everyone I am using user subroutine USRINT to give the initial conditions in CFX4.4,but when i read the followings: VARBCS(IU,IPHS,INODE) = UVEL(J) VARBCS(IK,IPHS,INODE) = STE(J) VARBCS(IE,IPHS,INODE) = SED(J) what's the meaning of UVEL(J),STE(J),SED(J),i can't find these in the manual,please give me a hand. Thanks in advance, Zidanzm.
What manual are you reading? UVEL(J) I presume is the velocity in the U direction at a particular node J. UVEL, STE and SED must be 1 dimensional arrays but I don't know what the last two stand for.

 zidanzm January 23, 2010 10:21

question go on

Quote:
 Originally Posted by kingjewel1 (Post 242567) What manual are you reading? UVEL(J) I presume is the velocity in the U direction at a particular node J. UVEL, STE and SED must be 1 dimensional arrays but I don't know what the last two stand for.
thank you very much! i read the CFX4.4 manual, but i can't find these things, so i am so anxious that i can't go on my work, can you give me a hand? thanks a lot.

 ghorrocks January 23, 2010 18:30

Wow, this post is like a step back in time. I have not played with CFX 4 for over 10 years now! Why haven't you moved to CFX V12?

But to answer your question (and I stress this is from 10 year old memories so could be dodgy) the VARBCS(var,iphase,inode) defines a boundary condition. I suspect UVEL, STE and SED are just local variables defined in the example fortran you are looking at. Just replace the UVEL, STE and SED variables with the values you want to write into the boundary condition.

But it is a bit strange referring to boundary conditions in a routine used to set initial conditions. Why do you want to set the boundaries in a routine designed to set an initial condition.

It would be best if you to post the whole fortran file, or at least enough of it so we know what you are trying to do.

 zidanzm January 24, 2010 20:50

Quote:
 Originally Posted by ghorrocks (Post 243563) Wow, this post is like a step back in time. I have not played with CFX 4 for over 10 years now! Why haven't you moved to CFX V12? But to answer your question (and I stress this is from 10 year old memories so could be dodgy) the VARBCS(var,iphase,inode) defines a boundary condition. I suspect UVEL, STE and SED are just local variables defined in the example fortran you are looking at. Just replace the UVEL, STE and SED variables with the values you want to write into the boundary condition. But it is a bit strange referring to boundary conditions in a routine used to set initial conditions. Why do you want to set the boundaries in a routine designed to set an initial condition. It would be best if you to post the whole fortran file, or at least enough of it so we know what you are trying to do.
the whole fortran file is as following:
SUBROUTINE USRBCS(VARBCS,VARAMB,A,B,C,ACND,BCND,CCND
+ ,IWGVEL,NDVWAL
+ ,FLOUT,NLABEL,NSTART,NEND,NCST,NCEN
+ ,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 USER ROUTINE TO SET REALS AT BOUNDARIES.
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 SUBROUTINE
C CUSR SRLIST
C
C************************************************* **********************
C CREATED
C MODIFIED
C 08/09/90 ADB RESTRUCTURED FOR USER-FRIENDLINESS.
C 10/08/91 IRH FURTHER RESTRUCTURING ADD ACND BCND CCND
C 22/09/91 IRH CHANGE ICALL TO IUCALL + ADD /SPARM/
C 10/03/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 30/06/92 NSW INCLUDE FLAG FOR CALLING BY ITERATION
C 03/08/92 NSW MODIFY DIMENSION STATEMENTS FOR VAX
C 21/12/92 CSH INCREASE IVERS TO 4
C 02/08/93 NSW INCORRECT AND MISLEADING COMMENT REMOVED
C 05/11/93 NSW INDICATE USE OF FLOUT IN MULTIPHASE FLOWS
C 23/11/93 CSH EXPLICITLY DIMENSION IPVERT ETC.
C 01/02/94 NSW SET VARIABLE POINTERS IN WALL EXAMPLE.
C CHANGE FLOW3D TO CFDS-FLOW3D.
C MODIFY MULTIPHASE MASS FLOW BOUNDARY TREATMENT.
C 03/03/94 FHW CORRECTION OF SPELLING MISTAKE
C 02/07/94 BAS SLIDING GRIDS - ADD NEW ARGUMENT IWGVEL
C TO ALLOW VARIANTS OF TRANSIENT-GRID WALL BC
C CHANGE VERSION NUMBER TO 5
C 09/08/94 NSW CORRECT SPELLING
C MOVE 'IF(IUSED.EQ.0) RETURN' OUT OF USER AREA
C 19/12/94 NSW CHANGE FOR CFX-F3D
C 02/02/95 NSW CHANGE COMMON /IMFBMP/
C 02/06/97 NSW MAKE EXAMPLE MORE LOGICAL
C 02/07/97 NSW UPDATE FOR CFX-4
C
C************************************************* **********************
C
C SUBROUTINE ARGUMENTS
C
C VARBCS - REAL BOUNDARY CONDITIONS
C VARAMB - AMBIENT VALUE OF VARIABLES
C A - COEFFICIENT IN WALL BOUNDARY CONDITION
C B - COEFFICIENT IN WALL BOUNDARY CONDITION
C C - COEFFICIENT IN WALL BOUNDARY CONDITION
C ACND - COEFFICIENT IN CONDUCTING WALL BOUNDARY CONDITION
C BCND - COEFFICIENT IN CONDUCTING WALL BOUNDARY CONDITION
C CCND - COEFFICIENT IN CONDUCTING WALL BOUNDARY CONDITION
C IWGVEL - USAGE OF INPUT VELOCITIES (0 = AS IS,1 = ADD GRID MOTION)
C NDVWAL - FIRST DIMENSION OF ARRAY IWGVEL
C FLOUT - MASS FLOW/FRACTIONAL MASS FLOW
C NLABEL - NUMBER OF DISTINCT OUTLETS
C NSTART - ARRAY POINTER
C NEND - ARRAY POINTER
C NCST - ARRAY POINTER
C NCEN - ARRAY POINTER
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
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 TO NODES FROM BOUNDARY FACES
C
C WORK - REAL WORKSPACE ARRAY
C IWORK - INTEGER WORKSPACE ARRAY
C CWORK - CHARACTER WORKSPACE ARRAY
C
C SUBROUTINE ARGUMENTS PRECEDED WITH A '*' ARE ARGUMENTS THAT MUST
C BE SET BY THE USER IN THIS ROUTINE.
C
C NOTE THAT OTHER DATA MAY BE OBTAINED FROM CFX-4 USING THE
C ROUTINE GETADD, FOR FURTHER DETAILS SEE THE VERSION 4
C USER MANUAL.
C
C************************************************* **********************
LOGICAL LDEN,LVIS,LTURB,LTEMP,LBUOY,LSCAL,LCOMP
+ ,LRECT,LCYN,LAXIS,LPOROS,LTRANS
C
CHARACTER*(*) CWORK
C
C+++++++++++++++++ USER AREA 1 +++++++++++++++++++++++++++++++++++++++++
C---- AREA FOR USERS EXPLICITLY DECLARED VARIABLES
C
C+++++++++++++++++ END OF USER AREA 1 ++++++++++++++++++++++++++++++++++
C
COMMON
+ /ALL/ NBLOCK,NCELL,NBDRY,NNODE,NFACE,NVERT,NDIM
+ /ALLWRK/ NRWS,NIWS,NCWS,IWRFRE,IWIFRE,IWCFRE
+ ,NDVAR,NDPROP,NDXNN,NDGEOM,NDCOEF,NILIST,NRLIST,NT OPOL
+ /BCSOUT/ IFLOUT
+ /CHKUSR/ IVERS,IUCALL,IUSED
+ /IDUM/ ILEN,JLEN
+ /IMFBMP/ IMFBMP,JMFBMP
+ /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
+ /UBCSFL/ IUBCSF
C
C+++++++++++++++++ USER AREA 2 +++++++++++++++++++++++++++++++++++++++++
C---- AREA FOR USERS TO DECLARE THEIR OWN COMMON BLOCKS
C NO CONFLICT WITH NON-USER COMMON BLOCKS
C
C+++++++++++++++++ END OF USER AREA 2 ++++++++++++++++++++++++++++++++++
C
DIMENSION
+ VARBCS(NVAR,NPHASE,NCELL+1:NNODE),VARAMB(NVAR,NPHA SE)
+,A(4+NSCAL,NPHASE,NSTART:*)
+,B(4+NSCAL,NPHASE,NSTART:*),C(4+NSCAL,NPHASE,NSTA RT:*)
+,FLOUT(*),ACND(NCST:*),BCND(NCST:*),CCND(NCST:*)
+,IWGVEL(NDVWAL,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,NPHAS E,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
DIMENSION UVEL(14),STE(14),SED(14)
C
C---- AREA FOR USERS TO DEFINE DATA STATEMENTS
C
DATA UVEL /0.9999,0.9966,0.9876,0.9761,0.9624,0.9437,0.9203,
+ 0.8955,0.8698,0.8430,0.8047,0.7570,0.7040,0.5984/
DATA STE /0.001414,0.001514,0.001713,0.001931,0.002158,0.002 491,
+ 0.002937,0.003426,0.003947,0.004487,0.005072,0.005 703,0.006534,
+ 0.007230/
DATA SED /0.0005293,0.0006068,0.0007761,0.0009894,0.001218,
+ 0.001534,0.001990,0.002332,0.003053,0.004702,0.008 009,0.01432,
+ 0.03079,0.1131/
C
C+++++++++++++++++ END OF USER AREA 3 ++++++++++++++++++++++++++++++++++
C
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=5
ICHKPR = 1
C
C+++++++++++++++++ USER AREA 4 +++++++++++++++++++++++++++++++++++++++++
C---- TO USE THIS USER ROUTINE FIRST SET IUSED=1
C AND SET IUBCSF FLAG:
C BOUNDARY CONDITIONS NOT CHANGING IUBCSF=0
C BOUNDARY CONDITIONS CHANGING WITH ITERATION IUBCSF=1
C BOUNDARY CONDITIONS CHANGING WITH TIME IUBCSF=2
C BOUNDARY CONDITIONS CHANGING WITH TIME AND ITERATION IUBCSF=3
C
IUSED=1
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+++++++++++++++++ USER AREA 5 +++++++++++++++++++++++++++++++++++++++++
C
C---- AREA FOR SETTING VALUES AT INLETS, PRESSURE BOUNDARIES
C AND OUTLETS. (NOTE THAT THE MASS FLOW AT OUTLETS IS
C SPECIFIED IN USER AREA 7)
C
C IF USING A REYNOLDS STRESS OR FLUX MODEL, NOTE THAT AT INLETS
C IT IS IMPORTANT THAT THE USER SETS ALL COMPONENTS OF THE
C REYNOLDS STRESS AND FLUX AND THE TURBULENT KINETIC ENERGY
C AS WELL AS THE ENERGY DISSIPATION RATE.
C
C SET THE VALUES IN VARBCS(NVAR,NPHASE,ILEN,JLEN,KLEN)
C
C---- EXAMPLE: SETTING A LINEAR T PROFILE ON INLET PATCH 'ENTRANCE'
C LEAVE OTHER VARIABLES AS SET IN COMMAND LANGUAGE
C
C-- INTERROGATE GETVAR FOR VARIABLE NUMBERS.
C
C CALL GETVAR('USRBCS','T ',IT)
C
C SET IPHS = 1 FOR SINGLE PHASE FLOW.
C
C IPHS = 1
C
C USE IPREC TO FIND ADDRESSES
C
C CALL IPREC('ENTRANCE','PATCH','CENTRES',IPT,ILEN,JLEN,K LEN,
C + CWORK,IWORK)
C
C XMAX=2.0
C XMIN=1.0
C TMAX=300.0
C TMIN=250.0
C LOOP OVER PATCH
C DO 103 K = 1, KLEN
C DO 102 J = 1, JLEN
C DO 101 I = 1, ILEN
C USE STATEMENT FUNCTION IP TO GET ADDRESSES
C INODE = IP(I,J,K)
C SET VARBCS
C F=(XP(INODE)-XMIN)/(XMAX-XMIN)
C VARBCS(IT,IPHS,INODE) = F*TMAX + (1.0-F)*TMIN
C 101 CONTINUE
C 102 CONTINUE
C 103 CONTINUE
C
C----END OF EXAMPLE
C
C----TO SET THE U VELOCITY, K AND EPSILON AT THE INLET
C----FOR REFERENCE EXAMPLE 3
C
C-- INTERROGATE GETVAR FOR VARIABLE NUMBERS.
C
CALL GETVAR('USRBCS','U ',IU)
CALL GETVAR('USRBCS','TE ',IK)
CALL GETVAR('USRBCS','ED ',IE)
C
C SET IPHS = 1 FOR SINGLE PHASE FLOW.
C
IPHS = 1
C
C USE IPREC TO FIND ADDRESSES
C
CALL IPREC('INLET','PATCH','CENTRES',IPT,ILEN,JLEN,KLEN ,
+ CWORK,IWORK)
C
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 SET VARBCS
VARBCS(IU,IPHS,INODE) = UVEL(J)
VARBCS(IK,IPHS,INODE) = STE(J)
VARBCS(IE,IPHS,INODE) = SED(J)
101 CONTINUE
102 CONTINUE
103 CONTINUE
return
end