advanced computational models fluent_notes
TRANSCRIPT
ME469B/4/GI 1
Advanced Computational Models
Grid Adaptation
Non-conformal Interfaces
Moving Boundaries
Deforming Boundaries…
ME469B/4/GI 2
Grid Adaptivity
The computational grid can be refined and/or coarsened based ongeometrical and numerical solution data
Useful for:Capture flow features in detailsIncrease resolution in near-wall regionsImprove grid quality…
ME469B/4/GI 3
Grid Adaptivity Example
Computational DomainFlow in a complex passage
A uniform triangular gridis likely to be inappropriate tocapture all the feature of the flow
ME469B/4/GI 4
Adaptation Process
Definition of the adaptation function (based on geometrical and/or solution data)
Selection of the cells to be refined or coarsened (marking or tagging)
Selection of grid refinement/coarsening scheme
Adaptation
Interpolation of the previous solution onto the new grid (automatic)
ME469B/4/GI 5
Adaptation Functions
GeometricalRegion BoundaryVolume
Solution basedIsovalue Gradienty+
ME469B/4/GI 6
Region Adaptation
This is the same option we used for “global” grid refinement to study thegrid convergence of the solutions
Adapt Æ Region
Select a region shape
Input the geometrical definitionof the region
ME469B/4/GI 7
Boundary Adaptation
Adapt Æ BoundarySelect a boundary of the computational domain
Three options:cell distancenormal distancevolume distance
ME469B/4/GI 8
Boundary Adaptation
Adaptation based on a cell’s distance from the selected boundary measuredin number of cells. (1 means only the cells attached to the boundary)
Adaptation based on a cell’s normal distance from the selected boundary
Adaptation based on a target boundary volume(specify a target volume and a growth factor a)
Vcell = Vtarget e ad
This adaptation attempts to generate boundary-layer type grid
ME469B/4/GI 9
Volume Adaptation
Adapt Æ VolumeBased 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 10
Isovalue Adaptation
Adapt Æ IsoValueAll field values are available (includingequation residuals, customized and grid-related functions)
Method:specify the functionspecify a rangespecify the inside/outside option
ME469B/4/GI 11
Gradient Adaptation
As before all field values are available(including equation residuals, customizedand grid-related functions)
Method:specify the functionspecify a range
Note that the option is refine/coarsenCells above the Refine Threshold are RefinedCells below the Coarsen Threshold are Coarsened
Adapt Æ Gradient
ME469B/4/GI 12
y+ Adaptation
Adapt Æ y+Useful for turbulent flow simulations
Method:specify the wall boundariesspecify the range (as before)
Note y* is a friendlier version of y+
y+ = r yp ut /m y* = r Cm1/4 kp
1/2 yp /m
ME469B/4/GI 13
Mark (Tag) and display
Before performing the adaptation you can mark the cell selected (based ona certain adaptation function) and display them
Adapt Æ Region Æ Control Æ Display
Only the selected cells will be displayed
ME469B/4/GI 14
Mark or Adapt?
Mark allows to evaluate the effect ofa refining/coarsening procedure withoutactually changing the grid
Marked cells are saved in registers thatcan be combined or manipulated before Adapting
Adapt is usually used only at the end whenall The desired cells are marked
markadapt
ME469B/4/GI 15
Managing Registers
Adapt Æ <method> Æ Manage Marked cells are saved in registers
Adapt registers: collection of cellsMask registers: binary tagging to all cells in active and inactive
Operations on the registers are:
Union: combine two adapt registers (or more)Intersection: combine adapt and mask registersChange Type: convert a adapt in mask and viceversaDelete: eliminate a register
Exchange: swap an adapt register (coarse Æ refine)Invert: swap a mask register (active Æ inactive)Limit: apply the adaptations limits to a register Fill: mark for coarsening all the cells not in the register
ME469B/4/GI 16
Adaptation controls
Adapt Æ <method> Æ Manage Æ Control Set limits on the adaptation procedure(i.e. maximum number of final cells)
Select the adaptation schemeConformalHanging Nodes
ME469B/4/GI 17
Hanging-Node and Conformal Adaptation
Cell to be refined
ME469B/4/GI 18
Hanging-Node Adaptation
Selected cells (father) are refined homothetically (kids)
Nodes are added on the edges of the father cell andconnectivity information are generated to linkthe kids to the father neighbors
Memory penalty associated to the additional connectivityInformation required and to the presence of an inactive father cell
Neighboring cells are not allowed to differ more than one-level of refinement(because of inaccuracy related to large volume variations)
Coarsening can be only performed on previously refined regions. Kids are deleted and the father cell becomes active
father
kids
ME469B/4/GI 19
Conformal Adaptation
Selected cells are refined by splitting the longest edge
It is inherently conservative because the cell connectivity is not modified
No memory penalty (the old cells are deleted and the only the new are stored)
Low quality meshes can be improved (refinement not homothetic)
Coarsening can be applied everywhere and corresponds to a local remeshing
Can only be applied to triangular (tetrahedral) grids
In is NOT as local as the hanging-node approach
ME469B/4/GI 20
Grid Adaptivity Guidelines
Surface mesh should be fine enough to capture all the essential geometricalfeatures of the model (especially for high curvature surfaces)
The initial mesh should be fine enough to capture the overall features of theflow
A reasonably converged solution must be obtained before adapting the grid
Suitable flow-adaptation criteria are crucial to obtain increased resolution ofselected region (i.e. velocity gradients are better than pressure gradient inincompressible flows and high values of turbulent quantities are relevant forturbulent flows)
ME469B/4/GI 21
Boundary Grid Adaptivity
Original geometry
Poor boundary resolution cannot be improved via grid refinement
ME469B/4/GI 22
Non-conformal grids
Grid generation can be simplified in certain problems by meshingvarious components separately. The grids have to be coupled usinga non-conformal interface
Triangular grid
Quadrilateral grid
ME469B/4/GI 23
Non-conformal grid interfaces
The matching conditions between the two faces have to be definedCoupled interface: the interface is actually an internal face (no bc)Periodic interface: the matching allows to specify pressure gradients
Define Æ Grid Interface
ME469B/4/GI 24
Non-conformal grid interfaces - Example
Channel flow
Periodic Boundaries
Non-conformal interface Velocity contours (cell values)
ME469B/4/GI 25
Non-conformal Interface Guidelines
Grid interface can be of any shape (2D and 3D) but the surfaces to be machedMUST 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
Non-conformal interfaces are binary connectivity between two (and onlytwo) zones.
ME469B/4/GI 26
Moving Zones
Several industrial applications involve flow through a domain which containsa moving component (propellers, turbines, etc.)
Time
movingstationary
ME469B/4/GI 27
Advanced Computational Models
• Grid Adaptivity• Non-Conformal Grid Interfaces• Moving Zones
ME469B/4/GI 28
Modeling Moving Zones
Different approaches can be followed:
1) Single Reference Frame Model (SRFM)2) Multiple Reference Frame Model (MRFM)3) Mixing Plane Model (MPM)4) Sliding Mesh Model (SMM)5) Mesh Deformation6) Remeshing
ME469B/4/GI 29
Simplest model available; entire computational domain is referred to a rotating reference frame (domain moves with the reference frame)
The equations are rewritten in the moving reference frame and a Coriolisacceleration term appears as a source for the momentum balance
Boundaries that move with the frame can assume any shape BUT boundariesthat are stationary MUST be surface of revolution
Single Reference Frame Model
ME469B/4/GI 30
Single Reference Frame Set-Up
Define Æ Models Æ Solver
Velocity formulation
Absolute: the unknowns are the fieldvariables in the stationary reference frame
Relative: the unknowns are the fieldvariables in the moving reference frame
Note: the relative is only available in theSegregated solver and it is usually faster
ME469B/4/GI 31
Single Reference Frame Boundary ConditionsDefine Æ Boundary ConditionÆ Fluid Æ Wall
Define the axis of rotationSelect moving reference frameDefine the angular speed
Stationary surfaces: zero absolute rotational speedMoving surfaces: zero rotational speed relative to
the adjacent zone
ME469B/4/GI 32
Many rotating machinery problems involve stationary components thatcannot be represented as surface of revolution or move at different velocity
The extension is to consider separate reference frames for each component
The set-up is similar to the SRFM
MRFM ignores the relative motions of subdomains and the Coriolis body-forces are local to each region (no equivalence between stationary andmoving reference frame)
Suitable for problems where the interaction between rotating and non-rotatingcomponents is small
Multiple Reference Frame Model
ME469B/4/GI 33
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 anotherand the problem is inherently unsteady
The equations are solved in the stationary reference frame and the meshes aremoved at each time step (no approximations to the governing equations)
The sliding mesh interface is defined as a non-conformal interface
ME469B/4/GI 34
SMM Example
Velocity distribution
time
1
ME469B/2/GI 1
Grid Generation
• Geometry definition (simple shapes, CAD import)• Grid generation algorithms• GAMBIT• Grid quality and improvement• Automation
ME469B/2/GI 2
Grid generation package: GAMBIT
The User Manual is available from the class Web Site
Geometry Grid BC Tools
GeometryTools
VolumeTools
VisualizationTools
GraphicsWindow
Special
TextWindow
2
ME469B/2/GI 3
Geometrical types - Topology
• Vertex
• Edge (2 or more vertices) • Face (3 or more edges)
• Volume (3 or more faces)
Bottom-up approach: generate low dimensional entities and build on top of them higher dimensional entities
ME469B/2/GI 4
Vertex:
Edge:
• Input Coordinates…
• Line segment (connect 2 vertices)• Circular arc• Quadratic functions• NURBS: Non-Uniform Rational B-Splines (connect N vertices)
Topologically any edge is ALWAYS a connection between 2 vertices(additional vertices used to build the geometry are NOT part of the edge)
3
ME469B/2/GI 5
Face:
• Rectangular• Circular• …• Sweep (translation or rotation of an edge)• Wireframe (connecting 3 or more edges)
ME469B/2/GI 6
Volume:
• Cuboid• Sphere• Cone• Pyramids• …• Sweep (translation or rotation of a face)• Wireframe (connecting 3 or more faces)
4
ME469B/2/GI 7
Manipulate Geometry - Boolean Operations:
• Unite• Substract• Intersect
Volume 1
Volume 2
it generates theintersection edge
ME469B/2/GI 8
Manipulate Geometry - Blend
smooth sharp edges
5
ME469B/2/GI 9
Create Entities - Faces
ME469B/2/GI 10
Create Entities - Faces
Some entities generated using “primitives” have fewer lower topological entitiesExample:
Cube volume: 6 faces, 12 edges, 8 verticesCylinder volume: 3 faces, 2 edges, 2 vertices
6
ME469B/2/GI 11
Manipulate Geometry – Create Entities
Parametric representationof the face
Create a vertex on a face
ME469B/2/GI 12
Manipulate Geometry – Create Entities
Create two edges by splitting an edge
Parametric representationof the edge
7
ME469B/2/GI 13
Import Geometries
• Realistic geometries are TOO complicated to be generated from “simple” shapes• Engineering design is based on CAD systems
• Gambit is based on ACIS geometrical libraries• ACIS (Andy, Charles & Ian’s System) is the most widely used 3D modeling software technology (http://www.spatial.com)
• It can also import:• STEP (STandard for Exchange of Product model data; ISO standard)• IGES (Initial Graphics Exchange Specification; ANSI standard)• STL (STereo Lithography; Rapid Prototyping Standard)• ….
Translation between CAD and CFD system is a major bottleneck
ME469B/2/GI 14
Clean-Up a CAD Model
• Eliminate components not exposed to the flow
• Eliminate duplicated entities
• Eliminate small details
• Water-proofing the surfaces
• Rebuild geometrical connectivity between parts
8
ME469B/2/GI 15
Example: Helicopter Rotor
The rotor-shaft connectionis VERY complicated
ME469B/2/GI 16
Geometrical entities
The geometry consists of 10 components3 blades, 1 shaft support, 6 connectors
9
ME469B/2/GI 17
Example: Import IGES Model
IGES export is available from everyCAD system
IGES models are a collection of“untrimmed” edges and faces
Imported geometry consists of:0 volumes~250 faces~1100 edges~1000 vertices
ME469B/2/GI 18
Example: Import STEP Model
STEP export is available from manyCAD system
STEP models are a collection of partsor components
Imported geometry consists of:10 volumes~190 faces~450 edges~300 vertices
10
ME469B/2/GI 19
Components “exploded”
For aerodynamic analysis the details of the rotor-shaftconnection are not important. The geometry of theblades MUST be preserved
blade
supportconnector-1
connector-2
ME469B/2/GI 20
Geometry simplification
Connectors eliminated
Support generated as a “simple” cylinder with blended side
11
ME469B/2/GI 21
Geometry simplification
Blade edge cleaned andsealed
Blade-support connectoris a “simple” cuboid
ME469B/2/GI 22
Clean Geometry
This example is available on the class Web site
12
ME469B/2/GI 23
Grid Generation
• Geometry definition (simple shapes, CAD import)• Grid generation algorithms• GAMBIT• Grid quality and improvement• Automation
ME469B/2/GI 24
Grid generation techniques
• 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
13
ME469B/2/GI 25
k
j
j=NJ=1j=1=NJ
k=1
k=NK
Physical Domain Computational Domain
Side
A1
Sid
e A
2
Side
C
Side B
Side D
Structured Grids: Mapping
Side
A2
Side A1
Side C
Side B
Side
D
ME469B/2/GI 26
Unstructured Grids: Triangulations
• Delaunay• Empty circle principle: any node must not be contained within the circumcircle (circle passing through the vertices of a triangle) on any triangle within the mesh• Automatic triangulation of random set of nodes• Nodes are inserted locally in a triangulation and triangles are redefined locally to satisfy the Delaunay criterion (available mathematical tools)
+ Inherent grid quality+ Elegant mathematical basis - Boundary integrity
14
ME469B/2/GI 27
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
+ Surface grid preserved+ Specialized layers near surfaces - Computationally complex - Low quality
ME469B/2/GI 28
Unstructured Grids: Triangulations
• 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
+ Requires least of surface representation+ Highly automated - Cannot match surface grid - Low quality near surfaces
15
ME469B/2/GI 29
Unstructured Grids: Paving
• Advancing front technique based on quads (instead of triangles)• Only in 2D
Triangulation Paving
ME469B/2/GI 30
Unstructured Grids: Coopering
• 2D mesh sweeping• Only for cylindrical volumes• unstructured surface mesh is generated on surface A (source face)
• structured grids are generated on cylindrical surfaces C & D
• mesh on surface A is sweeped in the volume to generate the full 3D m esh
16
ME469B/2/GI 31
ß Standard Elements:
Hex Tet Pyramid Wedge
ß Hex: Maximum Volume Covered per Edge Size
ß Hex: Maximum Ratio Nodes/Elements
ß Hex/Wedges: Clustering at Solid Wall with High Quality Elements
ß Tets: Automatic Meshing of Extremely Complicated Regions
ß Pyramids/Wedges: Transition Between Tets & Hex
Unstructured Grids: 3D elements
ME469B/2/GI 32
35K Total Elements 410K Total Elements
We NEED Hex-Based Meshing because:
ß Equiangular Tets are NOT Good for Thin Volumes
ß Too Many Elements for Reasonable Resolutions
(estimated >2M grid Points in conical-annular Swirler)
Cross-Section of the Swirler
Unstructured Grids: Hex or Tets?
17
ME469B/2/GI 33
What is available in GAMBIT
• Structured gridding (mapping)
• Unstructured triangulation (2D/3D)
• Unstructured paving (2D)
• Unstructured coopering (3D)
All GAMBIT meshes are exported as unstructured collection of (mixed) elements
+-+/--+
+++/---
-++/-+-
+-+++
Spee
d
Rob
ustn
ess
Qua
lity
& C
ontr
ol
Com
plex
Geo
met
ry
Mes
h si
zes
ME469B/2/GI 34
Grid generation – 1D - Edges
Straightforward
Select number of pointsSelect distribution of points
Edge direction is defined from 1st to 2nd vertexClustering toward one side is defined accordingly
18
ME469B/2/GI 35
Grid generation – 2D - Faces
Easy
Select number of points• use predefined edge meshes• use uniform spacing
Select meshing scheme• constraints on the edge meshing for mapping and paving schemes
ME469B/2/GI 36
Grid generation – 2D - Faces
It is possible to force the cell element typeat face-vertices
Mixing element-type is one of the main advantages of unstructured meshtechnology
elementsforced tobe triangles
19
ME469B/2/GI 37
Grid generation – 2D - Mesh-patching options
Matching interface Non-conformal interface
Overlapping interface Mixed-element interface
ME469B/2/GI 38
Grid generation – 3D - Volumes
Not so easy
Select number of points• use predefined face meshes• use uniform spacing
Select meshing scheme• constraints on the face meshing for mapping and cooper schemes
20
ME469B/2/GI 39
3D Grid generation – Advanced Cooper technique
“Creative” way of coopering: multisurface to multisurface sweep
ME469B/2/GI 40
Grid generation – Sizing functions
Instead of the bottom-up approach (1D to 3D) grid generationSizing functions can be specified to mesh volumes directly
21
ME469B/2/GI 41
Grid generation – Clustering points
Sizing functions can be used effectively to define the size of thecells BUT they cannot provide directional control (anisotropy)
One option is to build (grow) elements from the boundaries andto form “viscous” layers
ME469B/2/GI 42
Grid generation – Boundary Layers
22
ME469B/2/GI 43
Example – meshing a circle
Mapping Triangulation Paving Multiblock mapping
Boundary Layer Boundary Layer Boundary Layer Boundary Layer Transition Paving Paving Multiblock Paving Multiblock Paving
Circle defined as segments
ME469B/2/GI 44
Mesh linking
Edges, faces and volume meshescan be linked
Define corresponding entitiesand ALSO reference entities
Needed to “enforce” coincidentgrids on different entities (i.e. forperiodicity bc)
23
ME469B/2/GI 45
Virtual Geometry
GAMBIT operates on two different type of entities
REAL: with corresponding geometrical and topological characteristicsVIRTUAL: defined only with reference to REAL entities
REAL entities are what we used and described so far;VIRTUAL are used to SIMPLIFY, CLEAN UP, DECOMPOSE real entities
Note that some geometry tools cannot be applied to virtual entities(boolean operation, volume blending, creation of volumes by sweeping faces, etc.)
Real entities can be transformed in virtual but NOT viceversa
ME469B/2/GI 46
REAL VIRTUAL
Virtual Geometry Clean-Up
Example of edge connecting operation
24
ME469B/2/GI 47
Grid quality
Quality measures are NOT absolute but should be considered inconnection with solution schemes
The final accuracy of a procedure is ALWAYS a function of the gridquality
Several geometrical measures can be defined:
• Depending on the size of the elements• Depending on the shape of the elements• Depending on relative dimensions of neighboring elements
ME469B/2/GI 48
Quality measures available in GAMBIT
25
ME469B/2/GI 49
Examine meshes
Equiangular skewAspect ratio
• Define mesh element to examine• Define a cutting plane • Define the quality measure
ME469B/2/GI 50
Mesh improvement
• Smoothing operators are applied to redistribute nodes
Equiangular skewAspect ratio
Typically, improvement in 3D meshes are based on improved 2D meshes
26
ME469B/2/GI 51
Automation
• GAMBIT saves a “journal” file with the commands issues during a session
• Journal file are ASCII editable files
• Commands are quasi-English and easy-to-use
• They are useful to trace-back sessions to find errors
• They can be made general by introducing User Defined Parameters
ME469B/2/GI 52
GAMBIT Journal file
The command:
Volume create width 1 depth 1 height 1 offset 0 0 0 brick
Generates a cube of size 1 centered at 0 0 0
On the other hand the sequence
$W = 2.3$D = 1.5$H = 4Volume create width $W depth $D height $H offset 0 0 0 brick
Generates a cuboid of User-Specified Size centered at 0 0 0
27
ME469B/2/GI 53
/ --------------------------------------------------------/ 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//
Example of Journal file
ME469B/2/GI 54
Grid generation research
ß Structured grids: automatic generation
of mappable subdomainsNLR 2000-366 Report
(PDF available from class web site)
ß Unstructured tetrahedral grids: anisotropic Delaunay schemes
Shimada et al. “High quality anisotropic tetrahedral mesh generation
via ellipsoidal bubble packing” (PDF available)
28
ME469B/2/GI 55
Grid generation research
ß Unstructured hex-dominant grids: OCTREE based
SAMM – Computational Dynamics Ltd.Hexpress – Numeca International Inc.
ß Unstructured purely hexahedral grids: Whisker-Weaving
CUBIT – Sandia National Lab. (PS report available)
ME469B/2/GI 56
Grid generation – Links and References
• 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
29
ME469B/2/GI 57
Example #1Geometry Modeling
Objective: generation of a swirl-generator model in GAMBIT
• Four rectangular ducts inject tangentially in an expanding pipe.• Select the dimensions appropriately
The duct offset DO is the main design variable: with fixed mass flow the swirl generated is a function of DO
The shape of the pipe/ductintersection is a function ofthe duct offset
Use the “cyclone.jou” example as a baseline
DO
ME469B/2/GI 58
Example #2Grid Generation
Objective: generation of a grid for a swirl-generator model in GAMBIT• Generate an all-tetrahedra grid• Generate an all-hexahedra grid• Compare the quality of the grid especially in the channel-pipe intersection
1
ME469B/3/GI 1
Solution methods for theIncompressible Navier-Stokes Equations
l Discretization schemes for the Navier-Stokes equationsl Pressure-based approachl Density-based approachl Convergence acceleration l Periodic Flowsl Unsteady Flows
ME469B/3/GI 2
Background (from ME469A or similar)
Navier-Stokes (NS) equations
Finite Volume (FV) discretization
Discretization of space derivatives (upwind, central, QUICK, etc.)
Pressure-velocity coupling issue
Pressure correction schemes (SIMPLE, SIMPLEC, PISO)
Multigrid methods
2
ME469B/3/GI 3
NS equations
The advection term is non-linearThe mass and momentum equations are coupled (via the velocity)The pressure appears only as a source term in the momentum equationNo evolution equation for the pressureThere are four equations and five unknowns (r, V, p)
Conservation laws:
Rate of change + advection + diffusion = source
= 0
ME469B/3/GI 4
Compressible flows:
The mass conservation is a transport equation for density. With an additionalenergy equation p can be specified from a thermodynamic relation (ideal gas law)
Incompressible flows:
Density variation are not linked to the pressure. The mass conservation is aconstraint on the velocity field; this equation (combined with the momentum) canbe used to derive an equation for the pressure
NS equations
3
ME469B/3/GI 5
Pressure-based solution of the NS equation
The continuity equation is combined with the momentum and thedivergence-free constraint becomes an elliptic equation for the pressure
To clarify the difficulties related to the treatment of the pressure, wewill define EXPLICIT and IMPLICIT schemes to solve the NS equations:
It is assumed that space derivatives in the NS are already discretized:
ME469B/3/GI 6
Explicit scheme for NS equations
Semi-discrete form of the NS
Explicit time integration
The n+1 velocity field is NOT divergence free
Take the divergence of the momentum
Elliptic equation for the pressure
4
ME469B/3/GI 7
Explicit pressure-based scheme for NS equations
Velocity field (divergence free) available at time n
Compute Hn
Solve the Poisson equation for the pressure pn
Compute the new velocity field un+1
ME469B/3/GI 8
Implicit scheme for NS equations
Semi-discrete form of the NS
Implicit time integration
Take the divergence of the momentum
The equations are coupled and non-linear
5
ME469B/3/GI 9
Implicit scheme for NS equations
Compute an intermediate velocity field
(eqns are STILL non-linear)
Define a velocity and a pressure correction
Using the definition and combining
Derive an equation for u’
Enforce divergence-free condition at n+1
{{
ME469B/3/GI 10
Implicit pressure-based scheme for NS equations (SIMPLE)
Velocity field (divergence free) available at time n
Compute intermediate velocities u*
Solve the Poisson equation for the pressure correction p’ Neglecting the u*’ term
Compute the new velocity un+1 and pressure pn+1 fields
Solve the velocity correction equation for u’ Neglecting the u*’ term
SIMPLE: Semi-Implicit Method for Pressure-Linked Equations
6
ME469B/3/GI 11
Implicit pressure-based scheme for NS equations (SIMPLEC)
Velocity field (divergence free) available at time n
Compute intermediate velocities u*
Solve the Poisson equation for the pressure correction p’ Use an approximation to u*’ (neighbor values average u*’ ~ S u’)
Compute the new velocity un+1 and pressure pn+1 fields
Solve the velocity correction equation for u’ Use an approximation to u*’
SIMPLE: SIMPLE Corrected/Consistent
ME469B/3/GI 12
Implicit pressure-based scheme for NS equations (PISO)
Velocity field (divergence free) available at time n
Compute intermediate velocities u* and p’ as in SIMPLE
Solve the Poisson equation for the pressure correction p(m+1)’ u*’ is obtained from u m’
Compute the new velocity un+1 and pressure pn+1 fields
Solve the velocity correction equation for u(m+1)’ u*’ is obtained from u m’
PISO: Pressure Implicit with Splitting Operators
7
ME469B/3/GI 13
SIMPLE, SIMPLEC & PISO - Comments
In SIMPLE under-relaxation is required due to the neglect of u*’
un+1 = u* + au u’ p = pn + ap p’
There is an optimal relationship ap =1- au
SIMPLEC and PISO do not need under-relaxation
SIMPLEC/PISO allow faster convergence than SIMPLE
PISO is useful for irregular cells
ME469B/3/GI 14
NS equations
Conservation laws:
Rate of change + advection + diffusion = source
= 0
8
ME469B/3/GI 15
Segregated solver in FLUENT
FV discretization for mixed elements
The quantities at the cell faces can be computed using several different schemes
W
f
ME469B/3/GI 16
Options for the segregated solver in FLUENT
Discretization scheme for convective terms1st order upwind (UD)2nd order upwind (TVD)3rd order upwind (QUICK), only for quad and hex
Pressure interpolation scheme (pressure at the cell-faces)linear (linear between cell neighbors)second-order (similar to the TVD scheme for momentum)PRESTO (mimicking the staggered-variable arrangement)
Pressure-velocity coupling SIMPLESIMPLECPISO
Discretization of the equations
9
ME469B/3/GI 17
b
Pb
b
Solution of the equation
f is one of the velocity component and the convective terms must be linearized:
This correspond to a sparse linear system for each velocity component
Fluent segregated solver uses:Point Gauss-Seidel technique Multigrid acceleration
ME469B/3/GI 18
Set-up of problems with FLUENT
Graphics Window
Text Window
Command Menus
Read/Import the gridDefine the flow solver optionDefine the fluid propertiesDefine the discretization schemeDefine the boundary conditionDefine initial conditionsDefine convergence monitorsRun the simulationAnalyze the results
10
ME469B/3/GI 19
Solver set-up
Define Æ Models Æ Solver Define Æ Controls Æ Solution
define/models/solver segregated solve/set/discretization-scheme/mom 1define/models/steady solve/set/under-relaxation/mom 0.7
… …
Example: text commands can be used (useful for batch execution)
ME469B/3/GI 20
Material properties
Define Æ Materials
Quantities are ALWAYS dimensional
11
ME469B/3/GI 21
Initial and boundary conditions
Solve Æ Initialize Æ Initialize Define Æ Boundary Conditions
Only constant values can be specified BCs will be discussed case-by-caseMore flexibility is allowed via patching
ME469B/3/GI 22
Initial conditions using patching
Adapt Æ Region Æ Mark Solve Æ Initialize Æ Patch
Mark a certain region of the domain(cells are stored in a register)
Patch desired values for each variablein the region (register) selected
12
ME469B/3/GI 23
Convergence monitors
Solve Æ Monitors Æ Residuals Solve Æ Monitors Æ Surface
Convergence history of the equation residuals are stored together with the solutionUser-defined monitors are NOT stored by default
ME469B/3/GI 24
Postprocessing
Display Æ Contours Plot Æ XY Plot
Cell-centered data are ComputedThis switchinterpolates theresults on the cell-vertices
13
ME469B/3/GI 25
Detailed post-processing
Define additional quantities
Define plotting lines, planes and surfaces
Compute integral/averaged quantities
Define Æ Custom Field Function
ME469B/3/GI 26
Fluent GUI - Summary
File: I/O Grid: Modify (translate/scale/etc.), CheckDefine: Models (solver type/multiphase/etc.), Material (fluid properties), Boundary conditions Solve: Discretization, Initial Condition, Convergence MonitorsAdapt: Grid adaptation, Patch markingSurface: Create zones (postprocessing/monitors)Display: Postprocessing (View/Countors/Streamlines)Plot: XY Plots, ResidualsReport: Summary, IntegralParallel: Load Balancing, Monitors Typical simulation
14
ME469B/3/GI 27
Example – Driven cavity
Problem set-up Solver Set-Up
Material Properties:r = 1kg/m3
m = 0.001kg/ms
Reynolds number:H = 1m, Vslip= 1m/sRe = rVslipH/m = 1,000
Boundary Conditions: Slip wall (u = Vslip) on top No-slip walls the others
Initial Conditions:u = v = p = 0
Convergence Monitors:Averaged pressure andfriction on the no-slip walls
Classical test-case forincompressible flow solvers
Vslip=1
H
Segregated Solver
Discretization:2nd order upwindSIMPLE
MultigridV-Cycle
ME469B/3/GI 28
Example – Driven cavity
The effect of the meshing scheme
Quad-Mapping 1600 cells Tri-Paving 3600 cells Quad-Paving 1650 cells
Edge size on the boundaries is the same
15
ME469B/3/GI 29
Example – Driven cavity
The effect of the meshing scheme – Vorticity Contours
Quad-Mapping 1600 cells Tri-Paving 3600 cells Quad-Paving 1650 cells
ME469B/3/GI 30
Example – Driven cavity
The effect of the meshing scheme – Convergence
Quad-Mapping 1600 cells Tri-Paving 3600 cells Quad-Paving 1650 cells
16
ME469B/3/GI 31
Example – Driven cavity
Symbols corresponds toGhia et al., 1982
x-velocity component in the middle of the cavity
Quad-Mapping Tri-Paving Quad-Paving
The effect of the meshing scheme
ME469B/3/GI 32
Example – Driven cavity
Grid Sensitivity – Quad Mapping Scheme
1600 cells 6400 cells 25600 cells
Vorticity Contours
17
ME469B/3/GI 33
Example – Driven cavity
1600 cells 6400 cells 25600 cellsSymbols corresponds toGhia et al., 1982
x-velocity component in the middle of the cavityGrid Sensitivity – Quad Mapping Scheme
ME469B/3/GI 34
How to verify the accuracy?
Define a reference solution (analytical or computed on a very fine grid)Compute the solution on successively refined gridsDefine the error as the deviation of the current solution from the referenceCompute error normsPlot norms vs. grid size (the slope of the curve gives the order of accuracy)
Problems with unstructured grids:
1) Generation of a suitable succession of grids2) Definition of the grid size
18
ME469B/3/GI 35
Generation of successively refined grid
1) Modify grid dimensions in GAMBIT and regenerate the grid2) Split all the cells in FLUENT
Adapt Æ Region Æ Adapt
Element shape & metricproperties are preserved
The region MUST contain theentire domain
ME469B/3/GI 36
Driven Cavity - Error evaluation
Reference solution computed on a 320x320 grid (~100,000 cells)Reference solution interpolated on coarse mesh to evaluate local errors
Quad-Mapping Tri-Paving Quad-Paving
Note that the triangular grid has more than twice as many grid cells
19
ME469B/3/GI 37
Driven Cavity – Accuracy evaluation
Quad-Mapping Tri-Paving Quad-Paving
Quad and Pave meshingschemes yield very similaraccuracy (close to 2nd order)
Tri meshing scheme yieldsSlightly higher errors and loweraccuracy
Note that the definition of Dx isquestionable (a change willonly translate the curves notchange the slope)
(N)-1/2
Err
or (
L2
norm
)
Nominal 2nd order accuracyNominal 1st
order accuracy
ME469B/3/GI 38
Driven Cavity – Fluent vs. other CFD codes
FLUENT StarCD NASA INS2DSymbols corresponds toGhia et al., 1982
x-velocity component in the middle of the cavityQuad Mapping Scheme (1600 cells)
20
ME469B/3/GI 39
Techniques for the incompressible NS equations
Pressure correction schemes
Fractional step methods
Artificial compressibility approach
Vorticity-streamfunction formulation
Density-based approach
ME469B/3/GI 40
Vorticity-streamfunction approach
It is effectively a change-of-variables; introducing the streamfunction and the vorticityvector the continuity is automatically satisfied and the pressure disappears (if needed thesolution of a Poisson-like equation is still required). It is advantageous in 2D because itrequires the solution of only two PDEs but the treatment of BCs is difficult. In addition in3D the PDEs to be solved are six
Artificial compressibility approach
A time-derivative (of pressure) is added to the continuity equation with the goal oftransforming the incompressible NS into a hyperbolic system and then to apply schemessuitable for compressible flows. The key is the presence of a user-parameter b (related tothe artificial speed of sound) that determines the speed of convergence to steady state
Techniques for the incompressible NS equations
Fractional-step approachSimilar in concept to pressure-correction schemes, but the pressure (or a related quantity)is only used in the final correction step; it is equivalent to an approximate factorization
21
ME469B/3/GI 41
Density-based solvers for the NS equations
The equation are written in compressible form and, for low Mach numbers,the flow is effectively incompressible
The energy equation is added to link pressureand density through the equation of state
In compact (vector) form:
ME469B/3/GI 42
Stiffness occurs because of the disparity between fluid velocity and speed ofsound (infinite in zero-Mach limit)
The equations are solved in terms of the primitive variables
The time derivative is modified (preconditioned) to force all the eigenvaluesto be of the same order (similar to the artificial compressibility approach)
Note that the continuity becomes (again) anevolution equation for the pressure
Density-based solvers for the NS equations
Several choices are available for G
22
ME469B/3/GI 43
FLUENT density-based solver
Explicit SchemeMultistage Runge-Kutta schemeResidual SmoothingMultigrid acceleration
Implicit SchemeEuler (one-step) implicitNewton-type linearizationPoint Gauss-Seidel iterationsMultigrid acceleration
ME469B/3/GI 44
Example – Driven cavity
Problem set-up Solver Set-UpClassical test-case forincompressible flow solvers
Vslip=1
H
Coupled Solver
Discretization:2nd order upwindImplicit
MultigridV-Cycle
Material Properties:r = 1kg/m3
m = 0.001kg/ms
Reynolds number:H = 1m, Vslip= 1m/sRe = rVslipH/m = 1,000
Boundary Conditions: Slip wall (u = Vslip) on top No-slip walls the others
Initial Conditions:u = v = p = 0
Convergence Monitors:Averaged pressure andfriction on the no-slip walls
23
ME469B/3/GI 45
Example – Driven cavity
Effect of the solver - Quad mesh (1600 cells)
Vorticity Contours
Segregated Coupled
ME469B/3/GI 46
Example – Driven cavity
Segregated CoupledSymbols corresponds toGhia et al., 1982
x-velocity component in the middle of the cavityEffect of the solver - Quad mesh (1600 cells)
24
ME469B/3/GI 47
Multigrid acceleration
Basic idea: the global error (low-frequency) on a fine grid appears as a localerror (high-frequency) on coarse meshes.
Why it is important: linear system solver like Gauss-Seidel are effective inremoving high-frequency errors but VERY slow for global errors. Note that,on structured, grid line-relaxation (or ADI-type) schemes can be used toimprove the performance of Gauss-Seidel; on unstructured grid similarconcepts are extremely difficult to implement.
Convergence Speed: number of iterations on the finest grid required to reacha given level of convergence is roughly independent on the number of gridnodes (multigrid convergence)
ME469B/3/GI 48
Two-grid scheme
1. a smoothings are performed on the fine grid to reduce the high-frequency components of the errors (pre-smoothing, aS)
2. the residual (error) is transferred to next coarser level (restriction, R)3. g iterations are performed on this grid level for the “correction” equation4. the problem is transferred back to the fine grid (prolongation, P)5. b smoothings are performed on the fine grid to remove the high-
frequency errors introduced on the coarse mesh (post-smoothing, bS)
Parameters to be defined are a, b, g
25
ME469B/3/GI 49
Restriction & Prolongation Operators
Fine LevelCoarse Level
ME469B/3/GI 50
Algebraic Multigrid
The coarse levels are generated without the use of any discretization on coarselevels; in fact no hierarchy of meshes is needed
Geometric multigrid should perform better than AMG because non-linearityof the problem are retained on coarse levels (correction equation)
AMG is effectively a solver for linear systems and the restriction andprolongation 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
26
ME469B/3/GI 51
Driven Cavity – Accuracy evaluation
Quad-Mapping Tri-Paving Quad-Paving
Quad and Pave meshingschemes yield very similaraccuracy (close to 2nd order)
Tri meshing scheme yieldsSlightly higher errors and loweraccuracy
Note that the definition of Dx isquestionable (a change willonly translate the curves notchange the slope)
(N)-1/2
Err
or (
L2
norm
)
Nominal 2nd order accuracyNominal 1st
order accuracy
ME469B/3/GI 52
Multigrid for unstructured meshes
GEOMETRIC MULTIGRIDALGEBRAIC MULTIGRID
27
ME469B/3/GI 53
Algebraic Multigrid Performance
Convergence for the segregated solver
1600 cells 6400 cells 25600 cells
ME469B/3/GI 54
Algebraic Multigrid Performance
Convergence for the coupled solver
1600 cells 6400 cells 25600 cells
28
ME469B/3/GI 55
Periodic Flows
Geometricalperiodicity
Periodicity simply correspondsto matching conditions on thetwo boundaries
The velocity field is periodic BUTthe pressure field is not. The pressuregradient drives the flow and isperiodic. A pressure JUMP conditionon the boundary must be specified
ME469B/3/GI 56
Periodic Flows – Set-Up
Segregated solver Coupled Solver
In the segregated solver periodicity can be imposed by fixing either themass flow or the pressure dropIn the coupled solver periodicity is enforced by fixing the pressure drop
Define Æ Periodic Conditions Define Æ Boundary Conditions
29
ME469B/3/GI 57
An analytical solution of the Navier-Stokes equations (Poiseuille flow) canbe derived:
Solution in the form u=u(y)
The pressure drop balances the viscous drag on the walls
Navier-Stokes equations
Velocity distribution in the channel
Averaged velocity
Periodic Flow Example – 2D channel
hy
ME469B/3/GI 58
Periodic Flow Example – 2D channel
Problem set-up Solver Set-Up
Material Properties:r = 1kg/m3
m = 0.1kg/ms
Reynolds number:h = 2m, Vave= 1m/sRe = rVsliph/m = 20
Boundary Conditions: Periodicity Dp=0.3 No-slip top/bottom walls
Initial Conditions:u = 1; v = p = 0
Exact solution:Vave = 1
Coupled Solver
Discretization:2nd order upwindSIMPLE
MultigridV-Cycleh
Periodic boundaries
30
ME469B/3/GI 59
Periodic Flow Example – 2D channel
Quad-Mapping Tri-Paving
x-velocity distribution in the channel
Cell-centered valuesshowed (no interpolation)
ME469B/3/GI 60
Nominal 2nd order accuracy
Quad-Mapping Tri-Paving
The error in this case CAN be computed with reference to the exact solutionIn this case the computed averaged velocity error is plotted
This test-case is available on the class web site
(N)-1/2
Nominal 1st order accuracy
Periodic Flow Example – 2D channel
31
ME469B/3/GI 61
Unsteady flows
The algorithms we used so far are time-marching:From an initial condition they iterate until a steady-state is reachedThe time-evolution of the solution is NOT accurate
Typical Implicit Time-Accurate Scheme
Unsteady transport equation
1st order time integration
2nd order time integration
ME469B/3/GI 62
Unsteady flows – Dual time stepping
At each time step we build a steady-state-like problem and we use an iterative algorithm
Inner iteration steady-state
pseudo time-step
Outer iteration(time-step)
32
ME469B/3/GI 63
Unsteady flows – Set Up
Define Æ Models Æ Solver Solve Æ Iterate
Outeriteration
Inneriteration
ME469B/3/GI 64
Again an analytical solution of the Navier-Stokes equations can be derived:
Unsteady Flow – Impulsive start-up of a plate
Solution in the form u=u(y,t)
The only force acting is the viscous drag on the wall
Navier-Stokes equations
Velocity distribution
Wall shear stress
Vwall
y
33
ME469B/3/GI 65
Unsteady Flow – Impulsive start-up of a plate
Problem set-up Solver Set-Up
Material Properties:r = 1kg/m3
m = 0.1kg/ms
Reynolds number:Re = r VwallL/mVwall = 5.605L = mVwall/twall
Boundary Conditions: Slip wall (u = Vwall) on bottom No-slip wall (top) Periodicity Dp=0
Initial Conditions:u = v = p = 0
Exact Solutiontwall = 1 @ t = 1 H/L ~ 10
Segregated Solver
Discretization:2nd order upwindSIMPLE
MultigridV-Cycle
Vwall
H
periodic boundaries
ME469B/3/GI 66
Unsteady Flow – Impulsive start-up of a plate
This test-case is available on the class web site
Dt
Err
or (
L2
norm
)
Nominal 2nd order accuracyNominal 1st
order accuracy
1st order 2nd order
Time discretization
The error CAN be computed withreference to the exact solutionIn this case the computed wallshear stress is plotted
Influence of the BCs
34
ME469B/3/GI 67
Overview of commercial CFD codes
About 30 packages.
Three major general-purpose products (covering ~50% of the market):FLUENT, StarCD, CFX
UD/TVDQUICK
CDILU
AlgebraicCoupled-
SIMPLEUnstructuredMixed
CFX
UD/TVDQUICK
CD
Conjugate
Gradient--
SIMPLESIMPISO
PISO
UnstructuredMixed
StarCD
UD/TVDQUICK
Gauss-SeidelAlgebraicGeometric
CoupledImplicit
Preconditioned
SIMPLESIMPLEC
PISO
UnstructuredMixed
FLUENT
DiscretizationSystemSolver
MultigridDensity BasedPressureBased
Grid Type
ME469B/5/GI 1
Advanced Physical Models
• Heat Transfer• Buoyancy• Combustion and reaction modeling• Multiphase flows• Solidification and melting
ME469B/5/GI 2
Heat Transfer
Thermal analysis are crucial in many industrial applications
Turbulence is enhanced is internalturbine cooling passages to improveheat transfer
Roughness elements (ribs) areplaced in the channels
ME469B/5/GI 3
Heat Transfer Modeling
An energy equation must be solved together with the momentum and thecontinuity 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 turbulentflows after Reynolds-averaging the equation contains an unclosedcorrelation:
Momentum
Energy
ME469B/5/GI 4
Heat Transfer Modeling
Momentum
Energy
The Prandtl number is the measure of the momentum diffusivity vs. thethermal diffusivity
Pr=cp m/k
Pr is order 1 for gases (typically 0.7 for air)
Prt is an additional parameter in the turbulence model (typically 0.9)
ME469B/5/GI 5
Set-Up for Heat Transfer Calculations
Activate the energy equation
Define Æ Models Æ Energy
Specify material properties
Define Æ Materials
ME469B/5/GI 6
Wall thermal boundary conditions
The options are:
1) Fixed temperature2) Fixed thermal flux (temperature gradient)
BC
wallthickness
computationaldomain
ME469B/5/GI 7
Flow-thermal simulations
For incompressible fluidsthe temperature andmomentum equations aredecoupled
For the energy equations all the numerical options (discretization, under-relaxation, etc.) are available
ME469B/5/GI 8
Periodic flows
Many heat-transfer devices are characterized by geometrically periodicconfigurations (ribbed passages)
Temperature behaves like the pressure: it varies in the streamwise direction butits variation (gradient) is periodic
The energy equations can be rewritten in terms of a scaled temperature:
And the modified energy equation can be solved with periodic BC
ME469B/5/GI 9
Wall heat transfer (temperature gradients) are strongly connectedto wall friction coefficients and therefore to turbulence modeling
Example of Heat Transfer Calculations
Ribbed Passages
ME469B/5/GI 10
Problem set-up Solver Set-Up
Material Properties:r = 1kg/m3
m = 0.0001kg/msCp = 1000 J/Kg/oKk = 0.142 W/m oK
Reynolds number:h = 1m, L=10m, H=LReh = rUbh/m = 10,000
Boundary Conditions: Periodicity m=rUbH=10Kg/s No-slip walls
Initial Conditions:u = 1; v = p = 0
Turbulence model:k-e
Segregated Solver
Discretization:2nd order upwindSIMPLE
MultigridV-Cycle
Example: Ribbed Channel Flow
H
Periodic boundaries
L
h
h
ME469B/5/GI 11
Grid points are clustered at thewalls and in the shear layers
Grids in Ribbed Channel Flows
Unstructured gridding allows to separate the bottom and top BLshaving different resolutions in the streamwise direction
ME469B/5/GI 12
x/e
Heat Transfer Predictions
ME469B/5/GI 13
In many cases the correct prediction of the thermal field in a devicerequires the inclusion of conduction effects in solids
Conjugate simulations are referred to coupled fluid-solidtemperature calculations
Conjugate Heat Transfer
ME469B/5/GI 14
Set-Up Conjugate Heat Transfer
We need to specify two zones (fluid and solid) in the grid generationAnd then specify the material properties
Define Æ Materials Æ Fluid Define Æ Materials Æ Solid
ME469B/5/GI 15
Wall thermal boundary conditions
The boundary between the two zones is ALWAYS a wall and a shadowzone is created automatically by Fluent
wallthickness
Fluidzone
shadowwall
thickness
Solidzone
couplingcondition
ME469B/5/GI 16
The temperature field is affected by the treatment of the rib walls
Conjugate Heat Transfer
The rib is insulated
The rib is heated from the base
The rib is uniformly heated
ME469B/5/GI 17
Effect of the Thermal Wall Bc
ME469B/5/GI 18
Effect of the Thermal Wall Bc
ME469B/5/GI 19
Comments on Thermo-fluid simulations
In incompressible flows the energy equation is decoupled from themomentum equations and can be solved a posteriori with the velocityfield frozen
Additional modeling is involved for the solution of thermal equation inthe RANS context (therefore additional approximations and errors)
Wall quantities (temperature and heat flux) are very sensitive to themodeling of near-wall turbulence
Conjugate heat transfer (coupled fluid/solid) are often necessary todescribe accurately a physical device
1
ME469B/6/GI 1
User Programming
• What are User Defined Functions• Introduction to C• Set-Up C User Routines in Fluent• Implementing a Custom Turbulence Model• Programming in other CFD Commercial Codes
Acknowledgement: this handout is partially based on Fluent training material
ME469B/6/GI 2
Introduction to UDF Programming
Why programming in commercial codes?
• The codes are general-purpose but cannot anticipate all needs• New (physical) models can be developed in a user-friendly environment• Large number of problems (test-cases) can be addressed with the same implementation
What is a the User Defined Function (UDF)?
• C (Fluent) or FORTRAN (StarCD, CFX) routines programmed by the user linked to the solver to perform certain operations:
• initialization• special boundary condition (i.e. space or time dependent)• material properties• source terms• reaction rates• postprocessing and reporting• debugging• ….
2
ME469B/6/GI 3
A Simple UDF ExampleSpecify a Parabolic Velocity Profile at the Inlet
Goal: The UDF (inlet_parab) set the values of the x-velocity component at the cell facesof the inlet boundary zone
1) Determine the cell-faces belonging to the inlet zone2) Loop on all those faces3) Determine the coordinate of the face centroid4) Specify the x-velocity component
Inletzone
ME469B/6/GI 4
Parabolic Velocity Profile:
A Simple UDF Example
function inlet_parab
Definitions
Loop over all the inlet cell faces
Evaluate the face centroid coordinates
The function return the velocity
3
ME469B/6/GI 5
A Simple UDF Example
Compile/interpret the UDF:
Define Æ User Defined
Attach the profile to the inlet zone
Define Æ Boundary Condition
Equivalent to attach the profile from a separate simulation
ME469B/6/GI 6
Solve the equations
Solve Æ Iterate
Final Result
A Simple UDF Example
4
ME469B/6/GI 7
C Programming
Typical C function:
ME469B/6/GI 8
C vs. FORTRAN
5
ME469B/6/GI 9
Basic Programming Rules
Statements MUST end with a semicolon Æ ;
Comments are placed anywhere in the program between Æ /* …… */
Statements are grouped by curly brackets Æ { …… }
Variables defined within the body functions are local Variables defined outside the body functions are global and can be used byall the functions that follows
Variables MUST be ALWAYS defined explicitly
Integer/real/double functions have to return a integer/real/double value
C is case sensitive!
ME469B/6/GI 10
Basic Statements
Arithmetic expressions in C look like FORTRAN
a = y + (i-b)/4;
Functions which return values can be used in assignment
a = mycompute(y,i,b);
Functions which do not return values can be called directly
mystuff(a,y,i,b);
Mathematical and various other default functions are available
a = pow(b,2); /* pow(x,y) returns x raised to y */
6
ME469B/6/GI 11
Data Types and Arrays
Arrays of variables are defined using the notation
Note the brackets are square [] not round ()!!
Note that the arrays ALWAYS start from 0
Standard C types are: Integer, Real, Double, Char
C allows to define additional types
typedef struct list{int id, float x[3], int id_next};
int a[10]; /*define an array of ten integers */
ME469B/6/GI 12
Pointers
A pointer is a variable which contain the address of another variable
Pointers are defined as:
int *a_p; /* pointer to an integer variable */int a; /* an integer variable */
Set-up a pointer
a = 1;a_p = &a; /* &a return the address of variable a */
*a_p returns the content of the address pointed by a_p
7
ME469B/6/GI 13
Operators
Arithmetic Operators Logical Operators
ME469B/6/GI 14
Conditional Statements
if and if-else Example
8
ME469B/6/GI 15
Loop Procedure
for loops Example
ME469B/6/GI 16
C Preprocessor
It handles Macro substitutions
#define A B#define my_f(x,y) x+y*3-5
The preprocessor replaces A with B It also handles file inclusion
#include “udf.h”#include “math.h”
The files to be included MUST reside in the currect directory
9
ME469B/6/GI 17
Programming in C
Of course much more than just this….
Additional information are:
http://www.cs.cf.ac.uk/Dave/C/CE.html
Plenty of books:
“The C Programming Language”, Kernighan & Ritchie, 1988
ME469B/6/GI 18
UDF in Commercial CFD Codes
Commercial CFD codes allow the development of User Defined Functionsfor various applications. Anyway, the core of the software is closed.
UDF must be compiled and linked to the main code
Most codes provide macros and additional tools to facilitate the use of UDFs
In Fluent there are two options:Interpreted
The code is executed on a “line-by-line” basis at run time+ does not need a separate compiler (completely automatic)- slows down the execution and uses more memory- somewhat limited in scope
CompiledA library of UDF is compiled and linked to the main codeOvercomes all the disadvantages reported above
10
ME469B/6/GI 19
Interpret the UDFs
Define Æ User Defined Æ Interpreted
Default stack size might be too small for large arrays!
Display of code translation in assembly(and eventual compiling errors)
ME469B/6/GI 20
Compile the UDFs
Define Æ User Defined Æ Compiled
The library MUST be precompiled in a directory tree
11
ME469B/6/GI 21
Directory tree for compiled UDFs
my_library
Makefile src lnx86
makefile my_udf.c
2d 3d
makefile my_udf.c libudf.so
makefile my_udf.c libudf.so
Machine dependentirix6r10ultrahp700…
ME469B/6/GI 22
Makefiles for UDFs
In the directory
/usr/local/Fluent.Inc/fluent6/src
There are two files
Makefile.udf to be copied in the directory my_library makefile.udf to be copied in the directory my_library/src
The first one does not require modifications. In the second one two macros MUST be modified
SOURCE = my_udf.cFLUENT_INC = /usr/local/Fluent.Inc
12
ME469B/6/GI 23
UDFs in FLUENT
Boundary ConditionsInitial ConditionsAdjust FunctionSource TermsMaterial PropertiesExecute on DemandUser Defined ScalarsUser Defined Memory
Pointers to threadsGeometry MacrosCell and Face VariablesArithmetic and Trigonometric Functions
Available MACROS
ProgrammingTools
ME469B/6/GI 24
Boundary Conditions
The inlet profile specification is based on the macro DEFINE_PROFILE
DEFINE_PROFILE can be used for wall boundary conditions as wellto impose temperature, velocity, shear stress, etc.
It is possible to specify a constant value, a position-dependent ortime-dependent values and to link the values on the boundary to the valuesin the internal cells
Note that the BCs are applied to the faces of the cells (face centroids)
xx
xBC
InternalValues
13
ME469B/6/GI 25
Initial Conditions
The initial condition specification can be performed using the macro DEFINE_INIT
Space-dependent conditions might be imposed
The routine is executed once at the beginning of the solution process
It is attached in the UDFs hooks
Define Æ User Defined Æ Function Hooks
ME469B/6/GI 26
Initial Conditions
Note that the difference between the DEFINE_PROFILE and DEFINE_INITis that the former performs a loop on the face-centroids belonging to a certainzone whereas the latter loops on the cell-centroids
Example:
14
ME469B/6/GI 27
Adjust Function
Similar to the DEFINE_INIT but it is executed every iteration: DEFINE_ADJUST
Can be used for postprocessing, clipping, etc.
It is attached in the UDFs hooks
Define Æ User Defined Æ Function Hooks
ME469B/6/GI 28
Source Terms
To add a source term in the equations: DEFINE_SOURCE
Can be used for:ContinuityMomentum (component by component)Turbulent quantitiesEnergy
It is different from the previous macros because it works on a cell-by-cell basis(no need to perform loops!)
15
ME469B/6/GI 29
Define Æ Boundary Conditions Æ Fluid
Source Terms
Activate source terms
Attach the UDF
ME469B/6/GI 30
Source Terms
In FLUENT the source terms are written in the form
S (f) = A + B f
where f is the dependent variable
A is treated explicitly and B f is treated implicitly
In the DEFINE_SOURCE both terms A and B have to be specified
16
ME469B/6/GI 31
Material Properties
To define the properties of the materials : DEFINE_PROPERTIES
Can be used for:ViscosityDensityThermal Conductivity….
As for the source terms works on a cell-by-cell basis
ME469B/6/GI 32
Material Properties
Define Æ Material Property
All the available UDFsAre shown in the menu
17
ME469B/6/GI 33
Execute on Demand
Define Æ User Defined Æ Execute on Demand
To perform operations instantaneously : EXECUTE_ON_DEMAND
It is executed when activated by the user
Can be used for:DebuggingPostprocessing….
ME469B/6/GI 34
User Defined Scalar
In addition to the Continuity and Momentum Equations (and Energy) generic transport equations can be solved (up to 50!)
To include scalars in the calculations
1) Define the number of scalars
Define Æ User Defined Æ User Defined Scalars
2) Define the diffusion and source terms in the generic equation
18
ME469B/6/GI 35
User Defined Scalar
Define Æ Material Property
When UDS are defined in the material property panel the diffusivity of thescalars MUST be defined
Note that the default diffusivity for the scalars is constant and equal to 1!
ME469B/6/GI 36
User Defined Scalar
Boundary conditions for the scalars can be defined as
Constant ValueConstant GradientUser Defined
Define Æ Boundary Conditions Æ Wall
19
ME469B/6/GI 37
User Defined Scalar
The Source terms for the scalars are set using the DEFINE_SOURCE macroIntroduced before
The scalar equations can be further customized
1) Convective terms can be modified using the macroDEFINE_UDS_FLUX
2) Unsteady term can be modified using the macro DEFINE_UDS_UNSTEADY
ME469B/6/GI 38
User Defined Memory
The User Defined Scalars are used to solve additional equations eventuallycoupled to the mean flow equations
Sometimes it is useful to define temporary field variables to store and retrievevalues not directly available
UDM are defined:
More efficient storage compared to User Defined Scalars
Define Æ User Defined Æ User Defined Memory
20
ME469B/6/GI 39
I/O in UDF
User Defined Scalars and User Defined Memory are AUTOMATICALLYStored in the Fluent Data files
Additional I/O (from and to the Fluent Case and Data files) can be Accomplished using the macro DEFINE_RW_FILE
Define Æ User Defined Æ Function Hooks
ME469B/6/GI 40
Detailed Programming
The macros introduced before are interpreted/compiled and attached tothe various Fluent panels
The detailed programming is based on additional macros that allow toloop on cells to retrieve field variables, etc.
Loop MacrosGeometry MacrosField Variable MacrosControl MacrosArithmetic and Trigonometric Macros
Before looking at the Macros, the Fluent Data structure in introduced
21
ME469B/6/GI 41
Data Structure
It is based on a hierarchy of structures
Threads (zones) are collection of cells or faces Domain is a collections of threads
Domain
Thread
Cell
Thread
Face
Thread
Face
ME469B/6/GI 42
Every zone is associated to a single ID (available in the boundary conditions menu)
Threads
Given the ID of a thread the pointer can be retrieved as:
Thread *tf = Lookup_Thread(domain, ID);
Given the thread pointer the ID of the zone can be retrieved as:
ID = THREAD_ID(thread);
zone
ID
22
ME469B/6/GI 43
Loop Macros
ME469B/6/GI 44
cell0cell1
x
face
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)cell1_id = F_C1(face,thread)
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); face_thread = C_FACE_THREAD(cell,thread,nf); }
Number of faces of each cell is unknown
23
ME469B/6/GI 45
Geometry Macros
Many more available; refer to the FLUENT UDF Manual
ME469B/6/GI 46
Field Variables Macros
24
ME469B/6/GI 47
Field Variables Macros
Many more available; refer to the FLUENT UDF Manual
ME469B/6/GI 48
Control Macros
Many more available; refer to the FLUENT UDF Manual
25
ME469B/6/GI 49
An example of User Defined Programming
Development of a custom turbulence model can be accomplished using theUDFs.
k-e model with damping functions formulation:
Low-Re k-e model
TransportEquations
ME469B/6/GI 50
Low-Re k-e modelAn example of User Defined Programming
Eddy Viscosity
Damping functions
Turbulent Reynolds number definitions
Wall boundary conditions
y
P = Turbulent Kinetic Energy Production
S = Strain Rate Magnitude
26
ME469B/6/GI 51
Required UDF Routines
Source Terms DEFINE_SOURCE(k_source, thread, eqn) DEFINE_SOURCE(d_source, thread, eqn)
Diffusivity DEFINE_PROPERTY(ke_diffusivity, domain)
Boundary Condition DEFINE_PROFILE(wall_d_bc, domain)
Adjust Routine DEFINE_ADJUST(turb_adjust, domain)
ME469B/6/GI 52
Required field variables
Density C_R(cell,thread)
Molecular viscosity C_MU(cell,thread)
Eddy viscosity C_MU_T(cell,thread)
Strain Rate Magnitude Strain_rate(cell,thread)
Wall distance C_WALL_DIST(cell,thread)
27
ME469B/6/GI 53
#include "udf.h"
/* Turbulence model constants */#define C_MU 0.09#define SIG_TKE 1.0#define SIG_TDR 1.3#define C1_D 1.44#define C2_D 1.92
/* User-defined scalars */enum{ TKE, TDR, N_REQUIRED_UDS};
UDF Header
Required: includes all Fluent macros
Constant definitions (global)
Assign a number to each scalar
ME469B/6/GI 54
/* Reynolds number definitions */real Re_y(cell_t c, Thread *t){ return C_R(c,t)*sqrt(C_UDSI(c,t,TKE))*C_WALL_DIST(c,t)/C_MU_L(c,t);}
real Re_t(cell_t c, Thread *t){ return C_R(c,t)*SQR(C_UDSI(c,t,TKE))/C_MU_L(c,t)/C_UDSI(c,t,TDR);}
/* 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));}
real f_1(cell_t c, Thread *t){ return 1.;}
real f_2(cell_t c, Thread *t){ return (1.-2/9*exp(-Re_t(c,t)*Re_t(c,t)/36))*(1.-exp(-Re_y(c,t)/12));}
Damping Functions
These are defined on a cell-by-cell basis
28
ME469B/6/GI 55
Source Term Routines
DEFINE_SOURCE(k_source, c, t, dS, eqn){ real G_k;
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);}
The production term in the k equation is:
e is obtained from the definition of the eddy viscosity to increase the couplingbetween the equations and to define an implicit term
ME469B/6/GI 56
Source Term Routines
DEFINE_SOURCE(d_source, c, t, dS, eqn){ real G_k;
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);}
The production term in the e equation is:
It contains already both k and e. No need for manipulations!
29
ME469B/6/GI 57
Diffusivity
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; case TDR: diff = mu_t/SIG_TDR + mu; break; default: diff = mu_t + mu; } return diff;}
The diffusion terms in the scalar equations are set-up together
But each equation can havea different value
ME469B/6/GI 58
Eddy Viscosity
DEFINE_ADJUST(turb_adjust, domain){ Thread *t; cell_t c;
/* Set the turbulent viscosity */ thread_loop_c (t, domain) if (FLUID_THREAD_P(t)) { begin_c_loop(c,t) { C_MU_T(c,t) = C_R(c,t)*C_MU*f_mu(c,t)*SQR(C_UDSI(c,t,TKE))/C_UDSI(c,t,TDR); } end_c_loop(c,t) }}
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
30
ME469B/6/GI 59
Wall Boundary Conditions
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;
begin_f_loop(f,t) { c0 = F_C0(f,t); rootk = sqrt(MAX(C_UDSI(c0,t0,TKE), 0.)); F_CENTROID(xw,f,t); C_CENTROID(xc,c0,t0); NV_VV(dx, =, xc, -, xw); dy = ND_MAG(dx[0], dx[1], dx[2]); drootkdy = rootk/dy; F_PROFILE(f,t,position) = 2.*C_MU_L(c0,t0)/C_R(c0,t0)*drootkdy*drootkdy; } end_f_loop(f,t)}
Only the boundary condition for e is complicated because it requires the value of thederivative of k (the square root of k)
The derivative is rootk/dyrootk is the sqrt of k in
the adjacent cell centerdy is the distance between
cell and face center
ME469B/6/GI 60
Set-Up the Problem
Set-Up a case using the standard k-e
Define two scalars (TKE, TDR)
Compile and Attach the UDFs
Deactivate the Equations for k and e
Initialize and solve the RANS + TKE and TDR
31
ME469B/6/GI 61
Attach the UDF
Source terms
Boundary conditions
ME469B/6/GI 62
Open UDF Library
Output in the text windowAre the functions available
After compiling the libraryIt can be opened in Fluent
32
ME469B/6/GI 63
Perform the SimulationThe 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 64
Additional Information
Many additional macros are available to implement different physical modelscombustion modelsparticles-based models….
It is formally possible to develop additional numerical methods flux discretizationsvariable reconstruction and clipping….
Information are available in the FLUENT UDF manual (class web site)
33
ME469B/6/GI 65
UDF in other commercial CFD CodesCFX
CFX (v4) is a structured code; the data structure is much simpler because thefield variables are accessed directly. It uses 1D arrays where the quantities arestored in succession
CFX UDFs are written in FORTRAN
For example:
U(I,J,K) Æ U(IJK) where IJK = (K-1)*NI*NJ+(J-1)*NI
There are no macros, but examples of subroutines to perform the customization
USRBCUSRSRCUSRDIF….
ME469B/6/GI 66
UDF in other commercial CFD CodesStar-CD
StarCD is an unstructured code similar to Fluent in term of data organizationBut similar to CFX for the organization of the UDF.
StarCD has threads (as Fluent) and the UDF work normally on a cell-by-cellbasis
StarCD UDFs are written in FORTRAN
There are no macros, but examples of subroutines to perform the customization
BCDEFWSORSCADIFFUS….
1
ME469B/3/GI 1
Simulation of Turbulent Flows
• From the Navier-Stokes to the RANS equations• Turbulence modeling• k-e model(s)• Near-wall turbulence modeling• Examples and guidelines
ME469B/3/GI 2
Navier-Stokes equations
The Navier-Stokes equations (for an incompressible fluid) in an adimensional formcontain one parameter: the Reynolds number:
Re = r Vref Lref / m
it measures the relative importance of convection and diffusion mechanisms
What happens when we increase the Reynolds number?
2
ME469B/3/GI 3
Re < 5 Laminar Attached Steady
5 < Re < 40 Laminar Separated Steady
40 < Re < 200 Laminar Separated Periodic
200 < Re < 350K Laminar Separation/Turbulent Wake Periodic
350K < Re Turbulent Separation Chaotic
Re
Reynolds Number Effect
Experimental Observations
ME469B/3/GI 4
Laminar vs. Turbulent Flow
Laminar Flow Turbulent Flow
The flow is dominated by theobject shape and dimension (large scale)and by the motion and evolution of small eddies (small scales)
Challenging to compute
The flow is dominated by theobject shape and dimension (large scale)
Easy to compute
3
ME469B/3/GI 5
Why turbulent flows are challenging?
Unsteady aperiodic motion
Fluid properties exhibit quasi-random spatial variations (3D)
Strong dependence from initial conditions
Contain a wide range of scales (eddies)
The implication is that the turbulent simulations MUST be alwaysthree-dimensional, time accurate with extremely fine grids
ME469B/3/GI 6
Direct Numerical Simulation
The objective is to solve the time-dependent NS equations resolving ALLthe scale (eddies) for a sufficient time interval so that the fluid propertiesreach a statistical equilibrium
Grid requirement: N ~ (Ret)9/4 ~ 1x107 for Ret = 800
Time step requirement: Dt ~ (Ret)-1/2 ~ 1x10-5 for Ret = 800
y+ = r yp ut /m ut = (tw/r)1/2
4
ME469B/3/GI 7
Typical DNS channel flow simulations
Instantaneous Flow Field – Vortical Structures
ME469B/3/GI 8
DNS of Channel Flow: Averaged Results
Laminar and Turbulent Velocity profiles
5
ME469B/3/GI 9
DNS using Commercial CFD Codes?
Channel flow @ Ret = 395
ME469B/3/GI 10
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
Time averaged quantities are appropriate for engineering purposes
Large scale resolution (not to the level of the smallest eddies) is enough for applications
Can we extract time-average and large-scale quantities at areasonable computational cost?
6
ME469B/3/GI 11
Flow over a Backstep
Istantaneous
Time averaged
high velocityregionslow velocity
regions
Length of the recirculation region is of engineering interest
ME469B/3/GI 12
Velocity & Velocity Fluctuations
is a function of time with rapid fluctuations (turbulence)By re-defining it as the time average and the fluctuations
(x1)
(x2)
t
Velocity measurements in the turbulent wake of a cylinder
7
ME469B/3/GI 13
Reynolds-Averaged Navier-Stokes Equations
Closureproblem
Define Reynolds-averaged quantities
Substitute and average:
ME469B/3/GI 14
Unsteady RANS?Every turbulent flow is unsteady BUT not all the unsteadiness is turbulence!
RANS averaging based on time average can be applied only to “statistically”steady flows. What if flow has a large scale periodicity (vortex shedding)?
We can define the Reynolds-Averaging procedure in terms of Ensemble Average:
8
ME469B/3/GI 15
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!)
2) Reynolds stress transport models - equations derived directly manipulating the NS equations - still contain unknown (undetermined) quantities - no assumption of isotropy - very complicated and expensive to solve
3) Non-linear Eddy viscosity models (Algebraic Reynolds stress)
4) Model directly the divergence of the Reynods Stresses
ME469B/3/GI 16
Eddy viscosity models
Boussinesq relationship:
Guidelines for defining the eddy viscosity:
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
with:
9
ME469B/3/GI 17
Classification of eddy viscosity models
The various models (about 200) are classified in terms of number of transportequations 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 18
Zero-equation model Prandtl Mixing Length
From dimensional arguments and analogy with molecular transport
Definition of L is different for each problem (boundary layes, mixing layers, etc.)
Eddy viscosity is zero if the velocity gradients are zero
No “history” effect; purely local
L can be made “universal” using ad hoc functions of distance from the walls,pressure gradients, etc.
10
ME469B/3/GI 19
One-equation model k-model
An equation from k can be derived directly from the NS equations (using the definition)
k1/2 is assumed to be the velocity scaleit still requires a length scale L as before to define the eddy viscosity4 out of 7 terms in the k equation require further assumptions
Production is computed using the Boussinesq approximationDissipation is modeled (using dimensionality arguments) as k3/2/L Turbulent transport and pressure diffusion are modeled together:
ME469B/3/GI 20
One-equation model k-model
The ONLY advantage with respect to zero-equation models is the inclusion of thehistory effects.
Modern one-equation models abandoned the k-equation and are based on a ad-hocTransport equation for the eddy viscosity directly.
Spalart-Allmaras model:
The final form of the model is:
11
ME469B/3/GI 21
Two-equation model k-f family
The main drawback of the k one-equation model is the incomplete representationof the two scales required to build the eddy viscosity; two-equation models attemptto represent both scales independently.
• All models use the transport equation for the turbulent kinetic energy k• Several transport variables are used
e: turbulence dissipation rateL: turbulent length scalew: inverse of turbulent time scalew2
gyt
ME469B/3/GI 22
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 undeterminedquantities; it is therefore derived “mimicking” the k equation
The eddy viscosity is obtained as:
There are 5 free constants
12
ME469B/3/GI 23
Determining the constants?
The constants can be determined studying simple flows:
1. Decaying homogeneous isotropic turbulence
2. Homogeneous shear flow
3. The Logarithmic Layer
4. …
Or by comparison with experimental data
Standard k-e refers to a certain choice of the constants (Launder & Sharma 1972)
ME469B/3/GI 24
Structure of the Turbulent Boundary LayerUniversal Law (velocity profile)
At High Reynolds number the viscous dominated layer is so thin that it is verydifficult to resolve it
13
ME469B/3/GI 25
Wall Function Approach (High-Re k-e)
The laminar sublayer is NOT resolved
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+)
A slip condition (u ≠ 0) is imposed at the wall (imposed shear stress)
k boundary condition is usually imposed as a zero-gradient.
e is obtained by equilibrium condition (Pk=e )
If first grid point is too close (viscous layer) then the velocity is: u+ = y+
ME469B/3/GI 26
Near Wall Region Modeling
From a physical point of view:
It is important because solid walls are the main source of vorticityand turbulence (local extrema of turbulent kinetic energy, largevariations of turbulence dissipation, etc.)
In engineering applications:
Wall quantities (velocity gradients, pressure, etc.) are very important in several applications
Flow separation and reattachment are strongly dependent on a correct prediction of the development of turbulence near walls
14
ME469B/3/GI 27
Damping Functions Approach (Low-Re k-e)
The equations are integrated to the wall WITHOUT assuming an universal lawfor 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 nearthe 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 28
Damping Functions
We need to specify 5 constants plus 3 functions:
MANY choices are available (about 30 different formulations!). Fluenthas 6 different versions
Classic model is the Launder and Sharma model:
Others might be function of the distance from the wall, the pressure gradient, etc.
15
ME469B/3/GI 29
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 anda 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 thewall (y+~30)
The main assumption is related to the definition of e which is based on
ME469B/3/GI 30
Near-Wall Treatments for k-e models
+/---+/-Dampingfunctions
+/-++/-+/-Two layer
+/-++-Wallfunctions
AccuracyNumerics
GridrequirementPhysicsApproach
Summary and Comparison
16
ME469B/3/GI 31
Problem set-up Solver Set-Up
Material Properties:r = 1kg/m3
m = 0.0017kg/ms
Reynolds number:h = 2m, L=1mRet = rUth/m = 590
Boundary Conditions: Periodicity Dp/L=1=Ut
No-slip top/bottom walls
Initial Conditions:u = 1; v = p = 0
Turbulence model:k-e with wall functions
Segregated Solver
Discretization:2nd order upwindSIMPLE
MultigridV-Cycle
h
Periodic boundaries
Example: Turbulent Channel Flow
L
Grid
SAME GRID USEDFOR THE LAMINARFLOW @ Re=20
ME469B/3/GI 32
Turbulent Channel Flow
Velocity and k profiles
Ret = 590
17
ME469B/3/GI 33
Grid Convergence?
Velocity and k profiles
Ret = 590
Turbulence Channel Flow
ME469B/3/GI 34
From High-Re to Low-Re k-e
Grid Turbulent kinetic energy
Wall boundary conditiondk/dy=0 k=0
Wall clusteringy+=30 y+~1
Ret = 590
18
ME469B/3/GI 35
Velocity and k profiles
Low-Re k-e model
Ret = 590
Turbulence Channel Flow
ME469B/3/GI 36
Pros & Cons of k-e model
+ 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
A lot of variants have been introduced to overcome these problems
One (or more) constants become coefficients varying with S, distance from the walls, pressure gradient, etc.: RNG k-e, realizable k-e…
19
ME469B/3/GI 37
Alternatives/Improvements to k-e models
The k-w model was developed from the realization that most of the problemsexperienced by k-e-type models are due to the modeling of the e equation whichis neither accurate or easy to solve (e has a local extrema close to the wall)
Mathematically this is equivalent to a change of variables w~e/k
The v2-f model is based on the argument that k/e is the correct turbulent timescale in the flow (close to the wall and in the outer region) but k is not theappropriate turbulent velocity scale
An additional equation for the correct velocity scale v2 (independent from k) hasto be solved. Moreover, the damping effect produced from the presence of the wallis NOT local (as assumed in the damping function approach) but must beaccounted for globally using an elliptic equation
ME469B/3/GI 38
Velocity and k profiles
k-w model
Ret = 590
Turbulence Channel Flow
20
ME469B/3/GI 39
Reynolds Stress Models
Attempt to model directly the “new” terms appearing in the RANS equations
Mathematically is expensive because we have 6 additional equations:
More importantly ONLY the production term are exact, everythingelse MUST be modeled
RSM are extremely stiff numerically due to the coupling between theequations and suffer of the same near-wall problems of the k-e
ME469B/3/GI 40
Models available in Fluent
One-equation model
Two-equation modelk-e (3 versions + 3 wall treatments)k-w (2 versions)
Reynolds Stress model
Note that the coefficients might be adjusted!!!
Define Æ Models Æ Viscous
21
ME469B/3/GI 41
Models in Fluent hidden behind the GUI
Mixing Length
define/model/viscous/mixing-length y
Two-equation modelk-e Low-Re (6 versions)
define/model/viscous/turbulence-expert/low-re-ke ydefine/model/viscous/turbulence-expert/low-re-ke-index 2
Some turbulence models are NOTdirectly available in the GUI!!!
ME469B/3/GI 42
Comparison of Models
Velocity and k profiles
Ret = 590
Turbulence Channel Flow
22
ME469B/3/GI 43
Channel Flow Summary
Wall functions are accurate if the first grid point is in the logarithmic layer
Grid Convergence Study with wall functions approach FAILS
Damping Functions (and Two-Layer approaches) are accurate for the velocity profilesBut 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 44
Inlet boundary conditions for turbulent quantities
At inlet boundary conditions additional quantities have to be specified inturbulent flows depending on the turbulence model selected. Typically thereare three options:
1) k-e
2) Turbulence Intensity and Turbulence Length Scale
3) Turbulence Intensity and Turbulent Viscosity
23
ME469B/3/GI 45
Example: Asymmetric Diffuser
Problem set-up Solver Set-UpMaterial Properties:r = 1kg/m3
m = 0.0001kg/ms
Reynolds number:h = 2m,Re = rUh/m = 20,000
Boundary Conditions: Inlet profiles available from experiments No-slip top/bottom walls
Segregated Solver
Discretization:2nd order upwindSIMPLE
MultigridV-Cycle
Initial Conditions:
u = 1; v = p = 0
Turbulence model:
Two-equation models
Inflow
Outflow
ME469B/3/GI 46
Flow in Asymmetric Diffuser
k-e Low-Re
k-e Low-Re
v2-f
v2-f
Experiments indicatedthe presence of a largerecirculation region
k-e models with dampingfunction do NOT capture it
24
ME469B/3/GI 47
Flow in Asymmetric Diffuser
Skin friction on the bottom wall
ME469B/3/GI 48
Flow in Asymmetric Diffuser
Streamwise Velocity Turbulence Kinetic Energy
25
ME469B/3/GI 49
k-e with wall functions
No separation is captured!Series of grids generatedwith different clustering at wall
ME469B/3/GI 50
k-e with wall functions
In “complex” configuration it is impossible to generated a grid with the first grid pointin the logarithmic layer…..
…in addition, for complicated flows with recirculation the Universal Law is inaccurate
26
ME469B/3/GI 51
Example: NLR Two Component Airfoil
Problem set-up Solver Set-UpMaterial Properties:r = 1kg/m3
m = 3.98E-7Kg/ms
Reynolds number:h = 1m,Re = rUh/m = 2,512,600
Boundary Conditions: Constant velocity at AOA=a No-slip walls
Segregated Solver
Discretization:2nd order upwindSIMPLE
MultigridV-Cycle
Initial Conditions:
u = cosa; v = sina, p = 0
Turbulence model:
SA and k-e models
a
ME469B/3/GI 52
Computational Grid
Due to the high Reynolds numberresolution of the boundary layersrequires extreme clustering
27
ME469B/3/GI 53
How this grid is generated?
Multiblock Structured Grid
ME469B/3/GI 54
Pressure distributions
Pressure Distribution at Low and High Angle of Attack
28
ME469B/3/GI 55
Why k-e fails?
StreamwiseVelocity
Turbulentkinetic energy
Spurious production of k in the stagnation regionsFix: Use of a production limiter:
define/model/viscous/turbulence-expert/kato-launder-model y
ME469B/3/GI 56
GuidelinesSimulations 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 accuracy3) Project Requirement to evaluate the need for sophisticated turbulence models
Turbulence model Computational grid
physicsaccuracy
resources
Simulation
CFD
Pro
cess
29
ME469B/3/GI 57
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)
Guidelines
ME469B/3/GI 58
Estimating y+
Definition: y+ = r yp ut /m
y+ = r yp ut /m
ut = Ue (cf/2)1/2
To estimate ut we can use “classic” relationships for the skin friction:
• Flat Plate: cf/2 ~ 0.052 (Rex)-0.142
• Pipe: cf/2 ~ 0.046 (Rex)-0.2
Note that there are different laws for different Re number ranges
30
ME469B/3/GI 59
“Final” Guidelines
For k-e simulations:Two-layer is preferable over wall-functions (grid dependence + accuracy)Realizable k-e or Kato&Launder limiter have to be used
For k-w simulations:SST is usually better than standardGrid should be clustered at wall
SA is usually a good compromise between accuracy and simplicity. It also hasvery good convergence properties (as compared to the two-equation models)
Reynolds stress model is expensive and it require a good initial guess (typically ak-e-type simulation)
ME469B/3/GI 60
Summary of turbulence models in Commercial Codes
ynyyyyCFX
yynynnStarCD
ynyyyyFLUENT
Custom
Non-Linear
ModelsRSM
Two
equation
One
equation
Zeroequation