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 "cellToFace.H"
31 #include "syncTools.H"
32 #include "addToRunTimeSelectionTable.H"
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
39 defineTypeNameAndDebug(cellToFace, 0);
41 addToRunTimeSelectionTable(topoSetSource, cellToFace, word);
43 addToRunTimeSelectionTable(topoSetSource, cellToFace, istream);
48 Foam::topoSetSource::addToUsageTable Foam::cellToFace::usage_
51 "\n Usage: cellToFace <cellSet> all|both\n\n"
52 " Select -all : all faces of cells in the cellSet\n"
53 " -both: faces where both neighbours are in the cellSet\n\n"
57 const char* Foam::NamedEnum<Foam::cellToFace::cellAction, 2>::names[] =
63 const Foam::NamedEnum<Foam::cellToFace::cellAction, 2>
64 Foam::cellToFace::cellActionNames_;
67 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
69 void Foam::cellToFace::combine(topoSet& set, const bool add) const
72 if (!exists(mesh_.time().path()/topoSet::localPath(mesh_, setName_)))
74 SeriousError<< "Cannot load set "
78 cellSet loadedSet(mesh_, setName_);
82 // Add all faces from cell
85 cellSet::const_iterator iter = loadedSet.begin();
86 iter != loadedSet.end();
90 label cellI = iter.key();
92 const labelList& cFaces = mesh_.cells()[cellI];
94 forAll(cFaces, cFaceI)
96 addOrDelete(set, cFaces[cFaceI], add);
100 else if (option_ == BOTH)
102 // Add all faces whose both neighbours are in set.
104 label nInt = mesh_.nInternalFaces();
105 const labelList& own = mesh_.faceOwner();
106 const labelList& nei = mesh_.faceNeighbour();
107 const polyBoundaryMesh& patches = mesh_.boundaryMesh();
110 // Check all internal faces
111 for (label faceI = 0; faceI < nInt; faceI++)
113 if (loadedSet.found(own[faceI]) && loadedSet.found(nei[faceI]))
115 addOrDelete(set, faceI, add);
120 // Get coupled cell status
121 boolList neiInSet(mesh_.nFaces()-nInt, false);
123 forAll(patches, patchI)
125 const polyPatch& pp = patches[patchI];
129 label faceI = pp.start();
132 neiInSet[faceI-nInt] = loadedSet.found(own[faceI]);
137 syncTools::swapBoundaryFaceList(mesh_, neiInSet, false);
140 // Check all boundary faces
141 forAll(patches, patchI)
143 const polyPatch& pp = patches[patchI];
147 label faceI = pp.start();
150 if (loadedSet.found(own[faceI]) && neiInSet[faceI-nInt])
152 addOrDelete(set, faceI, add);
162 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
164 // Construct from componenta
165 Foam::cellToFace::cellToFace
167 const polyMesh& mesh,
169 const cellAction option
178 // Construct from dictionary
179 Foam::cellToFace::cellToFace
181 const polyMesh& mesh,
182 const dictionary& dict
186 setName_(dict.lookup("set")),
187 option_(cellActionNames_.read(dict.lookup("option")))
191 // Construct from Istream
192 Foam::cellToFace::cellToFace
194 const polyMesh& mesh,
199 setName_(checkIs(is)),
200 option_(cellActionNames_.read(checkIs(is)))
204 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
206 Foam::cellToFace::~cellToFace()
210 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
212 void Foam::cellToFace::applyToSet
214 const topoSetSource::setAction action,
218 if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
220 Info<< " Adding faces according to cellSet " << setName_
225 else if (action == topoSetSource::DELETE)
227 Info<< " Removing faces according to cellSet " << setName_
235 // ************************************************************************* //