From 191cc9a8143d206c84dd8c2694dc2d12eaa15e7d Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 25 Nov 2010 13:32:18 +0000 Subject: [PATCH] ENH: mapDistribute : optional initial value --- .../mapPolyMesh/mapDistribute/mapDistribute.H | 56 +++++++++++++++++++ .../mapDistribute/mapDistributeTemplates.C | 3 +- 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.H b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.H index e783887685..0df1ce8484 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 + void reverseDistribute + ( + const label constructSize, + const T& nullValue, + List& fld + ) + const + { + if (Pstream::defaultCommsType == Pstream::nonBlocking) + { + distribute + ( + Pstream::nonBlocking, + List(), + constructSize, + constructMap_, + subMap_, + fld, + eqOp(), + nullValue + ); + } + else if (Pstream::defaultCommsType == Pstream::scheduled) + { + distribute + ( + Pstream::scheduled, + schedule(), + constructSize, + constructMap_, + subMap_, + fld, + eqOp(), + nullValue + ); + } + else + { + distribute + ( + Pstream::blocking, + List(), + constructSize, + constructMap_, + subMap_, + fld, + eqOp(), + nullValue + ); + } + } + //- Do all sends using PstreamBuffers template void send(PstreamBuffers&, const List&) const; diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C index 443dbf502d..ef6c78299e 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; }