OpenFOAM guide/LduMatrix;;negSumDiag

From OpenFOAMWiki

Subtracts the off-diagonal entries from the diagonal.

for (register label face=0; face<l.size(); face++)
    Diag[l[face]] -= Lower[face];
    Diag[u[face]] -= Upper[face];


  • Diag is the diagonal coefficient;
  • l is the lduAddressing for the lower triangle;
  • u is the lduAddressing for the upper triangle;
  • Lower is the lower triangle; and
  • Upper is the upper triangle.

In terms of discretization coefficients, this is equivalent to:

A_p = \sum\limits_r A_r

and in terms of matrix coefficients, this is:

A_{ii} = -\sum\limits_o A_{o,i} -\sum\limits_n A_{n,i}