refinementHistory.H
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
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072 #ifndef refinementHistory_H
00073 #define refinementHistory_H
00074
00075 #include "DynamicList.H"
00076 #include "labelList.H"
00077 #include "FixedList.H"
00078 #include "SLList.H"
00079 #include "autoPtr.H"
00080 #include "regIOobject.H"
00081
00082
00083
00084 namespace Foam
00085 {
00086
00087
00088 class mapPolyMesh;
00089 class mapDistributePolyMesh;
00090
00091
00092
00093
00094
00095 class refinementHistory
00096 :
00097 public regIOobject
00098 {
00099 public:
00100
00101 class splitCell8
00102 {
00103 public:
00104
00105
00106
00107
00108 label parent_;
00109
00110
00111 autoPtr<FixedList<label, 8> > addedCellsPtr_;
00112
00113
00114 splitCell8();
00115
00116
00117 splitCell8(const label parent);
00118
00119
00120 splitCell8(Istream& is);
00121
00122
00123 splitCell8(const splitCell8&);
00124
00125
00126 void operator=(const splitCell8& s)
00127 {
00128
00129 if (this == &s)
00130 {
00131 FatalErrorIn("splitCell8::operator=(const Foam::splitCell8&)")
00132 << "Attempted assignment to self"
00133 << abort(FatalError);
00134 }
00135
00136 parent_ = s.parent_;
00137
00138 addedCellsPtr_.reset
00139 (
00140 s.addedCellsPtr_.valid()
00141 ? new FixedList<label, 8>(s.addedCellsPtr_())
00142 : NULL
00143 );
00144 }
00145
00146 bool operator==(const splitCell8& s) const
00147 {
00148 if (addedCellsPtr_.valid() != s.addedCellsPtr_.valid())
00149 {
00150 return false;
00151 }
00152 else if (parent_ != s.parent_)
00153 {
00154 return false;
00155 }
00156 else if (addedCellsPtr_.valid())
00157 {
00158 return addedCellsPtr_() == s.addedCellsPtr_();
00159 }
00160 else
00161 {
00162 return true;
00163 }
00164 }
00165
00166 bool operator!=(const splitCell8& s) const
00167 {
00168 return !operator==(s);
00169 }
00170
00171 friend Istream& operator>>(Istream&, splitCell8&);
00172 friend Ostream& operator<<(Ostream&, const splitCell8&);
00173 };
00174
00175
00176 private:
00177
00178 TypeName("refinementHistory");
00179
00180
00181
00182
00183 DynamicList<splitCell8> splitCells_;
00184
00185
00186 DynamicList<label> freeSplitCells_;
00187
00188
00189 labelList visibleCells_;
00190
00191
00192
00193
00194
00195 static void writeEntry
00196 (
00197 const List<splitCell8>&,
00198 const splitCell8&
00199 );
00200
00201 static void writeDebug
00202 (
00203 const labelList&,
00204 const List<splitCell8>&
00205 );
00206
00207
00208 void checkIndices() const;
00209
00210
00211 label allocateSplitCell(const label parent, const label i);
00212
00213
00214 void freeSplitCell(const label index);
00215
00216
00217 void markSplit
00218 (
00219 const label,
00220 labelList& oldToNew,
00221 DynamicList<splitCell8>&
00222 ) const;
00223
00224 void countProc
00225 (
00226 const label index,
00227 const label newProcNo,
00228 labelList& splitCellProc,
00229 labelList& splitCellNum
00230 ) const;
00231
00232 public:
00233
00234
00235
00236
00237 refinementHistory(const IOobject&);
00238
00239
00240 refinementHistory
00241 (
00242 const IOobject&,
00243 const List<splitCell8>& splitCells,
00244 const labelList& visibleCells
00245 );
00246
00247
00248
00249 refinementHistory(const IOobject&, const label nCells);
00250
00251
00252 refinementHistory(const IOobject&, const refinementHistory&);
00253
00254
00255 refinementHistory(const IOobject&, Istream&);
00256
00257
00258
00259
00260
00261
00262
00263 const labelList& visibleCells() const
00264 {
00265 return visibleCells_;
00266 }
00267
00268
00269 const DynamicList<splitCell8>& splitCells() const
00270 {
00271 return splitCells_;
00272 }
00273
00274
00275 const DynamicList<label>& freeSplitCells() const
00276 {
00277 return freeSplitCells_;
00278 }
00279
00280
00281
00282
00283 bool active() const
00284 {
00285 return visibleCells_.size() > 0;
00286 }
00287
00288
00289 label parentIndex(const label cellI) const
00290 {
00291 label index = visibleCells_[cellI];
00292
00293 if (index < 0)
00294 {
00295 FatalErrorIn("refinementHistory::parentIndex(const label)")
00296 << "Cell " << cellI << " is not visible"
00297 << abort(FatalError);
00298 }
00299 return splitCells_[index].parent_;
00300 }
00301
00302
00303 void storeSplit
00304 (
00305 const label cellI,
00306 const labelList& addedCells
00307 );
00308
00309
00310 void combineCells
00311 (
00312 const label masterCellI,
00313 const labelList& combinedCells
00314 );
00315
00316
00317
00318 void updateMesh(const mapPolyMesh&);
00319
00320
00321 void subset
00322 (
00323 const labelList& pointMap,
00324 const labelList& faceMap,
00325 const labelList& cellMap
00326 );
00327
00328
00329
00330
00331 void distribute(const mapDistributePolyMesh&);
00332
00333
00334
00335 void compact();
00336
00337
00338
00339 void resize(const label nCells);
00340
00341
00342 void writeDebug() const;
00343
00344
00345
00346 virtual bool readData(Istream&);
00347
00348
00349 virtual bool writeData(Ostream&) const;
00350
00351
00352
00353
00354
00355
00356
00357
00358 friend Istream& operator>>(Istream&, refinementHistory&);
00359 friend Ostream& operator<<(Ostream&, const refinementHistory&);
00360 };
00361
00362
00363
00364
00365 }
00366
00367
00368
00369 #endif
00370
00371
Copyright © 2000-2009 OpenCFD Ltd