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 #ifndef polyTopoChange_H
00065 #define polyTopoChange_H
00066
00067 #include "autoPtr.H"
00068 #include "DynamicList.H"
00069 #include "labelList.H"
00070 #include "IOobject.H"
00071 #include "typeInfo.H"
00072 #include "pointField.H"
00073 #include "PtrList.H"
00074 #include "cellList.H"
00075 #include "Map.H"
00076 #include "HashSet.H"
00077 #include "mapPolyMesh.H"
00078 #include "CompactListList.H"
00079 #include "PackedBoolList.H"
00080
00081
00082
00083 namespace Foam
00084 {
00085
00086
00087 class face;
00088 class primitiveMesh;
00089 class polyMesh;
00090 class fvMesh;
00091 class Time;
00092 class fileName;
00093 class polyBoundaryMesh;
00094 class polyPatch;
00095 class dictionary;
00096 class topoAction;
00097 class objectMap;
00098
00099
00100
00101
00102
00103 class polyTopoChange
00104 {
00105
00106
00107
00108 static const point greatPoint;
00109
00110
00111
00112
00113
00114
00115 bool strict_;
00116
00117
00118
00119
00120
00121 label nPatches_;
00122
00123
00124
00125
00126
00127 DynamicList<point> points_;
00128
00129
00130 DynamicList<label> pointMap_;
00131
00132
00133
00134 DynamicList<label> reversePointMap_;
00135
00136
00137 Map<label> pointZone_;
00138
00139
00140 labelHashSet retiredPoints_;
00141
00142
00143
00144
00145
00146 DynamicList<face> faces_;
00147
00148
00149 DynamicList<label> region_;
00150
00151
00152 DynamicList<label> faceOwner_;
00153
00154
00155 DynamicList<label> faceNeighbour_;
00156
00157
00158
00159 DynamicList<label> faceMap_;
00160
00161
00162
00163 DynamicList<label> reverseFaceMap_;
00164
00165
00166
00167 Map<label> faceFromPoint_;
00168
00169
00170
00171 Map<label> faceFromEdge_;
00172
00173
00174 PackedBoolList flipFaceFlux_;
00175
00176
00177 Map<label> faceZone_;
00178
00179
00180 PackedBoolList faceZoneFlip_;
00181
00182
00183 label nActiveFaces_;
00184
00185
00186
00187
00188
00189
00190 DynamicList<label> cellMap_;
00191
00192
00193
00194 DynamicList<label> reverseCellMap_;
00195
00196
00197 Map<label> cellFromPoint_;
00198
00199
00200 Map<label> cellFromEdge_;
00201
00202
00203 Map<label> cellFromFace_;
00204
00205
00206 DynamicList<label> cellZone_;
00207
00208
00209
00210
00211
00212 template<class T>
00213 static void reorder(const labelList& map, DynamicList<T>&);
00214 template<class T>
00215 static void reorder(const labelList& map, List<DynamicList<T> >&);
00216 template<class T>
00217 static void renumberKey(const labelList& map, Map<T>&);
00218
00219
00220 static void renumber(const labelList&, labelHashSet&);
00221
00222 static void renumberReverseMap(const labelList&, DynamicList<label>&);
00223
00224
00225 static void renumberCompact(const labelList&, labelList&);
00226
00227
00228 static labelHashSet getSetIndices(const PackedBoolList&);
00229
00230
00231 static void countMap
00232 (
00233 const labelList& map,
00234 const labelList& reverseMap,
00235 label& nAdd,
00236 label& nInflate,
00237 label& nMerge,
00238 label& nRemove
00239 );
00240
00241
00242 static void writeMeshStats(const polyMesh& mesh, Ostream&);
00243
00244
00245
00246 static void getMergeSets
00247 (
00248 const labelList& reverseCellMap,
00249 const labelList& cellMap,
00250 List<objectMap>& cellsFromCells
00251 );
00252
00253
00254 void checkFace
00255 (
00256 const face&,
00257 const label faceI,
00258 const label own,
00259 const label nei,
00260 const label patchI,
00261 const label zoneI
00262 ) const;
00263
00264
00265 void makeCells
00266 (
00267 const label nActiveFaces,
00268 labelList& cellFaces,
00269 labelList& cellFaceOffsets
00270 ) const;
00271
00272
00273 void makeCellCells
00274 (
00275 const label nActiveFaces,
00276 CompactListList<label>& cellCells
00277 ) const;
00278
00279
00280 label getCellOrder(const CompactListList<label>&, labelList&) const;
00281
00282
00283 void getFaceOrder
00284 (
00285 const label nActiveFaces,
00286 const labelList& cellFaces,
00287 const labelList& cellFaceOffsets,
00288
00289 labelList& oldToNew,
00290 labelList& patchSizes,
00291 labelList& patchStarts
00292 ) const;
00293
00294
00295 void reorderCompactFaces
00296 (
00297 const label newSize,
00298 const labelList& oldToNew
00299 );
00300
00301
00302
00303
00304
00305
00306 void compact
00307 (
00308 const bool orderCells,
00309 const bool orderPoints,
00310 label& nInternalPoints,
00311 labelList& patchSizes,
00312 labelList& patchStarts
00313 );
00314
00315
00316 static labelList selectFaces
00317 (
00318 const primitiveMesh&,
00319 const labelList& faceLabels,
00320 const bool internalFacesOnly
00321 );
00322
00323
00324 void calcPatchPointMap
00325 (
00326 const List<Map<label> >&,
00327 const polyBoundaryMesh&,
00328 labelListList&
00329 ) const;
00330
00331 void calcFaceInflationMaps
00332 (
00333 const polyMesh&,
00334 List<objectMap>&,
00335 List<objectMap>&,
00336 List<objectMap>&
00337 ) const;
00338
00339 void calcCellInflationMaps
00340 (
00341 const polyMesh&,
00342 List<objectMap>&,
00343 List<objectMap>&,
00344 List<objectMap>&,
00345 List<objectMap>&
00346 ) const;
00347
00348 void resetZones
00349 (
00350 const polyMesh&,
00351 polyMesh&,
00352 labelListList&,
00353 labelListList&,
00354 labelListList&
00355 ) const;
00356
00357 void calcFaceZonePointMap
00358 (
00359 const polyMesh&,
00360 const List<Map<label> >&,
00361 labelListList&
00362 ) const;
00363
00364
00365
00366
00367
00368 static face rotateFace(const face& f, const label nPos);
00369
00370
00371 void reorderCoupledFaces
00372 (
00373 const bool syncParallel,
00374 const polyBoundaryMesh&,
00375 const labelList& patchStarts,
00376 const labelList& patchSizes,
00377 const pointField& points
00378 );
00379
00380 void compactAndReorder
00381 (
00382 const polyMesh&,
00383 const bool syncParallel,
00384 const bool orderCells,
00385 const bool orderPoints,
00386 label& nInternalPoints,
00387 pointField& newPoints,
00388 labelList& patchSizes,
00389 labelList& patchStarts,
00390 List<objectMap>& pointsFromPoints,
00391 List<objectMap>& facesFromPoints,
00392 List<objectMap>& facesFromEdges,
00393 List<objectMap>& facesFromFaces,
00394 List<objectMap>& cellsFromPoints,
00395 List<objectMap>& cellsFromEdges,
00396 List<objectMap>& cellsFromFaces,
00397 List<objectMap>& cellsFromCells,
00398 List<Map<label> >& oldPatchMeshPointMaps,
00399 labelList& oldPatchNMeshPoints,
00400 labelList& oldPatchStarts,
00401 List<Map<label> >& oldFaceZoneMeshPointMaps
00402 );
00403
00404 public:
00405
00406
00407 ClassName("polyTopoChange");
00408
00409
00410
00411
00412
00413
00414
00415 polyTopoChange(const label nPatches, const bool strict = true);
00416
00417
00418 polyTopoChange(const polyMesh& mesh, const bool strict = true);
00419
00420
00421
00422
00423
00424
00425
00426 const DynamicList<point>& points() const
00427 {
00428 return points_;
00429 }
00430
00431 const DynamicList<face>& faces() const
00432 {
00433 return faces_;
00434 }
00435
00436 const DynamicList<label>& region() const
00437 {
00438 return region_;
00439 }
00440
00441 const DynamicList<label>& faceOwner() const
00442 {
00443 return faceOwner_;
00444 }
00445
00446 const DynamicList<label>& faceNeighbour() const
00447 {
00448 return faceNeighbour_;
00449 }
00450
00451
00452 inline bool pointRemoved(const label pointI) const;
00453
00454 inline bool faceRemoved(const label faceI) const;
00455
00456 inline bool cellRemoved(const label cellI) const;
00457
00458
00459
00460
00461
00462 void clear();
00463
00464
00465
00466 void addMesh
00467 (
00468 const polyMesh&,
00469 const labelList& patchMap,
00470 const labelList& pointZoneMap,
00471 const labelList& faceZoneMap,
00472 const labelList& cellZoneMap
00473 );
00474
00475
00476 void movePoints(const pointField& newPoints);
00477
00478
00479 label setAction(const topoAction& action);
00480
00481
00482
00483
00484
00485 label addPoint
00486 (
00487 const point&,
00488 const label masterPointID,
00489 const label zoneID,
00490 const bool inCell
00491 );
00492
00493
00494
00495
00496 void modifyPoint
00497 (
00498 const label,
00499 const point&,
00500 const label newZoneID,
00501 const bool inCell
00502 );
00503
00504
00505 void removePoint(const label, const label);
00506
00507
00508
00509 label addFace
00510 (
00511 const face& f,
00512 const label own,
00513 const label nei,
00514 const label masterPointID,
00515 const label masterEdgeID,
00516 const label masterFaceID,
00517 const bool flipFaceFlux,
00518 const label patchID,
00519 const label zoneID,
00520 const bool zoneFlip
00521 );
00522
00523
00524 void modifyFace
00525 (
00526 const face& f,
00527 const label faceI,
00528 const label own,
00529 const label nei,
00530 const bool flipFaceFlux,
00531 const label patchID,
00532 const label zoneID,
00533 const bool zoneFlip
00534 );
00535
00536
00537 void removeFace(const label, const label);
00538
00539
00540 label addCell
00541 (
00542 const label masterPointID,
00543 const label masterEdgeID,
00544 const label masterFaceID,
00545 const label masterCellID,
00546 const label zoneID
00547 );
00548
00549
00550 void modifyCell(const label, const label zoneID);
00551
00552
00553 void removeCell(const label, const label);
00554
00555
00556
00557 inline void setNumPatches(const label nPatches);
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574 autoPtr<mapPolyMesh> changeMesh
00575 (
00576 polyMesh& mesh,
00577 const bool inflate,
00578 const bool syncParallel = true,
00579 const bool orderCells = false,
00580 const bool orderPoints = false
00581 );
00582
00583
00584 autoPtr<mapPolyMesh> makeMesh
00585 (
00586 autoPtr<fvMesh>& newMesh,
00587 const IOobject& io,
00588 const fvMesh& mesh,
00589 const bool syncParallel = true,
00590 const bool orderCells = false,
00591 const bool orderPoints = false
00592 );
00593
00594 };
00595
00596
00597
00598
00599 }
00600
00601
00602
00603 #include "polyTopoChangeI.H"
00604
00605 #ifdef NoRepository
00606 # include "polyTopoChangeTemplates.C"
00607 #endif
00608
00609
00610
00611 #endif
00612
00613