From 624b6a72b8cfe1e0083947acb816e9c527251a60 Mon Sep 17 00:00:00 2001 From: Hrvoje Jasak Date: Mon, 17 Jun 2019 18:16:26 +0100 Subject: [PATCH] Rewrite of parallel gather-write of immersed boundary patch data --- .../immersedBoundaryFieldBase.C | 71 ++++++++++++++----- 1 file changed, 53 insertions(+), 18 deletions(-) diff --git a/src/immersedBoundary/immersedBoundary/immersedBoundaryFvPatchFields/immersedBoundaryFieldBase/immersedBoundaryFieldBase.C b/src/immersedBoundary/immersedBoundary/immersedBoundaryFvPatchFields/immersedBoundaryFieldBase/immersedBoundaryFieldBase.C index 526b1402a..d54ef9552 100644 --- a/src/immersedBoundary/immersedBoundary/immersedBoundaryFvPatchFields/immersedBoundaryFieldBase/immersedBoundaryFieldBase.C +++ b/src/immersedBoundary/immersedBoundary/immersedBoundaryFvPatchFields/immersedBoundaryFieldBase/immersedBoundaryFieldBase.C @@ -107,30 +107,65 @@ void Foam::immersedBoundaryFieldBase::writeField if (Pstream::master()) { // Assemble unique lists to correspond to a single surface - pointField allPoints(0); - Field 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 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& 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