mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: relax processorField waiting requirements
- for interface polling previously required that both send and recv
requests were completed before evaluating (values or matrix update).
However, only the recv needs to be complete, which helps disentangle
the inter-rank waiting.
NB: this change is possible following (1f5cf3958b) that replaced
UPstream::resetRequests() call in favour of UPstream::waitRequests()
This commit is contained in:
@ -58,12 +58,25 @@ Foam::lduCalculatedProcessorField<Type>::lduCalculatedProcessorField
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
bool Foam::lduCalculatedProcessorField<Type>::ready() const
|
||||
bool Foam::lduCalculatedProcessorField<Type>::all_ready() const
|
||||
{
|
||||
return UPstream::finishedRequestPair(recvRequest_, sendRequest_);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
bool Foam::lduCalculatedProcessorField<Type>::ready() const
|
||||
{
|
||||
const bool ok = UPstream::finishedRequest(recvRequest_);
|
||||
if (ok)
|
||||
{
|
||||
recvRequest_ = -1;
|
||||
if (UPstream::finishedRequest(sendRequest_)) sendRequest_ = -1;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::lduCalculatedProcessorField<Type>::initInterfaceMatrixUpdate
|
||||
(
|
||||
@ -77,10 +90,11 @@ void Foam::lduCalculatedProcessorField<Type>::initInterfaceMatrixUpdate
|
||||
const Pstream::commsTypes commsType
|
||||
) const
|
||||
{
|
||||
if (!this->ready())
|
||||
if (!this->all_ready())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Outstanding request."
|
||||
<< "Outstanding request(s) on interface "
|
||||
//<< procInterface_.name()
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
@ -167,12 +181,12 @@ void Foam::lduCalculatedProcessorField<Type>::updateInterfaceMatrix
|
||||
return;
|
||||
}
|
||||
|
||||
// Require receive data. Update the send request state.
|
||||
// OR: UPstream::waitRequestPair(recvRequest_, sendRequest_);
|
||||
|
||||
{
|
||||
// Require receive data.
|
||||
// Only update the send request state.
|
||||
UPstream::waitRequest(recvRequest_); recvRequest_ = -1;
|
||||
if (UPstream::finishedRequest(sendRequest_)) sendRequest_ = -1;
|
||||
|
||||
}
|
||||
|
||||
// Consume straight from receive buffer. Note use of our own
|
||||
// helper to avoid using fvPatch addressing
|
||||
|
||||
@ -103,6 +103,9 @@ protected:
|
||||
const solveScalarField& vals
|
||||
) const;
|
||||
|
||||
//- Receive and send requests have both completed
|
||||
virtual bool all_ready() const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
@ -112,14 +115,13 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from patch and internal field
|
||||
lduCalculatedProcessorField
|
||||
//- Construct from ldu interface
|
||||
explicit lduCalculatedProcessorField
|
||||
(
|
||||
const lduInterface& interface
|
||||
//const Field<Type>&
|
||||
);
|
||||
|
||||
//- Construct as copy
|
||||
//- Copy construct
|
||||
lduCalculatedProcessorField
|
||||
(
|
||||
const lduCalculatedProcessorField<Type>&
|
||||
@ -132,48 +134,9 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
//- Return communicator used for comms
|
||||
virtual label comm() const
|
||||
{
|
||||
return procInterface_.comm();
|
||||
}
|
||||
|
||||
//- Return processor number
|
||||
virtual int myProcNo() const
|
||||
{
|
||||
return procInterface_.myProcNo();
|
||||
}
|
||||
|
||||
//- Return neighbour processor number
|
||||
virtual int neighbProcNo() const
|
||||
{
|
||||
return procInterface_.myProcNo();
|
||||
}
|
||||
|
||||
//- Is the transform required
|
||||
virtual bool doTransform() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//- Return face transformation tensor
|
||||
virtual const tensorField& forwardT() const
|
||||
{
|
||||
return procInterface_.forwardT();
|
||||
}
|
||||
|
||||
//- Return rank of component for transform
|
||||
virtual int rank() const
|
||||
{
|
||||
return pTraits<Type>::rank;
|
||||
}
|
||||
|
||||
|
||||
// Evaluation
|
||||
|
||||
//- Is all data available
|
||||
//- Are all (receive) data available?
|
||||
virtual bool ready() const;
|
||||
|
||||
//- Initialise neighbour matrix update
|
||||
@ -231,6 +194,45 @@ public:
|
||||
{
|
||||
NotImplemented;
|
||||
}
|
||||
|
||||
|
||||
// Processor coupled interface functions
|
||||
|
||||
//- Return communicator used for communication
|
||||
virtual label comm() const
|
||||
{
|
||||
return procInterface_.comm();
|
||||
}
|
||||
|
||||
//- Return processor number
|
||||
virtual int myProcNo() const
|
||||
{
|
||||
return procInterface_.myProcNo();
|
||||
}
|
||||
|
||||
//- Return neighbour processor number
|
||||
virtual int neighbProcNo() const
|
||||
{
|
||||
return procInterface_.myProcNo();
|
||||
}
|
||||
|
||||
//- Is the transform required
|
||||
virtual bool doTransform() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//- Return face transformation tensor
|
||||
virtual const tensorField& forwardT() const
|
||||
{
|
||||
return procInterface_.forwardT();
|
||||
}
|
||||
|
||||
//- Return rank of component for transform
|
||||
virtual int rank() const
|
||||
{
|
||||
return pTraits<Type>::rank;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -136,4 +136,5 @@ Foam::lduPrimitiveProcessorInterface::internalFieldTransfer
|
||||
return processorLduInterface::receive<label>(commsType, faceCells_.size());
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -58,6 +58,7 @@ class lduPrimitiveProcessorInterface
|
||||
{
|
||||
// Private Data
|
||||
|
||||
//- Addressing
|
||||
const labelList faceCells_;
|
||||
|
||||
//- My processor rank in communicator
|
||||
@ -76,19 +77,18 @@ class lduPrimitiveProcessorInterface
|
||||
const label comm_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
|
||||
//- No copy assignment
|
||||
void operator=(const lduPrimitiveProcessorInterface&) = delete;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeNameNoDebug("processorInterface");
|
||||
|
||||
|
||||
// Generated Methods
|
||||
|
||||
//- No copy assignment
|
||||
void operator=(const lduPrimitiveProcessorInterface&) = delete;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
@ -199,7 +199,7 @@ public:
|
||||
|
||||
// Edit
|
||||
|
||||
//- Return message tag used for sending
|
||||
//- Message tag used for sending (modifiable)
|
||||
int& tag()
|
||||
{
|
||||
return tag_;
|
||||
|
||||
@ -40,9 +40,9 @@ SourceFiles
|
||||
#define Foam_lduInterfaceField_H
|
||||
|
||||
#include "lduInterface.H"
|
||||
#include "lduAddressing.H"
|
||||
#include "primitiveFieldsFwd.H"
|
||||
#include "Pstream.H"
|
||||
#include "lduAddressing.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -100,8 +100,6 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
//- Return the interface
|
||||
const lduInterface& interface() const noexcept
|
||||
{
|
||||
@ -115,7 +113,13 @@ public:
|
||||
}
|
||||
|
||||
|
||||
// Coupled interface matrix update
|
||||
// Coupled Interface
|
||||
|
||||
//- Are all (receive) data available?
|
||||
virtual bool ready() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//- Whether matrix has been updated
|
||||
bool updatedMatrix() const noexcept
|
||||
@ -131,11 +135,8 @@ public:
|
||||
return old;
|
||||
}
|
||||
|
||||
//- Is all data available
|
||||
virtual bool ready() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Coupled interface matrix update
|
||||
|
||||
//- Initialise neighbour matrix update.
|
||||
//- Add/subtract coupled contributions to matrix
|
||||
|
||||
@ -84,10 +84,10 @@ Foam::processorFaPatchField<Type>::processorFaPatchField
|
||||
<< " in file " << this->internalField().objectPath()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
if (debug && !ptf.ready())
|
||||
if (debug && !ptf.all_ready())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "On patch " << procPatch_.name() << " outstanding request."
|
||||
<< "Outstanding request(s) on patch " << procPatch_.name()
|
||||
<< abort(FatalError);
|
||||
}
|
||||
}
|
||||
@ -141,10 +141,10 @@ Foam::processorFaPatchField<Type>::processorFaPatchField
|
||||
scalarSendBuf_(std::move(ptf.scalarSendBuf_)),
|
||||
scalarRecvBuf_(std::move(ptf.scalarRecvBuf_))
|
||||
{
|
||||
if (debug && !ptf.ready())
|
||||
if (debug && !ptf.all_ready())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "On patch " << procPatch_.name() << " outstanding request."
|
||||
<< "Outstanding request(s) on patch " << procPatch_.name()
|
||||
<< abort(FatalError);
|
||||
}
|
||||
}
|
||||
@ -162,10 +162,10 @@ Foam::processorFaPatchField<Type>::processorFaPatchField
|
||||
sendRequest_(-1),
|
||||
recvRequest_(-1)
|
||||
{
|
||||
if (debug && !ptf.ready())
|
||||
if (debug && !ptf.all_ready())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "On patch " << procPatch_.name() << " outstanding request."
|
||||
<< "Outstanding request(s) on patch " << procPatch_.name()
|
||||
<< abort(FatalError);
|
||||
}
|
||||
}
|
||||
@ -174,12 +174,25 @@ Foam::processorFaPatchField<Type>::processorFaPatchField
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
bool Foam::processorFaPatchField<Type>::ready() const
|
||||
bool Foam::processorFaPatchField<Type>::all_ready() const
|
||||
{
|
||||
return UPstream::finishedRequestPair(recvRequest_, sendRequest_);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
bool Foam::processorFaPatchField<Type>::ready() const
|
||||
{
|
||||
const bool ok = UPstream::finishedRequest(recvRequest_);
|
||||
if (ok)
|
||||
{
|
||||
recvRequest_ = -1;
|
||||
if (UPstream::finishedRequest(sendRequest_)) sendRequest_ = -1;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::processorFaPatchField<Type>::patchNeighbourField() const
|
||||
@ -187,8 +200,7 @@ Foam::processorFaPatchField<Type>::patchNeighbourField() const
|
||||
if (debug && !this->ready())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "On patch " << procPatch_.name()
|
||||
<< " outstanding request."
|
||||
<< "Outstanding request on patch " << procPatch_.name()
|
||||
<< abort(FatalError);
|
||||
}
|
||||
return *this;
|
||||
@ -259,9 +271,8 @@ void Foam::processorFaPatchField<Type>::evaluate
|
||||
{
|
||||
// Fast path. Received into *this
|
||||
|
||||
// Require receive data. Update the send request state.
|
||||
// OR: UPstream::waitRequestPair(recvRequest_, sendRequest_);
|
||||
|
||||
// Require receive data.
|
||||
// Only update the send request state.
|
||||
UPstream::waitRequest(recvRequest_); recvRequest_ = -1;
|
||||
if (UPstream::finishedRequest(sendRequest_)) sendRequest_ = -1;
|
||||
}
|
||||
@ -303,11 +314,10 @@ void Foam::processorFaPatchField<Type>::initInterfaceMatrixUpdate
|
||||
if (commsType == UPstream::commsTypes::nonBlocking)
|
||||
{
|
||||
// Fast path.
|
||||
if (debug && !this->ready())
|
||||
if (debug && !this->all_ready())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "On patch " << procPatch_.name()
|
||||
<< " outstanding request."
|
||||
<< "Outstanding request(s) on patch " << procPatch_.name()
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
@ -368,9 +378,8 @@ void Foam::processorFaPatchField<Type>::updateInterfaceMatrix
|
||||
{
|
||||
// Fast path: consume straight from receive buffer
|
||||
|
||||
// Require receive data. Update the send request state.
|
||||
// OR: UPstream::waitRequestPair(recvRequest_, sendRequest_);
|
||||
|
||||
// Require receive data.
|
||||
// Only update the send request state.
|
||||
UPstream::waitRequest(recvRequest_); recvRequest_ = -1;
|
||||
if (UPstream::finishedRequest(sendRequest_)) sendRequest_ = -1;
|
||||
}
|
||||
@ -411,11 +420,10 @@ void Foam::processorFaPatchField<Type>::initInterfaceMatrixUpdate
|
||||
if (commsType == UPstream::commsTypes::nonBlocking)
|
||||
{
|
||||
// Fast path.
|
||||
if (debug && !this->ready())
|
||||
if (debug && !this->all_ready())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "On patch " << procPatch_.name()
|
||||
<< " outstanding request."
|
||||
<< "Outstanding request(s) on patch " << procPatch_.name()
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
@ -475,9 +483,8 @@ void Foam::processorFaPatchField<Type>::updateInterfaceMatrix
|
||||
{
|
||||
// Fast path: consume straight from receive buffer
|
||||
|
||||
// Require receive data. Update the send request state.
|
||||
// OR: UPstream::waitRequestPair(recvRequest_, sendRequest_);
|
||||
|
||||
// Require receive data.
|
||||
// Only update the send request state.
|
||||
UPstream::waitRequest(recvRequest_); recvRequest_ = -1;
|
||||
if (UPstream::finishedRequest(sendRequest_)) sendRequest_ = -1;
|
||||
}
|
||||
|
||||
@ -88,6 +88,12 @@ class processorFaPatchField
|
||||
mutable solveScalarField scalarRecvBuf_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Receive and send requests have both completed
|
||||
virtual bool all_ready() const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
@ -164,21 +170,21 @@ public:
|
||||
~processorFaPatchField() = default;
|
||||
|
||||
|
||||
// Member functions
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
// Coupling
|
||||
|
||||
//- Return true if running parallel
|
||||
virtual bool coupled() const
|
||||
{
|
||||
return Pstream::parRun();
|
||||
}
|
||||
//- The patch field is coupled if running in parallel
|
||||
virtual bool coupled() const { return UPstream::parRun(); }
|
||||
|
||||
//- Are all (receive) data available?
|
||||
virtual bool ready() const;
|
||||
|
||||
//- Return neighbour field given internal field
|
||||
tmp<Field<Type>> patchNeighbourField() const;
|
||||
|
||||
|
||||
// Evaluation functions
|
||||
// Evaluation
|
||||
|
||||
//- Initialise the evaluation of the patch field
|
||||
virtual void initEvaluate(const Pstream::commsTypes commsType);
|
||||
@ -189,9 +195,6 @@ public:
|
||||
//- Return patch-normal gradient
|
||||
virtual tmp<Field<Type>> snGrad() const;
|
||||
|
||||
//- Is all data available
|
||||
virtual bool ready() const;
|
||||
|
||||
|
||||
// Coupled interface functionality
|
||||
|
||||
@ -245,12 +248,13 @@ public:
|
||||
const Pstream::commsTypes commsType
|
||||
) const;
|
||||
|
||||
//- Processor coupled interface functions
|
||||
|
||||
//- Return communicator used for comms
|
||||
// Processor coupled interface functions
|
||||
|
||||
//- Return communicator used for communication
|
||||
virtual label comm() const
|
||||
{
|
||||
return UPstream::worldComm;
|
||||
return procPatch_.comm();
|
||||
}
|
||||
|
||||
//- Return processor number
|
||||
|
||||
@ -74,12 +74,25 @@ Foam::calculatedProcessorFvPatchField<Type>::calculatedProcessorFvPatchField
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
bool Foam::calculatedProcessorFvPatchField<Type>::ready() const
|
||||
bool Foam::calculatedProcessorFvPatchField<Type>::all_ready() const
|
||||
{
|
||||
return UPstream::finishedRequestPair(recvRequest_, sendRequest_);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
bool Foam::calculatedProcessorFvPatchField<Type>::ready() const
|
||||
{
|
||||
const bool ok = UPstream::finishedRequest(recvRequest_);
|
||||
if (ok)
|
||||
{
|
||||
recvRequest_ = -1;
|
||||
if (UPstream::finishedRequest(sendRequest_)) sendRequest_ = -1;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::calculatedProcessorFvPatchField<Type>::patchNeighbourField() const
|
||||
@ -87,10 +100,10 @@ Foam::calculatedProcessorFvPatchField<Type>::patchNeighbourField() const
|
||||
if (!this->ready())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "On patch of size " << procInterface_.faceCells().size()
|
||||
<< "Outstanding request on patch of size "
|
||||
<< procInterface_.faceCells().size()
|
||||
<< " between proc " << procInterface_.myProcNo()
|
||||
<< " and " << procInterface_.neighbProcNo()
|
||||
<< " outstanding request."
|
||||
<< abort(FatalError);
|
||||
}
|
||||
return *this;
|
||||
@ -160,9 +173,8 @@ void Foam::calculatedProcessorFvPatchField<Type>::evaluate
|
||||
{
|
||||
if (UPstream::parRun())
|
||||
{
|
||||
// Require receive data. Update the send request state.
|
||||
// OR: UPstream::waitRequestPair(recvRequest_, sendRequest_);
|
||||
|
||||
// Require receive data.
|
||||
// Only update the send request state.
|
||||
UPstream::waitRequest(recvRequest_); recvRequest_ = -1;
|
||||
if (UPstream::finishedRequest(sendRequest_)) sendRequest_ = -1;
|
||||
}
|
||||
@ -182,11 +194,11 @@ void Foam::calculatedProcessorFvPatchField<Type>::initInterfaceMatrixUpdate
|
||||
const Pstream::commsTypes commsType
|
||||
) const
|
||||
{
|
||||
if (!this->ready())
|
||||
if (!this->all_ready())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "On patch " //<< interface_.name()
|
||||
<< " outstanding request."
|
||||
<< "Outstanding request(s) on interface "
|
||||
//<< interface_.name()
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
@ -275,9 +287,8 @@ void Foam::calculatedProcessorFvPatchField<Type>::updateInterfaceMatrix
|
||||
|
||||
if (UPstream::parRun())
|
||||
{
|
||||
// Require receive data. Update the send request state.
|
||||
// OR: UPstream::waitRequestPair(recvRequest_, sendRequest_);
|
||||
|
||||
// Require receive data.
|
||||
// Only update the send request state.
|
||||
UPstream::waitRequest(recvRequest_); recvRequest_ = -1;
|
||||
if (UPstream::finishedRequest(sendRequest_)) sendRequest_ = -1;
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ class calculatedProcessorFvPatchField
|
||||
{
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
// Protected Data
|
||||
|
||||
//- Local reference cast into the interface
|
||||
const lduPrimitiveProcessorInterface& procInterface_;
|
||||
@ -106,6 +106,10 @@ protected:
|
||||
) const;
|
||||
|
||||
|
||||
//- Receive and send requests have both completed
|
||||
virtual bool all_ready() const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
@ -161,11 +165,91 @@ public:
|
||||
virtual ~calculatedProcessorFvPatchField() = default;
|
||||
|
||||
|
||||
// Member functions
|
||||
// Member Functions
|
||||
|
||||
// processorLduInterfaceField implementation
|
||||
// Coupling
|
||||
|
||||
//- Return communicator used for comms
|
||||
//- The patch field is coupled if running in parallel
|
||||
virtual bool coupled() const { return UPstream::parRun(); }
|
||||
|
||||
//- Are all (receive) data available?
|
||||
virtual bool ready() const;
|
||||
|
||||
//- Return neighbour field of internal field
|
||||
virtual tmp<Field<Type>> patchNeighbourField() const;
|
||||
|
||||
|
||||
// Evaluation
|
||||
|
||||
//- Initialise the evaluation of the patch field
|
||||
virtual void initEvaluate(const Pstream::commsTypes commsType);
|
||||
|
||||
//- Evaluate the patch field
|
||||
virtual void evaluate(const Pstream::commsTypes commsType);
|
||||
|
||||
|
||||
// Coupled interface functionality
|
||||
|
||||
//- Initialise neighbour matrix update
|
||||
virtual void initInterfaceMatrixUpdate
|
||||
(
|
||||
solveScalarField& result,
|
||||
const bool add,
|
||||
const lduAddressing& lduAddr,
|
||||
const label patchId,
|
||||
const solveScalarField& psiInternal,
|
||||
const scalarField& coeffs,
|
||||
const direction cmpt,
|
||||
const Pstream::commsTypes commsType
|
||||
) const;
|
||||
|
||||
//- Update result field based on interface functionality
|
||||
virtual void updateInterfaceMatrix
|
||||
(
|
||||
solveScalarField& result,
|
||||
const bool add,
|
||||
const lduAddressing& lduAddr,
|
||||
const label patchId,
|
||||
const solveScalarField& psiInternal,
|
||||
const scalarField& coeffs,
|
||||
const direction cmpt,
|
||||
const Pstream::commsTypes commsType
|
||||
) const;
|
||||
|
||||
//- Initialise neighbour matrix update
|
||||
virtual void initInterfaceMatrixUpdate
|
||||
(
|
||||
Field<Type>& result,
|
||||
const bool add,
|
||||
const lduAddressing& lduAddr,
|
||||
const label patchId,
|
||||
const Field<Type>& psiInternal,
|
||||
const scalarField& coeffs,
|
||||
const Pstream::commsTypes commsType
|
||||
) const
|
||||
{
|
||||
NotImplemented;
|
||||
}
|
||||
|
||||
//- Update result field based on interface functionality
|
||||
virtual void updateInterfaceMatrix
|
||||
(
|
||||
Field<Type>& result,
|
||||
const bool add,
|
||||
const lduAddressing& lduAddr,
|
||||
const label patchId,
|
||||
const Field<Type>& psiInternal,
|
||||
const scalarField& coeffs,
|
||||
const Pstream::commsTypes commsType
|
||||
) const
|
||||
{
|
||||
NotImplemented;
|
||||
}
|
||||
|
||||
|
||||
// Processor coupled interface functions
|
||||
|
||||
//- Return communicator used for communication
|
||||
virtual label comm() const
|
||||
{
|
||||
return procInterface_.comm();
|
||||
@ -177,7 +261,6 @@ public:
|
||||
return procInterface_.myProcNo();
|
||||
}
|
||||
|
||||
|
||||
//- Return neighbour processor number
|
||||
virtual int neighbProcNo() const
|
||||
{
|
||||
@ -201,92 +284,6 @@ public:
|
||||
{
|
||||
return pTraits<Type>::rank;
|
||||
}
|
||||
|
||||
|
||||
// Access
|
||||
|
||||
//- Return true if this patch field is coupled.
|
||||
// Our field supplies coefficients to the fvMatrix so
|
||||
// should behave as a processorFvPatchField (in
|
||||
// addBoundarySource it should not add to the source)
|
||||
virtual bool coupled() const
|
||||
{
|
||||
return Pstream::parRun();
|
||||
}
|
||||
|
||||
//- Return neighbour field of internal field
|
||||
virtual tmp<Field<Type>> patchNeighbourField() const;
|
||||
|
||||
|
||||
// Evaluation functions
|
||||
|
||||
//- Is all data available
|
||||
virtual bool ready() const;
|
||||
|
||||
//- Initialise the evaluation of the patch field
|
||||
virtual void initEvaluate(const Pstream::commsTypes commsType);
|
||||
|
||||
//- Evaluate the patch field
|
||||
virtual void evaluate(const Pstream::commsTypes commsType);
|
||||
|
||||
//- Initialise neighbour matrix update
|
||||
virtual void initInterfaceMatrixUpdate
|
||||
(
|
||||
solveScalarField& result,
|
||||
const bool add,
|
||||
const lduAddressing& lduAddr,
|
||||
const label patchId,
|
||||
const solveScalarField& psiInternal,
|
||||
const scalarField& coeffs,
|
||||
const direction cmpt,
|
||||
const Pstream::commsTypes commsType
|
||||
) const;
|
||||
|
||||
//- Update result field based on interface functionality
|
||||
virtual void updateInterfaceMatrix
|
||||
(
|
||||
solveScalarField& result,
|
||||
const bool add,
|
||||
const lduAddressing& lduAddr,
|
||||
const label patchId,
|
||||
const solveScalarField& psiInternal,
|
||||
const scalarField& coeffs,
|
||||
const direction cmpt,
|
||||
const Pstream::commsTypes commsType
|
||||
) const;
|
||||
|
||||
//- Initialise neighbour matrix update
|
||||
virtual void initInterfaceMatrixUpdate
|
||||
(
|
||||
Field<Type>& result,
|
||||
const bool add,
|
||||
const lduAddressing& lduAddr,
|
||||
const label patchId,
|
||||
const Field<Type>& psiInternal,
|
||||
const scalarField& coeffs,
|
||||
const Pstream::commsTypes commsType
|
||||
) const
|
||||
{
|
||||
NotImplemented;
|
||||
}
|
||||
|
||||
//- Update result field based on interface functionality
|
||||
virtual void updateInterfaceMatrix
|
||||
(
|
||||
Field<Type>& result,
|
||||
const bool add,
|
||||
const lduAddressing& lduAddr,
|
||||
const label patchId,
|
||||
const Field<Type>& psiInternal,
|
||||
const scalarField& coeffs,
|
||||
const Pstream::commsTypes commsType
|
||||
) const
|
||||
{
|
||||
NotImplemented;
|
||||
}
|
||||
|
||||
//- Write
|
||||
// virtual void write(Ostream& os) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -118,10 +118,10 @@ Foam::processorFvPatchField<Type>::processorFvPatchField
|
||||
<< " in file " << this->internalField().objectPath()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
if (debug && !ptf.ready())
|
||||
if (debug && !ptf.all_ready())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "On patch " << procPatch_.name() << " outstanding request."
|
||||
<< "Outstanding request(s) on patch " << procPatch_.name()
|
||||
<< abort(FatalError);
|
||||
}
|
||||
}
|
||||
@ -143,10 +143,10 @@ Foam::processorFvPatchField<Type>::processorFvPatchField
|
||||
scalarSendBuf_(std::move(ptf.scalarSendBuf_)),
|
||||
scalarRecvBuf_(std::move(ptf.scalarRecvBuf_))
|
||||
{
|
||||
if (debug && !ptf.ready())
|
||||
if (debug && !ptf.all_ready())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "On patch " << procPatch_.name() << " outstanding request."
|
||||
<< "Outstanding request(s) on patch " << procPatch_.name()
|
||||
<< abort(FatalError);
|
||||
}
|
||||
}
|
||||
@ -164,10 +164,10 @@ Foam::processorFvPatchField<Type>::processorFvPatchField
|
||||
sendRequest_(-1),
|
||||
recvRequest_(-1)
|
||||
{
|
||||
if (debug && !ptf.ready())
|
||||
if (debug && !ptf.all_ready())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "On patch " << procPatch_.name() << " outstanding request."
|
||||
<< "Outstanding request(s) on patch " << procPatch_.name()
|
||||
<< abort(FatalError);
|
||||
}
|
||||
}
|
||||
@ -176,12 +176,25 @@ Foam::processorFvPatchField<Type>::processorFvPatchField
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
bool Foam::processorFvPatchField<Type>::ready() const
|
||||
bool Foam::processorFvPatchField<Type>::all_ready() const
|
||||
{
|
||||
return UPstream::finishedRequestPair(recvRequest_, sendRequest_);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
bool Foam::processorFvPatchField<Type>::ready() const
|
||||
{
|
||||
const bool ok = UPstream::finishedRequest(recvRequest_);
|
||||
if (ok)
|
||||
{
|
||||
recvRequest_ = -1;
|
||||
if (UPstream::finishedRequest(sendRequest_)) sendRequest_ = -1;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::processorFvPatchField<Type>::patchNeighbourField() const
|
||||
@ -189,8 +202,7 @@ Foam::processorFvPatchField<Type>::patchNeighbourField() const
|
||||
if (debug && !this->ready())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "On patch " << procPatch_.name()
|
||||
<< " outstanding request."
|
||||
<< "Outstanding request on patch " << procPatch_.name()
|
||||
<< abort(FatalError);
|
||||
}
|
||||
return *this;
|
||||
@ -209,7 +221,7 @@ void Foam::processorFvPatchField<Type>::initEvaluate
|
||||
|
||||
if
|
||||
(
|
||||
commsType == Pstream::commsTypes::nonBlocking
|
||||
commsType == UPstream::commsTypes::nonBlocking
|
||||
&& (std::is_integral<Type>::value || !UPstream::floatTransfer)
|
||||
)
|
||||
{
|
||||
@ -263,15 +275,14 @@ void Foam::processorFvPatchField<Type>::evaluate
|
||||
{
|
||||
if
|
||||
(
|
||||
commsType == Pstream::commsTypes::nonBlocking
|
||||
commsType == UPstream::commsTypes::nonBlocking
|
||||
&& (std::is_integral<Type>::value || !UPstream::floatTransfer)
|
||||
)
|
||||
{
|
||||
// Fast path: received into *this
|
||||
|
||||
// Require receive data. Update the send request state.
|
||||
// OR: UPstream::waitRequestPair(recvRequest_, sendRequest_);
|
||||
|
||||
// Require receive data.
|
||||
// Only update the send request state.
|
||||
UPstream::waitRequest(recvRequest_); recvRequest_ = -1;
|
||||
if (UPstream::finishedRequest(sendRequest_)) sendRequest_ = -1;
|
||||
}
|
||||
@ -324,16 +335,15 @@ void Foam::processorFvPatchField<Type>::initInterfaceMatrixUpdate
|
||||
|
||||
if
|
||||
(
|
||||
commsType == Pstream::commsTypes::nonBlocking
|
||||
commsType == UPstream::commsTypes::nonBlocking
|
||||
&& !UPstream::floatTransfer
|
||||
)
|
||||
{
|
||||
// Fast path.
|
||||
if (debug && !this->ready())
|
||||
if (debug && !this->all_ready())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "On patch " << procPatch_.name()
|
||||
<< " outstanding request."
|
||||
<< "Outstanding request(s) on patch " << procPatch_.name()
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
@ -392,15 +402,14 @@ void Foam::processorFvPatchField<Type>::updateInterfaceMatrix
|
||||
|
||||
if
|
||||
(
|
||||
commsType == Pstream::commsTypes::nonBlocking
|
||||
commsType == UPstream::commsTypes::nonBlocking
|
||||
&& !UPstream::floatTransfer
|
||||
)
|
||||
{
|
||||
// Fast path: consume straight from receive buffer
|
||||
|
||||
// Require receive data. Update the send request state.
|
||||
// OR: UPstream::waitRequestPair(recvRequest_, sendRequest_);
|
||||
|
||||
// Require receive data.
|
||||
// Only update the send request state.
|
||||
UPstream::waitRequest(recvRequest_); recvRequest_ = -1;
|
||||
if (UPstream::finishedRequest(sendRequest_)) sendRequest_ = -1;
|
||||
}
|
||||
@ -447,16 +456,15 @@ void Foam::processorFvPatchField<Type>::initInterfaceMatrixUpdate
|
||||
|
||||
if
|
||||
(
|
||||
commsType == Pstream::commsTypes::nonBlocking
|
||||
commsType == UPstream::commsTypes::nonBlocking
|
||||
&& (std::is_integral<Type>::value || !UPstream::floatTransfer)
|
||||
)
|
||||
{
|
||||
// Fast path.
|
||||
if (debug && !this->ready())
|
||||
if (debug && !this->all_ready())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "On patch " << procPatch_.name()
|
||||
<< " outstanding request."
|
||||
<< "Outstanding request(s) on patch " << procPatch_.name()
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
@ -514,15 +522,14 @@ void Foam::processorFvPatchField<Type>::updateInterfaceMatrix
|
||||
|
||||
if
|
||||
(
|
||||
commsType == Pstream::commsTypes::nonBlocking
|
||||
commsType == UPstream::commsTypes::nonBlocking
|
||||
&& (std::is_integral<Type>::value || !UPstream::floatTransfer)
|
||||
)
|
||||
{
|
||||
// Fast path: consume straight from receive buffer
|
||||
|
||||
// Require receive data. Update the send request state.
|
||||
// OR: UPstream::waitRequestPair(recvRequest_, sendRequest_);
|
||||
|
||||
// Require receive data.
|
||||
// Only update the send request state.
|
||||
UPstream::waitRequest(recvRequest_); recvRequest_ = -1;
|
||||
if (UPstream::finishedRequest(sendRequest_)) sendRequest_ = -1;
|
||||
}
|
||||
|
||||
@ -96,6 +96,12 @@ class processorFvPatchField
|
||||
mutable solveScalarField scalarRecvBuf_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Receive and send requests have both completed
|
||||
virtual bool all_ready() const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
@ -174,19 +180,19 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
// Coupling
|
||||
|
||||
//- Return true if running parallel
|
||||
virtual bool coupled() const
|
||||
{
|
||||
return Pstream::parRun();
|
||||
}
|
||||
//- The patch field is coupled if running in parallel
|
||||
virtual bool coupled() const { return UPstream::parRun(); }
|
||||
|
||||
//- Are all (receive) data available?
|
||||
virtual bool ready() const;
|
||||
|
||||
//- Return neighbour field given internal field
|
||||
virtual tmp<Field<Type>> patchNeighbourField() const;
|
||||
|
||||
|
||||
// Evaluation functions
|
||||
// Evaluation
|
||||
|
||||
//- Initialise the evaluation of the patch field
|
||||
virtual void initEvaluate(const Pstream::commsTypes commsType);
|
||||
@ -200,8 +206,8 @@ public:
|
||||
const scalarField& deltaCoeffs
|
||||
) const;
|
||||
|
||||
//- Is all data available
|
||||
virtual bool ready() const;
|
||||
|
||||
// Coupled interface functionality
|
||||
|
||||
//- Initialise neighbour matrix update
|
||||
virtual void initInterfaceMatrixUpdate
|
||||
@ -254,9 +260,9 @@ public:
|
||||
) const;
|
||||
|
||||
|
||||
//- Processor coupled interface functions
|
||||
// Processor coupled interface functions
|
||||
|
||||
//- Return communicator used for comms
|
||||
//- Return communicator used for communication
|
||||
virtual label comm() const
|
||||
{
|
||||
return procPatch_.comm();
|
||||
|
||||
Reference in New Issue
Block a user