7.5 Indexing of unknowns 99
So it works and we obtained all the required solutions, including one for P by
the Gaussian elimination (we could also have inferred this from the fact that
we have three equations for the three unknowns v
x
, v
y
and P). Of course, it
would be impossible to apply (without reordering of equations and re-indexing of
unknowns) the same Gaussian elimination approach if the order of global indices
(and respectively equations) was inverted, i.e.
equation 1 (formulated for P ): 3v
y
+ v
x
= 5,
equation 2 (formulated for v
y
): 6P + 9v
y
+ 3v
x
= 21,
equation 3 (formulated for v
x
): 2P + 4v
y
+ 2v
x
= 10.
It should be mentioned, however, that more advanced direct solvers (including ‘\’
command of MATLAB) have internal re-ordering procedures that allow one to
obtain solutions in the latter case as well.
An alternative staggered grid structure uses ghost velocity nodes to formulate
boundary condition equations for v
x
and v
y
velocity components (Fig. 7.17). These
equations are not explicitly added to the global matrix and therefore the respective
unknowns for the ghost nodes are not indexed. Instead, these boundary condition
equations are used in an implicit manner by taking them into account while dis-
cretising the momentum and continuity equations for the internal nodes of the grid
located next to the ghost nodes. Values of v
x
and v
y
velocities in the ghost nodes are
recovered from the boundary condition equations after obtaining a global solution
for internal nodes. The manner of indexing unknowns is shown in Fig. 7.17 and
again is based on a convention that relates staggered nodes to (part of) the basic
nodes of the grid, numbered as
in
node
= (j −1) ×(N
y
− 1) +i,
where in
node
is the index for the given node, i and j are indices for the vertical
and horizontal gridlines intersecting at the considered node (Fig. 7.17). Note that
only (N
x
− 1) ×(N
y
− 1) basic nodes are numbered. Unknowns attached for each
numbered basic node are indexed respectively from 1 to (N
x
− 1) ×(N
y
− 1) ×3
according to the increasing basic node index
in
v
x
= 3 × in
node
− 2,
in
v
y
= 3 × in
node
− 1,
in
P
= 3 × in
node
.
This way of indexing again ensures that the index for pressure in a cell is bigger than
the indices for all the velocities surrounding the cell. The main advantage of this
staggered grid structure is that there is a smaller number of unknowns in the global
matrix equal to (N
x
− 1) × (N
y
− 1) × 3. In addition, the boundary condition for