From e92aa8fce40bfc87d15296e327dd536cb04dd6f2 Mon Sep 17 00:00:00 2001 From: mattijs <mattijs> Date: Wed, 14 Mar 2018 16:21:58 +0100 Subject: [PATCH] ENH: reduced amount seeding in regionSplit - now only seed boundary faces and an internal face of cell that itself has a blocked face. --- src/meshTools/regionSplit/regionSplit.C | 90 +++++++++++++++++++------ 1 file changed, 71 insertions(+), 19 deletions(-) diff --git a/src/meshTools/regionSplit/regionSplit.C b/src/meshTools/regionSplit/regionSplit.C index 3a1d74b9497..8e5f5e42ace 100644 --- a/src/meshTools/regionSplit/regionSplit.C +++ b/src/meshTools/regionSplit/regionSplit.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -57,36 +57,85 @@ void Foam::regionSplit::calcNonCompactRegionSplit // Take over blockedFaces by seeding a negative number // (so is always less than the decomposition) - label nUnblocked = 0; - forAll(faceData, facei) + + forAll(blockedFace, facei) { - if (blockedFace.size() && blockedFace[facei]) + if (blockedFace[facei]) { faceData[facei] = minData(-2); } - else + } + + // Seed all faces on (real) boundaries and faces on cells next to blockFace + // (since regions can only occur because of boundaries (or blocked faces)) + + PackedBoolList isSeed(mesh().nFaces()); + + // Get internal or coupled faces + PackedBoolList isConnection(syncTools::getInternalOrCoupledFaces(mesh())); + + + // 1. Seed (real) boundaries + for + ( + label facei = mesh().nInternalFaces(); + facei < mesh().nFaces(); + facei++ + ) + { + if (!isConnection[facei]) { - nUnblocked++; + isSeed.set(facei); } } - // Seed unblocked faces - labelList seedFaces(nUnblocked); - List<minData> seedData(nUnblocked); - nUnblocked = 0; - + // 2. Seed (internal) faces on cells next to blocked (internal) faces + // (since we can't seed the blocked faces themselves) - forAll(faceData, facei) + if (blockedFace.size()) { - if (blockedFace.empty() || !blockedFace[facei]) + for (const cell& cFaces : mesh().cells()) { - seedFaces[nUnblocked] = facei; - // Seed face with globally unique number - seedData[nUnblocked] = minData(globalFaces.toGlobal(facei)); - nUnblocked++; + bool blockedCell = false; + label connectedFacei = -1; + + for (const label facei : cFaces) + { + if (blockedFace[facei]) + { + blockedCell = true; + } + else if (isConnection[facei]) + { + connectedFacei = facei; + } + } + + if (blockedCell) + { + isSeed.set(connectedFacei); // silently ignores -1 + } } } + List<label> seedFaces(isSeed.used()); + List<minData> seedData(seedFaces.size()); + + // Seed face with globally unique number + forAll(seedFaces, i) + { + const label facei = seedFaces[i]; + seedData[i] = minData(globalFaces.toGlobal(facei)); + } + + if (debug) + { + Pout<< "Seeded " << seedFaces.size() + << " boundary and internal faces out of" + << " total:" << mesh().nInternalFaces() + << " boundary:" << mesh().nFaces()-mesh().nInternalFaces() + << endl; + } // Propagate information inwards FaceCellWave<minData> deltaCalc @@ -112,7 +161,10 @@ void Foam::regionSplit::calcNonCompactRegionSplit } else { - // Unvisited cell -> only possible if surrounded by blocked faces. + // Unvisited cell -> only possible if surrounded by blocked faces + // since: + // - all walls become seed faces + // - all faces on cells with blocked faces become seed faces // If so make up region from any of the faces const cell& cFaces = mesh().cells()[celli]; label facei = cFaces[0]; @@ -343,7 +395,7 @@ Foam::autoPtr<Foam::globalIndex> Foam::regionSplit::calcRegionSplit // Get the wanted region labels into recvNonLocal - labelListList recvNonLocal(Pstream::nProcs()); + labelListList recvNonLocal; Pstream::exchange<labelList, label>(sendNonLocal, recvNonLocal); // Now we have the wanted compact region labels that proci wants in -- GitLab