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 "pointToFace.H"
31 #include "addToRunTimeSelectionTable.H"
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
38 defineTypeNameAndDebug(pointToFace, 0);
40 addToRunTimeSelectionTable(topoSetSource, pointToFace, word);
42 addToRunTimeSelectionTable(topoSetSource, pointToFace, istream);
47 Foam::topoSetSource::addToUsageTable Foam::pointToFace::usage_
49 pointToFace::typeName,
50 "\n Usage: pointToFace <pointSet> any|all\n\n"
51 " Select faces with\n"
52 " -any point in the pointSet\n"
53 " -all points in the pointSet\n\n"
57 const char* Foam::NamedEnum<Foam::pointToFace::pointAction, 2>::names[] =
63 const Foam::NamedEnum<Foam::pointToFace::pointAction, 2>
64 Foam::pointToFace::pointActionNames_;
67 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
69 void Foam::pointToFace::combine(topoSet& set, const bool add) const
72 pointSet loadedSet(mesh_, setName_);
76 // Add faces with any point in loadedSet
79 pointSet::const_iterator iter = loadedSet.begin();
80 iter != loadedSet.end();
84 label pointI = iter.key();
86 const labelList& pFaces = mesh_.pointFaces()[pointI];
88 forAll(pFaces, pFaceI)
90 addOrDelete(set, pFaces[pFaceI], add);
94 else if (option_ == ALL)
96 // Add all faces whose points are all in set.
98 // Count number of points using face.
99 Map<label> numPoints(loadedSet.size());
101 forAllConstIter(pointSet, loadedSet, iter)
103 label pointI = iter.key();
105 const labelList& pFaces = mesh_.pointFaces()[pointI];
107 forAll(pFaces, pFaceI)
109 label faceI = pFaces[pFaceI];
111 Map<label>::iterator fndFace = numPoints.find(faceI);
113 if (fndFace == numPoints.end())
115 numPoints.insert(faceI, 1);
125 // Include faces that are referenced as many times as there are points
126 // in face -> all points of face
129 Map<label>::const_iterator iter = numPoints.begin();
130 iter != numPoints.end();
134 label faceI = iter.key();
136 if (iter() == mesh_.faces()[faceI].size())
138 addOrDelete(set, faceI, add);
145 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
147 // Construct from components
148 Foam::pointToFace::pointToFace
150 const polyMesh& mesh,
152 const pointAction option
161 // Construct from dictionary
162 Foam::pointToFace::pointToFace
164 const polyMesh& mesh,
165 const dictionary& dict
169 setName_(dict.lookup("set")),
170 option_(pointActionNames_.read(dict.lookup("option")))
174 // Construct from Istream
175 Foam::pointToFace::pointToFace
177 const polyMesh& mesh,
182 setName_(checkIs(is)),
183 option_(pointActionNames_.read(checkIs(is)))
187 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
189 Foam::pointToFace::~pointToFace()
193 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
195 void Foam::pointToFace::applyToSet
197 const topoSetSource::setAction action,
201 if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
203 Info<< " Adding faces according to pointSet " << setName_
208 else if (action == topoSetSource::DELETE)
210 Info<< " Removing faces according to pointSet " << setName_
218 // ************************************************************************* //