I tried to use the mixture fraction in an expression gradient directly but CFX did not like it. I have no error message in CFX-Pre but in CFX solve the gradient is not recognized. I checked again in CFX-Post and I can see the gradient available for display. Why can't I access this variable through an expression like other variables?
There is a limitation in the syntax of CCL that currently prevents reference to Gradient variables through expressions. However, gradients can be accessed by creating an expression which calls the user_getvar routine though a CEL function: ********************************* 1. Set up the connection to the FORTRAN first: USER ROUTINE DEFINITIONS: USER ROUTINE: UserSource2Routine Calling Name = user_source2 Library Name = AdVarSource Library Path = /mp/support2/jcooper/service/cecile Option = User CEL Function END END 2. Then, create a CEL function that provides a way of exchanging information with the FORTRAN routine FUNCTION: Function1 Argument Units = [] Option = User Function Result Units = [m m^-1] User Routine Name = UserSource2Routine END 3. Create an expression that invokes the function (this expression can be used in other expressions or anywhere that the gradient variable is required EXPRESSIONS: mixturegrad = Function1(1) END 4. Use the usersource template routine to call user_Getvar. Make sure that the routine USER_SOURCE_CAL is calculating the expression that is desired!!! The following template is set up to calculate the sum of the X, Y and Z Gradients squared. #include "cfx5ext.h" dllexport(user_source2) SUBROUTINE USER_SOURCE2 ( & NLOC,NRET,NARG,RET,ARGS,CRESLT,CZ,DZ,IZ,LZ,RZ) C-------------------- C Details C -------------------- C ARGS(1:NLOC,1) holds parameter ?a? evaluated at all locations C RET(1:NLOC,1) will hold return result C ------------------------------ C Preprocessor includes C ------------------------------ #include "MMS.h" #include "stack_point.h" C ------------------------------ C C---- Obtain grad(phi1) C in array shape GRAD_PHI(1:3,1:NLOC) located at RZ(pGRAD_PHI) C User_Variable_Name = User_Phase_Name(1:LENACT(User_Phase_Name)) & // '.Mixture Fraction.Gradient' CALL USER_GETVAR (User_Variable_Name, CRESLT, pGRAD_PHI, & CZ,DZ,IZ,LZ,RZ) IF (CRESLT .NE. 'GOOD') GO TO 999 C C---- Calculate source expression in RET(1:NLOC,1) C CALL USER_SOURCE_CAL( RET(1,1), ARGS(1,1), RZ(pGRAD_PHI), NLOC ) C END SUBROUTINE USER_SOURCE_CAL (SOURCE, A, GRAD_PHI, NLOC) C C Purpose: Source = a * grad(phi).grad(phi) C C Inputs INTEGER NLOC REAL A(NLOC), GRAD_PHI(3,NLOC) C Outputs REAL SOURCE(NLOC) C Locals INTEGER ILOC C DO ILOC = 1, NLOC SOURCE(ILOC) = ( GRAD_PHI(1,ILOC)**2 & + GRAD_PHI(2,ILOC)**2 & + GRAD_PHI(3,ILOC)**2 ) END DO C END |
||
|