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 "pointToCell.H"
31 #include "addToRunTimeSelectionTable.H"
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
38 defineTypeNameAndDebug(pointToCell, 0);
40 addToRunTimeSelectionTable(topoSetSource, pointToCell, word);
42 addToRunTimeSelectionTable(topoSetSource, pointToCell, istream);
47 Foam::topoSetSource::addToUsageTable Foam::pointToCell::usage_
49 pointToCell::typeName,
50 "\n Usage: pointToCell <pointSet> any\n\n"
51 " Select all cells with any point in the pointSet\n\n"
55 const char* Foam::NamedEnum<Foam::pointToCell::pointAction, 1>::names[] =
61 const Foam::NamedEnum<Foam::pointToCell::pointAction, 1>
62 Foam::pointToCell::pointActionNames_;
65 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
67 void Foam::pointToCell::combine(topoSet& set, const bool add) const
70 pointSet loadedSet(mesh_, setName_);
73 // Handle any selection
78 pointSet::const_iterator iter = loadedSet.begin();
79 iter != loadedSet.end();
83 label pointI = iter.key();
85 const labelList& pCells = mesh_.pointCells()[pointI];
87 forAll(pCells, pCellI)
89 addOrDelete(set, pCells[pCellI], add);
96 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
98 // Construct from components
99 Foam::pointToCell::pointToCell
101 const polyMesh& mesh,
103 const pointAction option
112 // Construct from dictionary
113 Foam::pointToCell::pointToCell
115 const polyMesh& mesh,
116 const dictionary& dict
120 setName_(dict.lookup("set")),
121 option_(pointActionNames_.read(dict.lookup("option")))
125 // Construct from Istream
126 Foam::pointToCell::pointToCell
128 const polyMesh& mesh,
133 setName_(checkIs(is)),
134 option_(pointActionNames_.read(checkIs(is)))
138 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
140 Foam::pointToCell::~pointToCell()
144 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
146 void Foam::pointToCell::applyToSet
148 const topoSetSource::setAction action,
152 if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
154 Info<< " Adding cells according to pointSet " << setName_
159 else if (action == topoSetSource::DELETE)
161 Info<< " Removing cells according to pointSet " << setName_
169 // ************************************************************************* //