Professional Documents
Culture Documents
9.1 Introduction
9.2 The computational mesh
9.3 Boundary conditions
9.4 Flow visualisation
Examples
9.1 Introduction
This course has focused on the “solving” process, but this is of little use without pre-
processing and post-processing facilities. Commercial CFD vendors supplement their flow
solvers with grid-generation and flow-visualisation tools, as well as graphical user interfaces
(GUIs) to simplify the setting-up of a CFD analysis.
Pre-Processing
The pre-processing stage consists of:
– determining the equations to be solved;
– specifying the boundary conditions;
– generating a computational mesh or grid.
It depends upon:
– the desired outputs of the simulation (e.g. force coefficients, heat transfer, ...);
– the capabilities of the solver.
Solving
In commercial CFD packages the solver is often operated as a “black box”. Nevertheless,
user intervention is necessary – to set under-relaxation factors and input parameters, for
example – whilst an understanding of discretisation methods and internal data structures is
required in order to supply mesh data in an appropriate form and to analyse output.
Post-Processing
The raw output of the solver is a huge set of numbers corresponding to the values of each
field variable (u, v, w, p, …) at each point of the mesh. This must be reduced to some
meaningful subset and/or manipulated further to obtain the desired predictive quantities. For
example, a subset of surface pressures and cell-face areas is required to compute a drag
coefficient.
The table below lists some of the more popular commercial CFD packages.
The purpose of the mesh generator is to decompose the flow domain into control volumes.
Precisely where the nodes are relative to the vertices depends on whether the solver uses, for
example, cell-centred or cell-vertex storage. Further complexity is introduced if a staggered
velocity grid is employed.
u p
9.2.2 Areas, Volumes and Cell-Averaged Derivatives (**** MSc Only ****)
Areas and volumes are easy to evaluate in Cartesian meshes, but general-purpose CFD,
which employs arbitrary polyhedral meshes, requires more sophisticated geometrical
techniques.
Areas
Triangles.
The vector area of a triangle with side vectors s1 and s2 is s2
A = 12 s1 ∧ s 2 A
The orientation depends on the order of vectors in the cross product. s1
A
Quadrilaterals
4 points do not, in general, lie in a plane. However, since the sum of the
outward vector areas from any closed surface is zero, i.e. r4
⌠ r3
dA = 0
⌡∂V
or ∑A f = 0
faces
any surface spanning the same set of points has the same vector area.
A
By adding vector areas of, e.g., triangles 123 and 134, the vector area of
any surface spanned by these points and bounded by the side vectors is r2
found (see Examples) to be half the cross product of the diagonals: r1
A = 12 d13 ∧ d 24 = 12 (r3 − r1 ) ∧ (r4 − r2 )
(Again, the order of points determines the orientation of the area vector).
General polygons
The vector area of an arbitrary polygonal face may be found by breaking it
up into triangles and summing the individual vector areas. Again, the vector
area is independent of how it is broken up.
∂x ∂y ∂z
If r ≡ ( x, y , z ) is the position vector, then ∇ • r =
+ + = 3 . Hence, integrating over
∂x ∂y ∂z
an arbitrary control volume and using the divergence theorem gives for the volume of a cell:
1⌠
V = r • dA
3 ⌡∂V
The last term vanishes because r – rf is perpendicular to Af for any point on a plane face.
If the cell faces are not planar, then the volume depends on how these
faces are broken down into triangles. Typically the area of a particular
face can be regarded as an assemblage of triangular elements connecting
the vertices of that face with a central reference point formed, e.g. rf
1
rf = ∑ ri
N vertices
Tetrahedra
The volume of a tetrahedron formed from side s3 vectors s1, s2, s3
(taken in a right-handed sense) is s1
V = 16 s1 • s 2 ∧ s 3
s2
Hexahedra
Volumes of arbitrary polyhedral cells are:
1
V = ∑r f • A f
3 faces
For hexahedra, on each face the reference point and vector area are:
r f = 14 (r1 + r2 + r3 + r4 )
A f = 12 (r1 − r3 ) ∧ (r2 − r4 )
To obtain an outward-directed face vector, the points with position vectors r1, r2, r3, r4 should
be in clockwise order when viewed along the outward normal (right-hand screw).
This is a generalisation to arbitrary hexahedra of the result for Cartesian control volumes.
The side “area” vectors are most easily obtained from their Cartesian projections:
dy dx
dA = − dx
0 ds
dy
To obtain an outward-directed dA, the edge increments (dx,dy,0) must dA
be taken anticlockwise around the cell.
Volume-Averaged Derivatives
By applying the divergence theorem to φex, where ex is the unit vector in the x direction, the
volume-averaged derivative of a scalar field φ is
∂φ ∂φ 1⌠
= ⌠
1
dV = φ dAx
∂x V ⌡ V ∂x V ⌡∂V
or
1
∇φ = ∑ φ f A f
V faces
Thus, for arbitrarily-shaped cells, average derivatives may be derived from the values of φ on
the cell faces, together with the components of the face area vectors and the cell volume.
As
Unstructured meshes can accommodate completely arbitrary geometries. However, there are
significant penalties to be paid for this flexibility, both in terms of the connectivity data
structures and solution algorithms. Grid generators and plotting routines for such meshes are
also very complex.
Volume-of-Fluid Approach
• It is necessary to store detailed geometric components for each control volume; for
example, in our research code STREAM we need to store (x,y,z) components of the
cell-face-area vector for “east”, “north” and “top” faces of each cell, plus the volume
of the cell itself – a total of 10 arrays.
ξ=
const.
• Unless the mesh happens to be orthogonal, the diffusive flux
through the east face (say) is no longer given exactly by
t.
∂φ φE − φP ons
A= A E η =c
∂n PE P
because the discretised derivative of φ normal to the face
involves cross-derivative terms parallel to the cell face and
nodes other than P and E. The extra off-diagonal diffusion
terms are typically transferred to the source term.
1 6 7 5
boundaries. There are no hard and
fast rules, but it is generally
8 desirable to avoid sharp changes in
grid direction (which lead to lower
accuracy) in important and rapidly changing regions of the flow, such as near solid
boundaries. One should also strive to minimise the non-orthogonality of the grid.
Coordinate systems in which coordinate lines cross at right angles are termed orthogonal.
Cartesian systems are obviously in this category, but other commonly-used orthogonal
systems include cylindrical and spherical polar coordinates.
However, most curvilinear systems are non-orthogonal. The direction normal to one face is
not necessarily along a coordinate line, and hence the diffusive flux, which depends on ∂φ/∂n,
cannot be approximated solely in terms of the nodes either side of the face. For example, in 2
dimensions, if the east face ( = constant) of a control volume ξ=
const.
coincides with x = constant, the normal derivative is
∂φ ∂φ ∂ ∂φ ∂
= + nst.
∂x ∂ ∂x ∂ ∂x η =co
E
The first derivative, ∂φ/∂ , can be discretised as (φ E − φ P ) / and
P
treated implicitly, but the derivative parallel to the cell face, ∂φ/∂ ,
depends on the values at other nodes; it has to be transferred to the
source side of the equation and treated explicitly.
Only two points are necessary to resolve a straight-line profile, but the more curved the
profile the more points are needed to resolve it accurately. In general, more points are needed
in rapidly-changing regions of the flow, such as:
– solid boundaries;
– separation, reattachment and impingement points;
– flow discontinuities; e.g. shocks, hydraulic jumps.
Simulations must demonstrate grid-independence, i.e. that a finer-resolution grid would not
significantly modify the solution. This generally requires a sequence of calculations on
successively finer grids.
Boundary conditions for turbulence modelling do impose some limitations on the cell size
near walls. Low-Reynolds-number models (resolving the near-wall viscous sublayer)
generally require that y+ < 1 for the near-wall node, whilst high-Reynolds-number models
relying on wall functions require (in principle) the near-wall node to lie in the log-law region,
ideally 30 < y+ < 150.
Multiple grids – combining cells so that there are 1, 1/2, 1/4, 1/8, ... times the number of cells
in some basic fine grid – are used deliberately in so-called multigrid methods. These calculate
the solution on alternately coarser and finer grids. The idea is that the solution is obtained
quickly on the coarsest grid where the number of cells is small and changes propagate rapidly
across the domain. The solution is then refined locally on the finest grid to obtain the most
accurate solution.
If two levels of grid are used then a process known as Richardson extrapolation may be used
to both estimate the error and, possibly, refine the solution. If the basic advection-diffusion
discretisation is known to be of order n and the exact (but unknown) solution of some
property φ is denoted φ*, then one would expect the error φ – φ* to be proportional to n,
where is the mesh spacing. Thus, for solutions φ and φ2 respectively on two grids with
mesh spacing and 2 ,
φ = φ* + C n
φ 2 = φ* + C (2 ) n
Two equations give us two equations for two unknowns, φ* and C, which we can solve to get
Unstructured-grid methods offer the possibility of local grid refinement: that is, adding more
cells in regions where the error is estimated to be high.
The number and type of boundary conditions must accord with the governing equations of the
flow. There are a number of common boundary types:
• inflow
values specified on the boundary, either by a predefined profile or (my preference)
by doing an initial 1-d, fully-developed-flow calculation;
• stagnation (or reservoir)
total pressure and total temperature fixed; used mainly as an inflow condition in
compressible or buoyancy-driven flow;
• outflow
zero normal gradient (∂φ/∂n = 0 where n is normal to the boundary) for all
variables;
• pressure
as for outflow, except fixed value of pressure; usual situation in compressible flow
if the exit is subsonic;
• wall
usually non-slip (zero velocity; wall stress computed by viscous-stress or wall-
function expressions); sometimes a slip wall (only the velocity component normal
to the wall vanishes);
• symmetry plane
∂φ/∂n = 0, except for the velocity component normal to the boundary, which is
zero; used where there is a geometric plane of symmetry, but also as a far-field
side boundaries, because they ensure that there is no flow through, and no viscous
stresses on, the boundary;
• periodic
used in repeating flow.
CFD has a reputation for producing colourful output and, whilst some of it is promotional,
the ability to display results effectively may be an invaluable design tool.
Visualisation tools are often packaged with commercial CFD products. However, many
excellent stand-alone applications or libraries are available. Some of the more popular in
CFD are listed below. Most have versions for various platforms, although some run only on
certain versions of unix. Some are aimed predominantly at the CFD user, but others are
general-purpose visualisation tools, which may equally well be applied in other branches of
engineering. Some are even free!
But for simple line, contour and vector plots, many researchers are still happy with the
original free, open-source plotting package ...
• Gnuplot (open-source software community) http://www.gnuplot.info/
x-y plots
Vector Plots
Streamline Plots
If isolines are at equal increments in , then clustering of lines corresponds to high velocities,
whilst regions where the streamlines are further apart signify low velocities. However, as
with vector plots, this has the effect of making it difficult to visualise the flow pattern in low-
velocity regions such as recirculation zones and a smaller increment in is needed here.
Particle paths can also be traced along solid surfaces using the wall stress vector. This often
reveals important features connected with separation/reattachment/impingement on 3-d
surfaces, which defines the basic flow topology.
The computational mesh is usually visualised by plotting the edges of control volumes – for
one coordinate surface only in 3 dimensions. It can be very difficult indeed to visualise fully-
unstructured 3-d meshes, and usually only the surface mesh and/or its projection onto a plane
section is portrayed.
Composite Plots
In 3 dimensions it is common to combine plots of the above types, emphasising the behaviour
of several important quantities in one plot. In this way, some sense can be made of the highly
complex flows now being studied with CFD.
(Robert Peel’s government eventually pulled the plug on Babbage’s research and he was
unable to build his “analytical engine”. Ever since then the British Government has preferred
to fight wars on the other side of the world rather than funding scientific research!)
Q1.
(a) Explain what is meant (in the context of computational meshes) by:
(i) structured;
(ii) multi-block structured;
(iii) unstructured;
(iv) chimera.
Q2.
Suppose that you are equipped with a flow solver that can cope with multi-block structured
curvilinear grids, where grid nodes must match at block interfaces. Indicate by sketches
suitable grid topologies that might be used to compute the following flow configurations. Use
symmetry where appropriate and “body-fitting” meshes, not “blocked-out” regions of cells.
Avoid sharp changes in grid direction where possible and certainly near solid boundaries.
D E 3 F
2 3 1 0.1 m
5
A B C
0.3 m 0.2 m
(b) Sketch the pattern of streamlines across the two cells in part (a).
Q4.
The figure below shows a quadrilateral cell, together with the coordinates of its vertices and
the velocity components on each face. If the value of the stream function at the bottom left
corner is = 0, find:
(a) the values of at the other vertices;
(b) the unknown velocity component vn.
(4,5)
velocity
n face u v
(1,3) w 3 –3
e e 3 1
s 0 2
w n 1 vn
s
(1,1) (3,1)
Q6.
(a) Derive the following formulae for the volume of a cell and the cell-averaged
derivative of a scalar field:
V= ⌠
1
(i) r • dA ;
3 ⌡∂V
∂φ 1⌠
(ii) = φ d Ax ;
∂x V ⌡∂V
where r is a position vector and dA a small element of (outward-directed) area on the
closed surface V.
A tetrahedral cell has vertices at A(2, –1, 0), B(0, 1, 0), C(2, 1, 1) and D(0, –1, 1).
(b) Find the outward vector areas of all faces. Check that they sum to zero.
(d) If the values of φ at the centroids of the faces (indicated by their vertices) are
φBCD = 5, φACD = 3, φABD = 4, φABC = 2,
∂φ ∂φ ∂φ
find the volume-averaged derivatives , ,
∂x ∂y ∂z
Q7.
The figure shows part of a non-Cartesian 2-d mesh. A
single quadrilateral cell is highlighted and the coordinates
of the corners marked. The values of a variable φ at the cell- N
centre nodes (labeled geographically) are: (0,4)
W
φP = 2, φE = 5, φW = 0, φN = 3, φS = 1. (3,3)
Find: (-2,2) P
(a) the area of the cell;
∂φ ∂φ
E
(b) the cell-averaged derivatives and , (2,0)
∂x ∂y S
assuming that cell-face values are the average of those at
the nodes either side of that cell face.
Q8.
One quadrilateral face of a hexahedral cell in a finite-volume mesh has vertices at
(2,0,1), (2,2,–1), (0,3,1), (–1,0,2)
(a) Find the vector area of this face (in either direction).
(b) Determine whether or not the vertices are coplanar.
Find: 4 1
(a) the area of the pentagon; (-2,-3)
∂φ ∂φ 5
(b) the cell-averaged derivatives and . (2,-4)
∂x ∂y
(b) Show that if the flow is irrotational then satisfies Laplace’s equation. If the flow is
not irrotational how is ∇2 related to the vorticity?
The figure below and the accompanying table show a 2-d quadrilateral cell, with coordinates
at the vertices and velocity components on the cell edges. The flow is incompressible. All
quantities are non-dimensional.
(4,4) velocity
face u v
(0,3) n w 3 2
e 3 –1
w e s 0 2
n 1 vn
s
(1,1) (3,1)
(c) Assuming that the stream function at the bottom left (SW) corner is 0, calculate the
stream function at the other vertices.
(d) Find the y-velocity component vn, whose value is not given in the table.
(e) By calculating ⌠
u • ds for the quadrilateral cell estimate the cell vorticity.
⌡
− 1 1 −1 1
Q6. (b) A BCD = 1 , A ACD = − 1 , A ABD = − 1 , A ABC = 1
2 2 − 2 − 2
(c) 4/3
∂φ ∂φ ∂φ
(d) = −3 , =0, =3
∂x ∂y ∂z
9/ 2
Q8. (a) A= 3
13 / 2
(b) No.
Q9. (a) 34
∂φ 14 ∂φ 20
(b) =− , =
∂x 17 ∂y 17