mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: support alternative construct map layout mapDistributeBase
- when constructing from a sendMap, can now also specify a linear receive layout instead of a localFirst layout This will make it easier to reduce some code (#2932) - add missing interface for simple distribute of List/DynamicList with a specified commsType. Was previously restricted to defaultCommsType only. ENH: mapDistribute distribute/reverseDistribute with specified commsType STYLE: prefer UPstream vs Pstream within mapDistribute
This commit is contained in:
@ -222,7 +222,7 @@ Foam::mapDistribute::mapDistribute
|
|||||||
:
|
:
|
||||||
mapDistributeBase(comm)
|
mapDistributeBase(comm)
|
||||||
{
|
{
|
||||||
const label myRank = Pstream::myProcNo(comm);
|
const label myRank = UPstream::myProcNo(comm);
|
||||||
|
|
||||||
// Construct per processor compact addressing of the global elements
|
// Construct per processor compact addressing of the global elements
|
||||||
// needed. The ones from the local processor are not included since
|
// needed. The ones from the local processor are not included since
|
||||||
@ -330,7 +330,7 @@ Foam::mapDistribute::mapDistribute
|
|||||||
:
|
:
|
||||||
mapDistributeBase(comm)
|
mapDistributeBase(comm)
|
||||||
{
|
{
|
||||||
const label myRank = Pstream::myProcNo(comm);
|
const label myRank = UPstream::myProcNo(comm);
|
||||||
|
|
||||||
// Construct per processor compact addressing of the global elements
|
// Construct per processor compact addressing of the global elements
|
||||||
// needed. The ones from the local processor are not included since
|
// needed. The ones from the local processor are not included since
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2015-2022 OpenCFD Ltd.
|
Copyright (C) 2015-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -409,7 +409,7 @@ public:
|
|||||||
// Access
|
// Access
|
||||||
|
|
||||||
//- For every globalIndexAndTransform::transformPermutations
|
//- For every globalIndexAndTransform::transformPermutations
|
||||||
// gives the elements that need to be transformed
|
//- gives the elements that need to be transformed
|
||||||
const labelListList& transformElements() const noexcept
|
const labelListList& transformElements() const noexcept
|
||||||
{
|
{
|
||||||
return transformElements_;
|
return transformElements_;
|
||||||
@ -433,7 +433,8 @@ public:
|
|||||||
//- Transfer the contents of the argument and annul the argument.
|
//- Transfer the contents of the argument and annul the argument.
|
||||||
void transfer(mapDistribute& map);
|
void transfer(mapDistribute& map);
|
||||||
|
|
||||||
//- Distribute data using default commsType.
|
//- Distribute List data using default commsType,
|
||||||
|
//- default flip/negate operator
|
||||||
template<class T>
|
template<class T>
|
||||||
void distribute
|
void distribute
|
||||||
(
|
(
|
||||||
@ -442,7 +443,40 @@ public:
|
|||||||
const int tag = UPstream::msgType()
|
const int tag = UPstream::msgType()
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Distribute data using default commsType.
|
//- Distribute DynamicList data using default commsType,
|
||||||
|
//- default flip/negate operator
|
||||||
|
template<class T>
|
||||||
|
void distribute
|
||||||
|
(
|
||||||
|
DynamicList<T>& fld,
|
||||||
|
const bool dummyTransform = true,
|
||||||
|
const int tag = UPstream::msgType()
|
||||||
|
) const;
|
||||||
|
|
||||||
|
//- Distribute List data using specified commsType,
|
||||||
|
//- default flip/negate operator
|
||||||
|
template<class T>
|
||||||
|
void distribute
|
||||||
|
(
|
||||||
|
const UPstream::commsTypes commsType,
|
||||||
|
List<T>& fld,
|
||||||
|
const bool dummyTransform = true,
|
||||||
|
const int tag = UPstream::msgType()
|
||||||
|
) const;
|
||||||
|
|
||||||
|
//- Distribute DynamicList data using specified commsType,
|
||||||
|
//- default flip/negate operator
|
||||||
|
template<class T>
|
||||||
|
void distribute
|
||||||
|
(
|
||||||
|
const UPstream::commsTypes commsType,
|
||||||
|
DynamicList<T>& fld,
|
||||||
|
const bool dummyTransform = true,
|
||||||
|
const int tag = UPstream::msgType()
|
||||||
|
) const;
|
||||||
|
|
||||||
|
//- Distribute List data using default commsType
|
||||||
|
//- and the specified negate operator (for flips).
|
||||||
template<class T, class NegateOp>
|
template<class T, class NegateOp>
|
||||||
void distribute
|
void distribute
|
||||||
(
|
(
|
||||||
@ -452,11 +486,14 @@ public:
|
|||||||
const int tag = UPstream::msgType()
|
const int tag = UPstream::msgType()
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Distribute data using default commsType.
|
//- Distribute List data using specified commsType
|
||||||
template<class T>
|
//- and the specified negate operator (for flips).
|
||||||
|
template<class T, class NegateOp>
|
||||||
void distribute
|
void distribute
|
||||||
(
|
(
|
||||||
DynamicList<T>& fld,
|
const UPstream::commsTypes commsType,
|
||||||
|
List<T>& fld,
|
||||||
|
const NegateOp& negOp,
|
||||||
const bool dummyTransform = true,
|
const bool dummyTransform = true,
|
||||||
const int tag = UPstream::msgType()
|
const int tag = UPstream::msgType()
|
||||||
) const;
|
) const;
|
||||||
@ -471,6 +508,17 @@ public:
|
|||||||
const int tag = UPstream::msgType()
|
const int tag = UPstream::msgType()
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
//- Reverse distribute data using specified commsType.
|
||||||
|
template<class T>
|
||||||
|
void reverseDistribute
|
||||||
|
(
|
||||||
|
const UPstream::commsTypes commsType,
|
||||||
|
const label constructSize,
|
||||||
|
List<T>& fld,
|
||||||
|
const bool dummyTransform = true,
|
||||||
|
const int tag = UPstream::msgType()
|
||||||
|
) const;
|
||||||
|
|
||||||
//- Reverse distribute data using default commsType.
|
//- Reverse distribute data using default commsType.
|
||||||
// Since constructSize might be larger than supplied size supply
|
// Since constructSize might be larger than supplied size supply
|
||||||
// a nullValue
|
// a nullValue
|
||||||
@ -484,6 +532,20 @@ public:
|
|||||||
const int tag = UPstream::msgType()
|
const int tag = UPstream::msgType()
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
//- Reverse distribute data using specified commsType.
|
||||||
|
// Since constructSize might be larger than supplied size supply
|
||||||
|
// a nullValue
|
||||||
|
template<class T>
|
||||||
|
void reverseDistribute
|
||||||
|
(
|
||||||
|
const UPstream::commsTypes commsType,
|
||||||
|
const label constructSize,
|
||||||
|
const T& nullValue,
|
||||||
|
List<T>& fld,
|
||||||
|
const bool dummyTransform = true,
|
||||||
|
const int tag = UPstream::msgType()
|
||||||
|
) const;
|
||||||
|
|
||||||
//- Distribute with transforms
|
//- Distribute with transforms
|
||||||
template<class T, class TransformOp>
|
template<class T, class TransformOp>
|
||||||
void distribute
|
void distribute
|
||||||
@ -494,6 +556,18 @@ public:
|
|||||||
const int tag = UPstream::msgType()
|
const int tag = UPstream::msgType()
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|
||||||
|
//- Distribute with transforms
|
||||||
|
template<class T, class TransformOp>
|
||||||
|
void distribute
|
||||||
|
(
|
||||||
|
const UPstream::commsTypes commsType,
|
||||||
|
const globalIndexAndTransform&,
|
||||||
|
List<T>& fld,
|
||||||
|
const TransformOp& top,
|
||||||
|
const int tag = UPstream::msgType()
|
||||||
|
) const;
|
||||||
|
|
||||||
//- Reverse distribute with transforms
|
//- Reverse distribute with transforms
|
||||||
template<class T, class TransformOp>
|
template<class T, class TransformOp>
|
||||||
void reverseDistribute
|
void reverseDistribute
|
||||||
@ -509,6 +583,31 @@ public:
|
|||||||
template<class T, class TransformOp>
|
template<class T, class TransformOp>
|
||||||
void reverseDistribute
|
void reverseDistribute
|
||||||
(
|
(
|
||||||
|
const UPstream::commsTypes commsType,
|
||||||
|
const globalIndexAndTransform&,
|
||||||
|
const label constructSize,
|
||||||
|
List<T>& fld,
|
||||||
|
const TransformOp& top,
|
||||||
|
const int tag = UPstream::msgType()
|
||||||
|
) const;
|
||||||
|
|
||||||
|
//- Reverse distribute with transforms
|
||||||
|
template<class T, class TransformOp>
|
||||||
|
void reverseDistribute
|
||||||
|
(
|
||||||
|
const globalIndexAndTransform&,
|
||||||
|
const label constructSize,
|
||||||
|
const T& nullValue,
|
||||||
|
List<T>& fld,
|
||||||
|
const TransformOp& top,
|
||||||
|
const int tag = UPstream::msgType()
|
||||||
|
) const;
|
||||||
|
|
||||||
|
//- Reverse distribute with transforms
|
||||||
|
template<class T, class TransformOp>
|
||||||
|
void reverseDistribute
|
||||||
|
(
|
||||||
|
const UPstream::commsTypes commsType,
|
||||||
const globalIndexAndTransform&,
|
const globalIndexAndTransform&,
|
||||||
const label constructSize,
|
const label constructSize,
|
||||||
const T& nullValue,
|
const T& nullValue,
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2015-2017 OpenFOAM Foundation
|
Copyright (C) 2015-2017 OpenFOAM Foundation
|
||||||
Copyright (C) 2015-2022 OpenCFD Ltd.
|
Copyright (C) 2015-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -191,8 +191,8 @@ Foam::List<Foam::labelPair> Foam::mapDistributeBase::schedule
|
|||||||
const label comm
|
const label comm
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const label myRank = Pstream::myProcNo(comm);
|
const label myRank = UPstream::myProcNo(comm);
|
||||||
const label nProcs = Pstream::nProcs(comm);
|
const label nProcs = UPstream::nProcs(comm);
|
||||||
|
|
||||||
// Communications: send and receive processor
|
// Communications: send and receive processor
|
||||||
List<labelPair> allComms;
|
List<labelPair> allComms;
|
||||||
@ -222,14 +222,14 @@ Foam::List<Foam::labelPair> Foam::mapDistributeBase::schedule
|
|||||||
|
|
||||||
|
|
||||||
// Gather/reduce
|
// Gather/reduce
|
||||||
if (Pstream::master(comm))
|
if (UPstream::master(comm))
|
||||||
{
|
{
|
||||||
// Receive and merge
|
// Receive and merge
|
||||||
for (const int proci : Pstream::subProcs(comm))
|
for (const int proci : UPstream::subProcs(comm))
|
||||||
{
|
{
|
||||||
IPstream fromProc
|
IPstream fromProc
|
||||||
(
|
(
|
||||||
Pstream::commsTypes::scheduled,
|
UPstream::commsTypes::scheduled,
|
||||||
proci,
|
proci,
|
||||||
0,
|
0,
|
||||||
tag,
|
tag,
|
||||||
@ -245,12 +245,12 @@ Foam::List<Foam::labelPair> Foam::mapDistributeBase::schedule
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (Pstream::parRun())
|
if (UPstream::parRun())
|
||||||
{
|
{
|
||||||
OPstream toMaster
|
OPstream toMaster
|
||||||
(
|
(
|
||||||
Pstream::commsTypes::scheduled,
|
UPstream::commsTypes::scheduled,
|
||||||
Pstream::masterNo(),
|
UPstream::masterNo(),
|
||||||
0,
|
0,
|
||||||
tag,
|
tag,
|
||||||
comm
|
comm
|
||||||
@ -310,8 +310,8 @@ const Foam::List<Foam::labelPair>& Foam::mapDistributeBase::whichSchedule
|
|||||||
|
|
||||||
void Foam::mapDistributeBase::printLayout(Ostream& os) const
|
void Foam::mapDistributeBase::printLayout(Ostream& os) const
|
||||||
{
|
{
|
||||||
const label myRank = Pstream::myProcNo(comm_);
|
const label myRank = UPstream::myProcNo(comm_);
|
||||||
const label nProcs = Pstream::nProcs(comm_);
|
const label nProcs = UPstream::nProcs(comm_);
|
||||||
|
|
||||||
// Determine offsets of remote data.
|
// Determine offsets of remote data.
|
||||||
labelList minIndex(nProcs, labelMax);
|
labelList minIndex(nProcs, labelMax);
|
||||||
@ -391,8 +391,8 @@ void Foam::mapDistributeBase::calcCompactAddressing
|
|||||||
List<Map<label>>& compactMap
|
List<Map<label>>& compactMap
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
const label myRank = Pstream::myProcNo(comm_);
|
const label myRank = UPstream::myProcNo(comm_);
|
||||||
const label nProcs = Pstream::nProcs(comm_);
|
const label nProcs = UPstream::nProcs(comm_);
|
||||||
|
|
||||||
// Count all (non-local) elements needed. Just for presizing map.
|
// Count all (non-local) elements needed. Just for presizing map.
|
||||||
labelList nNonLocal(nProcs, Zero);
|
labelList nNonLocal(nProcs, Zero);
|
||||||
@ -439,8 +439,8 @@ void Foam::mapDistributeBase::calcCompactAddressing
|
|||||||
List<Map<label>>& compactMap
|
List<Map<label>>& compactMap
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
const label myRank = Pstream::myProcNo(comm_);
|
const label myRank = UPstream::myProcNo(comm_);
|
||||||
const label nProcs = Pstream::nProcs(comm_);
|
const label nProcs = UPstream::nProcs(comm_);
|
||||||
|
|
||||||
// Count all (non-local) elements needed. Just for presizing map.
|
// Count all (non-local) elements needed. Just for presizing map.
|
||||||
labelList nNonLocal(nProcs, Zero);
|
labelList nNonLocal(nProcs, Zero);
|
||||||
@ -495,8 +495,8 @@ void Foam::mapDistributeBase::exchangeAddressing
|
|||||||
labelList& compactStart
|
labelList& compactStart
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const label myRank = Pstream::myProcNo(comm_);
|
const label myRank = UPstream::myProcNo(comm_);
|
||||||
const label nProcs = Pstream::nProcs(comm_);
|
const label nProcs = UPstream::nProcs(comm_);
|
||||||
|
|
||||||
// The overall compact addressing is
|
// The overall compact addressing is
|
||||||
// - myProcNo data first (uncompacted)
|
// - myProcNo data first (uncompacted)
|
||||||
@ -575,8 +575,8 @@ void Foam::mapDistributeBase::exchangeAddressing
|
|||||||
labelList& compactStart
|
labelList& compactStart
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const label myRank = Pstream::myProcNo(comm_);
|
const label myRank = UPstream::myProcNo(comm_);
|
||||||
const label nProcs = Pstream::nProcs(comm_);
|
const label nProcs = UPstream::nProcs(comm_);
|
||||||
|
|
||||||
// The overall compact addressing is
|
// The overall compact addressing is
|
||||||
// - myProcNo data first (uncompacted)
|
// - myProcNo data first (uncompacted)
|
||||||
@ -724,8 +724,8 @@ Foam::mapDistributeBase::mapDistributeBase
|
|||||||
comm_(comm),
|
comm_(comm),
|
||||||
schedulePtr_(nullptr)
|
schedulePtr_(nullptr)
|
||||||
{
|
{
|
||||||
const label myRank = Pstream::myProcNo(comm_);
|
const label myRank = UPstream::myProcNo(comm_);
|
||||||
const label nProcs = Pstream::nProcs(comm_);
|
const label nProcs = UPstream::nProcs(comm_);
|
||||||
|
|
||||||
if (sendProcs.size() != recvProcs.size())
|
if (sendProcs.size() != recvProcs.size())
|
||||||
{
|
{
|
||||||
@ -922,6 +922,7 @@ Foam::mapDistributeBase::mapDistributeBase
|
|||||||
|
|
||||||
Foam::mapDistributeBase::mapDistributeBase
|
Foam::mapDistributeBase::mapDistributeBase
|
||||||
(
|
(
|
||||||
|
const layoutTypes constructLayout,
|
||||||
labelListList&& subMap,
|
labelListList&& subMap,
|
||||||
const bool subHasFlip,
|
const bool subHasFlip,
|
||||||
const bool constructHasFlip,
|
const bool constructHasFlip,
|
||||||
@ -936,30 +937,21 @@ Foam::mapDistributeBase::mapDistributeBase
|
|||||||
comm_(comm),
|
comm_(comm),
|
||||||
schedulePtr_(nullptr)
|
schedulePtr_(nullptr)
|
||||||
{
|
{
|
||||||
const label myRank = Pstream::myProcNo(comm_);
|
const label myRank = UPstream::myProcNo(comm_);
|
||||||
const label nProcs = Pstream::nProcs(comm_);
|
const label nProcs = UPstream::nProcs(comm_);
|
||||||
|
|
||||||
// Send over how many i need to receive.
|
// Send over how many i need to receive.
|
||||||
labelList recvSizes;
|
labelList recvSizes;
|
||||||
Pstream::exchangeSizes(subMap_, recvSizes, comm_);
|
Pstream::exchangeSizes(subMap_, recvSizes, comm_);
|
||||||
|
|
||||||
// Determine order of receiving
|
|
||||||
constructSize_ = 0;
|
constructSize_ = 0;
|
||||||
constructMap_.resize(nProcs);
|
constructMap_.resize(nProcs);
|
||||||
|
|
||||||
|
// The order of receiving:
|
||||||
|
|
||||||
// My data first
|
if (constructLayout == layoutTypes::linear)
|
||||||
{
|
{
|
||||||
const label len = recvSizes[myRank];
|
forAll(constructMap_, proci)
|
||||||
|
|
||||||
constructMap_[myRank] = identity(len, constructSize_);
|
|
||||||
constructSize_ += len;
|
|
||||||
}
|
|
||||||
|
|
||||||
// What the other processors are sending to me
|
|
||||||
forAll(constructMap_, proci)
|
|
||||||
{
|
|
||||||
if (proci != myRank)
|
|
||||||
{
|
{
|
||||||
const label len = recvSizes[proci];
|
const label len = recvSizes[proci];
|
||||||
|
|
||||||
@ -967,9 +959,52 @@ Foam::mapDistributeBase::mapDistributeBase
|
|||||||
constructSize_ += len;
|
constructSize_ += len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// layoutTypes::localFirst
|
||||||
|
|
||||||
|
// My data first
|
||||||
|
{
|
||||||
|
const label len = recvSizes[myRank];
|
||||||
|
|
||||||
|
constructMap_[myRank] = identity(len, constructSize_);
|
||||||
|
constructSize_ += len;
|
||||||
|
}
|
||||||
|
|
||||||
|
// What the other processors are sending to me
|
||||||
|
forAll(constructMap_, proci)
|
||||||
|
{
|
||||||
|
if (proci != myRank)
|
||||||
|
{
|
||||||
|
const label len = recvSizes[proci];
|
||||||
|
|
||||||
|
constructMap_[proci] = identity(len, constructSize_);
|
||||||
|
constructSize_ += len;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::mapDistributeBase::mapDistributeBase
|
||||||
|
(
|
||||||
|
labelListList&& subMap,
|
||||||
|
const bool subHasFlip,
|
||||||
|
const bool constructHasFlip,
|
||||||
|
const label comm
|
||||||
|
)
|
||||||
|
:
|
||||||
|
mapDistributeBase
|
||||||
|
(
|
||||||
|
layoutTypes::localFirst,
|
||||||
|
std::move(subMap),
|
||||||
|
subHasFlip,
|
||||||
|
constructHasFlip,
|
||||||
|
comm
|
||||||
|
)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::labelList Foam::mapDistributeBase::subMapSizes() const
|
Foam::labelList Foam::mapDistributeBase::subMapSizes() const
|
||||||
|
|||||||
@ -107,6 +107,18 @@ Ostream& operator<<(Ostream&, const InfoProxy<mapDistributeBase>&);
|
|||||||
|
|
||||||
class mapDistributeBase
|
class mapDistributeBase
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- The map layout (eg, of the constructMap)
|
||||||
|
enum class layoutTypes : char
|
||||||
|
{
|
||||||
|
linear, //!< In processor-order
|
||||||
|
localFirst //!< Local processor first, others in linear order
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
// Private Data
|
// Private Data
|
||||||
|
|
||||||
//- Size of reconstructed data
|
//- Size of reconstructed data
|
||||||
@ -432,6 +444,17 @@ public:
|
|||||||
const label comm = UPstream::worldComm
|
const label comm = UPstream::worldComm
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//- Construct from my elements to send, targetting the specified
|
||||||
|
//- constructMap layout
|
||||||
|
explicit mapDistributeBase
|
||||||
|
(
|
||||||
|
const layoutTypes constructLayout,
|
||||||
|
labelListList&& subMap,
|
||||||
|
const bool subHasFlip = false,
|
||||||
|
const bool constructHasFlip = false,
|
||||||
|
const label comm = UPstream::worldComm
|
||||||
|
);
|
||||||
|
|
||||||
//- Construct from my elements to send.
|
//- Construct from my elements to send.
|
||||||
// Assumes layout is my elements first followed by elements
|
// Assumes layout is my elements first followed by elements
|
||||||
// from all other processors in consecutive order.
|
// from all other processors in consecutive order.
|
||||||
@ -792,7 +815,7 @@ public:
|
|||||||
template<class T, class NegateOp>
|
template<class T, class NegateOp>
|
||||||
static void distribute
|
static void distribute
|
||||||
(
|
(
|
||||||
const Pstream::commsTypes commsType,
|
const UPstream::commsTypes commsType,
|
||||||
const List<labelPair>& schedule,
|
const List<labelPair>& schedule,
|
||||||
const label constructSize,
|
const label constructSize,
|
||||||
const labelListList& subMap,
|
const labelListList& subMap,
|
||||||
@ -812,7 +835,7 @@ public:
|
|||||||
template<class T, class CombineOp, class NegateOp>
|
template<class T, class CombineOp, class NegateOp>
|
||||||
static void distribute
|
static void distribute
|
||||||
(
|
(
|
||||||
const Pstream::commsTypes commsType,
|
const UPstream::commsTypes commsType,
|
||||||
const List<labelPair>& schedule,
|
const List<labelPair>& schedule,
|
||||||
const label constructSize,
|
const label constructSize,
|
||||||
const labelListList& subMap,
|
const labelListList& subMap,
|
||||||
@ -828,7 +851,9 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
//- Distribute data using default commsType
|
// Distribute (simpler interface)
|
||||||
|
|
||||||
|
//- Distribute List data using default commsType
|
||||||
//- and the default flip/negate operator.
|
//- and the default flip/negate operator.
|
||||||
template<class T>
|
template<class T>
|
||||||
void distribute
|
void distribute
|
||||||
@ -837,7 +862,7 @@ public:
|
|||||||
const int tag = UPstream::msgType()
|
const int tag = UPstream::msgType()
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Distribute data using default commsType
|
//- Distribute DynamicList data using default commsType
|
||||||
//- and the default flip/negate operator.
|
//- and the default flip/negate operator.
|
||||||
template<class T>
|
template<class T>
|
||||||
void distribute
|
void distribute
|
||||||
@ -846,6 +871,26 @@ public:
|
|||||||
const int tag = UPstream::msgType()
|
const int tag = UPstream::msgType()
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
//- Distribute List data using specified commsType
|
||||||
|
//- and the default flip/negate operator.
|
||||||
|
template<class T>
|
||||||
|
void distribute
|
||||||
|
(
|
||||||
|
const UPstream::commsTypes commsType,
|
||||||
|
List<T>& values,
|
||||||
|
const int tag = UPstream::msgType()
|
||||||
|
) const;
|
||||||
|
|
||||||
|
//- Distribute DynamicList data using specified commsType
|
||||||
|
//- and the default flip/negate operator.
|
||||||
|
template<class T>
|
||||||
|
void distribute
|
||||||
|
(
|
||||||
|
const UPstream::commsTypes commsType,
|
||||||
|
DynamicList<T>& values,
|
||||||
|
const int tag = UPstream::msgType()
|
||||||
|
) const;
|
||||||
|
|
||||||
//- Distribute data using default commsType
|
//- Distribute data using default commsType
|
||||||
//- and the specified negate operator (for flips).
|
//- and the specified negate operator (for flips).
|
||||||
template<class T, class NegateOp>
|
template<class T, class NegateOp>
|
||||||
@ -864,7 +909,7 @@ public:
|
|||||||
template<class T, class NegateOp>
|
template<class T, class NegateOp>
|
||||||
void distribute
|
void distribute
|
||||||
(
|
(
|
||||||
const Pstream::commsTypes commsType,
|
const UPstream::commsTypes commsType,
|
||||||
List<T>& values,
|
List<T>& values,
|
||||||
const NegateOp& negOp,
|
const NegateOp& negOp,
|
||||||
const int tag = UPstream::msgType()
|
const int tag = UPstream::msgType()
|
||||||
@ -878,7 +923,7 @@ public:
|
|||||||
template<class T, class NegateOp>
|
template<class T, class NegateOp>
|
||||||
void distribute
|
void distribute
|
||||||
(
|
(
|
||||||
const Pstream::commsTypes commsType,
|
const UPstream::commsTypes commsType,
|
||||||
const T& nullValue,
|
const T& nullValue,
|
||||||
List<T>& values,
|
List<T>& values,
|
||||||
const NegateOp& negOp,
|
const NegateOp& negOp,
|
||||||
@ -886,6 +931,8 @@ public:
|
|||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|
||||||
|
// Reverse Distribute (simpler interface)
|
||||||
|
|
||||||
//- Reverse distribute data using default commsType
|
//- Reverse distribute data using default commsType
|
||||||
//- and the default flip/negate operator
|
//- and the default flip/negate operator
|
||||||
template<class T>
|
template<class T>
|
||||||
@ -914,7 +961,7 @@ public:
|
|||||||
template<class T>
|
template<class T>
|
||||||
void reverseDistribute
|
void reverseDistribute
|
||||||
(
|
(
|
||||||
const Pstream::commsTypes commsType,
|
const UPstream::commsTypes commsType,
|
||||||
const label constructSize,
|
const label constructSize,
|
||||||
List<T>& values,
|
List<T>& values,
|
||||||
const int tag = UPstream::msgType()
|
const int tag = UPstream::msgType()
|
||||||
@ -925,7 +972,7 @@ public:
|
|||||||
template<class T, class NegateOp>
|
template<class T, class NegateOp>
|
||||||
void reverseDistribute
|
void reverseDistribute
|
||||||
(
|
(
|
||||||
const Pstream::commsTypes commsType,
|
const UPstream::commsTypes commsType,
|
||||||
const label constructSize,
|
const label constructSize,
|
||||||
List<T>& values,
|
List<T>& values,
|
||||||
const NegateOp& negOp,
|
const NegateOp& negOp,
|
||||||
@ -939,7 +986,7 @@ public:
|
|||||||
template<class T>
|
template<class T>
|
||||||
void reverseDistribute
|
void reverseDistribute
|
||||||
(
|
(
|
||||||
const Pstream::commsTypes commsType,
|
const UPstream::commsTypes commsType,
|
||||||
const label constructSize,
|
const label constructSize,
|
||||||
const T& nullValue,
|
const T& nullValue,
|
||||||
List<T>& values,
|
List<T>& values,
|
||||||
@ -947,6 +994,8 @@ public:
|
|||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|
||||||
|
// Send/Receive
|
||||||
|
|
||||||
//- Do all sends using PstreamBuffers
|
//- Do all sends using PstreamBuffers
|
||||||
template<class T>
|
template<class T>
|
||||||
void send(PstreamBuffers& pBufs, const List<T>& field) const;
|
void send(PstreamBuffers& pBufs, const List<T>& field) const;
|
||||||
|
|||||||
@ -216,7 +216,7 @@ void Foam::mapDistributeBase::unionCombineMasks
|
|||||||
<< Foam::abort(FatalError);
|
<< Foam::abort(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Pstream::parRun())
|
if (UPstream::parRun())
|
||||||
{
|
{
|
||||||
// Scratch buffers for union operations
|
// Scratch buffers for union operations
|
||||||
List<bitSet> scratch(recvMasks.size());
|
List<bitSet> scratch(recvMasks.size());
|
||||||
@ -254,7 +254,7 @@ void Foam::mapDistributeBase::unionCombineMasks
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Non-parallel: 'synchronize' myself
|
// Non-parallel: 'synchronize' myself
|
||||||
const label myRank = Pstream::myProcNo(comm);
|
const label myRank = UPstream::myProcNo(comm);
|
||||||
|
|
||||||
recvMasks[myRank] &= sendMasks[myRank];
|
recvMasks[myRank] &= sendMasks[myRank];
|
||||||
sendMasks[myRank] = recvMasks[myRank];
|
sendMasks[myRank] = recvMasks[myRank];
|
||||||
|
|||||||
@ -417,7 +417,7 @@ void Foam::mapDistributeBase::receive
|
|||||||
template<class T, class NegateOp>
|
template<class T, class NegateOp>
|
||||||
void Foam::mapDistributeBase::distribute
|
void Foam::mapDistributeBase::distribute
|
||||||
(
|
(
|
||||||
const Pstream::commsTypes commsType,
|
const UPstream::commsTypes commsType,
|
||||||
const List<labelPair>& schedule,
|
const List<labelPair>& schedule,
|
||||||
const label constructSize,
|
const label constructSize,
|
||||||
const labelListList& subMap,
|
const labelListList& subMap,
|
||||||
@ -430,10 +430,10 @@ void Foam::mapDistributeBase::distribute
|
|||||||
const label comm
|
const label comm
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const label myRank = Pstream::myProcNo(comm);
|
const label myRank = UPstream::myProcNo(comm);
|
||||||
const label nProcs = Pstream::nProcs(comm);
|
const label nProcs = UPstream::nProcs(comm);
|
||||||
|
|
||||||
if (!Pstream::parRun())
|
if (!UPstream::parRun())
|
||||||
{
|
{
|
||||||
// Do only me to me.
|
// Do only me to me.
|
||||||
|
|
||||||
@ -460,13 +460,13 @@ void Foam::mapDistributeBase::distribute
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (commsType == Pstream::commsTypes::blocking)
|
if (commsType == UPstream::commsTypes::blocking)
|
||||||
{
|
{
|
||||||
// Since buffered sending can reuse the field to collect the
|
// Since buffered sending can reuse the field to collect the
|
||||||
// received data.
|
// received data.
|
||||||
|
|
||||||
// Send sub field to neighbour
|
// Send sub field to neighbour
|
||||||
for (const int domain : Pstream::allProcs(comm))
|
for (const int domain : UPstream::allProcs(comm))
|
||||||
{
|
{
|
||||||
const labelList& map = subMap[domain];
|
const labelList& map = subMap[domain];
|
||||||
|
|
||||||
@ -474,7 +474,7 @@ void Foam::mapDistributeBase::distribute
|
|||||||
{
|
{
|
||||||
OPstream toNbr
|
OPstream toNbr
|
||||||
(
|
(
|
||||||
Pstream::commsTypes::blocking,
|
UPstream::commsTypes::blocking,
|
||||||
domain,
|
domain,
|
||||||
0,
|
0,
|
||||||
tag,
|
tag,
|
||||||
@ -514,7 +514,7 @@ void Foam::mapDistributeBase::distribute
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Receive sub field from neighbour
|
// Receive sub field from neighbour
|
||||||
for (const int domain : Pstream::allProcs(comm))
|
for (const int domain : UPstream::allProcs(comm))
|
||||||
{
|
{
|
||||||
const labelList& map = constructMap[domain];
|
const labelList& map = constructMap[domain];
|
||||||
|
|
||||||
@ -522,7 +522,7 @@ void Foam::mapDistributeBase::distribute
|
|||||||
{
|
{
|
||||||
IPstream fromNbr
|
IPstream fromNbr
|
||||||
(
|
(
|
||||||
Pstream::commsTypes::blocking,
|
UPstream::commsTypes::blocking,
|
||||||
domain,
|
domain,
|
||||||
0,
|
0,
|
||||||
tag,
|
tag,
|
||||||
@ -544,7 +544,7 @@ void Foam::mapDistributeBase::distribute
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (commsType == Pstream::commsTypes::scheduled)
|
else if (commsType == UPstream::commsTypes::scheduled)
|
||||||
{
|
{
|
||||||
// Need to make sure I don't overwrite field with received data
|
// Need to make sure I don't overwrite field with received data
|
||||||
// since the data might need to be sent to another processor. So
|
// since the data might need to be sent to another processor. So
|
||||||
@ -587,7 +587,7 @@ void Foam::mapDistributeBase::distribute
|
|||||||
{
|
{
|
||||||
OPstream toNbr
|
OPstream toNbr
|
||||||
(
|
(
|
||||||
Pstream::commsTypes::scheduled,
|
UPstream::commsTypes::scheduled,
|
||||||
recvProc,
|
recvProc,
|
||||||
0,
|
0,
|
||||||
tag,
|
tag,
|
||||||
@ -605,7 +605,7 @@ void Foam::mapDistributeBase::distribute
|
|||||||
{
|
{
|
||||||
IPstream fromNbr
|
IPstream fromNbr
|
||||||
(
|
(
|
||||||
Pstream::commsTypes::scheduled,
|
UPstream::commsTypes::scheduled,
|
||||||
recvProc,
|
recvProc,
|
||||||
0,
|
0,
|
||||||
tag,
|
tag,
|
||||||
@ -634,7 +634,7 @@ void Foam::mapDistributeBase::distribute
|
|||||||
{
|
{
|
||||||
IPstream fromNbr
|
IPstream fromNbr
|
||||||
(
|
(
|
||||||
Pstream::commsTypes::scheduled,
|
UPstream::commsTypes::scheduled,
|
||||||
sendProc,
|
sendProc,
|
||||||
0,
|
0,
|
||||||
tag,
|
tag,
|
||||||
@ -659,7 +659,7 @@ void Foam::mapDistributeBase::distribute
|
|||||||
{
|
{
|
||||||
OPstream toNbr
|
OPstream toNbr
|
||||||
(
|
(
|
||||||
Pstream::commsTypes::scheduled,
|
UPstream::commsTypes::scheduled,
|
||||||
sendProc,
|
sendProc,
|
||||||
0,
|
0,
|
||||||
tag,
|
tag,
|
||||||
@ -678,16 +678,16 @@ void Foam::mapDistributeBase::distribute
|
|||||||
}
|
}
|
||||||
field.transfer(newField);
|
field.transfer(newField);
|
||||||
}
|
}
|
||||||
else if (commsType == Pstream::commsTypes::nonBlocking)
|
else if (commsType == UPstream::commsTypes::nonBlocking)
|
||||||
{
|
{
|
||||||
const label nOutstanding = Pstream::nRequests();
|
const label nOutstanding = UPstream::nRequests();
|
||||||
|
|
||||||
if (!is_contiguous<T>::value)
|
if (!is_contiguous<T>::value)
|
||||||
{
|
{
|
||||||
PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking, tag, comm);
|
PstreamBuffers pBufs(UPstream::commsTypes::nonBlocking, tag, comm);
|
||||||
|
|
||||||
// Stream data into buffer
|
// Stream data into buffer
|
||||||
for (const int domain : Pstream::allProcs(comm))
|
for (const int domain : UPstream::allProcs(comm))
|
||||||
{
|
{
|
||||||
const labelList& map = subMap[domain];
|
const labelList& map = subMap[domain];
|
||||||
|
|
||||||
@ -733,10 +733,10 @@ void Foam::mapDistributeBase::distribute
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Block ourselves, waiting only for the current comms
|
// Block ourselves, waiting only for the current comms
|
||||||
Pstream::waitRequests(nOutstanding);
|
UPstream::waitRequests(nOutstanding);
|
||||||
|
|
||||||
// Consume
|
// Consume
|
||||||
for (const int domain : Pstream::allProcs(comm))
|
for (const int domain : UPstream::allProcs(comm))
|
||||||
{
|
{
|
||||||
const labelList& map = constructMap[domain];
|
const labelList& map = constructMap[domain];
|
||||||
|
|
||||||
@ -765,7 +765,7 @@ void Foam::mapDistributeBase::distribute
|
|||||||
|
|
||||||
List<List<T>> sendFields(nProcs);
|
List<List<T>> sendFields(nProcs);
|
||||||
|
|
||||||
for (const int domain : Pstream::allProcs(comm))
|
for (const int domain : UPstream::allProcs(comm))
|
||||||
{
|
{
|
||||||
const labelList& map = subMap[domain];
|
const labelList& map = subMap[domain];
|
||||||
|
|
||||||
@ -776,7 +776,7 @@ void Foam::mapDistributeBase::distribute
|
|||||||
|
|
||||||
UOPstream::write
|
UOPstream::write
|
||||||
(
|
(
|
||||||
Pstream::commsTypes::nonBlocking,
|
UPstream::commsTypes::nonBlocking,
|
||||||
domain,
|
domain,
|
||||||
sendFields[domain].cdata_bytes(),
|
sendFields[domain].cdata_bytes(),
|
||||||
sendFields[domain].size_bytes(),
|
sendFields[domain].size_bytes(),
|
||||||
@ -790,7 +790,7 @@ void Foam::mapDistributeBase::distribute
|
|||||||
|
|
||||||
List<List<T>> recvFields(nProcs);
|
List<List<T>> recvFields(nProcs);
|
||||||
|
|
||||||
for (const int domain : Pstream::allProcs(comm))
|
for (const int domain : UPstream::allProcs(comm))
|
||||||
{
|
{
|
||||||
const labelList& map = constructMap[domain];
|
const labelList& map = constructMap[domain];
|
||||||
|
|
||||||
@ -799,7 +799,7 @@ void Foam::mapDistributeBase::distribute
|
|||||||
recvFields[domain].resize(map.size());
|
recvFields[domain].resize(map.size());
|
||||||
UIPstream::read
|
UIPstream::read
|
||||||
(
|
(
|
||||||
Pstream::commsTypes::nonBlocking,
|
UPstream::commsTypes::nonBlocking,
|
||||||
domain,
|
domain,
|
||||||
recvFields[domain].data_bytes(),
|
recvFields[domain].data_bytes(),
|
||||||
recvFields[domain].size_bytes(),
|
recvFields[domain].size_bytes(),
|
||||||
@ -839,12 +839,12 @@ void Foam::mapDistributeBase::distribute
|
|||||||
|
|
||||||
|
|
||||||
// Wait for outstanding requests
|
// Wait for outstanding requests
|
||||||
Pstream::waitRequests(nOutstanding);
|
UPstream::waitRequests(nOutstanding);
|
||||||
|
|
||||||
|
|
||||||
// Collect neighbour fields
|
// Collect neighbour fields
|
||||||
|
|
||||||
for (const int domain : Pstream::allProcs(comm))
|
for (const int domain : UPstream::allProcs(comm))
|
||||||
{
|
{
|
||||||
const labelList& map = constructMap[domain];
|
const labelList& map = constructMap[domain];
|
||||||
|
|
||||||
@ -879,7 +879,7 @@ void Foam::mapDistributeBase::distribute
|
|||||||
template<class T, class CombineOp, class NegateOp>
|
template<class T, class CombineOp, class NegateOp>
|
||||||
void Foam::mapDistributeBase::distribute
|
void Foam::mapDistributeBase::distribute
|
||||||
(
|
(
|
||||||
const Pstream::commsTypes commsType,
|
const UPstream::commsTypes commsType,
|
||||||
const List<labelPair>& schedule,
|
const List<labelPair>& schedule,
|
||||||
const label constructSize,
|
const label constructSize,
|
||||||
const labelListList& subMap,
|
const labelListList& subMap,
|
||||||
@ -894,10 +894,10 @@ void Foam::mapDistributeBase::distribute
|
|||||||
const label comm
|
const label comm
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const label myRank = Pstream::myProcNo(comm);
|
const label myRank = UPstream::myProcNo(comm);
|
||||||
const label nProcs = Pstream::nProcs(comm);
|
const label nProcs = UPstream::nProcs(comm);
|
||||||
|
|
||||||
if (!Pstream::parRun())
|
if (!UPstream::parRun())
|
||||||
{
|
{
|
||||||
// Do only me to me.
|
// Do only me to me.
|
||||||
|
|
||||||
@ -917,13 +917,13 @@ void Foam::mapDistributeBase::distribute
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (commsType == Pstream::commsTypes::blocking)
|
if (commsType == UPstream::commsTypes::blocking)
|
||||||
{
|
{
|
||||||
// Since buffered sending can reuse the field to collect the
|
// Since buffered sending can reuse the field to collect the
|
||||||
// received data.
|
// received data.
|
||||||
|
|
||||||
// Send sub field to neighbour
|
// Send sub field to neighbour
|
||||||
for (const int domain : Pstream::allProcs(comm))
|
for (const int domain : UPstream::allProcs(comm))
|
||||||
{
|
{
|
||||||
const labelList& map = subMap[domain];
|
const labelList& map = subMap[domain];
|
||||||
|
|
||||||
@ -931,7 +931,7 @@ void Foam::mapDistributeBase::distribute
|
|||||||
{
|
{
|
||||||
OPstream toNbr
|
OPstream toNbr
|
||||||
(
|
(
|
||||||
Pstream::commsTypes::blocking,
|
UPstream::commsTypes::blocking,
|
||||||
domain,
|
domain,
|
||||||
0,
|
0,
|
||||||
tag,
|
tag,
|
||||||
@ -971,7 +971,7 @@ void Foam::mapDistributeBase::distribute
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Receive sub field from neighbour
|
// Receive sub field from neighbour
|
||||||
for (const int domain : Pstream::allProcs(comm))
|
for (const int domain : UPstream::allProcs(comm))
|
||||||
{
|
{
|
||||||
const labelList& map = constructMap[domain];
|
const labelList& map = constructMap[domain];
|
||||||
|
|
||||||
@ -979,7 +979,7 @@ void Foam::mapDistributeBase::distribute
|
|||||||
{
|
{
|
||||||
IPstream fromNbr
|
IPstream fromNbr
|
||||||
(
|
(
|
||||||
Pstream::commsTypes::blocking,
|
UPstream::commsTypes::blocking,
|
||||||
domain,
|
domain,
|
||||||
0,
|
0,
|
||||||
tag,
|
tag,
|
||||||
@ -1001,7 +1001,7 @@ void Foam::mapDistributeBase::distribute
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (commsType == Pstream::commsTypes::scheduled)
|
else if (commsType == UPstream::commsTypes::scheduled)
|
||||||
{
|
{
|
||||||
// Need to make sure I don't overwrite field with received data
|
// Need to make sure I don't overwrite field with received data
|
||||||
// since the data might need to be sent to another processor. So
|
// since the data might need to be sent to another processor. So
|
||||||
@ -1045,7 +1045,7 @@ void Foam::mapDistributeBase::distribute
|
|||||||
{
|
{
|
||||||
OPstream toNbr
|
OPstream toNbr
|
||||||
(
|
(
|
||||||
Pstream::commsTypes::scheduled,
|
UPstream::commsTypes::scheduled,
|
||||||
recvProc,
|
recvProc,
|
||||||
0,
|
0,
|
||||||
tag,
|
tag,
|
||||||
@ -1064,7 +1064,7 @@ void Foam::mapDistributeBase::distribute
|
|||||||
{
|
{
|
||||||
IPstream fromNbr
|
IPstream fromNbr
|
||||||
(
|
(
|
||||||
Pstream::commsTypes::scheduled,
|
UPstream::commsTypes::scheduled,
|
||||||
recvProc,
|
recvProc,
|
||||||
0,
|
0,
|
||||||
tag,
|
tag,
|
||||||
@ -1092,7 +1092,7 @@ void Foam::mapDistributeBase::distribute
|
|||||||
{
|
{
|
||||||
IPstream fromNbr
|
IPstream fromNbr
|
||||||
(
|
(
|
||||||
Pstream::commsTypes::scheduled,
|
UPstream::commsTypes::scheduled,
|
||||||
sendProc,
|
sendProc,
|
||||||
0,
|
0,
|
||||||
tag,
|
tag,
|
||||||
@ -1116,7 +1116,7 @@ void Foam::mapDistributeBase::distribute
|
|||||||
{
|
{
|
||||||
OPstream toNbr
|
OPstream toNbr
|
||||||
(
|
(
|
||||||
Pstream::commsTypes::scheduled,
|
UPstream::commsTypes::scheduled,
|
||||||
sendProc,
|
sendProc,
|
||||||
0,
|
0,
|
||||||
tag,
|
tag,
|
||||||
@ -1136,16 +1136,16 @@ void Foam::mapDistributeBase::distribute
|
|||||||
}
|
}
|
||||||
field.transfer(newField);
|
field.transfer(newField);
|
||||||
}
|
}
|
||||||
else if (commsType == Pstream::commsTypes::nonBlocking)
|
else if (commsType == UPstream::commsTypes::nonBlocking)
|
||||||
{
|
{
|
||||||
const label nOutstanding = Pstream::nRequests();
|
const label nOutstanding = UPstream::nRequests();
|
||||||
|
|
||||||
if (!is_contiguous<T>::value)
|
if (!is_contiguous<T>::value)
|
||||||
{
|
{
|
||||||
PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking, tag, comm);
|
PstreamBuffers pBufs(UPstream::commsTypes::nonBlocking, tag, comm);
|
||||||
|
|
||||||
// Stream data into buffer
|
// Stream data into buffer
|
||||||
for (const int domain : Pstream::allProcs(comm))
|
for (const int domain : UPstream::allProcs(comm))
|
||||||
{
|
{
|
||||||
const labelList& map = subMap[domain];
|
const labelList& map = subMap[domain];
|
||||||
|
|
||||||
@ -1192,10 +1192,10 @@ void Foam::mapDistributeBase::distribute
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Block ourselves, waiting only for the current comms
|
// Block ourselves, waiting only for the current comms
|
||||||
Pstream::waitRequests(nOutstanding);
|
UPstream::waitRequests(nOutstanding);
|
||||||
|
|
||||||
// Consume
|
// Consume
|
||||||
for (const int domain : Pstream::allProcs(comm))
|
for (const int domain : UPstream::allProcs(comm))
|
||||||
{
|
{
|
||||||
const labelList& map = constructMap[domain];
|
const labelList& map = constructMap[domain];
|
||||||
|
|
||||||
@ -1224,7 +1224,7 @@ void Foam::mapDistributeBase::distribute
|
|||||||
|
|
||||||
List<List<T>> sendFields(nProcs);
|
List<List<T>> sendFields(nProcs);
|
||||||
|
|
||||||
for (const int domain : Pstream::allProcs(comm))
|
for (const int domain : UPstream::allProcs(comm))
|
||||||
{
|
{
|
||||||
const labelList& map = subMap[domain];
|
const labelList& map = subMap[domain];
|
||||||
|
|
||||||
@ -1235,7 +1235,7 @@ void Foam::mapDistributeBase::distribute
|
|||||||
|
|
||||||
UOPstream::write
|
UOPstream::write
|
||||||
(
|
(
|
||||||
Pstream::commsTypes::nonBlocking,
|
UPstream::commsTypes::nonBlocking,
|
||||||
domain,
|
domain,
|
||||||
sendFields[domain].cdata_bytes(),
|
sendFields[domain].cdata_bytes(),
|
||||||
sendFields[domain].size_bytes(),
|
sendFields[domain].size_bytes(),
|
||||||
@ -1249,7 +1249,7 @@ void Foam::mapDistributeBase::distribute
|
|||||||
|
|
||||||
List<List<T>> recvFields(nProcs);
|
List<List<T>> recvFields(nProcs);
|
||||||
|
|
||||||
for (const int domain : Pstream::allProcs(comm))
|
for (const int domain : UPstream::allProcs(comm))
|
||||||
{
|
{
|
||||||
const labelList& map = constructMap[domain];
|
const labelList& map = constructMap[domain];
|
||||||
|
|
||||||
@ -1258,7 +1258,7 @@ void Foam::mapDistributeBase::distribute
|
|||||||
recvFields[domain].resize(map.size());
|
recvFields[domain].resize(map.size());
|
||||||
UIPstream::read
|
UIPstream::read
|
||||||
(
|
(
|
||||||
Pstream::commsTypes::nonBlocking,
|
UPstream::commsTypes::nonBlocking,
|
||||||
domain,
|
domain,
|
||||||
recvFields[domain].data_bytes(),
|
recvFields[domain].data_bytes(),
|
||||||
recvFields[domain].size_bytes(),
|
recvFields[domain].size_bytes(),
|
||||||
@ -1298,12 +1298,12 @@ void Foam::mapDistributeBase::distribute
|
|||||||
|
|
||||||
|
|
||||||
// Wait for outstanding requests
|
// Wait for outstanding requests
|
||||||
Pstream::waitRequests(nOutstanding);
|
UPstream::waitRequests(nOutstanding);
|
||||||
|
|
||||||
|
|
||||||
// Collect neighbour fields
|
// Collect neighbour fields
|
||||||
|
|
||||||
for (const int domain : Pstream::allProcs(comm))
|
for (const int domain : UPstream::allProcs(comm))
|
||||||
{
|
{
|
||||||
const labelList& map = constructMap[domain];
|
const labelList& map = constructMap[domain];
|
||||||
|
|
||||||
@ -1340,7 +1340,7 @@ void Foam::mapDistributeBase::send(PstreamBuffers& pBufs, const List<T>& field)
|
|||||||
const
|
const
|
||||||
{
|
{
|
||||||
// Stream data into buffer
|
// Stream data into buffer
|
||||||
for (const int domain : Pstream::allProcs(comm_))
|
for (const int domain : UPstream::allProcs(comm_))
|
||||||
{
|
{
|
||||||
const labelList& map = subMap_[domain];
|
const labelList& map = subMap_[domain];
|
||||||
|
|
||||||
@ -1370,7 +1370,7 @@ const
|
|||||||
// Consume
|
// Consume
|
||||||
field.resize_nocopy(constructSize_);
|
field.resize_nocopy(constructSize_);
|
||||||
|
|
||||||
for (const int domain : Pstream::allProcs(comm_))
|
for (const int domain : UPstream::allProcs(comm_))
|
||||||
{
|
{
|
||||||
const labelList& map = constructMap_[domain];
|
const labelList& map = constructMap_[domain];
|
||||||
|
|
||||||
@ -1405,7 +1405,7 @@ const
|
|||||||
template<class T, class NegateOp>
|
template<class T, class NegateOp>
|
||||||
void Foam::mapDistributeBase::distribute
|
void Foam::mapDistributeBase::distribute
|
||||||
(
|
(
|
||||||
const Pstream::commsTypes commsType,
|
const UPstream::commsTypes commsType,
|
||||||
List<T>& values,
|
List<T>& values,
|
||||||
const NegateOp& negOp,
|
const NegateOp& negOp,
|
||||||
const int tag
|
const int tag
|
||||||
@ -1431,7 +1431,7 @@ void Foam::mapDistributeBase::distribute
|
|||||||
template<class T, class NegateOp>
|
template<class T, class NegateOp>
|
||||||
void Foam::mapDistributeBase::distribute
|
void Foam::mapDistributeBase::distribute
|
||||||
(
|
(
|
||||||
const Pstream::commsTypes commsType,
|
const UPstream::commsTypes commsType,
|
||||||
const T& nullValue,
|
const T& nullValue,
|
||||||
List<T>& values,
|
List<T>& values,
|
||||||
const NegateOp& negOp,
|
const NegateOp& negOp,
|
||||||
@ -1475,11 +1475,41 @@ void Foam::mapDistributeBase::distribute
|
|||||||
template<class T>
|
template<class T>
|
||||||
void Foam::mapDistributeBase::distribute
|
void Foam::mapDistributeBase::distribute
|
||||||
(
|
(
|
||||||
|
const UPstream::commsTypes commsType,
|
||||||
List<T>& values,
|
List<T>& values,
|
||||||
const int tag
|
const int tag
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
distribute(values, flipOp(), tag);
|
distribute(commsType, values, flipOp(), tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
void Foam::mapDistributeBase::distribute
|
||||||
|
(
|
||||||
|
const UPstream::commsTypes commsType,
|
||||||
|
DynamicList<T>& values,
|
||||||
|
const int tag
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
values.shrink();
|
||||||
|
|
||||||
|
List<T>& list = static_cast<List<T>&>(values);
|
||||||
|
|
||||||
|
distribute(commsType, list, tag);
|
||||||
|
|
||||||
|
values.setCapacity(list.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
void Foam::mapDistributeBase::distribute
|
||||||
|
(
|
||||||
|
List<T>& values,
|
||||||
|
const int tag
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
distribute(UPstream::defaultCommsType, values, tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1490,20 +1520,14 @@ void Foam::mapDistributeBase::distribute
|
|||||||
const int tag
|
const int tag
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
values.shrink();
|
distribute(UPstream::defaultCommsType, values, tag);
|
||||||
|
|
||||||
List<T>& list = static_cast<List<T>&>(values);
|
|
||||||
|
|
||||||
distribute(list, tag);
|
|
||||||
|
|
||||||
values.setCapacity(list.size());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
void Foam::mapDistributeBase::reverseDistribute
|
void Foam::mapDistributeBase::reverseDistribute
|
||||||
(
|
(
|
||||||
const Pstream::commsTypes commsType,
|
const UPstream::commsTypes commsType,
|
||||||
const label constructSize,
|
const label constructSize,
|
||||||
List<T>& values,
|
List<T>& values,
|
||||||
const int tag
|
const int tag
|
||||||
@ -1523,7 +1547,7 @@ void Foam::mapDistributeBase::reverseDistribute
|
|||||||
template<class T, class NegateOp>
|
template<class T, class NegateOp>
|
||||||
void Foam::mapDistributeBase::reverseDistribute
|
void Foam::mapDistributeBase::reverseDistribute
|
||||||
(
|
(
|
||||||
const Pstream::commsTypes commsType,
|
const UPstream::commsTypes commsType,
|
||||||
const label constructSize,
|
const label constructSize,
|
||||||
List<T>& values,
|
List<T>& values,
|
||||||
const NegateOp& negOp,
|
const NegateOp& negOp,
|
||||||
@ -1550,7 +1574,7 @@ void Foam::mapDistributeBase::reverseDistribute
|
|||||||
template<class T>
|
template<class T>
|
||||||
void Foam::mapDistributeBase::reverseDistribute
|
void Foam::mapDistributeBase::reverseDistribute
|
||||||
(
|
(
|
||||||
const Pstream::commsTypes commsType,
|
const UPstream::commsTypes commsType,
|
||||||
const label constructSize,
|
const label constructSize,
|
||||||
const T& nullValue,
|
const T& nullValue,
|
||||||
List<T>& values,
|
List<T>& values,
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
Copyright (C) 2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -39,7 +40,6 @@ void Foam::mapDistribute::applyDummyTransforms(List<T>& field) const
|
|||||||
forAll(transformElements_, trafoI)
|
forAll(transformElements_, trafoI)
|
||||||
{
|
{
|
||||||
const labelList& elems = transformElements_[trafoI];
|
const labelList& elems = transformElements_[trafoI];
|
||||||
|
|
||||||
label n = transformStart_[trafoI];
|
label n = transformStart_[trafoI];
|
||||||
|
|
||||||
forAll(elems, i)
|
forAll(elems, i)
|
||||||
@ -129,13 +129,14 @@ void Foam::mapDistribute::applyInverseTransforms
|
|||||||
template<class T, class NegateOp>
|
template<class T, class NegateOp>
|
||||||
void Foam::mapDistribute::distribute
|
void Foam::mapDistribute::distribute
|
||||||
(
|
(
|
||||||
|
const UPstream::commsTypes commsType,
|
||||||
List<T>& fld,
|
List<T>& fld,
|
||||||
const NegateOp& negOp,
|
const NegateOp& negOp,
|
||||||
const bool dummyTransform,
|
const bool dummyTransform,
|
||||||
const int tag
|
const int tag
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
mapDistributeBase::distribute(fld, negOp, tag);
|
mapDistributeBase::distribute(commsType, fld, negOp, tag);
|
||||||
|
|
||||||
//- Fill in transformed slots with copies
|
//- Fill in transformed slots with copies
|
||||||
if (dummyTransform)
|
if (dummyTransform)
|
||||||
@ -145,6 +146,32 @@ void Foam::mapDistribute::distribute
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T, class NegateOp>
|
||||||
|
void Foam::mapDistribute::distribute
|
||||||
|
(
|
||||||
|
List<T>& fld,
|
||||||
|
const NegateOp& negOp,
|
||||||
|
const bool dummyTransform,
|
||||||
|
const int tag
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
distribute(UPstream::defaultCommsType, fld, negOp, dummyTransform, tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
void Foam::mapDistribute::distribute
|
||||||
|
(
|
||||||
|
const UPstream::commsTypes commsType,
|
||||||
|
List<T>& fld,
|
||||||
|
const bool dummyTransform,
|
||||||
|
const int tag
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
distribute(commsType, fld, flipOp(), dummyTransform, tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
void Foam::mapDistribute::distribute
|
void Foam::mapDistribute::distribute
|
||||||
(
|
(
|
||||||
@ -153,7 +180,26 @@ void Foam::mapDistribute::distribute
|
|||||||
const int tag
|
const int tag
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
distribute(fld, flipOp(), dummyTransform, tag);
|
distribute(UPstream::defaultCommsType, fld, dummyTransform, tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
void Foam::mapDistribute::distribute
|
||||||
|
(
|
||||||
|
const UPstream::commsTypes commsType,
|
||||||
|
DynamicList<T>& fld,
|
||||||
|
const bool dummyTransform,
|
||||||
|
const int tag
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
fld.shrink();
|
||||||
|
|
||||||
|
List<T>& list = static_cast<List<T>&>(fld);
|
||||||
|
|
||||||
|
distribute(commsType, list, dummyTransform, tag);
|
||||||
|
|
||||||
|
fld.setCapacity(list.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -165,13 +211,26 @@ void Foam::mapDistribute::distribute
|
|||||||
const int tag
|
const int tag
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
fld.shrink();
|
distribute(UPstream::defaultCommsType, fld, dummyTransform, tag);
|
||||||
|
}
|
||||||
|
|
||||||
List<T>& list = static_cast<List<T>&>(fld);
|
|
||||||
|
|
||||||
distribute(list, dummyTransform, tag);
|
template<class T>
|
||||||
|
void Foam::mapDistribute::reverseDistribute
|
||||||
|
(
|
||||||
|
const UPstream::commsTypes commsType,
|
||||||
|
const label constructSize,
|
||||||
|
List<T>& fld,
|
||||||
|
const bool dummyTransform,
|
||||||
|
const int tag
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
if (dummyTransform)
|
||||||
|
{
|
||||||
|
applyDummyInverseTransforms(fld);
|
||||||
|
}
|
||||||
|
|
||||||
fld.setCapacity(list.size());
|
mapDistributeBase::reverseDistribute(commsType, constructSize, fld, tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -183,13 +242,42 @@ void Foam::mapDistribute::reverseDistribute
|
|||||||
const bool dummyTransform,
|
const bool dummyTransform,
|
||||||
const int tag
|
const int tag
|
||||||
) const
|
) const
|
||||||
|
{
|
||||||
|
reverseDistribute
|
||||||
|
(
|
||||||
|
UPstream::defaultCommsType,
|
||||||
|
constructSize,
|
||||||
|
fld,
|
||||||
|
dummyTransform,
|
||||||
|
tag
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
void Foam::mapDistribute::reverseDistribute
|
||||||
|
(
|
||||||
|
const UPstream::commsTypes commsType,
|
||||||
|
const label constructSize,
|
||||||
|
const T& nullValue,
|
||||||
|
List<T>& fld,
|
||||||
|
const bool dummyTransform,
|
||||||
|
const int tag
|
||||||
|
) const
|
||||||
{
|
{
|
||||||
if (dummyTransform)
|
if (dummyTransform)
|
||||||
{
|
{
|
||||||
applyDummyInverseTransforms(fld);
|
applyDummyInverseTransforms(fld);
|
||||||
}
|
}
|
||||||
|
|
||||||
mapDistributeBase::reverseDistribute(constructSize, fld, tag);
|
mapDistributeBase::reverseDistribute
|
||||||
|
(
|
||||||
|
commsType,
|
||||||
|
constructSize,
|
||||||
|
nullValue,
|
||||||
|
fld,
|
||||||
|
tag
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -203,12 +291,33 @@ void Foam::mapDistribute::reverseDistribute
|
|||||||
const int tag
|
const int tag
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
if (dummyTransform)
|
reverseDistribute
|
||||||
{
|
(
|
||||||
applyDummyInverseTransforms(fld);
|
UPstream::defaultCommsType,
|
||||||
}
|
constructSize,
|
||||||
|
nullValue,
|
||||||
|
fld,
|
||||||
|
dummyTransform,
|
||||||
|
tag
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
mapDistributeBase::reverseDistribute(constructSize, nullValue, fld, tag);
|
|
||||||
|
template<class T, class TransformOp>
|
||||||
|
void Foam::mapDistribute::distribute
|
||||||
|
(
|
||||||
|
const UPstream::commsTypes commsType,
|
||||||
|
const globalIndexAndTransform& git,
|
||||||
|
List<T>& fld,
|
||||||
|
const TransformOp& top,
|
||||||
|
const int tag
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
// Distribute. Leave out dummy transforms since we're doing them ourselves
|
||||||
|
distribute(commsType, fld, false, tag);
|
||||||
|
|
||||||
|
// Do transforms
|
||||||
|
applyTransforms(git, fld, top);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -222,10 +331,28 @@ void Foam::mapDistribute::distribute
|
|||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
// Distribute. Leave out dummy transforms since we're doing them ourselves
|
// Distribute. Leave out dummy transforms since we're doing them ourselves
|
||||||
distribute(fld, false, tag);
|
distribute(UPstream::defaultCommsType, git, fld, top, tag);
|
||||||
|
}
|
||||||
|
|
||||||
// Do transforms
|
|
||||||
applyTransforms(git, fld, top);
|
template<class T, class TransformOp>
|
||||||
|
void Foam::mapDistribute::reverseDistribute
|
||||||
|
(
|
||||||
|
const UPstream::commsTypes commsType,
|
||||||
|
const globalIndexAndTransform& git,
|
||||||
|
const label constructSize,
|
||||||
|
List<T>& fld,
|
||||||
|
const TransformOp& top,
|
||||||
|
const int tag
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
// Fill slots with reverse-transformed data. Note that it also copies
|
||||||
|
// back into the non-remote part of fld even though these values are not
|
||||||
|
// used.
|
||||||
|
applyInverseTransforms(git, fld, top);
|
||||||
|
|
||||||
|
// And send back (the remote slots). Disable dummy transformations.
|
||||||
|
reverseDistribute(commsType, constructSize, fld, false, tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -252,6 +379,7 @@ void Foam::mapDistribute::reverseDistribute
|
|||||||
template<class T, class TransformOp>
|
template<class T, class TransformOp>
|
||||||
void Foam::mapDistribute::reverseDistribute
|
void Foam::mapDistribute::reverseDistribute
|
||||||
(
|
(
|
||||||
|
const UPstream::commsTypes commsType,
|
||||||
const globalIndexAndTransform& git,
|
const globalIndexAndTransform& git,
|
||||||
const label constructSize,
|
const label constructSize,
|
||||||
const T& nullValue,
|
const T& nullValue,
|
||||||
@ -266,7 +394,39 @@ void Foam::mapDistribute::reverseDistribute
|
|||||||
applyInverseTransforms(git, fld, top); //, eqOp<T>());
|
applyInverseTransforms(git, fld, top); //, eqOp<T>());
|
||||||
|
|
||||||
// And send back (the remote slots) Disable dummy transformations.
|
// And send back (the remote slots) Disable dummy transformations.
|
||||||
reverseDistribute(constructSize, nullValue, fld, false, tag);
|
reverseDistribute
|
||||||
|
(
|
||||||
|
commsType,
|
||||||
|
constructSize,
|
||||||
|
nullValue,
|
||||||
|
fld,
|
||||||
|
false,
|
||||||
|
tag
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T, class TransformOp>
|
||||||
|
void Foam::mapDistribute::reverseDistribute
|
||||||
|
(
|
||||||
|
const globalIndexAndTransform& git,
|
||||||
|
const label constructSize,
|
||||||
|
const T& nullValue,
|
||||||
|
List<T>& fld,
|
||||||
|
const TransformOp& top,
|
||||||
|
const int tag
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
reverseDistribute
|
||||||
|
(
|
||||||
|
UPstream::defaultCommsType,
|
||||||
|
git,
|
||||||
|
constructSize,
|
||||||
|
nullValue,
|
||||||
|
fld,
|
||||||
|
top,
|
||||||
|
tag
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user