1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "nbrToCell.H"
29 #include "addToRunTimeSelectionTable.H"
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
36 defineTypeNameAndDebug(nbrToCell, 0);
38 addToRunTimeSelectionTable(topoSetSource, nbrToCell, word);
40 addToRunTimeSelectionTable(topoSetSource, nbrToCell, istream);
45 Foam::topoSetSource::addToUsageTable Foam::nbrToCell::usage_
48 "\n Usage: nbrToCell <nNeighbours>\n\n"
49 " Select all cells with <= nNeighbours neighbouring cells\n\n"
53 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
55 void Foam::nbrToCell::combine(topoSet& set, const bool add) const
57 const cellList& cells = mesh().cells();
58 const polyBoundaryMesh& patches = mesh_.boundaryMesh();
60 boolList isCoupled(mesh_.nFaces()-mesh_.nInternalFaces(), false);
62 forAll(patches, patchI)
64 const polyPatch& pp = patches[patchI];
68 label faceI = pp.start();
71 isCoupled[faceI-mesh_.nInternalFaces()] = true;
79 const cell& cFaces = cells[cellI];
85 label faceI = cFaces[i];
87 if (mesh_.isInternalFace(faceI))
91 else if (isCoupled[faceI-mesh_.nInternalFaces()])
97 if (nNbrCells <= minNbrs_)
99 addOrDelete(set, cellI, add);
105 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
107 // Construct from components
108 Foam::nbrToCell::nbrToCell
110 const polyMesh& mesh,
119 // Construct from dictionary
120 Foam::nbrToCell::nbrToCell
122 const polyMesh& mesh,
123 const dictionary& dict
127 minNbrs_(readLabel(dict.lookup("neighbours")))
131 // Construct from Istream
132 Foam::nbrToCell::nbrToCell
134 const polyMesh& mesh,
139 minNbrs_(readLabel(checkIs(is)))
143 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
145 Foam::nbrToCell::~nbrToCell()
149 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
151 void Foam::nbrToCell::applyToSet
153 const topoSetSource::setAction action,
157 if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
159 Info<< " Adding cells with only " << minNbrs_ << " or less"
160 " neighbouring cells" << " ..." << endl;
164 else if (action == topoSetSource::DELETE)
166 Info<< " Removing cells with only " << minNbrs_ << " or less"
167 " neighbouring cells" << " ..." << endl;
174 // ************************************************************************* //