From cc9053b3cb92c3211d9b64802336e5bfa3848740 Mon Sep 17 00:00:00 2001 From: Hrvoje Jasak Date: Fri, 15 Apr 2011 11:13:19 +0100 Subject: [PATCH] Residual calculation bug fix --- src/finiteVolume/fvMatrices/fvMatrix/fvMatrixSolve.C | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrixSolve.C b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrixSolve.C index 87e4e7242..ba63f5a49 100644 --- a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrixSolve.C +++ b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrixSolve.C @@ -95,7 +95,7 @@ Foam::lduMatrix::solverPerformance Foam::fvMatrix::solve { if (validComponents[cmpt] == -1) continue; - // copy field and source + // Copy field and source scalarField psiCmpt = psi_.internalField().component(cmpt); addBoundaryDiag(diag(), cmpt); @@ -191,7 +191,9 @@ Foam::lduMatrix::solverPerformance Foam::fvMatrix::solve() template Foam::tmp > Foam::fvMatrix::residual() const { - tmp > tres(source_); + // Bug fix: Creating a tmp out of a const reference will change the field + // HJ, 15/Apr/2011 + tmp > tres(new Field(source_)); Field& res = tres(); addBoundarySource(res); @@ -201,11 +203,11 @@ Foam::tmp > Foam::fvMatrix::residual() const lduInterfaceFieldPtrsList interfaces = psi_.boundaryField().interfaces(); // Loop over field components - for (direction cmpt=0; cmpt bouCoeffsCmpt