Documente Academic
Documente Profesional
Documente Cultură
ANSYS Conference
Training Manual
Customizing CFX
Workshop 1:
Setting an Inlet Velocity Profile with User Fortran
W1-1
Overview
Training Manual
W1-2
Training Manual
W1-3
CEL Option
Training Manual
W1-4
Training Manual
W1-5
Training Manual
#include "cfx5ext.h"
This include statement is always required
dllexport(ucf_template)
The dllexport line uses the subroutine name in lower case
SUBROUTINE UCF_TEMPLATE (
& NLOC, NRET, NARG, RET, ARGS, CRESLT, CZ,DZ,IZ,LZ,RZ )
CC
CD User routine: template for user CEL function
CC
CC -------------------CC
Input
CC -------------------CC
The solver will always know the locale
CC NLOC
- size of current locale
for the call and NLOC, the number of
CC NRET
- number of components in result
locations in the current locale
CC NARG
- number of arguments in call
CC ARGS() - (NLOC,NARG) argument values
Currently, NRET is always 1
CC
CC -------------------NARG is the number of variables which
CC
Modified
CC -------------------are passed to the routine to evaluate the
CC
return variable
CC Stacks possibly.
CC
ARGS() is the array where the input
CC -------------------arguments are stored
CC
Output
CC -------------------RET() is the array where the return values
CC
CC RET() - (NLOC,NRET) return values
are stored
CC CRESLT - 'GOOD' for success
ANSYS, Inc. Proprietary
2008 ANSYS, Inc. All rights reserved.
W1-6
Training Manual
5.
See the following slide for the required FORTRAN statements for the variable
assignments and the computation of the return value. After implementing these
statements, save the modified routine ucf_velocity.F
W1-7
ucf_velocity.F
Training Manual
C -----------------------------C
Argument list
C -----------------------------INTEGER NLOC,NARG,NRET
CHARACTER CRESLT*(*)
REAL ARGS(NLOC,NARG), RET(NLOC,NRET)
INTEGER IZ(*)
CHARACTER CZ(*)*(1)
DOUBLE PRECISION DZ(*)
LOGICAL LZ(*)
REAL RZ(*)
C -----------------------------C
Local Variables
C -----------------------------REAL VMAX, YBOUND, Y
INTEGER I
C --------------------------C
Executable Statements
C --------------------------C
C Define parameters vmax and ybound from the input arguments
C
VMAX = ARGS(1,1)
YBOUND = ARGS(1,2)
C
C Loop over Y from 1 to NLOC and compute the normal speed in RET:
DO 10 I = 1,NLOC
Y = ARGS(I,3)
RET(I,1) = VMAX*(1.0 - Y**2/YBOUND**2)
10
CONTINUE
END
ANSYS, Inc. Proprietary
2008 ANSYS, Inc. All rights reserved.
W1-8
Fortran Compilers
Training Manual
W1-9
Training Manual
followed by:
cfx5mkext ucf_velocity.F
W1-10
Training Manual
10. Set the Library Path to the folder where the Fortran source file
resides and click Ok
ANSYS, Inc. Proprietary
2008 ANSYS, Inc. All rights reserved.
W1-11
Training Manual
W1-12
Training Manual
0.001 [m/s]
0.05 [m]
W1-13
Training Manual
W1-14
Training Manual
W1-15
Training Manual
W1-16
Results
Training Manual
W1-17