diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.H b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.H index e7838876858cd4e13b9e9d084a8e19524a1a6380..0df1ce848414e83f3398634f742651aad6c62c3c 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.H +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.H @@ -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 template<class T> void send(PstreamBuffers&, const List<T>&) const; diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C index 443dbf502d984595664981ccffde17f85657efde..ef6c78299ea65e1985665aa241a364d2db84697d 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C @@ -446,10 +446,11 @@ void Foam::mapDistribute::distribute const labelList& map = constructMap[Pstream::myProcNo()]; field.setSize(constructSize); + field = nullValue; forAll(map, i) { - field[map[i]] = subField[i]; + cop(field[map[i]], subField[i]); } return; }