diff --git a/src/VectorN/finiteVolume/blockMatrixTools/blockMatrixTools.C b/src/VectorN/finiteVolume/blockMatrixTools/blockMatrixTools.C index e51fa657d..29140382c 100644 --- a/src/VectorN/finiteVolume/blockMatrixTools/blockMatrixTools.C +++ b/src/VectorN/finiteVolume/blockMatrixTools/blockMatrixTools.C @@ -446,6 +446,45 @@ void insertCoupling } +template +void updateSourceCoupling +( + BlockLduMatrix& blockM, + Field& x, + Field& b +) +{ + // Eliminate off-diagonal block coefficients from the square diagonal + // With this change, the segregated matrix can be assembled with complete + // source terms and linearisation can be provided independently. + // Once the linearisation coefficients are set (off-diagonal entries + // in the square block matrix, they are multiplied by the current value + // of the field and subtracted from the source term + + if (blockM.diag().activeType() == blockCoeffBase::SQUARE) + { + typename CoeffField::squareTypeField& blockDiag = + blockM.diag().asSquare(); + + typename CoeffField::linearTypeField lf(blockDiag.size()); + typename CoeffField::squareTypeField sf(blockDiag.size()); + + // Expand and contract + + // Take out the diagonal entries from the square coefficient + contractLinear(lf, blockDiag); + + // Expand the diagonal for full square, with zeroes in the off-diagonal + expandLinear(sf, lf); + + // Subtract from the source the difference between the full block + // diagonal and the diagonal terms only + // Sign is the same as in the derivative + b += (blockDiag - sf) & x; + } +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace blockMatrixTools diff --git a/src/VectorN/finiteVolume/blockMatrixTools/blockMatrixTools.H b/src/VectorN/finiteVolume/blockMatrixTools/blockMatrixTools.H index 9e275c781..5377ecc55 100644 --- a/src/VectorN/finiteVolume/blockMatrixTools/blockMatrixTools.H +++ b/src/VectorN/finiteVolume/blockMatrixTools/blockMatrixTools.H @@ -153,7 +153,7 @@ namespace blockMatrixTools // Subtracts the block-coefficient coupling as specified by the user // from the source, leaving the implicit update given by linearisation template - void updateCoupling + void updateSourceCoupling ( BlockLduMatrix& blockM, Field& x,