1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 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 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
29 Base class of a source for a topoSet.
31 Implementer has to modify the given set (see applyToSet) according to
32 its function and the setAction (one of add/delete/new)
37 \*---------------------------------------------------------------------------*/
39 #ifndef topoSetSource_H
40 #define topoSetSource_H
42 #include <OpenFOAM/pointField.H>
43 #include <OpenFOAM/word.H>
44 #include <OpenFOAM/labelList.H>
45 #include <OpenFOAM/faceList.H>
46 #include <OpenFOAM/typeInfo.H>
47 #include <OpenFOAM/runTimeSelectionTables.H>
48 #include <OpenFOAM/autoPtr.H>
49 #include <OpenFOAM/NamedEnum.H>
50 #include <OpenFOAM/HashTable.H>
52 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
57 // Forward declaration of classes
61 /*---------------------------------------------------------------------------*\
62 Class topoSetSource Declaration
63 \*---------------------------------------------------------------------------*/
71 //- 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, 7> 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 // ************************ vim: set sw=4 sts=4 et: ************************ //