Vous êtes sur la page 1sur 35

Pressure-Velocity Coupling in FOAM

Consistent Derivation for Steady and Transient


Flow Solvers
Hrvoje Jasak
hrvoje.jasak@fsb.hr

FSB, University of Zagreb, Croatia

Pressure-Velocity Coupling in FOAM – p. 1


Matrix Assembly
From Discretisation to Linear System of Equations
• Assembling the terms from the discretisation method: The value of the solution in
a point depends on the values around it: this is always the case. For each
computational point, we will create an equation
X
aP xP + aN xN = b
N

where N denotes the neighbourhood of a computational point


◦ Every time xP depends on itself, add contribution into aP
◦ Every time xN depends on itself, add contribution into aN
◦ Other contributions into b

Pressure-Velocity Coupling in FOAM – p. 2


Temporal Derivative
First Derivative in Time
• Time derivative captures the rate-of-change of φ. We only need to handle the
volume integral.
• Defining time-step size ∆t
• tnew = told + ∆t, defining time levels φn and φo

φo = φ(t = told )

φn = φ(t = tnew )

• Temporal derivative, first and second order approximation

∂φ φn − φo
=
∂t ∆t
3 n
∂φ 2
φ − 2φo + 12 φoo
=
∂t ∆t

Pressure-Velocity Coupling in FOAM – p. 3


Matrix Coefficients
First Derivative in Time
• Thus, with the volume integral:

∂φ φn − φo
Z
dV = VP
V ∂t ∆t

3 n
∂φ φ − 2φo + 12 φoo
Z
2
dV = VP
V ∂t ∆t
Temporal Derivative
• Calculus: given φn , φo and ∆t create a field of the time derivative of φ
• Method: matrix representation. Since ∂φ
∂t
in cell P depends on φP , the matrix will
only have a diagonal contribution and a source
VP
◦ Diagonal coefficient: aP = ∆t
VP φo
◦ Source contribution: rP = ∆t

Pressure-Velocity Coupling in FOAM – p. 4


Convection Operator
Convection Operator
• Convection term captures the transport by convective velocity
• Convection operator splits into a sum of face integrals (integral and differential
form)
I Z
φ(n•u)dS = ∇•(φu) dV
S V

• Integration follows the same path as before


I X X
φ(n•u)dS = φf (sf •uf ) = φf F
S f f

where φf is the face value of φ and

F = sf •uf

is the face flux: measure of the flow through the face


• In order to close the system, we need a way of evaluating φf from the cell values
φP and φN : face interpolation

Pressure-Velocity Coupling in FOAM – p. 5


Convection Operator
Face Interpolation Scheme for Convection
• Simplest face interpolation: central differencing. Second-order accurate, but
causes oscillations
φf = fx φP + (1 − fx )φN

• Upwind differencing: taking into account the transportive property of the term:
information comes from upstream. No oscillations, but smears the solution

φf = pos(F ) φP + neg(F ) φN

• There exists a large number of schemes, trying to achieve good accuracy without
causing oscillations: e.g. TVD, and NVD families: φf = f (φP , φN , F, . . .)
F
φD

φf
+

φf
− φC
φU

− +
U f C f D

Pressure-Velocity Coupling in FOAM – p. 6


Convection Operator
Convection Discretisation
• In the convection term, φf depends on the values of φ in two computational points:
P and N .
• Therefore, the solution in P will depend on the solution in N and vice versa, which
means we’ve got an off-diagonal coefficient in the matrix. In the case of central
differencing on a uniform mesh, a contribution for a face f is
1
◦ Diagonal coefficient: aP = 2
F
1
◦ Off-diagonal coefficient: aN = 2
F
◦ Source contribution: in our case, nothing. However, some other schemes may
have additional (gradient-based) correction terms
◦ Note that, in general the P -to-N coefficient will be different from the N -to-P
coefficient: the matrix is asymmetric
• Upwind differencing
◦ Diagonal coefficient: aP = max(F, 0)
◦ Off-diagonal coefficient: aN = min(F, 0)

Pressure-Velocity Coupling in FOAM – p. 7


Diffusion Operator
Diffusion Operator
• Diffusion term captures the gradient transport
• Integration same as before
I XZ
γ(n•∇φ)dS = γ(n•∇φ) dS
S f Sf
X
= γf sf •(∇φ)f
f

• γf evaluated from cell values using central differencing


• Evaluation of the face-normal gradient. If s and df = P N are aligned, use
difference across the face

φN − φP
sf •(∇φ)f = |sf |
|df |

• This is the component of the gradient in the direction of the df vector


• For non-orthogonal meshes, a correction term may be necessary

Pressure-Velocity Coupling in FOAM – p. 8


Diffusion Operator
Matrix Coefficients
• For an orthogonal mesh, a contribution for a face f is
|sf |
◦ Diagonal value: aP = −γf |df |
|sf |
◦ Off-diagonal value: aN = γf |df |

◦ Source contribution: for orthogonal meshes, nothing. Non-orthogonal


correction will produce a source
• The P -to-N and N -to-P coefficients are identical: symmetric matrix. This is an
important characteristic of the diffusion operator
• For non-orthogonal meshes, a correction is added to compensate for the angle
between the face area and P N vectors

s
k
f
d ∆
P N

Pressure-Velocity Coupling in FOAM – p. 9


Diffusion Operator
Limiting Non-Orthogonal Correction in a Laplacian
• Decomposition of face gradient into “orthogonal component” and “non-orthogonal
correction” depends on mesh quality: mesh non-orthogonality is measured from
P N and sf
• Mathematically, a Laplacian is a perfect operator: smooth, bounded, self-adjoint.
Its discretisation yields a symmetric matrix
• In contrast, non-orthogonal correction is explicit, unbounded and unsigned
• Limited non-orthogonal correction: explicit part clipped to be smaller than its
implicit counterpart, base on the current solution

|sf |
λ (φN − φP ) > kf •∇(φ)f
|df |

where λ is the limiter value

Pressure-Velocity Coupling in FOAM – p. 10


Linear System of Equations
Nomenclature
• Equations form a linear system or a matrix

[A][x] = [b]

where [A] contain matrix coefficients, [x] is the value of xP in all cells and [b] is the
right-hand-side
• [A] is potentially very big: N cells × N cells
• This is a square matrix: the number of equations equals the number of unknowns
• . . . but very few coefficients are non-zero. The matrix connectivity is always local,
potentially leading to storage savings if a good format can be found

Pressure-Velocity Coupling in FOAM – p. 11


Incompressible Flow Formulation
Incompressible Flow Equations
• Decoupling dependence of density on pressure, also resulting in the decoupling of
the energy equation from the rest of the system
• Equations can be solved both in the velocity-density or velocity-pressure
formulation
◦ Velocity-density formulation does not formally allow for M a = 0 (or c = ∞),
but formally this is never the case. In practice, matrix preconditioning
techniques are used to overcome zero diagonal coefficients
◦ Velocity-pressure formulation does not suffer from low-M a limit, but performs
considerably worse at high M a number
∂u
+ ∇•(uu) − ∇• (ν∇u) = −∇p
∂t

∇•u = 0

Pressure-Velocity Coupling in FOAM – p. 12


Pressure and Velocity
Pressure – Momentum Interaction
• Counting the equations and unknowns, the system seems well posed: 1 vector
and 1 scalar field governed by 1 vector and 1 scalar equation
• Linear coupling exists between the momentum equation and continuity. Note that
u is a vector variable governed by the vector equation. Continuity equation
imposes an additional criterion on velocity divergence (∇•u). This is an example of
a scalar constraint on a vector variable, as ∇•u is a scalar
• Non-linear u − u interaction in the convection is unlikely to cause trouble: use an
iterative solution technique. In practice

∇•(uu) ≈ ∇•(uo un )

where uo is the currently available solution or an initial guess and un is the “new”
solution. The algorithm cycles until uo = un

Pressure-Velocity Coupling in FOAM – p. 13


Derivation of the Pressure Equation
Pressure Equation as a Schur Complement
• Consider a general block matrix system M , consisting of 4 block matrices, A, B, C
and D, which are respectively p × p, p × q, q × p and q × q matrices and A is
invertible:
" #
A B
C D

• This structure will arise naturally when trying to solve a block system of equations

Ax + By = a
Cx + Dy = b

• The Schur complement arises when trying to eliminate x from the system using
partial Gaussian elimination by multiplying the first row with A−1 :

A−1 Ax + A−1 By = A−1 a

and
x = A−1 a − A−1 By

Pressure-Velocity Coupling in FOAM – p. 14


Derivation of the Pressure Equation
Pressure Equation as a Schur Complement
• Substituting the above into the second row:

(D − CA−1 B)y = b − CA−1 a

• Let us repeat the same set of operations on the block form of the pressure-velocity
system, attempting to assemble a pressure equation. Note that the operators in
the block system could be considered both as differential operators and in a
discretised form
" #" # " #
[Au ] [∇(.)] u 0
=
[∇•(.)] [0] p 0

• Formally, this leads to the following form of the pressure equation:

[∇•(.)][A−1
u ][∇(.)][p] = 0

Here, A−1
u represent the inverse of the momentum matrix in the discretised form,
which acts as diffusivity in the Laplace equation for the pressure.

Pressure-Velocity Coupling in FOAM – p. 15


Derivation of the Pressure Equation
Pressure Equation as a Schur Complement
• From the above, it is clear that the governing equation for the pressure is a
Laplacian, with the momentum matrix acting as a diffusion coefficient
◦ While [Au ] is a sparse matrix, its inverse is likely to be dense
◦ Discretised form of the divergence and gradient operator are sparse and
well-behaved. However, a triple product with [A−1 u ] would result in a dense
matrix, making it expensive to solve
• The above can be remedied be decomposing the momentum matrix before the
triple product into the diagonal part and off-diagonal matrix:

[Au ] = [Du ] + [LUu ],

where [Du ] only contains diagonal entries. [Du ] is easy to invert and will preserve
the sparseness pattern in the triple product.

Pressure-Velocity Coupling in FOAM – p. 16


Derivation of the Pressure Equation
Pressure Equation as a Schur Complement
• Revisiting saddle momentum equation before the formation of the Schur
complement and moving the off-diagonal component of [Au ] onto r.h.s. yields:
" #" # " #
[Du ] [∇(.)] u −[LUu ][u]
=
[∇•(.)] [0] p 0

A revised formulation of the pressure equation via a Schur’s complement yields:

−1 −1
[∇•(.)][Du ][∇(.)][p] = [∇•(.)][Du ][LUu ][u]

−1
In both cases, matrix [Du ] is simple to assemble.
• It follows that the pressure equation is a Poisson equation with the diagonal part of
the discretised momentum acting as diffusivity and the divergence of the velocity
on the r.h.s.

Pressure-Velocity Coupling in FOAM – p. 17


Derivation of the Pressure Equation
Standard Derivation of the Pressure Equation
• We shall now rewrite the above equations to formally derive an equation for the
pressure. This may be done in several ways: formally correct involves a Schur’s
complement of the block pressure-velocity system
• Start by discretising the momentum equation using the techniques described for a
scalar transport equation. For the purposes of derivation, the pressure gradient
term will remain in the differential form. For each CV, the discretised momentum
equation yields:
X
u
aP uP + auN uN = r − ∇p
N

• For simplicity, we shall introduce the H(u) operator, containing the off-diagonal
part of the momentum matrix and any associated r.h.s. contributions:
X
H(u) = r − au
N uN
N

• Note: H(u) carries ALL rhs luggage with it: this is a matrix-level operator and
cannot distinguish individual operator contributions

Pressure-Velocity Coupling in FOAM – p. 18


Derivation of the Pressure Equation
Standard Derivation of the Pressure Equation
• Using the above, it follows:

au
P uP = H(u) − ∇p

and
−1
uP = (au
P) (H(u) − ∇p)

• Substituting the expression for uP into the incompressible continuity equation


∇•u = 0 yields
−1 −1
∇• (au = ∇•((au
 
P ) ∇p P) H(u))

This is the form of the pressure equation for incompressible fluid


• Note the implied decomposition of the momentum matrix into the diagonal and
off-diagonal contribution, where au
P is an coefficient in [Du ] matrix and H(u) is the
product [LUu ][u]

Pressure-Velocity Coupling in FOAM – p. 19


Derivation of the Pressure Equation
Assembly of Conservative Fluxes
• Pressure equation is derived from continuity: divergence-free velocity
• Looking at the discretised form of the continuity equation
X X
∇•u = sf •u = F
f f

where F is the face flux


F = sf •u

• Conservative face flux should be created from the solution of the pressure
equation. Substituting expression for u into the flux equation, it follows:

−1 −1
F = −(au
P) sf •∇p + (au
P) sf •H(u)

• Note: this is the one and only set of conservative data for the velocity:
everything else is “pretending to be” divergence-free!
• Interpolating cell-centred u to the face carries discretisation error: which
differencing scheme is correct?

Pressure-Velocity Coupling in FOAM – p. 20


Derivation of the Pressure Equation
Assembly of Conservative Fluxes
• A part of the above, (au −1 s •∇p appears during the discretisation of the
P) f
Laplacian, for each face:

|sf |
(au
P)
−1
sf •∇p = (au
P)
−1
(pN − pP ) = apN (pN − pP )
|d|

|sf |
Here, apN = (au
P)
−1
|d|
is equal to the off-diagonal matrix coefficient in the
pressure Laplacian
• Note that in order for the face flux to be conservative, assembly of the flux must ba
completely consistent with the assembly of the pressure equation (e.g.
non-orthogonal correction)

Pressure-Velocity Coupling in FOAM – p. 21


Implementation: OLD Transient Solver

fvVectorMatrix UEqn
(
fvm::ddt(U) // Uff, Oh!
+ fvm::div(phi, U)
- fvm::laplacian(nu, U)
);

solve(UEqn == -fvc::grad(p));

Pressure-Velocity Coupling in FOAM – p. 22


Implementation: OLD Transient Solver

volScalarField rUA = 1.0/UEqn.A();


U = rUA*UEqn.H();
phi = (fvc::interpolate(U) & mesh.Sf())
+ fvc::ddtPhiCorr(rUA, U, phi);
adjustPhi(phi, U, p);
fvScalarMatrix pEqn
(
fvm::laplacian(rUA, p) == fvc::div(phi)
);
pEqn.solve();
phi -= pEqn.flux();
U -= rUA*fvc::grad(p);
U.correctBoundaryConditions();

Pressure-Velocity Coupling in FOAM – p. 23


Flux Corrector
Role and Operation of fvcDdtPhiCorr
• Need to eliminate divergence of interpolated old velocity u from the H(U) operator
and replace it with the divergence of old flux!!

rDeltaT = 1.0/mesh().time().deltaT();
phiCorr = phiAbs.oldTime()
- (fvc::interpolate(U.oldTime()) & mesh().Sf());
return fvcDdtPhiCoeff*
fvc::interpolate(rDeltaT*rA)*phiCorr;
• . . . but this is horrible and inconsistent reverse engineering!
• Make sure that at the point of call phi.oldTime() and U.oldTime() are
consistent (How?!?)
• What about topo changes where old fluxes may not exist on current faces?
• Equivalent error exists with under-relaxation: not fixed!
• Let’s do this properly: eliminate the problem instead of patching up the
errors

Pressure-Velocity Coupling in FOAM – p. 24


Implementation: NEW Transient Solver

// Convection-diffusion matrix
fvVectorMatrix HUEqn
(
fvm::div(phi, U)
- fvm::laplacian(nu, U)
);

// Time derivative matrix


fvVectorMatrix ddtUEqn(fvm::ddt(U)); // Happy!

solve(ddtUEqn + HUEqn == -fvc::grad(p));

Pressure-Velocity Coupling in FOAM – p. 25


Implementation: NEW Transient Solver

U = HUEqn.H()/aU;
phi = (fvc::interpolate(U) & mesh.Sf());
adjustPhi(phi, U, p);
fvScalarMatrix pEqn
(
fvm::laplacian(1/aU, p) == fvc::div(phi)
);
pEqn.solve();
phi -= pEqn.flux();
U = 1.0/(aU + ddtUEqn.A())*
(
U*aU - fvc::grad(p) + ddtUEqn.H()
);

Pressure-Velocity Coupling in FOAM – p. 26


Implementation: OLD Steady Solver

tmp<fvVectorMatrix> UEqn
(
fvm::div(phi, U)
+ turbulence->divDevReff(U)
);

UEqn().relax(); // Uff, oh!

solve(UEqn() == -fvc::grad(p));

Pressure-Velocity Coupling in FOAM – p. 27


Implementation: OLD Steady Solver

volScalarField AU = UEqn().A();
U = UEqn().H()/AU;
phi = fvc::interpolate(U) & mesh.Sf();
adjustPhi(phi, U, p);
fvScalarMatrix pEqn
(
fvm::laplacian(1.0/AU, p) == fvc::div(phi)
);
pEqn.solve();
p.relax();
U -= fvc::grad(p)/AU;
U.correctBoundaryConditions();

Pressure-Velocity Coupling in FOAM – p. 28


Implementation: NEW Steady Solver

tmp<fvVectorMatrix> HUEqn
(
fvm::div(phi, U)
+ turbulence->divDevReff()
);

solve
(
relax(HUEqn(), UUrf) // Keep orig. matrix intact!
==
-fvc::grad(p)
);

Pressure-Velocity Coupling in FOAM – p. 29


Implementation: NEW Steady Solver

volScalarField rUA = 1/HUEqn().A();


U = rUA*HUEqn().H();
phi = fvc::interpolate(U) & mesh.Sf();
adjustPhi(phi, U, p);
fvScalarMatrix pEqn
(
fvm::laplacian(rUA, p) == fvc::div(phi)
);
pEqn.solve();
phi -= pEqn.flux();
p.relax();
U = UUrf*(U-rUA*fvc::grad(p))+(1-UUrf)*U.prevIter();
U.correctBoundaryConditions();

Pressure-Velocity Coupling in FOAM – p. 30


Clean-Up of Numerics in FOAM
Numerics Clean-Up in the New Release: Transient Solver

Pressure-Velocity Coupling in FOAM – p. 31


Clean-Up of Numerics in FOAM
Numerics Clean-Up in the New Release: Time-Step Dependence

Pressure-Velocity Coupling in FOAM – p. 32


Block-Coupled Algorithms
Block-Coupled Pressure-Velocity Algorithms
• It is possible to formulate a system of equations which will discretise both the
pressure and momentum equation in a single matrix and solve them together:
pressure-based block-coupled solver
• Efficiency of such algorithms is good for steady-state computations
• . . . but at a cost of considerable increase in storage and choice of linear solver
technology
• Advantage of the pressure-based formulation is that it does not break down at the
incompressibility limit, unlike the density-based block-coupled algorithms

Pressure-Velocity Coupling in FOAM – p. 33


Performance of the Coupled p-U Solver
Performance Improvements of the Coupled p-U Solver: Speed and Robustness

Pressure-Velocity Coupling in FOAM – p. 34


Performance of the Coupled p-U Solver
Performance Improvements of the Coupled p-U Solver: Speed and Robustness

Pressure-Velocity Coupling in FOAM – p. 35

Vous aimerez peut-être aussi