From d4edb38234db8268907f04836d49bb93461b8a88 Mon Sep 17 00:00:00 2001 From: andy Date: Mon, 8 Jun 2009 12:17:16 +0100 Subject: [PATCH] added matrix correction operation --- src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C | 50 ++++++++++++++++++++++++- src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H | 12 ++++++ 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C index 7403554..3b48854 100644 --- a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C +++ b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C @@ -1268,7 +1268,10 @@ Foam::lduMatrix::solverPerformance Foam::solve(fvMatrix& fvm) } template -Foam::lduMatrix::solverPerformance Foam::solve(const tmp >& tfvm) +Foam::lduMatrix::solverPerformance Foam::solve +( + const tmp >& tfvm +) { lduMatrix::solverPerformance solverPerf = const_cast&>(tfvm()).solve(); @@ -1279,6 +1282,51 @@ Foam::lduMatrix::solverPerformance Foam::solve(const tmp >& tfvm) } +template +Foam::tmp > Foam::correction +( + const fvMatrix& A +) +{ + tmp > tAcorr = A - (A & A.psi()); + + if + ( + (A.hasUpper() || A.hasLower()) + && A.mesh().fluxRequired(A.psi().name()) + ) + { + tAcorr().faceFluxCorrectionPtr() = (-A.flux()).ptr(); + } + + return tAcorr; +} + + +template +Foam::tmp > Foam::correction +( + const tmp >& tA +) +{ + 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; +} + + // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // template diff --git a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H index 3171bec..056ce56 100644 --- a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H +++ b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H @@ -536,6 +536,18 @@ template lduMatrix::solverPerformance solve(const tmp >&); +//- Return the correction form of the given matrix +// by subtracting the matrix multiplied by the current field +template +tmp > correction(const fvMatrix&); + + +//- Return the correction form of the given temporary matrix +// by subtracting the matrix multiplied by the current field +template +tmp > correction(const tmp >&); + + // * * * * * * * * * * * * * * * Global operators * * * * * * * * * * * * * // template -- 2.11.4.GIT