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 "setsToFaceZone.H"
28 #include "faceZoneSet.H"
31 #include "addToRunTimeSelectionTable.H"
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
37 defineTypeNameAndDebug(setsToFaceZone, 0);
38 addToRunTimeSelectionTable(topoSetSource, setsToFaceZone, word);
39 addToRunTimeSelectionTable(topoSetSource, setsToFaceZone, istream);
43 Foam::topoSetSource::addToUsageTable Foam::setsToFaceZone::usage_
45 setsToFaceZone::typeName,
46 "\n Usage: setsToFaceZone <faceSet> <slaveCellSet>\n\n"
47 " Select all faces in the faceSet."
48 " Orientated so slave side is in cellSet.\n\n"
52 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
54 // Construct from components
55 Foam::setsToFaceZone::setsToFaceZone
58 const word& faceSetName,
59 const word& cellSetName
63 faceSetName_(faceSetName),
64 cellSetName_(cellSetName)
68 // Construct from dictionary
69 Foam::setsToFaceZone::setsToFaceZone
72 const dictionary& dict
76 faceSetName_(dict.lookup("faceSet")),
77 cellSetName_(dict.lookup("cellSet"))
81 // Construct from Istream
82 Foam::setsToFaceZone::setsToFaceZone
89 faceSetName_(checkIs(is)),
90 cellSetName_(checkIs(is))
94 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
96 Foam::setsToFaceZone::~setsToFaceZone()
100 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
102 void Foam::setsToFaceZone::applyToSet
104 const topoSetSource::setAction action,
108 if (!isA<faceZoneSet>(set))
112 "setsToFaceZone::applyToSet(const topoSetSource::setAction"
114 ) << "Operation only allowed on a faceZoneSet." << endl;
118 faceZoneSet& fzSet = refCast<faceZoneSet>(set);
120 if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
122 Info<< " Adding all faces from faceSet " << faceSetName_
126 faceSet fSet(mesh_, faceSetName_);
127 cellSet cSet(mesh_, cellSetName_);
129 // Start off from copy
130 DynamicList<label> newAddressing(fzSet.addressing());
131 DynamicList<bool> newFlipMap(fzSet.flipMap());
133 forAllConstIter(faceSet, fSet, iter)
135 label faceI = iter.key();
137 if (!fzSet.found(faceI))
141 label own = mesh_.faceOwner()[faceI];
142 bool ownFound = cSet.found(own);
144 if (mesh_.isInternalFace(faceI))
146 label nei = mesh_.faceNeighbour()[faceI];
147 bool neiFound = cSet.found(nei);
149 if (ownFound && !neiFound)
153 else if (!ownFound && neiFound)
161 "setsToFaceZone::applyToSet"
162 "(const topoSetSource::setAction, topoSet)"
163 ) << "One of owner or neighbour of internal face "
164 << faceI << " should be in cellSet "
166 << " to be able to determine orientation."
168 << "Face:" << faceI << " own:" << own
169 << " OwnInCellSet:" << ownFound
171 << " NeiInCellSet:" << neiFound
180 newAddressing.append(faceI);
181 newFlipMap.append(flip);
185 fzSet.addressing().transfer(newAddressing);
186 fzSet.flipMap().transfer(newFlipMap);
189 else if (action == topoSetSource::DELETE)
191 Info<< " Removing all faces from faceSet " << faceSetName_
195 faceZoneSet loadedSet(mesh_, faceSetName_);
198 DynamicList<label> newAddressing(fzSet.addressing().size());
199 DynamicList<bool> newFlipMap(fzSet.flipMap().size());
201 forAll(fzSet.addressing(), i)
203 if (!loadedSet.found(fzSet.addressing()[i]))
205 newAddressing.append(fzSet.addressing()[i]);
206 newFlipMap.append(fzSet.flipMap()[i]);
209 fzSet.addressing().transfer(newAddressing);
210 fzSet.flipMap().transfer(newFlipMap);
217 // ************************************************************************* //