Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef topoSetSource_H
00039 #define topoSetSource_H
00040
00041 #include <OpenFOAM/pointField.H>
00042 #include <OpenFOAM/word.H>
00043 #include <OpenFOAM/labelList.H>
00044 #include <OpenFOAM/faceList.H>
00045 #include <OpenFOAM/typeInfo.H>
00046 #include <OpenFOAM/runTimeSelectionTables.H>
00047 #include <OpenFOAM/autoPtr.H>
00048 #include <OpenFOAM/NamedEnum.H>
00049 #include <OpenFOAM/HashTable.H>
00050
00051
00052
00053 namespace Foam
00054 {
00055
00056
00057 class polyMesh;
00058 class topoSet;
00059
00060
00061
00062
00063
00064 class topoSetSource
00065 {
00066 public:
00067
00068
00069
00070
00071 enum setAction
00072 {
00073 CLEAR,
00074 NEW,
00075 INVERT,
00076 ADD,
00077 DELETE,
00078 SUBSET,
00079 LIST,
00080 REMOVE
00081 };
00082
00083 protected:
00084
00085
00086 static HashTable<string>* usageTablePtr_;
00087
00088
00089 class addToUsageTable
00090 {
00091 public:
00092
00093 addToUsageTable(const word& name, const string& msg)
00094 {
00095 if (!usageTablePtr_)
00096 {
00097 usageTablePtr_ = new HashTable<string>();
00098 }
00099 usageTablePtr_->insert(name, msg);
00100 }
00101
00102 ~addToUsageTable()
00103 {
00104 if (usageTablePtr_)
00105 {
00106 delete usageTablePtr_;
00107 usageTablePtr_ = NULL;
00108 }
00109 }
00110 };
00111
00112
00113
00114
00115 const polyMesh& mesh_;
00116
00117
00118 void addOrDelete(topoSet& set, const label cellI, const bool) const;
00119
00120
00121 private:
00122
00123 static const NamedEnum<setAction, 8> actionNames_;
00124
00125 static const string illegalSource_;
00126
00127
00128
00129
00130
00131 topoSetSource(const topoSetSource&);
00132
00133
00134 void operator=(const topoSetSource&);
00135
00136
00137 public:
00138
00139
00140 TypeName("topoSetSource");
00141
00142
00143
00144
00145
00146 static setAction toAction(const word& actionName)
00147 {
00148 return actionNames_[actionName];
00149 }
00150
00151
00152 static Istream& checkIs(Istream& is);
00153
00154
00155
00156
00157 declareRunTimeSelectionTable
00158 (
00159 autoPtr,
00160 topoSetSource,
00161 word,
00162 (
00163 const polyMesh& mesh,
00164 const dictionary& dict
00165 ),
00166 (mesh, dict)
00167 );
00168
00169
00170 declareRunTimeSelectionTable
00171 (
00172 autoPtr,
00173 topoSetSource,
00174 istream,
00175 (
00176 const polyMesh& mesh,
00177 Istream& is
00178 ),
00179 (mesh, is)
00180 );
00181
00182
00183
00184
00185 class iNew
00186 {
00187 const polyMesh& mesh_;
00188
00189 public:
00190
00191 iNew(const polyMesh& mesh)
00192 :
00193 mesh_(mesh)
00194 {}
00195
00196 autoPtr<topoSetSource> operator()(Istream& is) const
00197 {
00198 word topoSetSourceType(is);
00199 dictionary dict(is);
00200 return topoSetSource::New(topoSetSourceType, mesh_, dict);
00201 }
00202 };
00203
00204
00205 static const string& usage(const word& name)
00206 {
00207 if (!usageTablePtr_)
00208 {
00209 usageTablePtr_ = new HashTable<string>();
00210 }
00211
00212 const HashTable<string>& usageTable = *usageTablePtr_;
00213
00214 if (usageTable.found(name))
00215 {
00216 return usageTable[name];
00217 }
00218 else
00219 {
00220 return illegalSource_;
00221 }
00222 }
00223
00224
00225
00226
00227
00228 topoSetSource(const polyMesh& mesh);
00229
00230
00231 autoPtr<topoSetSource> clone() const
00232 {
00233 notImplemented("autoPtr<topoSetSource> clone() const");
00234 return autoPtr<topoSetSource>(NULL);
00235 }
00236
00237
00238
00239
00240
00241 static autoPtr<topoSetSource> New
00242 (
00243 const word& topoSetSourceType,
00244 const polyMesh& mesh,
00245 const dictionary& dict
00246 );
00247
00248
00249 static autoPtr<topoSetSource> New
00250 (
00251 const word& topoSetSourceType,
00252 const polyMesh& mesh,
00253 Istream& is
00254 );
00255
00256
00257
00258
00259 virtual ~topoSetSource();
00260
00261
00262
00263
00264 const polyMesh& mesh() const
00265 {
00266 return mesh_;
00267 }
00268
00269
00270
00271
00272 virtual void applyToSet(const setAction action, topoSet&) const = 0;
00273
00274 };
00275
00276
00277
00278
00279 }
00280
00281
00282
00283 #endif
00284
00285