1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-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/>.
28 Base class of a source for a topoSet.
30 Implementer has to modify the given set (see applyToSet) according to
31 its function and the setAction (one of add/delete/new)
36 \*---------------------------------------------------------------------------*/
38 #ifndef topoSetSource_H
39 #define topoSetSource_H
41 #include "pointField.H"
43 #include "labelList.H"
46 #include "runTimeSelectionTables.H"
48 #include "NamedEnum.H"
49 #include "HashTable.H"
51 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56 // Forward declaration of classes
60 /*---------------------------------------------------------------------------*\
61 Class topoSetSource Declaration
62 \*---------------------------------------------------------------------------*/
70 //- Enumeration defining the valid actions
85 //- A table of usage strings
86 static HashTable<string>* usageTablePtr_;
88 //- Class with constructor to add usage string to table
93 addToUsageTable(const word& name, const string& msg)
97 usageTablePtr_ = new HashTable<string>();
99 usageTablePtr_->insert(name, msg);
106 delete usageTablePtr_;
107 usageTablePtr_ = NULL;
115 const polyMesh& mesh_;
117 //- Add (if bool) cellI to set or delete cellI from set.
118 void addOrDelete(topoSet& set, const label cellI, const bool) const;
123 static const NamedEnum<setAction, 8> actionNames_;
125 static const string illegalSource_;
128 // Private Member Functions
130 //- Disallow default bitwise copy construct
131 topoSetSource(const topoSetSource&);
133 //- Disallow default bitwise assignment
134 void operator=(const topoSetSource&);
139 //- Runtime type information
140 TypeName("topoSetSource");
145 //- Convert string to action
146 static setAction toAction(const word& actionName)
148 return actionNames_[actionName];
151 //- Check state of stream.
152 static Istream& checkIs(Istream& is);
154 // Declare run-time constructor selection table
156 // For the dictionary constructor
157 declareRunTimeSelectionTable
163 const polyMesh& mesh,
164 const dictionary& dict
169 // For the Istream constructor
170 declareRunTimeSelectionTable
176 const polyMesh& mesh,
183 //- Class used for the read-construction of
184 // PtrLists of topoSetSource
187 const polyMesh& mesh_;
191 iNew(const polyMesh& mesh)
196 autoPtr<topoSetSource> operator()(Istream& is) const
198 word topoSetSourceType(is);
200 return topoSetSource::New(topoSetSourceType, mesh_, dict);
205 static const string& usage(const word& name)
209 usageTablePtr_ = new HashTable<string>();
212 const HashTable<string>& usageTable = *usageTablePtr_;
214 if (usageTable.found(name))
216 return usageTable[name];
220 return illegalSource_;
227 //- Construct from components
228 topoSetSource(const polyMesh& mesh);
231 autoPtr<topoSetSource> clone() const
233 notImplemented("autoPtr<topoSetSource> clone() const");
234 return autoPtr<topoSetSource>(NULL);
240 //- Return a reference to the selected topoSetSource
241 static autoPtr<topoSetSource> New
243 const word& topoSetSourceType,
244 const polyMesh& mesh,
245 const dictionary& dict
248 //- Return a reference to the selected topoSetSource
249 static autoPtr<topoSetSource> New
251 const word& topoSetSourceType,
252 const polyMesh& mesh,
259 virtual ~topoSetSource();
264 const polyMesh& mesh() const
272 virtual void applyToSet(const setAction action, topoSet&) const = 0;
277 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
279 } // End namespace Foam
281 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
285 // ************************************************************************* //