diff --git a/src/OpenFOAM/fields/pointPatchFields/constraint/processorCyclic/processorCyclicPointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/constraint/processorCyclic/processorCyclicPointPatchField.C index 5abd549408..8dee733480 100644 --- a/src/OpenFOAM/fields/pointPatchFields/constraint/processorCyclic/processorCyclicPointPatchField.C +++ b/src/OpenFOAM/fields/pointPatchFields/constraint/processorCyclic/processorCyclicPointPatchField.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2020-2021 OpenCFD Ltd. + Copyright (C) 2020-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -41,8 +41,7 @@ Foam::processorCyclicPointPatchField::processorCyclicPointPatchField ) : coupledPointPatchField(p, iF), - procPatch_(refCast(p)), - receiveBuf_(0) + procPatch_(refCast(p)) {} @@ -55,8 +54,7 @@ Foam::processorCyclicPointPatchField::processorCyclicPointPatchField ) : coupledPointPatchField(p, iF, dict), - procPatch_(refCast(p, dict)), - receiveBuf_(0) + procPatch_(refCast(p, dict)) {} @@ -70,8 +68,7 @@ Foam::processorCyclicPointPatchField::processorCyclicPointPatchField ) : coupledPointPatchField(ptf, p, iF, mapper), - procPatch_(refCast(ptf.patch())), - receiveBuf_(0) + procPatch_(refCast(ptf.patch())) {} @@ -83,15 +80,7 @@ Foam::processorCyclicPointPatchField::processorCyclicPointPatchField ) : coupledPointPatchField(ptf, iF), - procPatch_(refCast(ptf.patch())), - receiveBuf_(0) -{} - - -// * * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * // - -template -Foam::processorCyclicPointPatchField::~processorCyclicPointPatchField() + procPatch_(refCast(ptf.patch())) {} @@ -118,13 +107,13 @@ void Foam::processorCyclicPointPatchField::initSwapAddSeparated if (commsType == Pstream::commsTypes::nonBlocking) { - receiveBuf_.setSize(pf.size()); + recvBuf_.resize_nocopy(pf.size()); UIPstream::read ( commsType, procPatch_.neighbProcNo(), - receiveBuf_.data_bytes(), - receiveBuf_.size_bytes(), + recvBuf_.data_bytes(), + recvBuf_.size_bytes(), procPatch_.tag(), procPatch_.comm() ); @@ -151,16 +140,17 @@ void Foam::processorCyclicPointPatchField::swapAddSeparated { if (Pstream::parRun()) { - // If nonblocking data has already been received into receiveBuf_ + // If nonblocking, data is already in receive buffer + if (commsType != Pstream::commsTypes::nonBlocking) { - receiveBuf_.setSize(this->size()); + recvBuf_.resize_nocopy(this->size()); UIPstream::read ( commsType, procPatch_.neighbProcNo(), - receiveBuf_.data_bytes(), - receiveBuf_.size_bytes(), + recvBuf_.data_bytes(), + recvBuf_.size_bytes(), procPatch_.tag(), procPatch_.comm() ); @@ -172,11 +162,11 @@ void Foam::processorCyclicPointPatchField::swapAddSeparated procPatch_.procCyclicPolyPatch(); const tensor& forwardT = ppp.forwardT()[0]; - transform(receiveBuf_, forwardT, receiveBuf_); + transform(recvBuf_, forwardT, recvBuf_); } // All points are separated - this->addToInternalField(pField, receiveBuf_); + this->addToInternalField(pField, recvBuf_); } } diff --git a/src/OpenFOAM/fields/pointPatchFields/constraint/processorCyclic/processorCyclicPointPatchField.H b/src/OpenFOAM/fields/pointPatchFields/constraint/processorCyclic/processorCyclicPointPatchField.H index 25a8ec9f6b..50d8243521 100644 --- a/src/OpenFOAM/fields/pointPatchFields/constraint/processorCyclic/processorCyclicPointPatchField.H +++ b/src/OpenFOAM/fields/pointPatchFields/constraint/processorCyclic/processorCyclicPointPatchField.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation + Copyright (C) 2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -54,13 +55,13 @@ class processorCyclicPointPatchField : public coupledPointPatchField { - // Private data + // Private Data //- Local reference to processor patch const processorCyclicPointPatch& procPatch_; //- Receive buffer for non-blocking communication - mutable Field receiveBuf_; + mutable Field recvBuf_; public: @@ -132,7 +133,7 @@ public: //- Destructor - virtual ~processorCyclicPointPatchField(); + virtual ~processorCyclicPointPatchField() = default; // Member functions diff --git a/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterface/lduCalculatedProcessorField/lduCalculatedProcessorField.C b/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterface/lduCalculatedProcessorField/lduCalculatedProcessorField.C index c00354d358..11e837c530 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterface/lduCalculatedProcessorField/lduCalculatedProcessorField.C +++ b/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterface/lduCalculatedProcessorField/lduCalculatedProcessorField.C @@ -93,21 +93,21 @@ void Foam::lduCalculatedProcessorField::initInterfaceMatrixUpdate // Bypass patchInternalField since uses fvPatch addressing const labelList& fc = lduAddr.patchAddr(patchId); - scalarSendBuf_.setSize(fc.size()); + scalarSendBuf_.resize_nocopy(fc.size()); forAll(fc, i) { scalarSendBuf_[i] = psiInternal[fc[i]]; } - scalarReceiveBuf_.setSize(scalarSendBuf_.size()); + scalarRecvBuf_.resize_nocopy(scalarSendBuf_.size()); recvRequest_ = UPstream::nRequests(); UIPstream::read ( UPstream::commsTypes::nonBlocking, procInterface_.neighbProcNo(), - scalarReceiveBuf_.data_bytes(), - scalarReceiveBuf_.size_bytes(), + scalarRecvBuf_.data_bytes(), + scalarRecvBuf_.size_bytes(), procInterface_.tag(), procInterface_.comm() ); @@ -180,7 +180,7 @@ void Foam::lduCalculatedProcessorField::updateInterfaceMatrix // Consume straight from receive buffer. Note use of our own // helper to avoid using fvPatch addressing - addToInternalField(result, !add, coeffs, scalarReceiveBuf_); + addToInternalField(result, !add, coeffs, scalarRecvBuf_); this->updatedMatrix(true); } diff --git a/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterface/lduCalculatedProcessorField/lduCalculatedProcessorField.H b/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterface/lduCalculatedProcessorField/lduCalculatedProcessorField.H index 1bb956585a..bb2cba44e4 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterface/lduCalculatedProcessorField/lduCalculatedProcessorField.H +++ b/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterface/lduCalculatedProcessorField/lduCalculatedProcessorField.H @@ -84,13 +84,13 @@ protected: mutable Field sendBuf_; //- Receive buffer - mutable Field receiveBuf_; + mutable Field recvBuf_; //- Scalar send buffer mutable solveScalarField scalarSendBuf_; - //- Scalar receive buffer - mutable solveScalarField scalarReceiveBuf_; + //- Scalar recv buffer + mutable solveScalarField scalarRecvBuf_; // Protected Member Functions diff --git a/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterface/processorLduInterface.H b/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterface/processorLduInterface.H index 64ddf7ea3d..8005cdc131 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterface/processorLduInterface.H +++ b/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterface/processorLduInterface.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -57,11 +57,11 @@ class processorLduInterface //- Send buffer. // Only sized and used when compressed or non-blocking comms used. - mutable List sendBuf_; + mutable List byteSendBuf_; //- Receive buffer. // Only sized and used when compressed or non-blocking comms used. - mutable List receiveBuf_; + mutable List byteRecvBuf_; // Private Member Functions @@ -76,6 +76,7 @@ class processorLduInterface } } + public: //- Runtime type information @@ -118,7 +119,7 @@ public: template void send ( - const Pstream::commsTypes commsType, + const UPstream::commsTypes commsType, const UList& f ) const; @@ -126,7 +127,7 @@ public: template void receive ( - const Pstream::commsTypes commsType, + const UPstream::commsTypes commsType, UList& f ) const; @@ -134,7 +135,7 @@ public: template tmp> receive ( - const Pstream::commsTypes commsType, + const UPstream::commsTypes commsType, const label size ) const; @@ -143,7 +144,7 @@ public: template void compressedSend ( - const Pstream::commsTypes commsType, + const UPstream::commsTypes commsType, const UList& f ) const; @@ -151,7 +152,7 @@ public: template void compressedReceive ( - const Pstream::commsTypes commsType, + const UPstream::commsTypes commsType, UList& f ) const; @@ -159,7 +160,7 @@ public: template tmp> compressedReceive ( - const Pstream::commsTypes commsType, + const UPstream::commsTypes commsType, const label size ) const; }; diff --git a/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterface/processorLduInterfaceTemplates.C b/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterface/processorLduInterfaceTemplates.C index 4b75ba207b..2ccb499292 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterface/processorLduInterfaceTemplates.C +++ b/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterface/processorLduInterfaceTemplates.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2019-2021 OpenCFD Ltd. + Copyright (C) 2019-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -35,7 +35,7 @@ License template void Foam::processorLduInterface::send ( - const Pstream::commsTypes commsType, + const UPstream::commsTypes commsType, const UList& f ) const { @@ -43,8 +43,8 @@ void Foam::processorLduInterface::send if ( - commsType == Pstream::commsTypes::blocking - || commsType == Pstream::commsTypes::scheduled + commsType == UPstream::commsTypes::blocking + || commsType == UPstream::commsTypes::scheduled ) { UOPstream::write @@ -57,31 +57,31 @@ void Foam::processorLduInterface::send comm() ); } - else if (commsType == Pstream::commsTypes::nonBlocking) + else if (commsType == UPstream::commsTypes::nonBlocking) { - resizeBuf(receiveBuf_, nBytes); + resizeBuf(byteSendBuf_, nBytes); + std::memcpy + ( + static_cast(byteSendBuf_.data()), f.cdata(), nBytes + ); + + resizeBuf(byteRecvBuf_, nBytes); UIPstream::read ( commsType, neighbProcNo(), - receiveBuf_.data(), + byteRecvBuf_.data(), nBytes, tag(), comm() ); - resizeBuf(sendBuf_, nBytes); - std::memcpy - ( - static_cast(sendBuf_.data()), f.cdata(), nBytes - ); - UOPstream::write ( commsType, neighbProcNo(), - sendBuf_.cdata(), + byteSendBuf_.cdata(), nBytes, tag(), comm() @@ -99,14 +99,16 @@ void Foam::processorLduInterface::send template void Foam::processorLduInterface::receive ( - const Pstream::commsTypes commsType, + const UPstream::commsTypes commsType, UList& f ) const { + const label nBytes = f.byteSize(); + if ( - commsType == Pstream::commsTypes::blocking - || commsType == Pstream::commsTypes::scheduled + commsType == UPstream::commsTypes::blocking + || commsType == UPstream::commsTypes::scheduled ) { UIPstream::read @@ -114,16 +116,16 @@ void Foam::processorLduInterface::receive commsType, neighbProcNo(), f.data_bytes(), - f.byteSize(), + nBytes, tag(), comm() ); } - else if (commsType == Pstream::commsTypes::nonBlocking) + else if (commsType == UPstream::commsTypes::nonBlocking) { std::memcpy ( - static_cast(f.data()), receiveBuf_.cdata(), f.byteSize() + static_cast(f.data()), byteRecvBuf_.cdata(), nBytes ); } else @@ -138,7 +140,7 @@ void Foam::processorLduInterface::receive template Foam::tmp> Foam::processorLduInterface::receive ( - const Pstream::commsTypes commsType, + const UPstream::commsTypes commsType, const label size ) const { @@ -151,7 +153,7 @@ Foam::tmp> Foam::processorLduInterface::receive template void Foam::processorLduInterface::compressedSend ( - const Pstream::commsTypes commsType, + const UPstream::commsTypes commsType, const UList& f ) const { @@ -170,8 +172,8 @@ void Foam::processorLduInterface::compressedSend const scalar *sArray = reinterpret_cast(f.cdata()); const scalar *slast = &sArray[nm1]; - resizeBuf(sendBuf_, nBytes); - float *fArray = reinterpret_cast(sendBuf_.data()); + resizeBuf(byteSendBuf_, nBytes); + float *fArray = reinterpret_cast(byteSendBuf_.data()); for (label i=0; i void Foam::processorLduInterface::compressedReceive ( - const Pstream::commsTypes commsType, + const UPstream::commsTypes commsType, UList& f ) const { @@ -256,23 +258,23 @@ void Foam::processorLduInterface::compressedReceive if ( - commsType == Pstream::commsTypes::blocking - || commsType == Pstream::commsTypes::scheduled + commsType == UPstream::commsTypes::blocking + || commsType == UPstream::commsTypes::scheduled ) { - resizeBuf(receiveBuf_, nBytes); + resizeBuf(byteRecvBuf_, nBytes); UIPstream::read ( commsType, neighbProcNo(), - receiveBuf_.data(), + byteRecvBuf_.data(), nBytes, tag(), comm() ); } - else if (commsType != Pstream::commsTypes::nonBlocking) + else if (commsType != UPstream::commsTypes::nonBlocking) { FatalErrorInFunction << "Unsupported communications type " << int(commsType) @@ -280,7 +282,7 @@ void Foam::processorLduInterface::compressedReceive } const float *fArray = - reinterpret_cast(receiveBuf_.cdata()); + reinterpret_cast(byteRecvBuf_.cdata()); f.last() = reinterpret_cast(fArray[nm1]); scalar *sArray = reinterpret_cast(f.data()); const scalar *slast = &sArray[nm1]; @@ -300,7 +302,7 @@ void Foam::processorLduInterface::compressedReceive template Foam::tmp> Foam::processorLduInterface::compressedReceive ( - const Pstream::commsTypes commsType, + const UPstream::commsTypes commsType, const label size ) const { diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/processorGAMGInterfaceField/processorGAMGInterfaceField.C b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/processorGAMGInterfaceField/processorGAMGInterfaceField.C index 61dca087e0..8309c1b31a 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/processorGAMGInterfaceField/processorGAMGInterfaceField.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/processorGAMGInterfaceField/processorGAMGInterfaceField.C @@ -111,15 +111,15 @@ void Foam::processorGAMGInterfaceField::initInterfaceMatrixUpdate ) { // Fast path. - scalarReceiveBuf_.setSize(scalarSendBuf_.size()); + scalarRecvBuf_.resize_nocopy(scalarSendBuf_.size()); recvRequest_ = UPstream::nRequests(); UIPstream::read ( UPstream::commsTypes::nonBlocking, procInterface_.neighbProcNo(), - scalarReceiveBuf_.data_bytes(), - scalarReceiveBuf_.size_bytes(), + scalarRecvBuf_.data_bytes(), + scalarRecvBuf_.size_bytes(), procInterface_.tag(), comm() ); @@ -175,28 +175,20 @@ void Foam::processorGAMGInterfaceField::updateInterfaceMatrix UPstream::waitRequest(recvRequest_); recvRequest_ = -1; sendRequest_ = -1; - - // Transform according to the transformation tensor - transformCoupleField(scalarReceiveBuf_, cmpt); - - // Multiply the field by coefficients and add into the result - addToInternalField(result, !add, faceCells, coeffs, scalarReceiveBuf_); } else { - solveScalarField pnf - ( - procInterface_.compressedReceive - ( - commsType, - coeffs.size() - ) - ); - transformCoupleField(pnf, cmpt); - - addToInternalField(result, !add, faceCells, coeffs, pnf); + scalarRecvBuf_.resize_nocopy(coeffs.size()); + procInterface_.compressedReceive(commsType, scalarRecvBuf_); } + + // Transform according to the transformation tensor + transformCoupleField(scalarRecvBuf_, cmpt); + + // Multiply the field by coefficients and add into the result + addToInternalField(result, !add, faceCells, coeffs, scalarRecvBuf_); + this->updatedMatrix(true); } diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/processorGAMGInterfaceField/processorGAMGInterfaceField.H b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/processorGAMGInterfaceField/processorGAMGInterfaceField.H index ee07b013d9..c42c448c95 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/processorGAMGInterfaceField/processorGAMGInterfaceField.H +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/processorGAMGInterfaceField/processorGAMGInterfaceField.H @@ -79,8 +79,8 @@ class processorGAMGInterfaceField //- Scalar send buffer mutable solveScalarField scalarSendBuf_; - //- Scalar receive buffer - mutable solveScalarField scalarReceiveBuf_; + //- Scalar recv buffer + mutable solveScalarField scalarRecvBuf_; diff --git a/src/finiteArea/faMesh/faMeshDemandDrivenData.C b/src/finiteArea/faMesh/faMeshDemandDrivenData.C index 0a7620fc8c..9cfd9eda45 100644 --- a/src/finiteArea/faMesh/faMeshDemandDrivenData.C +++ b/src/finiteArea/faMesh/faMeshDemandDrivenData.C @@ -1590,7 +1590,7 @@ void Foam::faMesh::calcPointAreaNormals(vectorField& result) const } // Receive neighbour values - patchPointNormals.resize(nbrPatchPoints.size()); + patchPointNormals.resize_nocopy(nbrPatchPoints.size()); { UIPstream::read diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/calculatedProcessor/calculatedProcessorFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/calculatedProcessor/calculatedProcessorFvPatchField.C index 74878841fb..875c98105f 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/calculatedProcessor/calculatedProcessorFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/calculatedProcessor/calculatedProcessorFvPatchField.C @@ -123,7 +123,7 @@ void Foam::calculatedProcessorFvPatchField::initEvaluate { const Field& iF = this->internalField(); const labelList& fc = procInterface_.faceCells(); - sendBuf_.setSize(fc.size()); + sendBuf_.resize_nocopy(fc.size()); forAll(fc, i) { sendBuf_[i] = iF[fc[i]]; @@ -131,7 +131,7 @@ void Foam::calculatedProcessorFvPatchField::initEvaluate } // Receive straight into *this - this->setSize(sendBuf_.size()); + this->resize_nocopy(sendBuf_.size()); recvRequest_ = UPstream::nRequests(); UIPstream::read @@ -198,21 +198,21 @@ void Foam::calculatedProcessorFvPatchField::initInterfaceMatrixUpdate // Bypass patchInternalField since uses fvPatch addressing const labelList& fc = lduAddr.patchAddr(patchId); - scalarSendBuf_.setSize(fc.size()); + scalarSendBuf_.resize_nocopy(fc.size()); forAll(fc, i) { scalarSendBuf_[i] = psiInternal[fc[i]]; } - scalarReceiveBuf_.setSize(scalarSendBuf_.size()); + scalarRecvBuf_.resize_nocopy(scalarSendBuf_.size()); recvRequest_ = UPstream::nRequests(); UIPstream::read ( UPstream::commsTypes::nonBlocking, procInterface_.neighbProcNo(), - scalarReceiveBuf_.data_bytes(), - scalarReceiveBuf_.size_bytes(), + scalarRecvBuf_.data_bytes(), + scalarRecvBuf_.size_bytes(), procInterface_.tag(), procInterface_.comm() ); @@ -288,7 +288,7 @@ void Foam::calculatedProcessorFvPatchField::updateInterfaceMatrix // Consume straight from receive buffer. Note use of our own // helper to avoid using fvPatch addressing - addToInternalField(result, !add, coeffs, scalarReceiveBuf_); + addToInternalField(result, !add, coeffs, scalarRecvBuf_); this->updatedMatrix(true); } diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/calculatedProcessor/calculatedProcessorFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/constraint/calculatedProcessor/calculatedProcessorFvPatchField.H index 22cd2ae1fa..7367148a71 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/calculatedProcessor/calculatedProcessorFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/constraint/calculatedProcessor/calculatedProcessorFvPatchField.H @@ -86,13 +86,13 @@ protected: mutable Field sendBuf_; //- Receive buffer - mutable Field receiveBuf_; + mutable Field recvBuf_; //- Scalar send buffer mutable solveScalarField scalarSendBuf_; - //- Scalar receive buffer - mutable solveScalarField scalarReceiveBuf_; + //- Scalar recv buffer + mutable solveScalarField scalarRecvBuf_; // Protected Member Functions diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchField.C index 7aa36a5c32..4175ed06c2 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchField.C @@ -138,9 +138,9 @@ Foam::processorFvPatchField::processorFvPatchField sendRequest_(-1), recvRequest_(-1), sendBuf_(std::move(ptf.sendBuf_)), - receiveBuf_(std::move(ptf.receiveBuf_)), + recvBuf_(std::move(ptf.recvBuf_)), scalarSendBuf_(std::move(ptf.scalarSendBuf_)), - scalarReceiveBuf_(std::move(ptf.scalarReceiveBuf_)) + scalarRecvBuf_(std::move(ptf.scalarRecvBuf_)) { if (debug && !ptf.ready()) { @@ -226,7 +226,7 @@ void Foam::processorFvPatchField::initEvaluate } // Receive straight into *this - this->setSize(sendBuf_.size()); + this->resize_nocopy(sendBuf_.size()); recvRequest_ = UPstream::nRequests(); UIPstream::read @@ -320,7 +320,7 @@ void Foam::processorFvPatchField::initInterfaceMatrixUpdate const labelUList& faceCells = lduAddr.patchAddr(patchId); - scalarSendBuf_.setSize(this->patch().size()); + scalarSendBuf_.resize_nocopy(this->patch().size()); forAll(scalarSendBuf_, facei) { scalarSendBuf_[facei] = psiInternal[faceCells[facei]]; @@ -341,16 +341,15 @@ void Foam::processorFvPatchField::initInterfaceMatrixUpdate << abort(FatalError); } - - scalarReceiveBuf_.setSize(scalarSendBuf_.size()); + scalarRecvBuf_.resize_nocopy(scalarSendBuf_.size()); recvRequest_ = UPstream::nRequests(); UIPstream::read ( UPstream::commsTypes::nonBlocking, procPatch_.neighbProcNo(), - scalarReceiveBuf_.data_bytes(), - scalarReceiveBuf_.size_bytes(), + scalarRecvBuf_.data_bytes(), + scalarRecvBuf_.size_bytes(), procPatch_.tag(), procPatch_.comm() ); @@ -407,44 +406,23 @@ void Foam::processorFvPatchField::updateInterfaceMatrix UPstream::waitRequest(recvRequest_); recvRequest_ = -1; sendRequest_ = -1; - - if (!std::is_arithmetic::value) - { - // Transform non-scalar data according to the transformation tensor - transformCoupleField(scalarReceiveBuf_, cmpt); - } - - // Multiply the field by coefficients and add into the result - this->addToInternalField - ( - result, - !add, - faceCells, - coeffs, - scalarReceiveBuf_ - ); } else { - solveScalarField pnf - ( - procPatch_.compressedReceive - ( - commsType, - this->size() - )() - ); - - if (!std::is_arithmetic::value) - { - // Transform non-scalar data according to the transformation tensor - transformCoupleField(pnf, cmpt); - } - - // Multiply the field by coefficients and add into the result - this->addToInternalField(result, !add, faceCells, coeffs, pnf); + scalarRecvBuf_.resize_nocopy(this->size()); + procPatch_.compressedReceive(commsType, scalarRecvBuf_); } + + if (!std::is_arithmetic::value) + { + // Transform non-scalar data according to the transformation tensor + transformCoupleField(scalarRecvBuf_, cmpt); + } + + // Multiply the field by coefficients and add into the result + this->addToInternalField(result, !add, faceCells, coeffs, scalarRecvBuf_); + this->updatedMatrix(true); } @@ -461,7 +439,7 @@ void Foam::processorFvPatchField::initInterfaceMatrixUpdate const Pstream::commsTypes commsType ) const { - sendBuf_.setSize(this->patch().size()); + sendBuf_.resize_nocopy(this->patch().size()); const labelUList& faceCells = lduAddr.patchAddr(patchId); @@ -485,16 +463,15 @@ void Foam::processorFvPatchField::initInterfaceMatrixUpdate << abort(FatalError); } - - receiveBuf_.setSize(sendBuf_.size()); + recvBuf_.resize_nocopy(sendBuf_.size()); recvRequest_ = UPstream::nRequests(); UIPstream::read ( UPstream::commsTypes::nonBlocking, procPatch_.neighbProcNo(), - receiveBuf_.data_bytes(), - receiveBuf_.size_bytes(), + recvBuf_.data_bytes(), + recvBuf_.size_bytes(), procPatch_.tag(), procPatch_.comm() ); @@ -550,27 +527,20 @@ void Foam::processorFvPatchField::updateInterfaceMatrix UPstream::waitRequest(recvRequest_); recvRequest_ = -1; sendRequest_ = -1; - - // Transform according to the transformation tensor - transformCoupleField(receiveBuf_); - - // Multiply the field by coefficients and add into the result - this->addToInternalField(result, !add, faceCells, coeffs, receiveBuf_); } else { - Field pnf - ( - procPatch_.compressedReceive(commsType, this->size())() - ); - - // Transform according to the transformation tensor - transformCoupleField(pnf); - - // Multiply the field by coefficients and add into the result - this->addToInternalField(result, !add, faceCells, coeffs, pnf); + recvBuf_.resize_nocopy(this->size()); + procPatch_.compressedReceive(commsType, recvBuf_); } + + // Transform according to the transformation tensor + transformCoupleField(recvBuf_); + + // Multiply the field by coefficients and add into the result + this->addToInternalField(result, !add, faceCells, coeffs, recvBuf_); + this->updatedMatrix(true); } diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchField.H index 1971a1a6b3..48e2f092ba 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchField.H @@ -87,13 +87,13 @@ class processorFvPatchField mutable Field sendBuf_; //- Receive buffer. - mutable Field receiveBuf_; + mutable Field recvBuf_; //- Scalar send buffer mutable solveScalarField scalarSendBuf_; - //- Scalar receive buffer - mutable solveScalarField scalarReceiveBuf_; + //- Scalar recv buffer + mutable solveScalarField scalarRecvBuf_; public: diff --git a/src/overset/lduPrimitiveProcessorInterface/GAMG/calculatedProcessorGAMGInterfaceField.C b/src/overset/lduPrimitiveProcessorInterface/GAMG/calculatedProcessorGAMGInterfaceField.C index e3f667e34a..cc58546967 100644 --- a/src/overset/lduPrimitiveProcessorInterface/GAMG/calculatedProcessorGAMGInterfaceField.C +++ b/src/overset/lduPrimitiveProcessorInterface/GAMG/calculatedProcessorGAMGInterfaceField.C @@ -112,15 +112,15 @@ void Foam::calculatedProcessorGAMGInterfaceField::initInterfaceMatrixUpdate ) { // Fast path. - scalarReceiveBuf_.setSize(scalarSendBuf_.size()); + scalarRecvBuf_.resize_nocopy(scalarSendBuf_.size()); recvRequest_ = UPstream::nRequests(); UIPstream::read ( UPstream::commsTypes::nonBlocking, procInterface_.neighbProcNo(), - scalarReceiveBuf_.data_bytes(), - scalarReceiveBuf_.size_bytes(), + scalarRecvBuf_.data_bytes(), + scalarRecvBuf_.size_bytes(), procInterface_.tag(), comm() ); @@ -176,28 +176,20 @@ void Foam::calculatedProcessorGAMGInterfaceField::updateInterfaceMatrix UPstream::waitRequest(recvRequest_); recvRequest_ = -1; sendRequest_ = -1; - - // Transform according to the transformation tensor - transformCoupleField(scalarReceiveBuf_, cmpt); - - // Multiply the field by coefficients and add into the result - addToInternalField(result, !add, faceCells, coeffs, scalarReceiveBuf_); } else { - solveScalarField pnf - ( - procInterface_.compressedReceive - ( - commsType, - this->size() - )() - ); - transformCoupleField(pnf, cmpt); - - addToInternalField(result, !add, faceCells, coeffs, pnf); + scalarRecvBuf_.resize_nocopy(this->size()); + procInterface_.compressedReceive(commsType, scalarRecvBuf_); } + + // Transform according to the transformation tensor + transformCoupleField(scalarRecvBuf_, cmpt); + + // Multiply the field by coefficients and add into the result + addToInternalField(result, !add, faceCells, coeffs, scalarRecvBuf_); + this->updatedMatrix(true); } diff --git a/src/overset/lduPrimitiveProcessorInterface/GAMG/calculatedProcessorGAMGInterfaceField.H b/src/overset/lduPrimitiveProcessorInterface/GAMG/calculatedProcessorGAMGInterfaceField.H index ad6f4ed478..6a0b14d372 100644 --- a/src/overset/lduPrimitiveProcessorInterface/GAMG/calculatedProcessorGAMGInterfaceField.H +++ b/src/overset/lduPrimitiveProcessorInterface/GAMG/calculatedProcessorGAMGInterfaceField.H @@ -78,8 +78,8 @@ class calculatedProcessorGAMGInterfaceField //- Scalar send buffer mutable solveScalarField scalarSendBuf_; - //- Scalar receive buffer - mutable solveScalarField scalarReceiveBuf_; + //- Scalar recv buffer + mutable solveScalarField scalarRecvBuf_;