initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / meshTools / sets / pointSources / cellToPoint / cellToPoint.C
blob4b83fcae80e799041701f65d92aabe5fa1cd89cb
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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 Description
27 \*---------------------------------------------------------------------------*/
29 #include "cellToPoint.H"
30 #include "polyMesh.H"
31 #include "cellSet.H"
33 #include "addToRunTimeSelectionTable.H"
35 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
37 namespace Foam
40 defineTypeNameAndDebug(cellToPoint, 0);
42 addToRunTimeSelectionTable(topoSetSource, cellToPoint, word);
44 addToRunTimeSelectionTable(topoSetSource, cellToPoint, istream);
49 Foam::topoSetSource::addToUsageTable Foam::cellToPoint::usage_
51     cellToPoint::typeName,
52     "\n    Usage: cellToPoint <cellSet> all\n\n"
53     "    Select all points of cells in the cellSet\n\n"
56 template<>
57 const char* Foam::NamedEnum<Foam::cellToPoint::cellAction, 1>::names[] =
59     "all"
62 const Foam::NamedEnum<Foam::cellToPoint::cellAction, 1>
63     Foam::cellToPoint::cellActionNames_;
66 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
68 void Foam::cellToPoint::combine(topoSet& set, const bool add) const
70     // Load the set
71     cellSet loadedSet(mesh_, setName_);
73     // Add all point from cells in loadedSet
74     for
75     (
76         cellSet::const_iterator iter = loadedSet.begin();
77         iter != loadedSet.end();
78         ++iter
79     )
80     {
81         label cellI = iter.key();
83         const labelList& cFaces = mesh_.cells()[cellI];
85         forAll(cFaces, cFaceI)
86         {
87             const face& f = mesh_.faces()[cFaces[cFaceI]];
89             forAll(f, fp)
90             {
91                 addOrDelete(set, f[fp], add);
92             }
93         }
94     }
98 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
100 // Construct from components
101 Foam::cellToPoint::cellToPoint
103     const polyMesh& mesh,
104     const word& setName,
105     const cellAction option
108     topoSetSource(mesh),
109     setName_(setName),
110     option_(option)
114 // Construct from dictionary
115 Foam::cellToPoint::cellToPoint
117     const polyMesh& mesh,
118     const dictionary& dict
121     topoSetSource(mesh),
122     setName_(dict.lookup("set")),
123     option_(cellActionNames_.read(dict.lookup("option")))
127 // Construct from Istream
128 Foam::cellToPoint::cellToPoint
130     const polyMesh& mesh,
131     Istream& is        
134     topoSetSource(mesh),
135     setName_(checkIs(is)),
136     option_(cellActionNames_.read(checkIs(is)))
140 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
142 Foam::cellToPoint::~cellToPoint()
146 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
148 void Foam::cellToPoint::applyToSet
150     const topoSetSource::setAction action,
151     topoSet& set
152 ) const
154     if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
155     {
156         Pout<< "    Adding from " << setName_ << " ..." << endl;
158         combine(set, true);
159     }
160     else if (action == topoSetSource::DELETE)
161     {
162         Pout<< "    Removing from " << setName_ << " ..." << endl;
164         combine(set, false);
165     }
169 // ************************************************************************* //