1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "nbrToCell.H"
30 #include "addToRunTimeSelectionTable.H"
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
37 defineTypeNameAndDebug(nbrToCell, 0);
39 addToRunTimeSelectionTable(topoSetSource, nbrToCell, word);
41 addToRunTimeSelectionTable(topoSetSource, nbrToCell, istream);
46 Foam::topoSetSource::addToUsageTable Foam::nbrToCell::usage_
49 "\n Usage: nbrToCell <nNeighbours>\n\n"
50 " Select all cells with <= nNeighbours neighbouring cells\n\n"
54 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
56 void Foam::nbrToCell::combine(topoSet& set, const bool add) const
58 const cellList& cells = mesh().cells();
59 const polyBoundaryMesh& patches = mesh_.boundaryMesh();
61 boolList isCoupled(mesh_.nFaces()-mesh_.nInternalFaces(), false);
63 forAll(patches, patchI)
65 const polyPatch& pp = patches[patchI];
69 label faceI = pp.start();
72 isCoupled[faceI-mesh_.nInternalFaces()] = true;
80 const cell& cFaces = cells[cellI];
86 label faceI = cFaces[i];
88 if (mesh_.isInternalFace(faceI))
92 else if (isCoupled[faceI-mesh_.nInternalFaces()])
98 if (nNbrCells <= minNbrs_)
100 addOrDelete(set, cellI, add);
106 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
108 // Construct from components
109 Foam::nbrToCell::nbrToCell
111 const polyMesh& mesh,
120 // Construct from dictionary
121 Foam::nbrToCell::nbrToCell
123 const polyMesh& mesh,
124 const dictionary& dict
128 minNbrs_(readLabel(dict.lookup("neighbours")))
132 // Construct from Istream
133 Foam::nbrToCell::nbrToCell
135 const polyMesh& mesh,
140 minNbrs_(readLabel(checkIs(is)))
144 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
146 Foam::nbrToCell::~nbrToCell()
150 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
152 void Foam::nbrToCell::applyToSet
154 const topoSetSource::setAction action,
158 if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
160 Info<< " Adding cells with only " << minNbrs_ << " or less"
161 " neighbouring cells" << " ..." << endl;
165 else if (action == topoSetSource::DELETE)
167 Info<< " Removing cells with only " << minNbrs_ << " or less"
168 " neighbouring cells" << " ..." << endl;
175 // ************************************************************************* //