Bugfix: processor polling in non-blocking comms

This commit is contained in:
Hrvoje Jasak 2016-11-29 12:44:48 +00:00
parent 727c4d67fb
commit a91cb63d88
5 changed files with 85 additions and 118 deletions

View file

@ -600,4 +600,40 @@ void Foam::processorFvPatchField<Type>::updateInterfaceMatrix
}
template<class Type>
bool Foam::processorFvPatchField<Type>::ready() const
{
if
(
outstandingSendRequest_ >= 0
&& outstandingSendRequest_ < Pstream::nRequests()
)
{
bool finished = Pstream::finishedRequest(outstandingSendRequest_);
if (!finished)
{
return false;
}
}
outstandingSendRequest_ = -1;
if
(
outstandingRecvRequest_ >= 0
&& outstandingRecvRequest_ < Pstream::nRequests()
)
{
bool finished = Pstream::finishedRequest(outstandingRecvRequest_);
if (!finished)
{
return false;
}
}
outstandingRecvRequest_ = -1;
return true;
}
// ************************************************************************* //

View file

@ -285,6 +285,9 @@ public:
// Communication support
//- Is all data available
virtual bool ready() const;
//- Return communicator used for parallel communication
virtual int comm() const
{

View file

@ -32,26 +32,6 @@ namespace Foam
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<>
void processorFvPatchField<scalar>::initInterfaceMatrixUpdate
(
const scalarField& psiInternal,
scalarField&,
const lduMatrix&,
const scalarField&,
const direction,
const Pstream::commsTypes commsType,
const bool switchToLhs
) const
{
procPatch_.send
(
commsType,
patch().patchInternalField(psiInternal)()
);
}
template<>
void processorFvPatchField<scalar>::updateInterfaceMatrix
(
@ -64,82 +44,60 @@ void processorFvPatchField<scalar>::updateInterfaceMatrix
const bool switchToLhs
) const
{
scalarField pnf
(
procPatch_.receive<scalar>(commsType, this->size())()
);
if (this->updatedMatrix())
{
return;
}
const unallocLabelList& faceCells = patch().faceCells();
if (commsType == Pstream::nonBlocking)
{
// Fast path.
if
(
outstandingRecvRequest_ >= 0
&& outstandingRecvRequest_ < Pstream::nRequests()
)
{
Pstream::waitRequest(outstandingRecvRequest_);
}
// Recv finished so assume sending finished as well.
outstandingSendRequest_ = -1;
outstandingRecvRequest_ = -1;
}
else
{
// Check size
scalarReceiveBuf_.setSize(this->size());
procPatch_.receive<scalar>(commsType, scalarReceiveBuf_);
}
// The data is now in scalarReceiveBuf_ for both cases
// Transform according to the transformation tensor
// No transform for scalar. HJ, 29/Nov/2016
// Multiply the field by coefficients and add into the result
const unallocLabelList& faceCells = this->patch().faceCells();
if (switchToLhs)
{
forAll (faceCells, facei)
forAll(faceCells, elemI)
{
result[faceCells[facei]] += coeffs[facei]*pnf[facei];
result[faceCells[elemI]] += coeffs[elemI]*scalarReceiveBuf_[elemI];
}
}
else
{
forAll (faceCells, facei)
forAll(faceCells, elemI)
{
result[faceCells[facei]] -= coeffs[facei]*pnf[facei];
}
result[faceCells[elemI]] -= coeffs[elemI]*scalarReceiveBuf_[elemI];
}
}
template<>
void processorFvPatchField<scalar>::initInterfaceMatrixUpdate
(
const scalarField& psiInternal,
scalarField&,
const BlockLduMatrix<scalar>&,
const CoeffField<scalar>&,
const Pstream::commsTypes commsType,
const bool switchToLhs
) const
{
procPatch_.send
(
commsType,
patch().patchInternalField(psiInternal)()
);
}
template<>
void processorFvPatchField<scalar>::updateInterfaceMatrix
(
const scalarField&,
scalarField& result,
const BlockLduMatrix<scalar>&,
const CoeffField<scalar>& coeffs,
const Pstream::commsTypes commsType,
const bool switchToLhs
) const
{
scalarField pnf
(
procPatch_.receive<scalar>(commsType, this->size())()
);
const unallocLabelList& faceCells = patch().faceCells();
const scalarField& scalarCoeffs = coeffs.asScalar();
if (switchToLhs)
{
forAll (faceCells, facei)
{
result[faceCells[facei]] += scalarCoeffs[facei]*pnf[facei];
}
}
else
{
forAll (faceCells, facei)
{
result[faceCells[facei]] -= scalarCoeffs[facei]*pnf[facei];
}
}
const_cast<processorFvPatchField<scalar>&>(*this).updatedMatrix() = true;
}

View file

@ -36,18 +36,8 @@ namespace Foam
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<>
void processorFvPatchField<scalar>::initInterfaceMatrixUpdate
(
const scalarField&,
scalarField&,
const lduMatrix&,
const scalarField&,
const direction,
const Pstream::commsTypes commsType,
const bool switchToLhs
) const;
// Removed unnecessary specialisation for initInterfaceMatrixUpdate
// HJ, 29/Nov/2016
template<>
void processorFvPatchField<scalar>::updateInterfaceMatrix
@ -62,29 +52,11 @@ void processorFvPatchField<scalar>::updateInterfaceMatrix
) const;
template<>
void processorFvPatchField<scalar>::initInterfaceMatrixUpdate
(
const scalarField& psiInternal,
scalarField&,
const BlockLduMatrix<scalar>&,
const CoeffField<scalar>&,
const Pstream::commsTypes commsType,
const bool switchToLhs
) const;
// Removed unnecessary specialisation for initInterfaceMatrixUpdate
// and updateInterfaceMatrix for block matrices
// HJ, 29/Nov/2016
template<>
void processorFvPatchField<scalar>::updateInterfaceMatrix
(
const scalarField&,
scalarField& result,
const BlockLduMatrix<scalar>&,
const CoeffField<scalar>& coeffs,
const Pstream::commsTypes commsType,
const bool switchToLhs
) const;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam

View file

@ -922,8 +922,6 @@ Foam::Pstream::defaultCommsType
(
"commsType",
"nonBlocking",
// "scheduled",
// "blocking",
"blocking, nonBlocking, scheduled"
);