1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
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 "zoneToCell.H"
29 #include "addToRunTimeSelectionTable.H"
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
36 defineTypeNameAndDebug(zoneToCell, 0);
38 addToRunTimeSelectionTable(topoSetSource, zoneToCell, word);
40 addToRunTimeSelectionTable(topoSetSource, zoneToCell, istream);
45 Foam::topoSetSource::addToUsageTable Foam::zoneToCell::usage_
48 "\n Usage: zoneToCell zone\n\n"
49 " Select all cells in the cellZone."
50 " Note:accepts wildcards for zone.\n\n"
54 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
56 void Foam::zoneToCell::combine(topoSet& set, const bool add) const
58 bool hasMatched = false;
60 forAll(mesh_.cellZones(), i)
62 const cellZone& zone = mesh_.cellZones()[i];
64 if (zoneName_.match(zone.name()))
66 const labelList& cellLabels = mesh_.cellZones()[i];
68 Info<< " Found matching zone " << zone.name()
69 << " with " << cellLabels.size() << " cells." << endl;
75 // Only do active cells
76 if (cellLabels[i] < mesh_.nCells())
78 addOrDelete(set, cellLabels[i], add);
86 WarningIn("zoneToCell::combine(topoSet&, const bool)")
87 << "Cannot find any cellZone named " << zoneName_ << endl
88 << "Valid names are " << mesh_.cellZones().names() << endl;
93 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
95 // Construct from components
96 Foam::zoneToCell::zoneToCell
107 // Construct from dictionary
108 Foam::zoneToCell::zoneToCell
110 const polyMesh& mesh,
111 const dictionary& dict
115 zoneName_(dict.lookup("name"))
119 // Construct from Istream
120 Foam::zoneToCell::zoneToCell
122 const polyMesh& mesh,
127 zoneName_(checkIs(is))
131 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
133 Foam::zoneToCell::~zoneToCell()
137 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
139 void Foam::zoneToCell::applyToSet
141 const topoSetSource::setAction action,
145 if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
147 Info<< " Adding all cells of cellZone " << zoneName_ << " ..."
152 else if (action == topoSetSource::DELETE)
154 Info<< " Removing all cells of cellZone " << zoneName_ << " ..."
162 // ************************************************************************* //