1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 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 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 "faceZoneToCell.H"
30 #include "addToRunTimeSelectionTable.H"
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
37 defineTypeNameAndDebug(faceZoneToCell, 0);
39 addToRunTimeSelectionTable(topoSetSource, faceZoneToCell, word);
41 addToRunTimeSelectionTable(topoSetSource, faceZoneToCell, istream);
46 Foam::topoSetSource::addToUsageTable Foam::faceZoneToCell::usage_
48 faceZoneToCell::typeName,
49 "\n Usage: faceZoneToCell zone master|slave\n\n"
50 " Select master or slave side of the faceZone."
51 " Note:accepts wildcards for zone.\n\n"
56 const char* Foam::NamedEnum<Foam::faceZoneToCell::faceAction, 2>::names[] =
63 const Foam::NamedEnum<Foam::faceZoneToCell::faceAction, 2>
64 Foam::faceZoneToCell::faceActionNames_;
67 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
69 void Foam::faceZoneToCell::combine(topoSet& set, const bool add) const
71 bool hasMatched = false;
73 forAll(mesh_.faceZones(), i)
75 const faceZone& zone = mesh_.faceZones()[i];
77 if (zoneName_.match(zone.name()))
79 const labelList& cellLabels =
86 Info<< " Found matching zone " << zone.name()
87 << " with " << cellLabels.size() << " cells on selected side."
94 // Only do active cells
95 if (cellLabels[i] < mesh_.nCells())
97 addOrDelete(set, cellLabels[i], add);
105 WarningIn("faceZoneToCell::combine(topoSet&, const bool)")
106 << "Cannot find any faceZone named " << zoneName_ << endl
107 << "Valid names are " << mesh_.faceZones().names() << endl;
112 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
114 // Construct from components
115 Foam::faceZoneToCell::faceZoneToCell
117 const polyMesh& mesh,
118 const word& zoneName,
119 const faceAction option
128 // Construct from dictionary
129 Foam::faceZoneToCell::faceZoneToCell
131 const polyMesh& mesh,
132 const dictionary& dict
136 zoneName_(dict.lookup("name")),
137 option_(faceActionNames_.read(dict.lookup("option")))
141 // Construct from Istream
142 Foam::faceZoneToCell::faceZoneToCell
144 const polyMesh& mesh,
149 zoneName_(checkIs(is)),
150 option_(faceActionNames_.read(checkIs(is)))
154 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
156 Foam::faceZoneToCell::~faceZoneToCell()
160 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
162 void Foam::faceZoneToCell::applyToSet
164 const topoSetSource::setAction action,
168 if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
170 Info<< " Adding all " << faceActionNames_[option_]
171 << " cells of faceZone " << zoneName_ << " ..." << endl;
175 else if (action == topoSetSource::DELETE)
177 Info<< " Removing all " << faceActionNames_[option_]
178 << " cells of faceZone " << zoneName_ << " ..." << endl;
185 // ************************************************************************* //