From 09e3441440a3e95228ef7a02e0675ca1801302ba Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 9 Aug 2019 11:01:29 +0200 Subject: [PATCH] ENH: renamed attachedToCell to haloToCell and fix parallel consistency - was added for #1394 --- src/meshTools/Make/files | 2 +- .../haloToCell.C} | 129 ++++++------------ .../haloToCell.H} | 27 ++-- 3 files changed, 61 insertions(+), 97 deletions(-) rename src/meshTools/sets/cellSources/{attachedToCell/attachedToCell.C => haloToCell/haloToCell.C} (60%) rename src/meshTools/sets/cellSources/{attachedToCell/attachedToCell.H => haloToCell/haloToCell.H} (81%) diff --git a/src/meshTools/Make/files b/src/meshTools/Make/files index fb78d1f065..09f00280dc 100644 --- a/src/meshTools/Make/files +++ b/src/meshTools/Make/files @@ -152,7 +152,6 @@ sets/topoSetSource/topoSetSource.C cellSources = sets/cellSources $(cellSources)/topoSetCellSource/topoSetCellSource.C -$(cellSources)/attachedToCell/attachedToCell.C $(cellSources)/boundaryToCell/boundaryToCell.C $(cellSources)/boxToCell/boxToCell.C $(cellSources)/cellToCell/cellToCell.C @@ -161,6 +160,7 @@ $(cellSources)/cylinderToCell/cylinderToCell.C $(cellSources)/faceToCell/faceToCell.C $(cellSources)/faceZoneToCell/faceZoneToCell.C $(cellSources)/fieldToCell/fieldToCell.C +$(cellSources)/haloToCell/haloToCell.C $(cellSources)/labelToCell/labelToCell.C $(cellSources)/nbrToCell/nbrToCell.C $(cellSources)/nearestToCell/nearestToCell.C diff --git a/src/meshTools/sets/cellSources/attachedToCell/attachedToCell.C b/src/meshTools/sets/cellSources/haloToCell/haloToCell.C similarity index 60% rename from src/meshTools/sets/cellSources/attachedToCell/attachedToCell.C rename to src/meshTools/sets/cellSources/haloToCell/haloToCell.C index 3938c245c2..8c053044c8 100644 --- a/src/meshTools/sets/cellSources/attachedToCell/attachedToCell.C +++ b/src/meshTools/sets/cellSources/haloToCell/haloToCell.C @@ -23,7 +23,7 @@ License \*---------------------------------------------------------------------------*/ -#include "attachedToCell.H" +#include "haloToCell.H" #include "polyMesh.H" #include "cellSet.H" #include "syncTools.H" @@ -33,60 +33,44 @@ License namespace Foam { - defineTypeNameAndDebug(attachedToCell, 0); - addToRunTimeSelectionTable(topoSetSource, attachedToCell, word); - addToRunTimeSelectionTable(topoSetSource, attachedToCell, istream); - addToRunTimeSelectionTable(topoSetCellSource, attachedToCell, word); - addToRunTimeSelectionTable(topoSetCellSource, attachedToCell, istream); + defineTypeNameAndDebug(haloToCell, 0); + addToRunTimeSelectionTable(topoSetSource, haloToCell, word); + addToRunTimeSelectionTable(topoSetSource, haloToCell, istream); + addToRunTimeSelectionTable(topoSetCellSource, haloToCell, word); + addToRunTimeSelectionTable(topoSetCellSource, haloToCell, istream); addNamedToRunTimeSelectionTable ( topoSetCellSource, - attachedToCell, + haloToCell, word, - attached + halo ); addNamedToRunTimeSelectionTable ( topoSetCellSource, - attachedToCell, + haloToCell, istream, - attached + halo ); } -Foam::topoSetSource::addToUsageTable Foam::attachedToCell::usage_ +Foam::topoSetSource::addToUsageTable Foam::haloToCell::usage_ ( - attachedToCell::typeName, - "\n Usage: attachedToCell\n\n" - " Select attached cells\n\n" + haloToCell::typeName, + "\n Usage: haloToCell\n\n" + " Select halo cells\n\n" ); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -void Foam::attachedToCell::combine(topoSet& set, const bool add) const +void Foam::haloToCell::combine(topoSet& set, const bool add) const { const cellList& cells = mesh_.cells(); const labelList& faceOwn = mesh_.faceOwner(); const labelList& faceNei = mesh_.faceNeighbour(); - const label nIntFaces = mesh_.nInternalFaces(); - const polyBoundaryMesh& patches = mesh_.boundaryMesh(); - boolList isCoupled(mesh_.nBoundaryFaces(), false); - - for (const polyPatch& pp : patches) - { - if (pp.coupled()) - { - label facei = pp.start(); - forAll(pp, i) - { - isCoupled[facei-nIntFaces] = true; - ++facei; - } - } - } // The starting set of cells bitSet current(cells.size()); @@ -97,19 +81,16 @@ void Foam::attachedToCell::combine(topoSet& set, const bool add) const } // The perimeter faces of the cell set - bitSet outsideFaces(mesh().nFaces()); + bitSet outsideFaces(mesh_.nFaces()); - // Get coupled cell status - boolList neiInSet(mesh_.nFaces()-nIntFaces, false); - - bitSet updates(current); + bitSet updates(cells.size()); for (label stepi = 0; stepi < steps_; ++stepi) { - // Mark up all perimeter faces - - // Don't attempt extra efficiency with caching old values, - // this make the parallel transfer too troublesome + // Mark up perimeter faces. Each mesh face is attached exactly + // (0,1,2) times to a cell in the set. Using flip() each time means + // the only 'on' bits correspond to faces that are attached once to + // the cell set - ie, faces on the perimeter of the set. outsideFaces.reset(); for (const label celli : current) @@ -120,36 +101,18 @@ void Foam::attachedToCell::combine(topoSet& set, const bool add) const } } - // Coupled faces - neiInSet = false; + // Use xor to eliminate perimeter faces that are actually attached + // on both sides of the interface. - for + syncTools::syncFaceList ( - bitSet::const_iterator iter = outsideFaces.cbegin(nIntFaces); - iter != outsideFaces.cend(); - ++iter - ) - { - const label facei = *iter; - - if (isCoupled[facei-nIntFaces]) - { - neiInSet[facei-nIntFaces] = true; - } - } - - syncTools::swapBoundaryFaceList(mesh_, neiInSet); - - forAll(neiInSet, bfacei) - { - if (neiInSet[bfacei]) - { - outsideFaces.flip(bfacei+nIntFaces); - } - } + mesh_, + outsideFaces, + bitXorEqOp() + ); + // Select all cells attached to the perimeter faces. updates.reset(); - for (const label facei : outsideFaces) { updates.set(faceOwn[facei]); @@ -161,9 +124,7 @@ void Foam::attachedToCell::combine(topoSet& set, const bool add) const if (add) { - // Face information retained for next loop - - // Changed cells + // Restrict to cells not already in the current set updates -= current; if (verbose_) @@ -172,11 +133,12 @@ void Foam::attachedToCell::combine(topoSet& set, const bool add) const << " by " << updates.count() << endl; } + // Add to current set for the next loop current |= updates; } else { - // Changed cells + // Restrict to cells already in the current set updates &= current; if (verbose_) @@ -185,25 +147,23 @@ void Foam::attachedToCell::combine(topoSet& set, const bool add) const << " by " << updates.count() << endl; } + // Remove from current set for the next loop current -= updates; } - for (const label celli: updates) - { - addOrDelete(set, celli, add); - } - if (updates.none()) { break; } + + addOrDelete(set, updates, add); } } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::attachedToCell::attachedToCell +Foam::haloToCell::haloToCell ( const polyMesh& mesh, const label steps @@ -214,29 +174,29 @@ Foam::attachedToCell::attachedToCell {} -Foam::attachedToCell::attachedToCell +Foam::haloToCell::haloToCell ( const polyMesh& mesh, const dictionary& dict ) : - attachedToCell(mesh, dict.getOrDefault