n
K
Solver Variable and Expression Name are both
accessed via the right mouse button
CEL in CFX-Pre: Example 1
CFX Expression Language
11-9
ANSYS, Inc. Proprietary
2009 ANSYS, Inc. All rights reserved.
April 28, 2009
Inventory #002598
Training Manual
Alternatively, an expression can be entered directly into a field
CEL in CFX-Pre: Example 1
CFX Expression Language
11-10
ANSYS, Inc. Proprietary
2009 ANSYS, Inc. All rights reserved.
April 28, 2009
Inventory #002598
Training Manual
Using an if Function
Set inlet temperature to 300 K for the first 19 iterations then raise it to
320 K after 20 iterations
Solver variable
accessed with the right
mouse button
Note: On the 21
st
iteration
inlet temp = 310 K
CEL in CFX-Pre: Example 2
CFX Expression Language
11-11
ANSYS, Inc. Proprietary
2009 ANSYS, Inc. All rights reserved.
April 28, 2009
Inventory #002598
Training Manual
You can also define your own 1-D linear, or 3-D cloud of points
interpolation functions
Import
data
points or
add
manually
User Functions
CFX Expression Language
11-12
ANSYS, Inc. Proprietary
2009 ANSYS, Inc. All rights reserved.
April 28, 2009
Inventory #002598
Training Manual
Example: Having the timestep change
with iteration number as shown here
Timestep size is in seconds
Continued on next
slide...
User Functions: Example
Iteration Number is
dimensionless
CFX Expression Language
11-13
ANSYS, Inc. Proprietary
2009 ANSYS, Inc. All rights reserved.
April 28, 2009
Inventory #002598
Training Manual
Example: Having the timestep change
with iteration number as shown here
User Functions: Example
CFX Expression Language
11-14
ANSYS, Inc. Proprietary
2009 ANSYS, Inc. All rights reserved.
April 28, 2009
Inventory #002598
Training Manual
Integrated quantities can be used in expressions to evaluate variables over
some location
Examples:
Calculate the area average of Cp on an isosurface: areaAve(Cp)@iso1
Mass flow of particular fluid through a locator: oil.massFlow()@slice1
Available in CFX-Pre and CFD-Post
Usage is more strict in CFX-Pre
E.g. the argument supplied to the function must be a variable, not an expression
@<locator> syntax must always supply a named location used in the
physics definition
A boundary condition name, a domain name, a monitor point name, etc.
To reference general mesh regions use the syntax @REGION:<name>
Phases/components can be referenced using:
[<phase name>.][<component name>.]<function>@<locator>
E.g. Air.Nitrogen.massFlow()@outlet
Integrated Quantities
CFX Expression Language
11-15
ANSYS, Inc. Proprietary
2009 ANSYS, Inc. All rights reserved.
April 28, 2009
Inventory #002598
Training Manual
Integrated Quantities
Some functions allow an x, y or z operator:
area_x()@boundary gives the area projected in the x-direction
force_z()@wall gives the z component of the force on the wall
See documentation for a full list
These functions also allow an optional coordinate frame:
force_z_MyCoord()@wall gives the z component of the force on the wall using the
coordinate frame MyCoord
Each function requires either 0 or 1 arguments
areaAve requires 1 argument: areaAve(Temperature)@Wall
massFlow requires 0 arguments: massFlow()@Inlet
Return value units depend on the argument units
areaAve(Temperature)@Wall will return a value with units of Temperature
CFX Expression Language
11-16
ANSYS, Inc. Proprietary
2009 ANSYS, Inc. All rights reserved.
April 28, 2009
Inventory #002598
Training Manual
Below is a partial list of functions
See documentation for a complete list
Right-clicking when creating an expression will show most functions
Function Name and Syntax
<required> [<optional>]
area( )@<Location>
Area of a boundary or
interface.
Any 2D region (e.g., boundary
or interface)
area_x( )@<Location>
area_y( )@<Location>
area_z( )@<Location>
The (signed) component of the
normal area vector in the local
x, y or z direction. Any 2D region (e.g., a
boundary or interface)
areaAve(<var>)@<Location>
Area-weighted average of <var>
on a boundary.
Any 2D region (e.g., a
boundary or interface)
areaInt(<var>)@<Location>
Area-weighted integral of <var>
on a boundary.
Any 2D region (e.g., a
boundary or interface)
ave(<var>)@<Location>
Arithmetic average of <var>
within a domain or subdomain.
Any 3D region (e.g., domain or
subdomain)
[<Fluid>.]force( )@<Location>
The magnitude of the force
vector on a boundary. Any 2D region (e.g., a wall)
Operation Valid <Location>
Integrated Quantities
CFX Expression Language
11-17
ANSYS, Inc. Proprietary
2009 ANSYS, Inc. All rights reserved.
April 28, 2009
Inventory #002598
Training Manual
Function Name and Syntax
<required> [<optional>]
[<Fluid>.]force_x( )@<Location>
[<Fluid>.]force_y( )@<Location>
[<Fluid>.]force_z( )@<Location>
The (signed) component of the
force vector in the local x, y
or z direction. Any 2D region (e.g., a wall)
inside()@<Location>
Similar to the subdomain
variable, but allows a specific
2D or 3D location to be given.
Any 2D or 3D named sub-
region of the physical location
on which the expression is
evaluated.
mass()@<Location>
The total mass within a domain
or subdomain. This is fluid
dependent.
Any 3D region (e.g., domain or
subdomain)
massAve(<var>)@<Location>
Mass-weighted average of
<var> on a domain or
subdomain.
Any 3D region (e.g., domain or
subdomain)
massInt(<var>)@<Location>
The mass-weighted integration
of <var> within a domain or
subdomain
Any 3D region (e.g., domain or
subdomain)
[<Fluid>.]massFlow()@<Location> Mass flow through a boundary.
Any fluid surfaces (e.g., Inlets,
Outlets, Openings and fluid-
fluid interfaces)
[<Fluid>.]massFlowAve(<var>)
@<Location>
Mass flow weighted average of
<var> on a boundary.
Any fluid surfaces (e.g., Inlets,
Outlets, Openings and fluid-
fluid interfaces)
Operation Valid <Location>
Integrated Quantities
CFX Expression Language
11-18
ANSYS, Inc. Proprietary
2009 ANSYS, Inc. All rights reserved.
April 28, 2009
Inventory #002598
Training Manual
Function Name and Syntax
<required> [<optional>]
[<Fluid>.]massFlowAveAbs(<var>)
@<Location>
Absolute mass flow weighted
average of <var> on a
boundary.
Any fluid surfaces (e.g., Inlets,
Outlets, Openings and fluid-
fluid interfaces)
[<Fluid>.]massFlowInt(<var>)
@<Location>
Mass flow weighted integration
of <var> on a boundary.
Any fluid surfaces (e.g., Inlets,
Outlets, Openings and fluid-
fluid interfaces)
maxVal(<var>)@<Location>
Maximum Value of <var>
within a domain or subdomain.
Any 3D region (e.g., domain or
subdomain)
minVal(<var>)@<Location>
Minimum Value of <var> within
a domain or subdomain.
Any 3D region (e.g., domain or
subdomain)
probe(<var>)@<Location>
Returns the value of the
specified variable on the
specified Point locator.
Any point object (e.g., a
Source Point or Cartesian
Monitor Point)
rmsAve(<var>)@<Location>
RMS average of <var> within a
domain.
Any 3D region (e.g., domain or
subdomain)
sum(<var>)@<Location>
Sum of <var> over all domain
or subdomain vertices.
Any 3D region (e.g., domain or
subdomain)
Operation Valid <Location>
Integrated Quantities
CFX Expression Language
11-19
ANSYS, Inc. Proprietary
2009 ANSYS, Inc. All rights reserved.
April 28, 2009
Inventory #002598
Training Manual
Useful Functions
The inside() function returns 1 when inside the specified location and
0 when outside
Useful to limit the scope of a function to a subdomain or boundary
The step() function return 1 when the argument is positive and 0
when the argument is negative
Useful as an on-off switch
if() function can also be used as a switch
areaAve() and massFlowAve() are used to evaluate the average of a
quantity on a location
areaAve() is an area-weighted average. It is usually used on wall
boundaries and when the quantity is not carried with the flow, e.g.
Pressure at an outlet, Temperature on a wall
massFlowAve() is an average weighted by the local mass flow. It is
usually used to evaluate quantities that are carried with the flow, e.g.
Temperature at an outlet