Rewrite of parallel gather-write of immersed boundary patch data

This commit is contained in:
Hrvoje Jasak 2019-06-17 18:16:26 +01:00
parent 328c75a101
commit 624b6a72b8

View file

@ -107,30 +107,65 @@ void Foam::immersedBoundaryFieldBase<Type>::writeField
if (Pstream::master())
{
// Assemble unique lists to correspond to a single surface
pointField allPoints(0);
Field<Type> completeField(0);
faceList allFaces(0);
label prevProcPatchSize = 0;
forAll(procPoints, procI)
// Count points and faces; currently unmerged
label nAllPoints = 0;
label nAllFaces = 0;
forAll (procPoints, procI)
{
allPoints.append(procPoints[procI]);
completeField.append(procFields[procI]);
nAllPoints += procPoints[procI].size();
nAllFaces += procFaces[procI].size();
}
// Point labels in faces need to be incremented with respect to
// the size of the size of the previous processore patch
forAll(procFaces[procI], faceI)
pointField allPoints(nAllPoints);
faceList allFaces(nAllFaces);
Field<Type> completeField(nAllFaces);
// Reset counters
nAllPoints = 0;
nAllFaces = 0;
forAll (procPoints, procI)
{
const pointField& curPoints = procPoints[procI];
labelList renumberPoints(curPoints.size());
forAll (curPoints, cpI)
{
face curFace = procFaces[procI][faceI];
forAll(curFace, pointI)
{
curFace[pointI] += prevProcPatchSize;
}
allFaces.append(curFace);
allPoints[nAllPoints] = curPoints[cpI];
renumberPoints[cpI] = nAllPoints;
nAllPoints++;
}
// Increment the total number of points
prevProcPatchSize += procPoints[procI].size();
const faceList& curFaces = procFaces[procI];
const Field<Type>& curField = procFields[procI];
forAll (curFaces, cfI)
{
// Point labels in faces need to be renumbered with respect
// to the size of the size of the previous processore patch
const face& oldFace = curFaces[cfI];
// Make a copy of face to renumber
face renumberedFace(oldFace.size());
forAll (oldFace, fpI)
{
renumberedFace[fpI] = renumberPoints[oldFace[fpI]];
}
allFaces[nAllFaces] = renumberedFace;
completeField[nAllFaces] = curField[cfI];
nAllFaces++;
}
}
if (nAllPoints != allPoints.size() || nAllFaces != allFaces.size())
{
FatalErrorInFunction
<< "Problem with merge of immersed boundary patch data"
<< abort(FatalError);
}
writerPtr->write