Professional Documents
Culture Documents
Advanced Computational Models FLUENT - NOTES
Advanced Computational Models FLUENT - NOTES
Grid Adaptation
Non-conformal Interfaces
Moving Boundaries
Deforming Boundaries…
ME469B/4/GI 1
Grid Adaptivity
Useful for:
Capture flow features in details
Increase resolution in near-wall regions
Improve grid quality
…
ME469B/4/GI 2
Grid Adaptivity Example
Computational Domain
Flow in a complex passage
Adaptation
ME469B/4/GI 4
Adaptation Functions
Geometrical
Region
Boundary
Volume
Solution based
Isovalue
Gradient
y+
ME469B/4/GI 5
Region Adaptation
This is the same option we used for “global” grid refinement to study the
grid convergence of the solutions
Adapt Æ Region
ME469B/4/GI 6
Boundary Adaptation
Adapt Æ Boundary
Select a boundary of the
computational domain
Three options:
cell distance
normal distance
volume distance
ME469B/4/GI 7
Boundary Adaptation
Vcell = Vtarget e ad
ME469B/4/GI 8
Volume Adaptation
Adapt Æ Volume
Based on cell volume (area in 2D):
Two options:
magnitude (threshold values)
change (neighbor change)
Allow to compute the range in your grid
ME469B/4/GI 9
Isovalue Adaptation
Adapt Æ IsoValue
All field values are available (including
equation residuals, customized and grid-
related functions)
Method:
specify the function
specify a range
specify the inside/outside option
ME469B/4/GI 10
Gradient Adaptation
Method:
specify the function
specify a range
ME469B/4/GI 11
y+ Adaptation
Method:
specify the wall boundaries
specify the range (as before)
y+ = r yp ut /m y* = r Cm1/4 kp1/2 yp /m
ME469B/4/GI 12
Mark (Tag) and display
Before performing the adaptation you can mark the cell selected (based on
a certain adaptation function) and display them
ME469B/4/GI 13
Mark or Adapt?
ME469B/4/GI 14
Managing Registers
ME469B/4/GI 15
Adaptation controls
Set limits on the adaptation procedure
(i.e. maximum number of final cells) Adapt Æ <method> Æ Manage Æ Control
ME469B/4/GI 16
Hanging-Node and Conformal Adaptation
Cell to be refined
ME469B/4/GI 17
Hanging-Node Adaptation
father
Neighboring cells are not allowed to differ more than one-level of refinement
(because of inaccuracy related to large volume variations)
ME469B/4/GI 18
Conformal Adaptation
No memory penalty (the old cells are deleted and the only the new are stored)
ME469B/4/GI 19
Grid Adaptivity Guidelines
Surface mesh should be fine enough to capture all the essential geometrical
features of the model (especially for high curvature surfaces)
The initial mesh should be fine enough to capture the overall features of the
flow
ME469B/4/GI 20
Boundary Grid Adaptivity
Poor boundary resolution cannot be improved via grid refinement
Original geometry
ME469B/4/GI 21
Non-conformal grids
Grid generation can be simplified in certain problems by meshing
various components separately. The grids have to be coupled using
a non-conformal interface
Quadrilateral grid
Triangular grid
ME469B/4/GI 22
Non-conformal grid interfaces
The matching conditions between the two faces have to be defined
Coupled interface: the interface is actually an internal face (no bc)
Periodic interface: the matching allows to specify pressure gradients
ME469B/4/GI 23
Non-conformal grid interfaces - Example
Channel flow
Periodic Boundaries
ME469B/4/GI 24
Non-conformal Interface Guidelines
Grid interface can be of any shape (2D and 3D) but the surfaces to be mached
MUST be based on the same geometry especially for highly curved surfaces
Grid resolution at the two sides of the interfaces can be different; accuracy
(and fluxes conservation) degrades for highly different mesh size
ME469B/4/GI 25
Moving Zones
stationary moving
Time
ME469B/4/GI 26
Advanced Computational Models
• Grid Adaptivity
• Non-Conformal Grid Interfaces
• Moving Zones
ME469B/4/GI 27
Modeling Moving Zones
ME469B/4/GI 28
Single Reference Frame Model
The equations are rewritten in the moving reference frame and a Coriolis
acceleration term appears as a source for the momentum balance
Boundaries that move with the frame can assume any shape BUT boundaries
that are stationary MUST be surface of revolution
ME469B/4/GI 29
Single Reference Frame Set-Up
Velocity formulation
ME469B/4/GI 30
Single Reference Frame Boundary Conditions
Define Æ Boundary Condition
Æ Fluid Æ Wall
ME469B/4/GI 31
Multiple Reference Frame Model
Suitable for problems where the interaction between rotating and non-rotating
components is small
ME469B/4/GI 32
Sliding Mesh Model
Like the MRFM the domain is divided into moving and stationary components
Unlike the MRFM the mesh in each subdomain moves with respect to one another
and the problem is inherently unsteady
The equations are solved in the stationary reference frame and the meshes are
moved at each time step (no approximations to the governing equations)
ME469B/4/GI 33
SMM Example
time
ME469B/2/GI 1
Geometry
Tools
Graphics
Window
Volume
Tools
Visualization
Text Tools
Window
1
Geometrical types - Topology
• Vertex
ME469B/2/GI 3
Vertex:
• Input Coordinates…
Edge:
2
Face:
• Rectangular
• Circular
•…
• Sweep (translation or rotation of an edge)
• Wireframe (connecting 3 or more edges)
ME469B/2/GI 5
Volume:
• Cuboid
• Sphere
• Cone
• Pyramids
•…
• Sweep (translation or rotation of a face)
• Wireframe (connecting 3 or more faces)
ME469B/2/GI 6
3
Manipulate Geometry - Boolean Operations:
Volume 1
• Unite
• Substract
• Intersect
Volume 2
it generates the
intersection edge
ME469B/2/GI 7
4
Create Entities - Faces
ME469B/2/GI 9
Some entities generated using “primitives” have fewer lower topological entities
Example:
Cube volume: 6 faces, 12 edges, 8 vertices
Cylinder volume: 3 faces, 2 edges, 2 vertices
ME469B/2/GI 10
5
Manipulate Geometry – Create Entities
Create a vertex on a face
Parametric representation
of the face
ME469B/2/GI 11
ME469B/2/GI 12
6
Import Geometries
ME469B/2/GI 14
7
Example: Helicopter Rotor
ME469B/2/GI 15
Geometrical entities
8
Example: Import IGES Model
ME469B/2/GI 17
ME469B/2/GI 18
9
Components “exploded”
connector-1
support
blade
connector-2
ME469B/2/GI 19
Geometry simplification
Connectors eliminated
Support generated as a
“simple” cylinder with
blended side
ME469B/2/GI 20
10
Geometry simplification
Blade-support connector
is a “simple” cuboid
ME469B/2/GI 21
Clean Geometry
ME469B/2/GI 22
11
Grid Generation
ME469B/2/GI 23
• Structured grids
• Ordered set of (locally orthogonal) lines
• Several Techniques can be used to Map a computational domain into
a physical domain: Transfinite Interpolation, Morphing, PDE Based, etc.
• The grid lines are curved to fit the shape of the boundaries
• Unstructured grids
• Unorganized collection of polygons (polyhedron)
• Three main techniques are available to generate automatically triangles
(tetrahedra): Delaunay triangulation, Advancing front, OCTREE
• Paving for automatic generation of quads in 2D
ME469B/2/GI 24
12
Structured Grids: Mapping
Side B
eC
k=NK
Side A1 Side A2
Side C
Side D
k k=1
Side D
j
Side A1
ME469B/2/GI 25
ME469B/2/GI 26
13
Unstructured Grids: Triangulations
• Advancing front
• Triangles are built inward from the boundary surfaces
• The last layer of elements constitutes the active front
• An optimal location for a new nodes is generated for each segment on
the front; the new node is generated by checking all existing nodes and
this new optimal location
• Intersection checks are required to avoid front overlap
ME469B/2/GI 27
• OCTREE
• Squares containing the boundaries are recursively subdivided until
desired resolution is obtained
• Irregular cells (or triangulation) are generated near the surface where
square intersect the boundary
ME469B/2/GI 28
14
Unstructured Grids: Paving
Triangulation Paving
ME469B/2/GI 29
• 2D mesh sweeping
• Only for cylindrical volumes
• unstructured surface mesh is generated
on surface A (source face)
ME469B/2/GI 30
15
Unstructured Grids: 3D elements
ß Standard Elements:
ME469B/2/GI 31
16
Complex Geometry
What is available in GAMBIT
Mesh sizes
Speed
• Structured gridding (mapping) + + + - +
- + +/- + -
• Unstructured triangulation (2D/3D)
- - +/- + +
• Unstructured paving (2D)
+ - +/- - +
• Unstructured coopering (3D)
Straightforward
ME469B/2/GI 34
17
Grid generation – 2D - Faces
Easy
ME469B/2/GI 35
elements
forced to
be triangles
ME469B/2/GI 36
18
Grid generation – 2D - Mesh-patching options
ME469B/2/GI 37
Not so easy
ME469B/2/GI 38
19
3D Grid generation – Advanced Cooper technique
ME469B/2/GI 39
ME469B/2/GI 40
20
Grid generation – Clustering points
ME469B/2/GI 41
ME469B/2/GI 42
21
Example – meshing a circle
ME469B/2/GI 43
Mesh linking
ME469B/2/GI 44
22
Virtual Geometry
ME469B/2/GI 45
REAL VIRTUAL
ME469B/2/GI 46
23
Grid quality
ME469B/2/GI 47
ME469B/2/GI 48
24
Examine meshes
ME469B/2/GI 49
Mesh improvement
ME469B/2/GI 50
25
Automation
• GAMBIT saves a “journal” file with the commands issues during a session
ME469B/2/GI 51
The command:
$W = 2.3
$D = 1.5
$H = 4
Volume create width $W depth $D height $H offset 0 0 0 brick
ME469B/2/GI 52
26
/ --------------------------------------------------------
Example of Journal file / CYCLONE GRID GENERATION
/ ME269B - Spring 2002
/ --------------------------------------------------------
/
/ R1 = External radius of Cyclone
/ R2 = Gas Outlet Pipe (External)
/ R3 = Gas Outlet Pipe (Internal)
/ RB = Particles Outlet (Bottom)
/ H1 = Height of the Cylindrical Part of Cyclone
/ H2 = Height of the Conical Part
/ HE = Depth of the Outlet Channel into the Cyclone
/
/ inletl = Length (x) of the Gas Inlet Channel
/ inleta = Height (z) of the Gas Inlet Channel
/ inletb = Span (y) of the Gas Inlet Channel
/ outletl = Length (z) of the outlet (gas) pipe
/
/ cellsize = Average size of the cells
/
/ Remark: z-axis is the Cyclone Axis
/ --------------------------------------------------------
/
/ Input Quantities
/
$R1 = 1.555
$R2 = 0.45
$R3 = 0.4
$RB = 0.75
$H1 = 4.5
$H2 = 5
$HE = 3.6
$inletl = 2
$inleta = 1.03
$inletb = 0.7
$outletl = 7.2
$cellsize = 0.18
/
/
ME469B/2/GI 53
ME469B/2/GI 54
27
Grid generation research
ß Unstructured hex-dominant grids: OCTREE based
SAMM – Computational Dynamics Ltd.
Hexpress – Numeca International Inc.
ME469B/2/GI 55
• Links
• Mesh generation and grid generation on the Web
http://www-users.informatik.rwth-aachen.de/~roberts/meshgeneration.html
• Meshing research corner
http://www.andrew.cmu.edu/user/sowen/mesh.html
• General CFD: Topic mesh generation
http://www.cfd-online.com
• References:
• Handbook of grid generation. Thompson, Soni, Weatherill, CRC Press
• Numerical Grid Generation: Foundation & Applications.
Thompson, Warsi, Mastin. North Holland Press
ME469B/2/GI 56
28
Example #1
Geometry Modeling
The duct offset DO is the main design variable: with fixed mass flow the swirl generated is a function of DO
DO
Example #2
Grid Generation
ME469B/2/GI 58
29
Solution methods for the
Incompressible Navier-Stokes Equations
ME469B/3/GI 1
Multigrid methods
ME469B/3/GI 2
1
NS equations
Conservation laws:
=0
NS equations
Compressible flows:
Incompressible flows:
Density variation are not linked to the pressure. The mass conservation is a
constraint on the velocity field; this equation (combined with the momentum) can
be used to derive an equation for the pressure
ME469B/3/GI 4
2
Pressure-based solution of the NS equation
ME469B/3/GI 5
ME469B/3/GI 6
3
Explicit pressure-based scheme for NS equations
Compute Hn
ME469B/3/GI 7
ME469B/3/GI 8
4
Implicit scheme for NS equations
ME469B/3/GI 9
ME469B/3/GI 10
5
Implicit pressure-based scheme for NS equations (SIMPLEC)
SIMPLE: SIMPLE Corrected/Consistent
ME469B/3/GI 11
ME469B/3/GI 12
6
SIMPLE, SIMPLEC & PISO - Comments
un+1 = u* + au u’ p = pn + ap p’
ME469B/3/GI 13
NS equations
Conservation laws:
=0
ME469B/3/GI 14
7
Segregated solver in FLUENT
f
W
The quantities at the cell faces can be computed using several different schemes
ME469B/3/GI 15
ME469B/3/GI 16
8
Solution of the equation
f is one of the velocity component and the convective terms must be linearized:
ME469B/3/GI 17
Text Window
ME469B/3/GI 18
9
Solver set-up
Material properties
Define Æ Materials
ME469B/3/GI 20
10
Initial and boundary conditions
ME469B/3/GI 21
ME469B/3/GI 22
11
Convergence monitors
Convergence history of the equation residuals are stored together with the solution
User-defined monitors are NOT stored by default
ME469B/3/GI 23
Postprocessing
Cell-centered
data are
Computed
This switch
interpolates the
results on the
cell-vertices
ME469B/3/GI 24
12
Detailed post-processing
Define additional quantities
ME469B/3/GI 25
ME469B/3/GI 26
13
Example – Driven cavity
Classical test-case for Problem set-up Solver Set-Up
incompressible flow solvers
Material Properties:
r = 1kg/m3 Segregated Solver
m = 0.001kg/ms
Discretization:
2nd order upwind
Reynolds number:
SIMPLE
H = 1m, Vslip= 1m/s
Vslip=1 Re = rVslipH/m = 1,000
Multigrid
V-Cycle
Boundary Conditions:
Slip wall (u = Vslip) on top
No-slip walls the others
H Initial Conditions:
u=v=p=0
Convergence Monitors:
Averaged pressure and
friction on the no-slip walls
ME469B/3/GI 27
14
Example – Driven cavity
ME469B/3/GI 29
ME469B/3/GI 30
15
Example – Driven cavity
The effect of the meshing scheme
x-velocity component in the middle of the cavity
Vorticity Contours
ME469B/3/GI 32
16
Example – Driven cavity
Grid Sensitivity – Quad Mapping Scheme
x-velocity component in the middle of the cavity
Symbols corresponds to
1600 cells 6400 cells 25600 cells
Ghia et al., 1982
ME469B/3/GI 33
ME469B/3/GI 34
17
Generation of successively refined grid
1) Modify grid dimensions in GAMBIT and regenerate the grid
2) Split all the cells in FLUENT
Note that the triangular grid has more than twice as many grid cells
ME469B/3/GI 36
18
Driven Cavity – Accuracy evaluation Nominal 2nd
Nominal 1st
order accuracy
order accuracy
(N)-1/2
Quad-Mapping Tri-Paving Quad-Paving
ME469B/3/GI 37
Symbols corresponds to
FLUENT StarCD NASA INS2D
Ghia et al., 1982
ME469B/3/GI 38
19
Techniques for the incompressible NS equations
Vorticity-streamfunction formulation
Density-based approach
ME469B/3/GI 39
Vorticity-streamfunction approach
It is effectively a change-of-variables; introducing the streamfunction and the vorticity
vector the continuity is automatically satisfied and the pressure disappears (if needed the
solution of a Poisson-like equation is still required). It is advantageous in 2D because it
requires the solution of only two PDEs but the treatment of BCs is difficult. In addition in
3D the PDEs to be solved are six
ME469B/3/GI 40
20
Density-based solvers for the NS equations
The equation are written in compressible form and, for low Mach numbers,
the flow is effectively incompressible
ME469B/3/GI 41
Stiffness occurs because of the disparity between fluid velocity and speed of
sound (infinite in zero-Mach limit)
The equations are solved in terms of the primitive variables
ME469B/3/GI 42
21
FLUENT density-based solver
Explicit Scheme
Multistage Runge-Kutta scheme
Residual Smoothing
Multigrid acceleration
Implicit Scheme
Euler (one-step) implicit
Newton-type linearization
Point Gauss-Seidel iterations
Multigrid acceleration
ME469B/3/GI 43
H Initial Conditions:
u=v=p=0
Convergence Monitors:
Averaged pressure and
friction on the no-slip walls
ME469B/3/GI 44
22
Example – Driven cavity
Segregated Coupled
Vorticity Contours
ME469B/3/GI 45
Symbols corresponds to
Segregated Coupled
Ghia et al., 1982
ME469B/3/GI 46
23
Multigrid acceleration
Basic idea: the global error (low-frequency) on a fine grid appears as a local
error (high-frequency) on coarse meshes.
ME469B/3/GI 47
Two-grid scheme
ME469B/3/GI 48
24
Restriction & Prolongation Operators
Fine Level
Coarse Level
ME469B/3/GI 49
Algebraic Multigrid
The coarse levels are generated without the use of any discretization on coarse
levels; in fact no hierarchy of meshes is needed
AMG is effectively a solver for linear systems and the restriction and
prolongation operators might be viewed as means to modify (group or split)
the coefficient matrix
The same multigrid options (cycle type and a, b, g smoothing) are available
ME469B/3/GI 50
25
Driven Cavity – Accuracy evaluation Nominal 2nd
Nominal 1st
order accuracy
order accuracy
(N)-1/2
Quad-Mapping Tri-Paving Quad-Paving
ME469B/3/GI 51
GEOMETRIC MULTIGRID
ALGEBRAIC MULTIGRID
ME469B/3/GI 52
26
Algebraic Multigrid Performance
ME469B/3/GI 53
ME469B/3/GI 54
27
Periodic Flows
Geometrical
periodicity
ME469B/3/GI 55
28
Periodic Flow Example – 2D channel
Navier-Stokes equations
Averaged velocity
ME469B/3/GI 57
Exact solution:
Vave = 1
ME469B/3/GI 58
29
Periodic Flow Example – 2D channel
Cell-centered values
showed (no interpolation)
Quad-Mapping Tri-Paving
ME469B/3/GI 59
Nominal 1st
order accuracy
Nominal 2nd
order accuracy
(N)-1/2
Quad-Mapping Tri-Paving
30
Unsteady flows
The algorithms we used so far are time-marching:
From an initial condition they iterate until a steady-state is reached
The time-evolution of the solution is NOT accurate
ME469B/3/GI 61
ME469B/3/GI 62
31
Unsteady flows – Set Up
Inner
iteration
ME469B/3/GI 63
Vwall
Navier-Stokes equations
Velocity distribution
ME469B/3/GI 64
32
Unsteady Flow – Impulsive start-up of a plate
Problem set-up Solver Set-Up
Material Properties:
periodic boundaries Segregated Solver
r = 1kg/m3
m = 0.1kg/ms
Discretization:
Reynolds number: 2nd order upwind
Re = r VwallL/m SIMPLE
H Vwall = 5.605
L = mVwall/twall Multigrid
V-Cycle
Boundary Conditions:
Slip wall (u = Vwall) on bottom
No-slip wall (top)
Periodicity Dp=0
Initial Conditions:
Vwall u=v=p=0
Exact Solution
ME469B/3/GI twall = 1 @ t = 1 H/L ~ 10 65
Time discretization
1st order 2nd order
33
Overview of commercial CFD codes
About 30 packages.
ME469B/3/GI 67
34
Advanced Physical Models
• Heat Transfer
• Buoyancy
• Combustion and reaction modeling
• Multiphase flows
• Solidification and melting
ME469B/5/GI 1
Heat Transfer
Thermal analysis are crucial in many industrial applications
ME469B/5/GI 2
Heat Transfer Modeling
An energy equation must be solved together with the momentum and the
continuity equations
For incompressible flows the energy equation is decoupled from the others
(r is NOT a function of the temperature)
For laminar flows the energy equation can be solved directly; for turbulent
flows after Reynolds-averaging the equation contains an unclosed
correlation:
Momentum
Energy
ME469B/5/GI 3
Heat Transfer Modeling
Momentum
Energy
The Prandtl number is the measure of the momentum diffusivity vs. the
thermal diffusivity
Pr=cp m/k
ME469B/5/GI 4
Set-Up for Heat Transfer Calculations
Define Æ Models Æ Energy
Define Æ Materials
ME469B/5/GI 5
Wall thermal boundary conditions
The options are:
1) Fixed temperature
2) Fixed thermal flux (temperature gradient)
wall
thickness
computational BC
domain
ME469B/5/GI 6
Flow-thermal simulations
For the energy equations all the numerical options (discretization, under-
relaxation, etc.) are available
ME469B/5/GI 7
Periodic flows
Temperature behaves like the pressure: it varies in the streamwise direction but
its variation (gradient) is periodic
ME469B/5/GI 8
Example of Heat Transfer Calculations
Ribbed Passages
ME469B/5/GI 9
Example: Ribbed Channel Flow
Problem set-up Solver Set-Up
Boundary Conditions:
Periodic Periodicity m=rUbH=10Kg/s
boundaries No-slip walls
Initial Conditions:
u = 1; v = p = 0
Turbulence model:
ME469B/5/GI k-e 10
Grids in Ribbed Channel Flows
ME469B/5/GI 11
Heat Transfer Predictions
x/e
ME469B/5/GI 12
Conjugate Heat Transfer
In many cases the correct prediction of the thermal field in a device
requires the inclusion of conduction effects in solids
ME469B/5/GI 13
Set-Up Conjugate Heat Transfer
We need to specify two zones (fluid and solid) in the grid generation
And then specify the material properties
ME469B/5/GI 14
Wall thermal boundary conditions
The boundary between the two zones is ALWAYS a wall and a shadow
zone is created automatically by Fluent
shadow
wall wall
thickness thickness
Fluid Solid
zone zone
coupling
condition
ME469B/5/GI 15
Conjugate Heat Transfer
The temperature field is affected by the treatment of the rib walls
ME469B/5/GI 16
Effect of the Thermal Wall Bc
ME469B/5/GI 17
Effect of the Thermal Wall Bc
ME469B/5/GI 18
Comments on Thermo-fluid simulations
Wall quantities (temperature and heat flux) are very sensitive to the
modeling of near-wall turbulence
ME469B/5/GI 19
User Programming
ME469B/6/GI 1
1
A Simple UDF Example
Specify a Parabolic Velocity Profile at the Inlet
Goal: The UDF (inlet_parab) set the values of the x-velocity component at the cell faces
of the inlet boundary zone
Inlet
zone
ME469B/6/GI 3
function inlet_parab
Definitions
ME469B/6/GI 4
2
A Simple UDF Example
Solve Æ Iterate
Final Result
ME469B/6/GI 6
3
C Programming
Typical C function:
ME469B/6/GI 7
C vs. FORTRAN
ME469B/6/GI 8
4
Basic Programming Rules
Statements MUST end with a semicolon Æ ;
C is case sensitive!
ME469B/6/GI 9
Basic Statements
a = y + (i-b)/4;
mystuff(a,y,i,b);
ME469B/6/GI 10
5
Data Types and Arrays
ME469B/6/GI 11
Pointers
Set-up a pointer
a = 1;
a_p = &a; /* &a return the address of variable a */
ME469B/6/GI 12
6
Operators
ME469B/6/GI 13
Conditional Statements
ME469B/6/GI 14
7
Loop Procedure
ME469B/6/GI 15
C Preprocessor
#define A B
#define my_f(x,y) x+y*3-5
#include “udf.h”
#include “math.h”
ME469B/6/GI 16
8
Programming in C
http://www.cs.cf.ac.uk/Dave/C/CE.html
Plenty of books:
ME469B/6/GI 17
Most codes provide macros and additional tools to facilitate the use of UDFs
9
Interpret the UDFs
Display of code translation in assembly
Define Æ User Defined Æ Interpreted (and eventual compiling errors)
ME469B/6/GI 19
ME469B/6/GI 20
10
Directory tree for compiled UDFs
Machine dependent
my_library irix6r10
ultra
hp700
Makefile src lnx86 …
makefile my_udf.c
2d 3d
ME469B/6/GI 21
In the directory
/usr/local/Fluent.Inc/fluent6/src
SOURCE = my_udf.c
FLUENT_INC = /usr/local/Fluent.Inc
ME469B/6/GI 22
11
UDFs in FLUENT
Boundary Conditions
Initial Conditions
Adjust Function
Source Terms Available MACROS
Material Properties
Execute on Demand
User Defined Scalars
User Defined Memory
Pointers to threads
Geometry Macros Programming
Cell and Face Variables Tools
Arithmetic and Trigonometric Functions
ME469B/6/GI 23
Boundary Conditions
The inlet profile specification is based on the macro DEFINE_PROFILE
Note that the BCs are applied to the faces of the cells (face centroids)
ME469B/6/GI 24
12
Initial Conditions
The initial condition specification can be performed using the macro DEFINE_INIT
ME469B/6/GI 25
Initial Conditions
Note that the difference between the DEFINE_PROFILE and DEFINE_INIT
is that the former performs a loop on the face-centroids belonging to a certain
zone whereas the latter loops on the cell-centroids
Example:
ME469B/6/GI 26
13
Adjust Function
Similar to the DEFINE_INIT but it is executed every iteration: DEFINE_ADJUST
ME469B/6/GI 27
Source Terms
ME469B/6/GI 28
14
Source Terms
Define Æ Boundary Conditions Æ Fluid
ME469B/6/GI 29
Source Terms
S (f) = A + B f
ME469B/6/GI 30
15
Material Properties
ME469B/6/GI 31
Material Properties
ME469B/6/GI 32
16
Execute on Demand
To perform operations instantaneously : EXECUTE_ON_DEMAND
ME469B/6/GI 33
ME469B/6/GI 34
17
User Defined Scalar
When UDS are defined in the material property panel the diffusivity of the
scalars MUST be defined
Note that the default diffusivity for the scalars is constant and equal to 1!
ME469B/6/GI 35
Constant Value
Constant Gradient
User Defined
ME469B/6/GI 36
18
User Defined Scalar
The Source terms for the scalars are set using the DEFINE_SOURCE macro
Introduced before
ME469B/6/GI 37
The User Defined Scalars are used to solve additional equations eventually
coupled to the mean flow equations
ME469B/6/GI 38
19
I/O in UDF
Additional I/O (from and to the Fluent Case and Data files) can be
Accomplished using the macro DEFINE_RW_FILE
ME469B/6/GI 39
Detailed Programming
The macros introduced before are interpreted/compiled and attached to
the various Fluent panels
Loop Macros
Geometry Macros
Field Variable Macros
Control Macros
Arithmetic and Trigonometric Macros
ME469B/6/GI 40
20
Data Structure
Domain
ME469B/6/GI 41
Threads
Every zone is associated to a single ID (available in the boundary conditions menu)
zone
ID
Given the thread pointer the ID of the zone can be retrieved as:
ID = THREAD_ID(thread);
ME469B/6/GI 42
21
Loop Macros
ME469B/6/GI 43
Cell-face connectivity
When looping on faces the surrounding cells can be accessed using the macros:
cell0_thread = F_C0_THREAD(face,thread)
cell1_thread = F_C1_THREAD(face,thread)
cell0_id = F_C0(face,thread)
x
cell1_id = F_C1(face,thread)
cell1
cell0 face
When looping on cells adjacent faces and cells can be accessed using the macros:
for(nf=0;nf<C_NFACES(cell,thread);nf++)
{ face_id = C_FACE(cell,thread,nf); Number of faces
face_thread = C_FACE_THREAD(cell,thread,nf); of each cell is
} unknown
ME469B/6/GI 44
22
Geometry Macros
ME469B/6/GI 45
ME469B/6/GI 46
23
Field Variables Macros
ME469B/6/GI 47
Control Macros
ME469B/6/GI 48
24
An example of User Defined Programming
Low-Re k-e model
Transport
Equations
ME469B/6/GI 49
Damping functions
ME469B/6/GI 50
25
Required UDF Routines
ME469B/6/GI 51
Density C_R(cell,thread)
ME469B/6/GI 52
26
UDF Header
/* User-defined scalars */
enum
{
TKE,
TDR, Assign a number to each scalar
N_REQUIRED_UDS
};
ME469B/6/GI 53
Damping Functions
These are defined on a cell-by-cell basis
/* Damping Functions */
real f_mu(cell_t c, Thread *t)
{ return tanh(0.008*Re_y(c,t))*(1.+4/pow(Re_t(c,t),0.75));}
ME469B/6/GI 54
27
Source Term Routines
The production term in the k equation is:
e is obtained from the definition of the eddy viscosity to increase the coupling
between the equations and to define an implicit term
G_k = C_MU_T(c,t)*SQR(Strainrate_Mag(c,t));
dS[eqn] = -2.*C_R(c,t)*C_R(c,t)*C_MU*f_mu(c,t)*C_UDSI(c,t,TKE)/C_MU_T(c,t);
return G_k - C_R(c,t)*C_R(c,t)*C_MU*f_mu(c,t)*SQR(C_UDSI(c,t,TKE))/C_MU_T(c,t);
}
ME469B/6/GI 55
G_k = C_MU_T(c,t)*SQR(Strainrate_Mag(c,t));
dS[eqn] = C1_D*f_1(c,t)*G_k/C_UDSI(c,t,TKE)
- 2.*C2_D*f_2(c,t)*C_R(c,t)*C_UDSI(c,t,TDR)/C_UDSI(c,t,TKE);
return C1_D*f_1(c,t)*G_k*C_UDSI(c,t,TDR)/C_UDSI(c,t,TKE)
- C2_D*f_2(c,t)*C_R(c,t)*SQR(C_UDSI(c,t,TDR))/C_UDSI(c,t,TKE);
}
ME469B/6/GI 56
28
Diffusivity
The diffusion terms in the scalar equations are set-up together
DEFINE_DIFFUSIVITY(ke_diffusivity, c, t, eqn)
{
real diff;
real mu = C_MU_L(c,t);
real mu_t = C_R(c,t)*C_MU*f_mu(c,t)*SQR(C_UDSI(c,t,TKE))/C_UDSI(c,t,TDR);
switch (eqn)
{
case TKE:
diff = mu_t/SIG_TKE + mu;
break; But each equation can have
case TDR: a different value
diff = mu_t/SIG_TDR + mu;
break;
default:
diff = mu_t + mu;
}
return diff;
}
ME469B/6/GI 57
Eddy Viscosity
The eddy viscosity is set in the adjust routine (called at the beginning of each
Iteration) and it is used in the mean flow and in the scalar equations
DEFINE_ADJUST(turb_adjust, domain)
{
Thread *t;
cell_t c;
ME469B/6/GI 58
29
Wall Boundary Conditions
Only the boundary condition for e is complicated because it requires the value of the
derivative of k (the square root of k)
DEFINE_PROFILE(wall_d_bc, t, position)
{
face_t f;
cell_t c0;
Thread *t0 = t->t0; /* t0 is cell thread */
real xw[ND_ND], xc[ND_ND], dx[ND_ND], rootk, dy, drootkdy;
ME469B/6/GI 60
30
Attach the UDF
Source terms
Boundary conditions
ME469B/6/GI 61
ME469B/6/GI 62
31
Perform the Simulation
The convergence is for the mean flow + the two scalars
(turbulent quantities deactivated!)
For postprocessing purposes the UDS have to be used instead of turbulent quantities
ME469B/6/GI 63
Additional Information
Information are available in the FLUENT UDF manual (class web site)
ME469B/6/GI 64
32
UDF in other commercial CFD Codes CFX
CFX (v4) is a structured code; the data structure is much simpler because the
field variables are accessed directly. It uses 1D arrays where the quantities are
stored in succession
For example:
USRBC
USRSRC
USRDIF
….
ME469B/6/GI 65
StarCD has threads (as Fluent) and the UDF work normally on a cell-by-cell
basis
BCDEFW
SORSCA
DIFFUS
….
ME469B/6/GI 66
33
Simulation of Turbulent Flows
ME469B/3/GI 1
Navier-Stokes equations
Re = r Vref Lref / m
it measures the relative importance of convection and diffusion mechanisms
ME469B/3/GI 2
1
Reynolds Number Effect
ME469B/3/GI 4
2
Why turbulent flows are challenging?
ME469B/3/GI 5
y+ = r yp ut /m ut = (tw/r)1/2
ME469B/3/GI 6
3
Typical DNS channel flow simulations
ME469B/3/GI
Instantaneous Flow Field – Vortical Structures 7
4
DNS using Commercial CFD Codes?
Beyond DNS
DNS is possible but only for low Reynolds number flows (and simple geometries)
The (time and space) details provided by DNS are NOT required for design purposes
Large scale resolution (not to the level of the smallest eddies) is enough for applications
ME469B/3/GI 10
5
Flow over a Backstep
Istantaneous
high velocity
low velocity regions
regions
Time averaged
(x1)
(x2)
t
Velocity measurements in the turbulent wake of a cylinder
ME469B/3/GI 12
6
Reynolds-Averaged Navier-Stokes Equations
Closure
problem
ME469B/3/GI 13
Unsteady RANS?
Every turbulent flow is unsteady BUT not all the unsteadiness is turbulence!
ME469B/3/GI 14
7
Turbulence modeling
Define the Reynolds stresses in terms on known (averaged) quantities
1) Boussinesq hypothesis
- simple relationship between Reynolds stresses and velocity
gradients through the eddy viscosity (similar to molecular viscosity)
- isotropic (eddy viscosity is a scalar!)
ME469B/3/GI 15
1) Dimensional arguments
- units are [m2/s]
- define 2 out of three scales: velocity, length, time
2) Physical arguments
- asymptotic analysis
- consistency with experimental findings
3) Numerical arguments
- simple and easy to compute
ME469B/3/GI 16
8
Classification of eddy viscosity models
The various models (about 200) are classified in terms of number of transport
equations solved in addition to the RANS equations:
1) zero-equation/algebraic models:
Mixing Length, Cebeci-Smith, Baldwin-Lomax, etc
2) one-equation models:
Wolfstein, Baldwin-Barth, Spalart-Allmaras, k-model, etc
3) two-equation models:
k-e, k-w, k-t, k-L, etc.
4) three-equation models:
k-e-A
5) four-equation models:
v2-f model
ME469B/3/GI 17
Definition of L is different for each problem (boundary layes, mixing layers, etc.)
L can be made “universal” using ad hoc functions of distance from the walls,
pressure gradients, etc.
ME469B/3/GI 18
9
One-equation model k-model
An equation from k can be derived directly from the NS equations (using the definition)
ME469B/3/GI 19
The ONLY advantage with respect to zero-equation models is the inclusion of the
history effects.
Modern one-equation models abandoned the k-equation and are based on a ad-hoc
Transport equation for the eddy viscosity directly.
Spalart-Allmaras model:
ME469B/3/GI 20
10
Two-equation model k-f family
• All models use the transport equation for the turbulent kinetic energy k
• Several transport variables are used
ME469B/3/GI 21
k-e model
The k equation is the same as before:
The e equation can be obtained from the NS equations but it contains several undetermined
quantities; it is therefore derived “mimicking” the k equation
ME469B/3/GI 22
11
Determining the constants?
Standard k-e refers to a certain choice of the constants (Launder & Sharma 1972)
ME469B/3/GI 23
At High Reynolds number the viscous dominated layer is so thin that it is very
difficult to resolve it
ME469B/3/GI 24
12
Wall Function Approach (High-Re k-e)
First grid point is assumed to be in the logarithmic layer (y+>11) and the
velocity is assumed to be described by:
u+ = (1/k)ln(Ey+)
If first grid point is too close (viscous layer) then the velocity is: u+ = y+
ME469B/3/GI 25
In engineering applications:
ME469B/3/GI 26
13
Damping Functions Approach (Low-Re k-e)
The equations are integrated to the wall WITHOUT assuming an universal law
for the velocity profile and an equilibrium conditions for k and e
The problem is that the model predicts the wrong behavior for k and e near
the solid walls (from DNS and experimental observation)
The equations are modified using algebraic functions to “damp” certain terms:
The damping functions are designed to correct the behavior of the eddy viscosity
ME469B/3/GI 27
Damping Functions
Others might be function of the distance from the wall, the pressure gradient, etc.
ME469B/3/GI 28
14
Two-Layer Approach
The computational domain is divided in two regions: viscosity affected (near wall)
and fully turbulent core (outer region)
Two different models are used: the complete k-e model for the outer region and
a simplified model (typically a one-equation k-based model) for the near-wall
The separation between the two regions is defined in terms of a distance from the
wall (y+~30)
ME469B/3/GI 29
Grid
Approach Physics requirement Numerics Accuracy
Wall - + + +/-
functions
ME469B/3/GI 30
15
Example: Turbulent Channel Flow
Problem set-up Solver Set-Up
Material Properties: Segregated Solver
r = 1kg/m3
m = 0.0017kg/ms Discretization:
2nd order upwind
Reynolds number: SIMPLE
L h = 2m, L=1m
h Ret = rUth/m = 590 Multigrid
V-Cycle
Boundary Conditions:
Periodicity Dp/L=1=Ut
Periodic No-slip top/bottom walls Grid
boundaries SAME GRID USED
Initial Conditions: FOR THE LAMINAR
u = 1; v = p = 0 FLOW @ Re=20
Turbulence model:
k-e with wall functions
ME469B/3/GI 31
16
Grid Convergence? Turbulence Channel Flow
Ret = 590
ME469B/3/GI
Ret = 590 34
17
Low-Re k-e model Turbulence Channel Flow
Ret = 590
+ Simple
+ Affordable
+ Reasonably accurate for wide variety of flows (without separation)
+ History effects
- Overly diffusive
- Cannot predict different flows with the same set of constants (universality)
- Source terms are stiff numerically
- Not accurate in the region close to no-slip walls where k and e
exhibit large peaks (DNS and experimental observations)
- Near wall treatment
18
Alternatives/Improvements to k-e models
The k-w model was developed from the realization that most of the problems
experienced by k-e-type models are due to the modeling of the e equation which
is neither accurate or easy to solve (e has a local extrema close to the wall)
The v2-f model is based on the argument that k/e is the correct turbulent time
scale in the flow (close to the wall and in the outer region) but k is not the
appropriate turbulent velocity scale
An additional equation for the correct velocity scale v2 (independent from k) has
to be solved. Moreover, the damping effect produced from the presence of the wall
is NOT local (as assumed in the damping function approach) but must be
accounted for globally using an elliptic equation
ME469B/3/GI 37
19
Reynolds Stress Models
Attempt to model directly the “new” terms appearing in the RANS equations
Mathematically is expensive because we have 6 additional equations:
RSM are extremely stiff numerically due to the coupling between the
equations and suffer of the same near-wall problems of the k-e
ME469B/3/GI 39
Two-equation model
k-e (3 versions + 3 wall treatments)
k-w (2 versions)
ME469B/3/GI 40
20
Models in Fluent hidden behind the GUI
Mixing Length
define/model/viscous/mixing-length y
Two-equation model
k-e Low-Re (6 versions)
define/model/viscous/turbulence-expert/low-re-ke y
define/model/viscous/turbulence-expert/low-re-ke-index 2
ME469B/3/GI 41
21
Channel Flow Summary
Wall functions are accurate if the first grid point is in the logarithmic layer
Damping Functions (and Two-Layer approaches) are accurate for the velocity profiles
But the turbulent kinetic energy peak is underpredicted
k-w model is a viable alternative to k-e and has less sensitivity to the grid clustering
SA model and v2-f model are equivalent in capturing the velocity profile
v2-f model is accurate in predicting the peak of turbulence kinetic energy near the wall
ME469B/3/GI 43
1) k-e
ME469B/3/GI 44
22
Example: Asymmetric Diffuser
Problem set-up Solver Set-Up
Material Properties: Initial Conditions: Segregated Solver
r = 1kg/m3
u = 1; v = p = 0
m = 0.0001kg/ms Discretization:
2nd order upwind
Reynolds number: SIMPLE
Turbulence model:
h = 2m,
Re = rUh/m = 20,000 Two-equation models Multigrid
V-Cycle
Boundary Conditions:
Inlet profiles available from experiments
No-slip top/bottom walls
Outflow
Inflow
ME469B/3/GI 45
k-e Low-Re
Experiments indicated
the presence of a large
recirculation region
v2-f
v2-f
ME469B/3/GI 46
23
Flow in Asymmetric Diffuser
ME469B/3/GI 48
24
k-e with wall functions
ME469B/3/GI 49
…in addition, for complicated flows with recirculation the Universal Law is inaccurate
ME469B/3/GI 50
25
Example: NLR Two Component Airfoil
Problem set-up Solver Set-Up
Material Properties: Initial Conditions: Segregated Solver
r = 1kg/m3
u = cosa; v = sina, p = 0
m = 3.98E-7Kg/ms Discretization:
2nd order upwind
Reynolds number: SIMPLE
Turbulence model:
h = 1m,
Re = rUh/m = 2,512,600 SA and k-e models Multigrid
V-Cycle
Boundary Conditions:
Constant velocity at AOA=a
No-slip walls
ME469B/3/GI 51
Computational Grid
ME469B/3/GI 52
26
How this grid is generated?
ME469B/3/GI 53
Pressure distributions
27
Why k-e fails?
Streamwise
Velocity
Turbulent
kinetic
energy
ME469B/3/GI 55
Guidelines
Simulations of turbulence flows require “decisions” based on:
1) Flow Physics
to characterize the flow features (turbulence, high gradients, etc.)
2) Computational requirements
to evaluate the grids resolution required for a certain accuracy
3) Project Requirement
to evaluate the need for sophisticated turbulence models
physics
CFD Process
accuracy
resources
Simulation
ME469B/3/GI 56
28
Guidelines
Modeling procedure:
• Determine relevant Reynolds number to estimate if the flow is turbulent
• Select a turbulence model option and a near-wall treatment
• Estimate the physical dimension of the first grid point off the wall (y+)
• Generate the grid
• Perform the simulation
• “Reality” check (experiments, literature, model consistency)
ME469B/3/GI 57
Estimating y+
Definition: y+ = r yp ut /m
y+ = r yp ut /m
ut = Ue (cf/2)1/2
Note that there are different laws for different Re number ranges
ME469B/3/GI 58
29
“Final” Guidelines
Reynolds stress model is expensive and it require a good initial guess (typically a
k-e-type simulation)
ME469B/3/GI 59
FLUENT y y y y n y
StarCD n n y n y y
CFX y y y y n y
ME469B/3/GI 60
30