diff --git a/src/foam/fields/PointPatchFieldTemplates/constraint/processor/ProcessorPointPatchField.C b/src/foam/fields/PointPatchFieldTemplates/constraint/processor/ProcessorPointPatchField.C index 01aaf3aa6..263e1020e 100644 --- a/src/foam/fields/PointPatchFieldTemplates/constraint/processor/ProcessorPointPatchField.C +++ b/src/foam/fields/PointPatchFieldTemplates/constraint/processor/ProcessorPointPatchField.C @@ -84,7 +84,7 @@ sendField //HJ: This needs complete rewrite: // - move communications into a patch - // - allow for various types of communication + // - allow for various types of communication - done HR, 12/6/2017 // HJ, 15/Apr/2009 if (commsType == Pstream::blocking || commsType == Pstream::scheduled) @@ -101,6 +101,7 @@ sendField { resizeBuf(receiveBuf_, f.size()*sizeof(Type)); + outstandingRecvRequest_ = Pstream::nRequests(); IPstream::read ( commsType, @@ -112,6 +113,7 @@ sendField resizeBuf(sendBuf_, f.byteSize()); memcpy(sendBuf_.begin(), f.begin(), f.byteSize()); + outstandingSendRequest_ = Pstream::nRequests(); OPstream::write ( commsType, @@ -127,22 +129,6 @@ sendField << exit(FatalError); } - // Not using non-blocking comms -// if (commsType == Pstream::nonBlocking) -// { -// FatalErrorIn("void ProcessorPointPatchField::sendField") -// << "Non-blocking comms not implemented" -// << abort(FatalError); -// } - -// OPstream::write -// ( -// commsType, -// procPatch_.neighbProcNo(), -// reinterpret_cast(f.begin()), -// f.byteSize() -// ); - tf.clear(); } @@ -167,13 +153,36 @@ receivePointField { tmp > tf(new Field(this->size())); - IPstream::read - ( - commsType, - procPatch_.neighbProcNo(), - reinterpret_cast(tf().begin()), - tf().byteSize() - ); + if (Pstream::parRun()) + { + if (commsType == Pstream::nonBlocking) + { + // Receive into tf + + if + ( + outstandingRecvRequest_ >= 0 + && outstandingRecvRequest_ < Pstream::nRequests() + ) + { + Pstream::waitRequest(outstandingRecvRequest_); + } + outstandingSendRequest_ = -1; + outstandingRecvRequest_ = -1; + + memcpy(tf().begin(), receiveBuf_.begin(), tf().byteSize()); + } + else + { + IPstream::read + ( + commsType, + procPatch_.neighbProcNo(), + reinterpret_cast(tf().begin()), + tf().byteSize() + ); + } + } return tf; } @@ -202,13 +211,36 @@ receiveEdgeField new Field(procPatch_.localEdgeIndices().size()) ); - IPstream::read - ( - commsType, - procPatch_.neighbProcNo(), - reinterpret_cast(tf().begin()), - tf().byteSize() - ); + if (Pstream::parRun()) + { + if (commsType == Pstream::nonBlocking) + { + // Receive into tf + + if + ( + outstandingRecvRequest_ >= 0 + && outstandingRecvRequest_ < Pstream::nRequests() + ) + { + Pstream::waitRequest(outstandingRecvRequest_); + } + outstandingSendRequest_ = -1; + outstandingRecvRequest_ = -1; + + memcpy(tf().begin(), receiveBuf_.begin(), tf().byteSize()); + } + else + { + IPstream::read + ( + commsType, + procPatch_.neighbProcNo(), + reinterpret_cast(tf().begin()), + tf().byteSize() + ); + } + } return tf; } @@ -470,7 +502,7 @@ initEvaluate { if (this->isPointField()) { - initAddFieldTempl(Pstream::blocking, this->internalField()); + initAddFieldTempl(commsType, this->internalField()); } } } @@ -551,7 +583,7 @@ ProcessorPointPatchField :: initAddField() const { - initAddFieldTempl(Pstream::blocking, this->internalField()); + initAddFieldTempl(Pstream::defaultComms(), this->internalField()); } @@ -570,7 +602,7 @@ ProcessorPointPatchField :: addField(Field& f) const { - addFieldTempl(Pstream::blocking, f); + addFieldTempl(Pstream::defaultComms(), f); } @@ -636,7 +668,7 @@ ProcessorPointPatchField :: initAddDiag(const scalarField& d) const { - initAddFieldTempl(Pstream::blocking, d); + initAddFieldTempl(Pstream::defaultComms(), d); } @@ -655,7 +687,7 @@ ProcessorPointPatchField :: initAddSource(const scalarField& s) const { - initAddFieldTempl(Pstream::blocking, s); + initAddFieldTempl(Pstream::defaultComms(), s); } @@ -674,7 +706,7 @@ ProcessorPointPatchField :: addDiag(scalarField& d) const { - addFieldTempl(Pstream::blocking, d); + addFieldTempl(Pstream::defaultComms(), d); } @@ -693,7 +725,7 @@ ProcessorPointPatchField :: addSource(scalarField& s) const { - addFieldTempl(Pstream::blocking, s); + addFieldTempl(Pstream::defaultComms(), s); } diff --git a/src/foam/fields/PointPatchFieldTemplates/constraint/processor/ProcessorPointPatchField.H b/src/foam/fields/PointPatchFieldTemplates/constraint/processor/ProcessorPointPatchField.H index cdbf8673c..8f42cc7d4 100644 --- a/src/foam/fields/PointPatchFieldTemplates/constraint/processor/ProcessorPointPatchField.H +++ b/src/foam/fields/PointPatchFieldTemplates/constraint/processor/ProcessorPointPatchField.H @@ -75,6 +75,12 @@ class ProcessorPointPatchField // Non-blocking parallel communications // Temporary: move to patch. HJ, 15/Apr/2008 + //- Outstanding request + mutable label outstandingSendRequest_; + + //- Outstanding request + mutable label outstandingRecvRequest_; + //- Send buffer. // Only sized and used when compressed or non-blocking comms used. mutable List sendBuf_;