1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "faceZoneToCell.H"
29 #include "addToRunTimeSelectionTable.H"
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
36 defineTypeNameAndDebug(faceZoneToCell, 0);
38 addToRunTimeSelectionTable(topoSetSource, faceZoneToCell, word);
40 addToRunTimeSelectionTable(topoSetSource, faceZoneToCell, istream);
45 Foam::topoSetSource::addToUsageTable Foam::faceZoneToCell::usage_
47 faceZoneToCell::typeName,
48 "\n Usage: faceZoneToCell zone master|slave\n\n"
49 " Select master or slave side of the faceZone."
50 " Note:accepts wildcards for zone.\n\n"
55 const char* Foam::NamedEnum<Foam::faceZoneToCell::faceAction, 2>::names[] =
62 const Foam::NamedEnum<Foam::faceZoneToCell::faceAction, 2>
63 Foam::faceZoneToCell::faceActionNames_;
66 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
68 void Foam::faceZoneToCell::combine(topoSet& set, const bool add) const
70 bool hasMatched = false;
72 forAll(mesh_.faceZones(), i)
74 const faceZone& zone = mesh_.faceZones()[i];
76 if (zoneName_.match(zone.name()))
78 const labelList& cellLabels =
85 Info<< " Found matching zone " << zone.name()
86 << " with " << cellLabels.size() << " cells on selected side."
93 // Only do active cells
94 if (cellLabels[i] < mesh_.nCells())
96 addOrDelete(set, cellLabels[i], add);
104 WarningIn("faceZoneToCell::combine(topoSet&, const bool)")
105 << "Cannot find any faceZone named " << zoneName_ << endl
106 << "Valid names are " << mesh_.faceZones().names() << endl;
111 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
113 // Construct from components
114 Foam::faceZoneToCell::faceZoneToCell
116 const polyMesh& mesh,
117 const word& zoneName,
118 const faceAction option
127 // Construct from dictionary
128 Foam::faceZoneToCell::faceZoneToCell
130 const polyMesh& mesh,
131 const dictionary& dict
135 zoneName_(dict.lookup("name")),
136 option_(faceActionNames_.read(dict.lookup("option")))
140 // Construct from Istream
141 Foam::faceZoneToCell::faceZoneToCell
143 const polyMesh& mesh,
148 zoneName_(checkIs(is)),
149 option_(faceActionNames_.read(checkIs(is)))
153 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
155 Foam::faceZoneToCell::~faceZoneToCell()
159 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
161 void Foam::faceZoneToCell::applyToSet
163 const topoSetSource::setAction action,
167 if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
169 Info<< " Adding all " << faceActionNames_[option_]
170 << " cells of faceZone " << zoneName_ << " ..." << endl;
174 else if (action == topoSetSource::DELETE)
176 Info<< " Removing all " << faceActionNames_[option_]
177 << " cells of faceZone " << zoneName_ << " ..." << endl;
184 // ************************************************************************* //