diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/removeCells.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/removeCells.C index dc8d7aaa6f..38269d63a6 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/removeCells.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/removeCells.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. @@ -24,6 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include "removeCells.H" +#include "bitSet.H" #include "polyMesh.H" #include "polyTopoChange.H" #include "polyRemoveCell.H" @@ -39,23 +40,43 @@ namespace Foam defineTypeNameAndDebug(removeCells, 0); } -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // +// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * // -void Foam::removeCells::uncount -( - const labelList& f, - labelList& nUsage -) +namespace { - forAll(f, fp) + +// Increase count (usage) of elements of list +inline void incrCount(const Foam::labelUList& list, Foam::labelList& counter) +{ + for (auto idx : list) { - nUsage[f[fp]]--; + ++counter[idx]; } } +// Decrease count (usage) of elements of list +inline void decrCount(const Foam::labelUList& list, Foam::labelList& counter) +{ + for (auto idx : list) + { + --counter[idx]; + } +} + +} // End anonymous namespace + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // +Foam::removeCells::removeCells +( + const polyMesh& mesh +) +: + removeCells(mesh, true) +{} + + Foam::removeCells::removeCells ( const polyMesh& mesh, @@ -71,47 +92,37 @@ Foam::removeCells::removeCells Foam::labelList Foam::removeCells::getExposedFaces ( - const labelList& cellLabels + const bitSet& removedCell ) const { - // Create list of cells to be removed - boolList removedCell(mesh_.nCells(), false); - - // Go from labelList of cells-to-remove to a boolList. - forAll(cellLabels, i) - { - removedCell[cellLabels[i]] = true; - } - - const labelList& faceOwner = mesh_.faceOwner(); const labelList& faceNeighbour = mesh_.faceNeighbour(); // Count cells using face. labelList nCellsUsingFace(mesh_.nFaces(), 0); - for (label facei = 0; facei < mesh_.nInternalFaces(); facei++) + for (label facei = 0; facei < mesh_.nInternalFaces(); ++facei) { - label own = faceOwner[facei]; - label nei = faceNeighbour[facei]; + const label own = faceOwner[facei]; + const label nei = faceNeighbour[facei]; if (!removedCell[own]) { - nCellsUsingFace[facei]++; + ++nCellsUsingFace[facei]; } if (!removedCell[nei]) { - nCellsUsingFace[facei]++; + ++nCellsUsingFace[facei]; } } - for (label facei = mesh_.nInternalFaces(); facei < mesh_.nFaces(); facei++) + for (label facei = mesh_.nInternalFaces(); facei < mesh_.nFaces(); ++facei) { - label own = faceOwner[facei]; + const label own = faceOwner[facei]; if (!removedCell[own]) { - nCellsUsingFace[facei]++; + ++nCellsUsingFace[facei]; } } @@ -147,7 +158,7 @@ Foam::labelList Foam::removeCells::getExposedFaces DynamicList