diff --git a/src/coupledMatrix/coupledLduMatrix/coupledLduMatrix.C b/src/coupledMatrix/coupledLduMatrix/coupledLduMatrix.C index 93c39a017..b8e7fc68a 100644 --- a/src/coupledMatrix/coupledLduMatrix/coupledLduMatrix.C +++ b/src/coupledMatrix/coupledLduMatrix/coupledLduMatrix.C @@ -195,7 +195,8 @@ void Foam::coupledLduMatrix::initMatrixInterfaces const lduInterfaceFieldPtrsListList& interfaces, const FieldField& x, FieldField& result, - const direction cmpt + const direction cmpt, + const bool switchToLhs ) const { const PtrList& matrices = *this; @@ -205,7 +206,7 @@ void Foam::coupledLduMatrix::initMatrixInterfaces // interfaces. The reason is that non-processor coupled // interfaces require a complex comms pattern involving more than // pairwise communications. - // Under normal circumstances this is achieved naturall, since + // Under normal circumstances this is achieved naturally, since // processor interfaces come last on the list and other coupled // interfaces execute complex comms at init() level. // For coupled matrices, the update loop needs to be split over @@ -244,22 +245,66 @@ void Foam::coupledLduMatrix::initMatrixInterfaces ( Pstream::defaultCommsType() ), - false + switchToLhs ); } } } } + else if (Pstream::defaultCommsType() == Pstream::scheduled) + { + // ERROR: Does not work with scheduled comms. + // To investigate. HJ, 11/Jun/2015 + forAll (matrices, rowI) + { + const lduSchedule& patchSchedule = + matrices[rowI].patchSchedule(); + + // Loop over the "global" patches are on the list of + // interfaces but beyond the end of the schedule + // which only handles "normal" patches + for + ( + label interfaceI = patchSchedule.size()/2; + interfaceI < interfaces.size(); + interfaceI++ + ) + { + if (interfaces[rowI].set(interfaceI)) + { + if + ( + !isA + ( + interfaces[rowI][interfaceI] + ) + ) + { + interfaces[rowI][interfaceI]. + initInterfaceMatrixUpdate + ( + x[rowI], + result[rowI], + matrices[rowI], + coupleCoeffs[rowI][interfaceI], + cmpt, + static_cast + ( + Pstream::defaultCommsType() + ), + switchToLhs + ); + } + } + } + } + } else { - matrices[rowI].initMatrixInterfaces - ( - coupleCoeffs[rowI], - interfaces[rowI], - x[rowI], - result[rowI], - cmpt - ); + FatalErrorIn("void coupledLduMatrix::initMatrixInterfaces") + << "Unsuported communications type " + << Pstream::commsTypeNames[Pstream::defaultCommsType()] + << exit(FatalError); } } @@ -295,12 +340,67 @@ void Foam::coupledLduMatrix::initMatrixInterfaces ( Pstream::defaultCommsType() ), - false + switchToLhs ); } } } } + else if (Pstream::defaultCommsType() == Pstream::scheduled) + { + // ERROR: Does not work with scheduled comms. + // To investigate. HJ, 11/Jun/2015 + forAll (matrices, rowI) + { + const lduSchedule& patchSchedule = + matrices[rowI].patchSchedule(); + + // Loop over the "global" patches are on the list of + // interfaces but beyond the end of the schedule + // which only handles "normal" patches + for + ( + label interfaceI = patchSchedule.size()/2; + interfaceI < interfaces.size(); + interfaceI++ + ) + { + if (interfaces[rowI].set(interfaceI)) + { + if + ( + isA + ( + interfaces[rowI][interfaceI] + ) + ) + { + interfaces[rowI][interfaceI]. + initInterfaceMatrixUpdate + ( + x[rowI], + result[rowI], + matrices[rowI], + coupleCoeffs[rowI][interfaceI], + cmpt, + static_cast + ( + Pstream::defaultCommsType() + ), + switchToLhs + ); + } + } + } + } + } + else + { + FatalErrorIn("void coupledLduMatrix::initMatrixInterfaces") + << "Unsuported communications type " + << Pstream::commsTypeNames[Pstream::defaultCommsType()] + << exit(FatalError); + } } } @@ -311,7 +411,8 @@ void Foam::coupledLduMatrix::updateMatrixInterfaces const lduInterfaceFieldPtrsListList& interfaces, const FieldField& x, FieldField& result, - const direction cmpt + const direction cmpt, + const bool switchToLhs ) const { const PtrList& matrices = *this; @@ -324,7 +425,8 @@ void Foam::coupledLduMatrix::updateMatrixInterfaces interfaces[rowI], x[rowI], result[rowI], - cmpt + cmpt, + switchToLhs ); } } diff --git a/src/coupledMatrix/coupledLduMatrix/coupledLduMatrix.H b/src/coupledMatrix/coupledLduMatrix/coupledLduMatrix.H index 67d5a1d22..8d762faf9 100644 --- a/src/coupledMatrix/coupledLduMatrix/coupledLduMatrix.H +++ b/src/coupledMatrix/coupledLduMatrix/coupledLduMatrix.H @@ -128,7 +128,8 @@ public: const lduInterfaceFieldPtrsListList& interfaces, const FieldField& x, FieldField& result, - const direction cmpt + const direction cmpt, + const bool switchToLhs = false ) const; //- Update coupled interfaces for matrix operations @@ -138,7 +139,8 @@ public: const lduInterfaceFieldPtrsListList& interfaces, const FieldField& x, FieldField& result, - const direction cmpt + const direction cmpt, + const bool switchToLhs = false ) const; }; diff --git a/src/coupledMatrix/coupledLduPrecon/GaussSeidelPrecon/coupledGaussSeidelPrecon.C b/src/coupledMatrix/coupledLduPrecon/GaussSeidelPrecon/coupledGaussSeidelPrecon.C index b7f46cdb6..361518b89 100644 --- a/src/coupledMatrix/coupledLduPrecon/GaussSeidelPrecon/coupledGaussSeidelPrecon.C +++ b/src/coupledMatrix/coupledLduPrecon/GaussSeidelPrecon/coupledGaussSeidelPrecon.C @@ -340,7 +340,8 @@ void Foam::coupledGaussSeidelPrecon::precondition interfaces_, x, bPrime_, - cmpt + cmpt, + true // switch to lhs ); matrix_.updateMatrixInterfaces @@ -349,7 +350,8 @@ void Foam::coupledGaussSeidelPrecon::precondition interfaces_, x, bPrime_, - cmpt + cmpt, + true // switch to lhs ); }