diff --git a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixTemplates.C b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixTemplates.C index fa5236bd99..11ece2171d 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixTemplates.C +++ b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixTemplates.C @@ -57,22 +57,7 @@ Foam::tmp > Foam::lduMatrix::H(const Field& psi) const for (register label face=0; face Foam::tmp > Foam::lduMatrix::faceH(const Field& psi) const { - const scalarField& Lower = const_cast(*this).lower(); - const scalarField& Upper = const_cast(*this).upper(); - - // Take refereces to addressing - const unallocLabelList& l = lduAddr().lowerAddr(); - const unallocLabelList& u = lduAddr().upperAddr(); - - tmp > tfaceHpsi(new Field (Lower.size())); - Field & faceHpsi = tfaceHpsi(); - - for (register label face=0; face(*this).lower(); + const scalarField& Upper = const_cast(*this).upper(); - return tfaceHpsi; + const unallocLabelList& l = lduAddr().lowerAddr(); + const unallocLabelList& u = lduAddr().upperAddr(); + + tmp > tfaceHpsi(new Field (Lower.size())); + Field & faceHpsi = tfaceHpsi(); + + for (register label face=0; face& psi) const") + << "Cannot calculate faceH" + " the matrix does not have any off-diagonal coefficients." + << exit(FatalError); + + return tmp >(NULL); + } } diff --git a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C index 0fcf2e626d..78fede73f8 100644 --- a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C +++ b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C @@ -1303,7 +1303,14 @@ Foam::tmp > Foam::correction const fvMatrix& A ) { - return A - (A & A.psi()); + tmp > tAcorr = A - (A & A.psi()); + + if ((A.hasUpper() || A.hasLower()) && A.mesh().fluxRequired(A.psi().name())) + { + tAcorr().faceFluxCorrectionPtr() = (-A.flux()).ptr(); + } + + return tAcorr; } @@ -1313,7 +1320,17 @@ Foam::tmp > Foam::correction const tmp >& tA ) { - return tA - (tA() & tA().psi()); + tmp > tAcorr = tA - (tA() & tA().psi()); + + // Note the matrix coefficients are still that of matrix A + const fvMatrix& A = tAcorr(); + + if ((A.hasUpper() || A.hasLower()) && A.mesh().fluxRequired(A.psi().name())) + { + tAcorr().faceFluxCorrectionPtr() = (-A.flux()).ptr(); + } + + return tAcorr; }