ENH: mapDistribute : optional initial value

This commit is contained in:
mattijs
2010-11-25 13:32:18 +00:00
parent ae1e1cc963
commit 191cc9a814
2 changed files with 58 additions and 1 deletions

View File

@ -319,6 +319,62 @@ public:
} }
} }
//- Reverse distribute data using default commsType.
// Since constructSize might be larger than supplied size supply
// a nullValue
template<class T>
void reverseDistribute
(
const label constructSize,
const T& nullValue,
List<T>& fld
)
const
{
if (Pstream::defaultCommsType == Pstream::nonBlocking)
{
distribute
(
Pstream::nonBlocking,
List<labelPair>(),
constructSize,
constructMap_,
subMap_,
fld,
eqOp<T>(),
nullValue
);
}
else if (Pstream::defaultCommsType == Pstream::scheduled)
{
distribute
(
Pstream::scheduled,
schedule(),
constructSize,
constructMap_,
subMap_,
fld,
eqOp<T>(),
nullValue
);
}
else
{
distribute
(
Pstream::blocking,
List<labelPair>(),
constructSize,
constructMap_,
subMap_,
fld,
eqOp<T>(),
nullValue
);
}
}
//- Do all sends using PstreamBuffers //- Do all sends using PstreamBuffers
template<class T> template<class T>
void send(PstreamBuffers&, const List<T>&) const; void send(PstreamBuffers&, const List<T>&) const;

View File

@ -446,10 +446,11 @@ void Foam::mapDistribute::distribute
const labelList& map = constructMap[Pstream::myProcNo()]; const labelList& map = constructMap[Pstream::myProcNo()];
field.setSize(constructSize); field.setSize(constructSize);
field = nullValue;
forAll(map, i) forAll(map, i)
{ {
field[map[i]] = subField[i]; cop(field[map[i]], subField[i]);
} }
return; return;
} }