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 "zoneToCell.H"
30 #include "addToRunTimeSelectionTable.H"
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
37 defineTypeNameAndDebug(zoneToCell, 0);
39 addToRunTimeSelectionTable(topoSetSource, zoneToCell, word);
41 addToRunTimeSelectionTable(topoSetSource, zoneToCell, istream);
46 Foam::topoSetSource::addToUsageTable Foam::zoneToCell::usage_
49 "\n Usage: zoneToCell zone\n\n"
50 " Select all cells in the cellZone."
51 " Note:accepts wildcards for zone.\n\n"
55 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
57 void Foam::zoneToCell::combine(topoSet& set, const bool add) const
59 bool hasMatched = false;
61 forAll(mesh_.cellZones(), i)
63 const cellZone& zone = mesh_.cellZones()[i];
65 if (zoneName_.match(zone.name()))
67 const labelList& cellLabels = mesh_.cellZones()[i];
69 Info<< " Found matching zone " << zone.name()
70 << " with " << cellLabels.size() << " cells." << endl;
76 // Only do active cells
77 if (cellLabels[i] < mesh_.nCells())
79 addOrDelete(set, cellLabels[i], add);
87 WarningIn("zoneToCell::combine(topoSet&, const bool)")
88 << "Cannot find any cellZone named " << zoneName_ << endl
89 << "Valid names are " << mesh_.cellZones().names() << endl;
94 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
96 // Construct from components
97 Foam::zoneToCell::zoneToCell
108 // Construct from dictionary
109 Foam::zoneToCell::zoneToCell
111 const polyMesh& mesh,
112 const dictionary& dict
116 zoneName_(dict.lookup("name"))
120 // Construct from Istream
121 Foam::zoneToCell::zoneToCell
123 const polyMesh& mesh,
128 zoneName_(checkIs(is))
132 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
134 Foam::zoneToCell::~zoneToCell()
138 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
140 void Foam::zoneToCell::applyToSet
142 const topoSetSource::setAction action,
146 if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
148 Info<< " Adding all cells of cellZone " << zoneName_ << " ..."
153 else if (action == topoSetSource::DELETE)
155 Info<< " Removing all cells of cellZone " << zoneName_ << " ..."
163 // ************************************************************************* //