1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-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 types of sources
82 //- Enumeration defining the valid actions
97 //- A table of usage strings
98 static HashTable<string>* usageTablePtr_;
100 //- Class with constructor to add usage string to table
101 class addToUsageTable
105 addToUsageTable(const word& name, const string& msg)
109 usageTablePtr_ = new HashTable<string>();
111 usageTablePtr_->insert(name, msg);
118 delete usageTablePtr_;
119 usageTablePtr_ = NULL;
127 const polyMesh& mesh_;
129 //- Add (if bool) cellI to set or delete cellI from set.
130 void addOrDelete(topoSet& set, const label cellI, const bool) const;
135 static const NamedEnum<setAction, 8> actionNames_;
137 static const string illegalSource_;
140 // Private Member Functions
142 //- Disallow default bitwise copy construct
143 topoSetSource(const topoSetSource&);
145 //- Disallow default bitwise assignment
146 void operator=(const topoSetSource&);
151 //- Runtime type information
152 TypeName("topoSetSource");
157 //- Convert string to action
158 static setAction toAction(const word& actionName)
160 return actionNames_[actionName];
163 //- Check state of stream.
164 static Istream& checkIs(Istream& is);
166 // Declare run-time constructor selection table
168 // For the dictionary constructor
169 declareRunTimeSelectionTable
175 const polyMesh& mesh,
176 const dictionary& dict
181 // For the Istream constructor
182 declareRunTimeSelectionTable
188 const polyMesh& mesh,
195 //- Class used for the read-construction of
196 // PtrLists of topoSetSource
199 const polyMesh& mesh_;
203 iNew(const polyMesh& mesh)
208 autoPtr<topoSetSource> operator()(Istream& is) const
210 word topoSetSourceType(is);
212 return topoSetSource::New(topoSetSourceType, mesh_, dict);
217 static const string& usage(const word& name)
221 usageTablePtr_ = new HashTable<string>();
224 const HashTable<string>& usageTable = *usageTablePtr_;
226 if (usageTable.found(name))
228 return usageTable[name];
232 return illegalSource_;
239 //- Construct from components
240 topoSetSource(const polyMesh& mesh);
243 autoPtr<topoSetSource> clone() const
245 notImplemented("autoPtr<topoSetSource> clone() const");
246 return autoPtr<topoSetSource>(NULL);
252 //- Return a reference to the selected topoSetSource
253 static autoPtr<topoSetSource> New
255 const word& topoSetSourceType,
256 const polyMesh& mesh,
257 const dictionary& dict
260 //- Return a reference to the selected topoSetSource
261 static autoPtr<topoSetSource> New
263 const word& topoSetSourceType,
264 const polyMesh& mesh,
270 virtual ~topoSetSource();
275 const polyMesh& mesh() const
283 virtual sourceType setType() const = 0;
285 virtual void applyToSet(const setAction action, topoSet&) const = 0;
290 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
292 } // End namespace Foam
294 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
298 // ************************************************************************* //