diff --git a/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixUpdateMatrixInterfaces.C b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixUpdateMatrixInterfaces.C index 5376a1947b..2bf5f533fe 100644 --- a/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixUpdateMatrixInterfaces.C +++ b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixUpdateMatrixInterfaces.C @@ -128,28 +128,42 @@ void Foam::LduMatrix::updateMatrixInterfaces // without waiting for all requests. DynamicList indices; // (work array) - while + + for ( - UPstream::nPollProcInterfaces < 0 - && UPstream::waitSomeRequests(startRequest, &indices) + bool pollingActive = (UPstream::nPollProcInterfaces < 0); + ( + pollingActive + && UPstream::waitSomeRequests(startRequest, &indices) + ); + /*nil*/ ) { + pollingActive = false; + forAll(interfaces_, interfacei) { auto* intf = interfaces_.get(interfacei); - if (intf && !intf->updatedMatrix() && intf->ready()) + if (intf && !intf->updatedMatrix()) { - intf->updateInterfaceMatrix - ( - result, - add, - lduMesh_.lduAddr(), - interfacei, - psiif, - interfaceCoeffs[interfacei], - commsType - ); + if (intf->ready()) + { + intf->updateInterfaceMatrix + ( + result, + add, + lduMesh_.lduAddr(), + interfacei, + psiif, + interfaceCoeffs[interfacei], + commsType + ); + } + else + { + pollingActive = true; + } } } } diff --git a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixUpdateMatrixInterfaces.C b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixUpdateMatrixInterfaces.C index 1d20ed7023..17fbdc6043 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixUpdateMatrixInterfaces.C +++ b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixUpdateMatrixInterfaces.C @@ -131,29 +131,50 @@ void Foam::lduMatrix::updateMatrixInterfaces // without waiting for all requests. DynamicList indices; // (work array) - while + + // const label maxPolling = + // ( + // (UPstream::nPollProcInterfaces < 0) + // ? (UPstream::nRequests() - startRequest) + // : UPstream::nPollProcInterfaces + // ); + + for ( - UPstream::nPollProcInterfaces < 0 - && UPstream::waitSomeRequests(startRequest, &indices) + bool pollingActive = (UPstream::nPollProcInterfaces < 0); + ( + pollingActive + && UPstream::waitSomeRequests(startRequest, &indices) + ); + /*nil*/ ) { + pollingActive = false; + forAll(interfaces, interfacei) { auto* intf = interfaces.get(interfacei); - if (intf && !intf->updatedMatrix() && intf->ready()) + if (intf && !intf->updatedMatrix()) { - intf->updateInterfaceMatrix - ( - result, - add, - mesh().lduAddr(), - interfacei, - psiif, - coupleCoeffs[interfacei], - cmpt, - commsType - ); + if (intf->ready()) + { + intf->updateInterfaceMatrix + ( + result, + add, + mesh().lduAddr(), + interfacei, + psiif, + coupleCoeffs[interfacei], + cmpt, + commsType + ); + } + else + { + pollingActive = true; + } } } }