From 5e020d39a1f7b7f14202d0bdae3080a543d82eb7 Mon Sep 17 00:00:00 2001 From: Henry Date: Mon, 21 Mar 2011 10:52:54 +0000 Subject: [PATCH] fvMatrix: Added properly parallel matrix scaling operation Note that the previous version which allows matrix scaling by a dimensionedScalarField is not currently correct for asymmetric matrices in parallel and the transfer of the scaling factor values from the neighbouring processors is required. --- .../fvMatrices/fvMatrix/fvMatrix.C | 37 +++++++++++++++++++ .../fvMatrices/fvMatrix/fvMatrix.H | 1 + 2 files changed, 38 insertions(+) diff --git a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C index 618959fb79..85ab9c341b 100644 --- a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C +++ b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C @@ -1180,6 +1180,43 @@ void Foam::fvMatrix::operator*= } +template +void Foam::fvMatrix::operator*= +( + const volScalarField& vsf +) +{ + dimensions_ *= vsf.dimensions(); + lduMatrix::operator*=(vsf.field()); + source_ *= vsf.field(); + + forAll(vsf.boundaryField(), patchI) + { + const fvPatchScalarField& psf = vsf.boundaryField()[patchI]; + + if (psf.coupled()) + { + internalCoeffs_[patchI] *= psf.patchInternalField(); + boundaryCoeffs_[patchI] *= psf.patchNeighbourField(); + } + else + { + internalCoeffs_[patchI] *= psf.patchInternalField(); + boundaryCoeffs_[patchI] *= psf; + } + } + + if (faceFluxCorrectionPtr_) + { + FatalErrorIn + ( + "fvMatrix::operator*=" + "(const DimensionedField&)" + ) << "cannot scale a matrix containing a faceFluxCorrection" + << abort(FatalError); + } +} + template void Foam::fvMatrix::operator*= ( diff --git a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H index 8e53051af6..0d1ba42623 100644 --- a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H +++ b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H @@ -460,6 +460,7 @@ public: void operator*=(const DimensionedField&); void operator*=(const tmp >&); + void operator*=(const volScalarField&); void operator*=(const tmp&); void operator*=(const dimensioned&);