ENH: consistent use of resize_nocopy for processor transfers

STYLE: rename some internal buffers with the data types

  low-level  : byteSendBuf_, byteRecvBuf_
  field level: sendBuf_, recvBuf_
  solve level: scalarSendBuf_, scalarRecvBuf_
This commit is contained in:
Mark Olesen
2023-01-12 18:48:07 +01:00
parent bf2f87f7e3
commit b15638a2d2
15 changed files with 152 additions and 204 deletions

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2020-2021 OpenCFD Ltd. Copyright (C) 2020-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -41,8 +41,7 @@ Foam::processorCyclicPointPatchField<Type>::processorCyclicPointPatchField
) )
: :
coupledPointPatchField<Type>(p, iF), coupledPointPatchField<Type>(p, iF),
procPatch_(refCast<const processorCyclicPointPatch>(p)), procPatch_(refCast<const processorCyclicPointPatch>(p))
receiveBuf_(0)
{} {}
@ -55,8 +54,7 @@ Foam::processorCyclicPointPatchField<Type>::processorCyclicPointPatchField
) )
: :
coupledPointPatchField<Type>(p, iF, dict), coupledPointPatchField<Type>(p, iF, dict),
procPatch_(refCast<const processorCyclicPointPatch>(p, dict)), procPatch_(refCast<const processorCyclicPointPatch>(p, dict))
receiveBuf_(0)
{} {}
@ -70,8 +68,7 @@ Foam::processorCyclicPointPatchField<Type>::processorCyclicPointPatchField
) )
: :
coupledPointPatchField<Type>(ptf, p, iF, mapper), coupledPointPatchField<Type>(ptf, p, iF, mapper),
procPatch_(refCast<const processorCyclicPointPatch>(ptf.patch())), procPatch_(refCast<const processorCyclicPointPatch>(ptf.patch()))
receiveBuf_(0)
{} {}
@ -83,15 +80,7 @@ Foam::processorCyclicPointPatchField<Type>::processorCyclicPointPatchField
) )
: :
coupledPointPatchField<Type>(ptf, iF), coupledPointPatchField<Type>(ptf, iF),
procPatch_(refCast<const processorCyclicPointPatch>(ptf.patch())), procPatch_(refCast<const processorCyclicPointPatch>(ptf.patch()))
receiveBuf_(0)
{}
// * * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * //
template<class Type>
Foam::processorCyclicPointPatchField<Type>::~processorCyclicPointPatchField()
{} {}
@ -118,13 +107,13 @@ void Foam::processorCyclicPointPatchField<Type>::initSwapAddSeparated
if (commsType == Pstream::commsTypes::nonBlocking) if (commsType == Pstream::commsTypes::nonBlocking)
{ {
receiveBuf_.setSize(pf.size()); recvBuf_.resize_nocopy(pf.size());
UIPstream::read UIPstream::read
( (
commsType, commsType,
procPatch_.neighbProcNo(), procPatch_.neighbProcNo(),
receiveBuf_.data_bytes(), recvBuf_.data_bytes(),
receiveBuf_.size_bytes(), recvBuf_.size_bytes(),
procPatch_.tag(), procPatch_.tag(),
procPatch_.comm() procPatch_.comm()
); );
@ -151,16 +140,17 @@ void Foam::processorCyclicPointPatchField<Type>::swapAddSeparated
{ {
if (Pstream::parRun()) 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) if (commsType != Pstream::commsTypes::nonBlocking)
{ {
receiveBuf_.setSize(this->size()); recvBuf_.resize_nocopy(this->size());
UIPstream::read UIPstream::read
( (
commsType, commsType,
procPatch_.neighbProcNo(), procPatch_.neighbProcNo(),
receiveBuf_.data_bytes(), recvBuf_.data_bytes(),
receiveBuf_.size_bytes(), recvBuf_.size_bytes(),
procPatch_.tag(), procPatch_.tag(),
procPatch_.comm() procPatch_.comm()
); );
@ -172,11 +162,11 @@ void Foam::processorCyclicPointPatchField<Type>::swapAddSeparated
procPatch_.procCyclicPolyPatch(); procPatch_.procCyclicPolyPatch();
const tensor& forwardT = ppp.forwardT()[0]; const tensor& forwardT = ppp.forwardT()[0];
transform(receiveBuf_, forwardT, receiveBuf_); transform(recvBuf_, forwardT, recvBuf_);
} }
// All points are separated // All points are separated
this->addToInternalField(pField, receiveBuf_); this->addToInternalField(pField, recvBuf_);
} }
} }

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -54,13 +55,13 @@ class processorCyclicPointPatchField
: :
public coupledPointPatchField<Type> public coupledPointPatchField<Type>
{ {
// Private data // Private Data
//- Local reference to processor patch //- Local reference to processor patch
const processorCyclicPointPatch& procPatch_; const processorCyclicPointPatch& procPatch_;
//- Receive buffer for non-blocking communication //- Receive buffer for non-blocking communication
mutable Field<Type> receiveBuf_; mutable Field<Type> recvBuf_;
public: public:
@ -132,7 +133,7 @@ public:
//- Destructor //- Destructor
virtual ~processorCyclicPointPatchField(); virtual ~processorCyclicPointPatchField() = default;
// Member functions // Member functions

View File

@ -93,21 +93,21 @@ void Foam::lduCalculatedProcessorField<Type>::initInterfaceMatrixUpdate
// Bypass patchInternalField since uses fvPatch addressing // Bypass patchInternalField since uses fvPatch addressing
const labelList& fc = lduAddr.patchAddr(patchId); const labelList& fc = lduAddr.patchAddr(patchId);
scalarSendBuf_.setSize(fc.size()); scalarSendBuf_.resize_nocopy(fc.size());
forAll(fc, i) forAll(fc, i)
{ {
scalarSendBuf_[i] = psiInternal[fc[i]]; scalarSendBuf_[i] = psiInternal[fc[i]];
} }
scalarReceiveBuf_.setSize(scalarSendBuf_.size()); scalarRecvBuf_.resize_nocopy(scalarSendBuf_.size());
recvRequest_ = UPstream::nRequests(); recvRequest_ = UPstream::nRequests();
UIPstream::read UIPstream::read
( (
UPstream::commsTypes::nonBlocking, UPstream::commsTypes::nonBlocking,
procInterface_.neighbProcNo(), procInterface_.neighbProcNo(),
scalarReceiveBuf_.data_bytes(), scalarRecvBuf_.data_bytes(),
scalarReceiveBuf_.size_bytes(), scalarRecvBuf_.size_bytes(),
procInterface_.tag(), procInterface_.tag(),
procInterface_.comm() procInterface_.comm()
); );
@ -180,7 +180,7 @@ void Foam::lduCalculatedProcessorField<Type>::updateInterfaceMatrix
// Consume straight from receive buffer. Note use of our own // Consume straight from receive buffer. Note use of our own
// helper to avoid using fvPatch addressing // helper to avoid using fvPatch addressing
addToInternalField(result, !add, coeffs, scalarReceiveBuf_); addToInternalField(result, !add, coeffs, scalarRecvBuf_);
this->updatedMatrix(true); this->updatedMatrix(true);
} }

View File

@ -84,13 +84,13 @@ protected:
mutable Field<Type> sendBuf_; mutable Field<Type> sendBuf_;
//- Receive buffer //- Receive buffer
mutable Field<Type> receiveBuf_; mutable Field<Type> recvBuf_;
//- Scalar send buffer //- Scalar send buffer
mutable solveScalarField scalarSendBuf_; mutable solveScalarField scalarSendBuf_;
//- Scalar receive buffer //- Scalar recv buffer
mutable solveScalarField scalarReceiveBuf_; mutable solveScalarField scalarRecvBuf_;
// Protected Member Functions // Protected Member Functions

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -57,11 +57,11 @@ class processorLduInterface
//- Send buffer. //- Send buffer.
// Only sized and used when compressed or non-blocking comms used. // Only sized and used when compressed or non-blocking comms used.
mutable List<char> sendBuf_; mutable List<char> byteSendBuf_;
//- Receive buffer. //- Receive buffer.
// Only sized and used when compressed or non-blocking comms used. // Only sized and used when compressed or non-blocking comms used.
mutable List<char> receiveBuf_; mutable List<char> byteRecvBuf_;
// Private Member Functions // Private Member Functions
@ -76,6 +76,7 @@ class processorLduInterface
} }
} }
public: public:
//- Runtime type information //- Runtime type information
@ -118,7 +119,7 @@ public:
template<class Type> template<class Type>
void send void send
( (
const Pstream::commsTypes commsType, const UPstream::commsTypes commsType,
const UList<Type>& f const UList<Type>& f
) const; ) const;
@ -126,7 +127,7 @@ public:
template<class Type> template<class Type>
void receive void receive
( (
const Pstream::commsTypes commsType, const UPstream::commsTypes commsType,
UList<Type>& f UList<Type>& f
) const; ) const;
@ -134,7 +135,7 @@ public:
template<class Type> template<class Type>
tmp<Field<Type>> receive tmp<Field<Type>> receive
( (
const Pstream::commsTypes commsType, const UPstream::commsTypes commsType,
const label size const label size
) const; ) const;
@ -143,7 +144,7 @@ public:
template<class Type> template<class Type>
void compressedSend void compressedSend
( (
const Pstream::commsTypes commsType, const UPstream::commsTypes commsType,
const UList<Type>& f const UList<Type>& f
) const; ) const;
@ -151,7 +152,7 @@ public:
template<class Type> template<class Type>
void compressedReceive void compressedReceive
( (
const Pstream::commsTypes commsType, const UPstream::commsTypes commsType,
UList<Type>& f UList<Type>& f
) const; ) const;
@ -159,7 +160,7 @@ public:
template<class Type> template<class Type>
tmp<Field<Type>> compressedReceive tmp<Field<Type>> compressedReceive
( (
const Pstream::commsTypes commsType, const UPstream::commsTypes commsType,
const label size const label size
) const; ) const;
}; };

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2019-2021 OpenCFD Ltd. Copyright (C) 2019-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -35,7 +35,7 @@ License
template<class Type> template<class Type>
void Foam::processorLduInterface::send void Foam::processorLduInterface::send
( (
const Pstream::commsTypes commsType, const UPstream::commsTypes commsType,
const UList<Type>& f const UList<Type>& f
) const ) const
{ {
@ -43,8 +43,8 @@ void Foam::processorLduInterface::send
if if
( (
commsType == Pstream::commsTypes::blocking commsType == UPstream::commsTypes::blocking
|| commsType == Pstream::commsTypes::scheduled || commsType == UPstream::commsTypes::scheduled
) )
{ {
UOPstream::write UOPstream::write
@ -57,31 +57,31 @@ void Foam::processorLduInterface::send
comm() comm()
); );
} }
else if (commsType == Pstream::commsTypes::nonBlocking) else if (commsType == UPstream::commsTypes::nonBlocking)
{ {
resizeBuf(receiveBuf_, nBytes); resizeBuf(byteSendBuf_, nBytes);
std::memcpy
(
static_cast<void*>(byteSendBuf_.data()), f.cdata(), nBytes
);
resizeBuf(byteRecvBuf_, nBytes);
UIPstream::read UIPstream::read
( (
commsType, commsType,
neighbProcNo(), neighbProcNo(),
receiveBuf_.data(), byteRecvBuf_.data(),
nBytes, nBytes,
tag(), tag(),
comm() comm()
); );
resizeBuf(sendBuf_, nBytes);
std::memcpy
(
static_cast<void*>(sendBuf_.data()), f.cdata(), nBytes
);
UOPstream::write UOPstream::write
( (
commsType, commsType,
neighbProcNo(), neighbProcNo(),
sendBuf_.cdata(), byteSendBuf_.cdata(),
nBytes, nBytes,
tag(), tag(),
comm() comm()
@ -99,14 +99,16 @@ void Foam::processorLduInterface::send
template<class Type> template<class Type>
void Foam::processorLduInterface::receive void Foam::processorLduInterface::receive
( (
const Pstream::commsTypes commsType, const UPstream::commsTypes commsType,
UList<Type>& f UList<Type>& f
) const ) const
{ {
const label nBytes = f.byteSize();
if if
( (
commsType == Pstream::commsTypes::blocking commsType == UPstream::commsTypes::blocking
|| commsType == Pstream::commsTypes::scheduled || commsType == UPstream::commsTypes::scheduled
) )
{ {
UIPstream::read UIPstream::read
@ -114,16 +116,16 @@ void Foam::processorLduInterface::receive
commsType, commsType,
neighbProcNo(), neighbProcNo(),
f.data_bytes(), f.data_bytes(),
f.byteSize(), nBytes,
tag(), tag(),
comm() comm()
); );
} }
else if (commsType == Pstream::commsTypes::nonBlocking) else if (commsType == UPstream::commsTypes::nonBlocking)
{ {
std::memcpy std::memcpy
( (
static_cast<void*>(f.data()), receiveBuf_.cdata(), f.byteSize() static_cast<void*>(f.data()), byteRecvBuf_.cdata(), nBytes
); );
} }
else else
@ -138,7 +140,7 @@ void Foam::processorLduInterface::receive
template<class Type> template<class Type>
Foam::tmp<Foam::Field<Type>> Foam::processorLduInterface::receive Foam::tmp<Foam::Field<Type>> Foam::processorLduInterface::receive
( (
const Pstream::commsTypes commsType, const UPstream::commsTypes commsType,
const label size const label size
) const ) const
{ {
@ -151,7 +153,7 @@ Foam::tmp<Foam::Field<Type>> Foam::processorLduInterface::receive
template<class Type> template<class Type>
void Foam::processorLduInterface::compressedSend void Foam::processorLduInterface::compressedSend
( (
const Pstream::commsTypes commsType, const UPstream::commsTypes commsType,
const UList<Type>& f const UList<Type>& f
) const ) const
{ {
@ -170,8 +172,8 @@ void Foam::processorLduInterface::compressedSend
const scalar *sArray = reinterpret_cast<const scalar*>(f.cdata()); const scalar *sArray = reinterpret_cast<const scalar*>(f.cdata());
const scalar *slast = &sArray[nm1]; const scalar *slast = &sArray[nm1];
resizeBuf(sendBuf_, nBytes); resizeBuf(byteSendBuf_, nBytes);
float *fArray = reinterpret_cast<float*>(sendBuf_.data()); float *fArray = reinterpret_cast<float*>(byteSendBuf_.data());
for (label i=0; i<nm1; i++) for (label i=0; i<nm1; i++)
{ {
@ -182,29 +184,29 @@ void Foam::processorLduInterface::compressedSend
if if
( (
commsType == Pstream::commsTypes::blocking commsType == UPstream::commsTypes::blocking
|| commsType == Pstream::commsTypes::scheduled || commsType == UPstream::commsTypes::scheduled
) )
{ {
UOPstream::write UOPstream::write
( (
commsType, commsType,
neighbProcNo(), neighbProcNo(),
sendBuf_.cdata(), byteSendBuf_.cdata(),
nBytes, nBytes,
tag(), tag(),
comm() comm()
); );
} }
else if (commsType == Pstream::commsTypes::nonBlocking) else if (commsType == UPstream::commsTypes::nonBlocking)
{ {
resizeBuf(receiveBuf_, nBytes); resizeBuf(byteRecvBuf_, nBytes);
UIPstream::read UIPstream::read
( (
commsType, commsType,
neighbProcNo(), neighbProcNo(),
receiveBuf_.data(), byteRecvBuf_.data(),
nBytes, nBytes,
tag(), tag(),
comm() comm()
@ -214,7 +216,7 @@ void Foam::processorLduInterface::compressedSend
( (
commsType, commsType,
neighbProcNo(), neighbProcNo(),
sendBuf_.cdata(), byteSendBuf_.cdata(),
nBytes, nBytes,
tag(), tag(),
comm() comm()
@ -237,7 +239,7 @@ void Foam::processorLduInterface::compressedSend
template<class Type> template<class Type>
void Foam::processorLduInterface::compressedReceive void Foam::processorLduInterface::compressedReceive
( (
const Pstream::commsTypes commsType, const UPstream::commsTypes commsType,
UList<Type>& f UList<Type>& f
) const ) const
{ {
@ -256,23 +258,23 @@ void Foam::processorLduInterface::compressedReceive
if if
( (
commsType == Pstream::commsTypes::blocking commsType == UPstream::commsTypes::blocking
|| commsType == Pstream::commsTypes::scheduled || commsType == UPstream::commsTypes::scheduled
) )
{ {
resizeBuf(receiveBuf_, nBytes); resizeBuf(byteRecvBuf_, nBytes);
UIPstream::read UIPstream::read
( (
commsType, commsType,
neighbProcNo(), neighbProcNo(),
receiveBuf_.data(), byteRecvBuf_.data(),
nBytes, nBytes,
tag(), tag(),
comm() comm()
); );
} }
else if (commsType != Pstream::commsTypes::nonBlocking) else if (commsType != UPstream::commsTypes::nonBlocking)
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unsupported communications type " << int(commsType) << "Unsupported communications type " << int(commsType)
@ -280,7 +282,7 @@ void Foam::processorLduInterface::compressedReceive
} }
const float *fArray = const float *fArray =
reinterpret_cast<const float*>(receiveBuf_.cdata()); reinterpret_cast<const float*>(byteRecvBuf_.cdata());
f.last() = reinterpret_cast<const Type&>(fArray[nm1]); f.last() = reinterpret_cast<const Type&>(fArray[nm1]);
scalar *sArray = reinterpret_cast<scalar*>(f.data()); scalar *sArray = reinterpret_cast<scalar*>(f.data());
const scalar *slast = &sArray[nm1]; const scalar *slast = &sArray[nm1];
@ -300,7 +302,7 @@ void Foam::processorLduInterface::compressedReceive
template<class Type> template<class Type>
Foam::tmp<Foam::Field<Type>> Foam::processorLduInterface::compressedReceive Foam::tmp<Foam::Field<Type>> Foam::processorLduInterface::compressedReceive
( (
const Pstream::commsTypes commsType, const UPstream::commsTypes commsType,
const label size const label size
) const ) const
{ {

View File

@ -111,15 +111,15 @@ void Foam::processorGAMGInterfaceField::initInterfaceMatrixUpdate
) )
{ {
// Fast path. // Fast path.
scalarReceiveBuf_.setSize(scalarSendBuf_.size()); scalarRecvBuf_.resize_nocopy(scalarSendBuf_.size());
recvRequest_ = UPstream::nRequests(); recvRequest_ = UPstream::nRequests();
UIPstream::read UIPstream::read
( (
UPstream::commsTypes::nonBlocking, UPstream::commsTypes::nonBlocking,
procInterface_.neighbProcNo(), procInterface_.neighbProcNo(),
scalarReceiveBuf_.data_bytes(), scalarRecvBuf_.data_bytes(),
scalarReceiveBuf_.size_bytes(), scalarRecvBuf_.size_bytes(),
procInterface_.tag(), procInterface_.tag(),
comm() comm()
); );
@ -175,28 +175,20 @@ void Foam::processorGAMGInterfaceField::updateInterfaceMatrix
UPstream::waitRequest(recvRequest_); UPstream::waitRequest(recvRequest_);
recvRequest_ = -1; recvRequest_ = -1;
sendRequest_ = -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 else
{ {
solveScalarField pnf scalarRecvBuf_.resize_nocopy(coeffs.size());
( procInterface_.compressedReceive(commsType, scalarRecvBuf_);
procInterface_.compressedReceive<solveScalar>
(
commsType,
coeffs.size()
)
);
transformCoupleField(pnf, cmpt);
addToInternalField(result, !add, faceCells, coeffs, pnf);
} }
// 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); this->updatedMatrix(true);
} }

View File

@ -79,8 +79,8 @@ class processorGAMGInterfaceField
//- Scalar send buffer //- Scalar send buffer
mutable solveScalarField scalarSendBuf_; mutable solveScalarField scalarSendBuf_;
//- Scalar receive buffer //- Scalar recv buffer
mutable solveScalarField scalarReceiveBuf_; mutable solveScalarField scalarRecvBuf_;

View File

@ -1590,7 +1590,7 @@ void Foam::faMesh::calcPointAreaNormals(vectorField& result) const
} }
// Receive neighbour values // Receive neighbour values
patchPointNormals.resize(nbrPatchPoints.size()); patchPointNormals.resize_nocopy(nbrPatchPoints.size());
{ {
UIPstream::read UIPstream::read

View File

@ -123,7 +123,7 @@ void Foam::calculatedProcessorFvPatchField<Type>::initEvaluate
{ {
const Field<Type>& iF = this->internalField(); const Field<Type>& iF = this->internalField();
const labelList& fc = procInterface_.faceCells(); const labelList& fc = procInterface_.faceCells();
sendBuf_.setSize(fc.size()); sendBuf_.resize_nocopy(fc.size());
forAll(fc, i) forAll(fc, i)
{ {
sendBuf_[i] = iF[fc[i]]; sendBuf_[i] = iF[fc[i]];
@ -131,7 +131,7 @@ void Foam::calculatedProcessorFvPatchField<Type>::initEvaluate
} }
// Receive straight into *this // Receive straight into *this
this->setSize(sendBuf_.size()); this->resize_nocopy(sendBuf_.size());
recvRequest_ = UPstream::nRequests(); recvRequest_ = UPstream::nRequests();
UIPstream::read UIPstream::read
@ -198,21 +198,21 @@ void Foam::calculatedProcessorFvPatchField<Type>::initInterfaceMatrixUpdate
// Bypass patchInternalField since uses fvPatch addressing // Bypass patchInternalField since uses fvPatch addressing
const labelList& fc = lduAddr.patchAddr(patchId); const labelList& fc = lduAddr.patchAddr(patchId);
scalarSendBuf_.setSize(fc.size()); scalarSendBuf_.resize_nocopy(fc.size());
forAll(fc, i) forAll(fc, i)
{ {
scalarSendBuf_[i] = psiInternal[fc[i]]; scalarSendBuf_[i] = psiInternal[fc[i]];
} }
scalarReceiveBuf_.setSize(scalarSendBuf_.size()); scalarRecvBuf_.resize_nocopy(scalarSendBuf_.size());
recvRequest_ = UPstream::nRequests(); recvRequest_ = UPstream::nRequests();
UIPstream::read UIPstream::read
( (
UPstream::commsTypes::nonBlocking, UPstream::commsTypes::nonBlocking,
procInterface_.neighbProcNo(), procInterface_.neighbProcNo(),
scalarReceiveBuf_.data_bytes(), scalarRecvBuf_.data_bytes(),
scalarReceiveBuf_.size_bytes(), scalarRecvBuf_.size_bytes(),
procInterface_.tag(), procInterface_.tag(),
procInterface_.comm() procInterface_.comm()
); );
@ -288,7 +288,7 @@ void Foam::calculatedProcessorFvPatchField<Type>::updateInterfaceMatrix
// Consume straight from receive buffer. Note use of our own // Consume straight from receive buffer. Note use of our own
// helper to avoid using fvPatch addressing // helper to avoid using fvPatch addressing
addToInternalField(result, !add, coeffs, scalarReceiveBuf_); addToInternalField(result, !add, coeffs, scalarRecvBuf_);
this->updatedMatrix(true); this->updatedMatrix(true);
} }

View File

@ -86,13 +86,13 @@ protected:
mutable Field<Type> sendBuf_; mutable Field<Type> sendBuf_;
//- Receive buffer //- Receive buffer
mutable Field<Type> receiveBuf_; mutable Field<Type> recvBuf_;
//- Scalar send buffer //- Scalar send buffer
mutable solveScalarField scalarSendBuf_; mutable solveScalarField scalarSendBuf_;
//- Scalar receive buffer //- Scalar recv buffer
mutable solveScalarField scalarReceiveBuf_; mutable solveScalarField scalarRecvBuf_;
// Protected Member Functions // Protected Member Functions

View File

@ -138,9 +138,9 @@ Foam::processorFvPatchField<Type>::processorFvPatchField
sendRequest_(-1), sendRequest_(-1),
recvRequest_(-1), recvRequest_(-1),
sendBuf_(std::move(ptf.sendBuf_)), sendBuf_(std::move(ptf.sendBuf_)),
receiveBuf_(std::move(ptf.receiveBuf_)), recvBuf_(std::move(ptf.recvBuf_)),
scalarSendBuf_(std::move(ptf.scalarSendBuf_)), scalarSendBuf_(std::move(ptf.scalarSendBuf_)),
scalarReceiveBuf_(std::move(ptf.scalarReceiveBuf_)) scalarRecvBuf_(std::move(ptf.scalarRecvBuf_))
{ {
if (debug && !ptf.ready()) if (debug && !ptf.ready())
{ {
@ -226,7 +226,7 @@ void Foam::processorFvPatchField<Type>::initEvaluate
} }
// Receive straight into *this // Receive straight into *this
this->setSize(sendBuf_.size()); this->resize_nocopy(sendBuf_.size());
recvRequest_ = UPstream::nRequests(); recvRequest_ = UPstream::nRequests();
UIPstream::read UIPstream::read
@ -320,7 +320,7 @@ void Foam::processorFvPatchField<Type>::initInterfaceMatrixUpdate
const labelUList& faceCells = lduAddr.patchAddr(patchId); const labelUList& faceCells = lduAddr.patchAddr(patchId);
scalarSendBuf_.setSize(this->patch().size()); scalarSendBuf_.resize_nocopy(this->patch().size());
forAll(scalarSendBuf_, facei) forAll(scalarSendBuf_, facei)
{ {
scalarSendBuf_[facei] = psiInternal[faceCells[facei]]; scalarSendBuf_[facei] = psiInternal[faceCells[facei]];
@ -341,16 +341,15 @@ void Foam::processorFvPatchField<Type>::initInterfaceMatrixUpdate
<< abort(FatalError); << abort(FatalError);
} }
scalarRecvBuf_.resize_nocopy(scalarSendBuf_.size());
scalarReceiveBuf_.setSize(scalarSendBuf_.size());
recvRequest_ = UPstream::nRequests(); recvRequest_ = UPstream::nRequests();
UIPstream::read UIPstream::read
( (
UPstream::commsTypes::nonBlocking, UPstream::commsTypes::nonBlocking,
procPatch_.neighbProcNo(), procPatch_.neighbProcNo(),
scalarReceiveBuf_.data_bytes(), scalarRecvBuf_.data_bytes(),
scalarReceiveBuf_.size_bytes(), scalarRecvBuf_.size_bytes(),
procPatch_.tag(), procPatch_.tag(),
procPatch_.comm() procPatch_.comm()
); );
@ -407,44 +406,23 @@ void Foam::processorFvPatchField<Type>::updateInterfaceMatrix
UPstream::waitRequest(recvRequest_); UPstream::waitRequest(recvRequest_);
recvRequest_ = -1; recvRequest_ = -1;
sendRequest_ = -1; sendRequest_ = -1;
if (!std::is_arithmetic<Type>::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 else
{ {
solveScalarField pnf scalarRecvBuf_.resize_nocopy(this->size());
( procPatch_.compressedReceive(commsType, scalarRecvBuf_);
procPatch_.compressedReceive<solveScalar>
(
commsType,
this->size()
)()
);
if (!std::is_arithmetic<Type>::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);
} }
if (!std::is_arithmetic<Type>::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); this->updatedMatrix(true);
} }
@ -461,7 +439,7 @@ void Foam::processorFvPatchField<Type>::initInterfaceMatrixUpdate
const Pstream::commsTypes commsType const Pstream::commsTypes commsType
) const ) const
{ {
sendBuf_.setSize(this->patch().size()); sendBuf_.resize_nocopy(this->patch().size());
const labelUList& faceCells = lduAddr.patchAddr(patchId); const labelUList& faceCells = lduAddr.patchAddr(patchId);
@ -485,16 +463,15 @@ void Foam::processorFvPatchField<Type>::initInterfaceMatrixUpdate
<< abort(FatalError); << abort(FatalError);
} }
recvBuf_.resize_nocopy(sendBuf_.size());
receiveBuf_.setSize(sendBuf_.size());
recvRequest_ = UPstream::nRequests(); recvRequest_ = UPstream::nRequests();
UIPstream::read UIPstream::read
( (
UPstream::commsTypes::nonBlocking, UPstream::commsTypes::nonBlocking,
procPatch_.neighbProcNo(), procPatch_.neighbProcNo(),
receiveBuf_.data_bytes(), recvBuf_.data_bytes(),
receiveBuf_.size_bytes(), recvBuf_.size_bytes(),
procPatch_.tag(), procPatch_.tag(),
procPatch_.comm() procPatch_.comm()
); );
@ -550,27 +527,20 @@ void Foam::processorFvPatchField<Type>::updateInterfaceMatrix
UPstream::waitRequest(recvRequest_); UPstream::waitRequest(recvRequest_);
recvRequest_ = -1; recvRequest_ = -1;
sendRequest_ = -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 else
{ {
Field<Type> pnf recvBuf_.resize_nocopy(this->size());
( procPatch_.compressedReceive(commsType, recvBuf_);
procPatch_.compressedReceive<Type>(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);
} }
// 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); this->updatedMatrix(true);
} }

View File

@ -87,13 +87,13 @@ class processorFvPatchField
mutable Field<Type> sendBuf_; mutable Field<Type> sendBuf_;
//- Receive buffer. //- Receive buffer.
mutable Field<Type> receiveBuf_; mutable Field<Type> recvBuf_;
//- Scalar send buffer //- Scalar send buffer
mutable solveScalarField scalarSendBuf_; mutable solveScalarField scalarSendBuf_;
//- Scalar receive buffer //- Scalar recv buffer
mutable solveScalarField scalarReceiveBuf_; mutable solveScalarField scalarRecvBuf_;
public: public:

View File

@ -112,15 +112,15 @@ void Foam::calculatedProcessorGAMGInterfaceField::initInterfaceMatrixUpdate
) )
{ {
// Fast path. // Fast path.
scalarReceiveBuf_.setSize(scalarSendBuf_.size()); scalarRecvBuf_.resize_nocopy(scalarSendBuf_.size());
recvRequest_ = UPstream::nRequests(); recvRequest_ = UPstream::nRequests();
UIPstream::read UIPstream::read
( (
UPstream::commsTypes::nonBlocking, UPstream::commsTypes::nonBlocking,
procInterface_.neighbProcNo(), procInterface_.neighbProcNo(),
scalarReceiveBuf_.data_bytes(), scalarRecvBuf_.data_bytes(),
scalarReceiveBuf_.size_bytes(), scalarRecvBuf_.size_bytes(),
procInterface_.tag(), procInterface_.tag(),
comm() comm()
); );
@ -176,28 +176,20 @@ void Foam::calculatedProcessorGAMGInterfaceField::updateInterfaceMatrix
UPstream::waitRequest(recvRequest_); UPstream::waitRequest(recvRequest_);
recvRequest_ = -1; recvRequest_ = -1;
sendRequest_ = -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 else
{ {
solveScalarField pnf scalarRecvBuf_.resize_nocopy(this->size());
( procInterface_.compressedReceive(commsType, scalarRecvBuf_);
procInterface_.compressedReceive<solveScalar>
(
commsType,
this->size()
)()
);
transformCoupleField(pnf, cmpt);
addToInternalField(result, !add, faceCells, coeffs, pnf);
} }
// 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); this->updatedMatrix(true);
} }

View File

@ -78,8 +78,8 @@ class calculatedProcessorGAMGInterfaceField
//- Scalar send buffer //- Scalar send buffer
mutable solveScalarField scalarSendBuf_; mutable solveScalarField scalarSendBuf_;
//- Scalar receive buffer //- Scalar recv buffer
mutable solveScalarField scalarReceiveBuf_; mutable solveScalarField scalarRecvBuf_;