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