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 #ifndef meshRefinement_H
00045 #define meshRefinement_H
00046
00047 #include "hexRef8.H"
00048 #include "mapPolyMesh.H"
00049 #include "autoPtr.H"
00050 #include "labelPair.H"
00051 #include "indirectPrimitivePatch.H"
00052 #include "pointFieldsFwd.H"
00053 #include "Tuple2.H"
00054 #include "pointIndexHit.H"
00055
00056
00057
00058 namespace Foam
00059 {
00060
00061
00062 class fvMesh;
00063 class mapDistributePolyMesh;
00064 class decompositionMethod;
00065 class refinementSurfaces;
00066 class shellSurfaces;
00067 class removeCells;
00068 class featureEdgeMesh;
00069 class fvMeshDistribute;
00070 class searchableSurface;
00071 class regionSplit;
00072 class globalIndex;
00073
00074
00075
00076
00077
00078 class meshRefinement
00079 {
00080
00081 public:
00082
00083
00084
00085
00086 enum writeFlag
00087 {
00088 MESH = 1,
00089 SCALARLEVELS = 2,
00090 OBJINTERSECTIONS = 4
00091 };
00092
00093
00094
00095 enum mapType
00096 {
00097 MASTERONLY = 1,
00098 KEEPALL = 2,
00099 REMOVE = 4
00100 };
00101
00102
00103 private:
00104
00105
00106
00107
00108 fvMesh& mesh_;
00109
00110
00111 const scalar mergeDistance_;
00112
00113
00114 const bool overwrite_;
00115
00116
00117 const word oldInstance_;
00118
00119
00120 const refinementSurfaces& surfaces_;
00121
00122
00123 const shellSurfaces& shells_;
00124
00125
00126 hexRef8 meshCutter_;
00127
00128
00129 labelIOList surfaceIndex_;
00130
00131
00132 List<Tuple2<mapType, labelList> > userFaceData_;
00133
00134
00135
00136 wordList meshedPatches_;
00137
00138
00139
00140
00141
00142 template<class T>
00143 static void updateList
00144 (
00145 const labelList& newToOld,
00146 const T& nullValue,
00147 List<T>& elems
00148 );
00149
00150
00151 template<class GeoField>
00152 static void addPatchFields(fvMesh&, const word& patchFieldType);
00153
00154
00155 template<class GeoField>
00156 static void reorderPatchFields(fvMesh&, const labelList& oldToNew);
00157
00158
00159
00160 static labelList getChangedFaces
00161 (
00162 const mapPolyMesh&,
00163 const labelList& oldCellsToRefine
00164 );
00165
00166
00167 void calcNeighbourData
00168 (
00169 labelList& neiLevel,
00170 pointField& neiCc
00171 ) const;
00172
00173
00174 void updateIntersections(const labelList& changedFaces);
00175
00176
00177 autoPtr<mapPolyMesh> doRemoveCells
00178 (
00179 const labelList& cellsToRemove,
00180 const labelList& exposedFaces,
00181 const labelList& exposedPatchIDs,
00182 removeCells& cellRemover
00183 );
00184
00185
00186
00187
00188 labelList getInsideCells(const word&) const;
00189
00190
00191 autoPtr<mapPolyMesh> removeInsideCells
00192 (
00193 const string& msg,
00194 const label exposedPatchI
00195 );
00196
00197
00198
00199
00200
00201
00202 void getCoupledRegionMaster
00203 (
00204 const globalIndex& globalCells,
00205 const boolList& blockedFace,
00206 const regionSplit& globalRegion,
00207 Map<label>& regionToMaster
00208 ) const;
00209
00210
00211
00212 void calcLocalRegions
00213 (
00214 const globalIndex& globalCells,
00215 const labelList& globalRegion,
00216 const Map<label>& coupledRegionToMaster,
00217
00218 Map<label>& globalToLocalRegion,
00219 pointField& localPoints
00220 ) const;
00221
00222
00223 static label getShiftedRegion
00224 (
00225 const globalIndex& indexer,
00226 const Map<label>& globalToLocalRegion,
00227 const Map<label>& coupledRegionToShifted,
00228 const label globalRegion
00229 );
00230
00231
00232 static void addUnique(const label, labelList&);
00233
00234
00235 void calcRegionRegions
00236 (
00237 const labelList& globalRegion,
00238 const Map<label>& globalToLocalRegion,
00239 const Map<label>& coupledRegionToMaster,
00240 labelListList& regionRegions
00241 ) const;
00242
00243
00244
00245
00246
00247
00248
00249 static bool markForRefine
00250 (
00251 const label markValue,
00252 const label nAllowRefine,
00253 label& cellValue,
00254 label& nRefine
00255 );
00256
00257
00258
00259 label markFeatureRefinement
00260 (
00261 const point& keepPoint,
00262 const PtrList<featureEdgeMesh>& featureMeshes,
00263 const labelList& featureLevels,
00264 const label nAllowRefine,
00265
00266 labelList& refineCell,
00267 label& nRefine
00268 ) const;
00269
00270
00271 label markInternalRefinement
00272 (
00273 const label nAllowRefine,
00274 labelList& refineCell,
00275 label& nRefine
00276 ) const;
00277
00278
00279
00280 labelList getRefineCandidateFaces
00281 (
00282 const labelList& refineCell
00283 ) const;
00284
00285
00286 label markSurfaceRefinement
00287 (
00288 const label nAllowRefine,
00289 const labelList& neiLevel,
00290 const pointField& neiCc,
00291 labelList& refineCell,
00292 label& nRefine
00293 ) const;
00294
00295
00296
00297
00298 bool checkCurvature
00299 (
00300 const scalar curvature,
00301 const label nAllowRefine,
00302 const label surfaceLevel,
00303 const vector& surfaceNormal,
00304 const label cellI,
00305 label& cellMaxLevel,
00306 vector& cellMaxNormal,
00307 labelList& refineCell,
00308 label& nRefine
00309 ) const;
00310
00311
00312
00313
00314
00315 label markSurfaceCurvatureRefinement
00316 (
00317 const scalar curvature,
00318 const label nAllowRefine,
00319 const labelList& neiLevel,
00320 const pointField& neiCc,
00321 labelList& refineCell,
00322 label& nRefine
00323 ) const;
00324
00325
00326
00327
00328 void getBafflePatches
00329 (
00330 const labelList& globalToPatch,
00331 const labelList& neiLevel,
00332 const pointField& neiCc,
00333 labelList& ownPatch,
00334 labelList& neiPatch
00335 ) const;
00336
00337
00338
00339 label getBafflePatch
00340 (
00341 const labelList& facePatch,
00342 const label faceI
00343 ) const;
00344
00345
00346
00347
00348 label createBaffle
00349 (
00350 const label faceI,
00351 const label ownPatch,
00352 const label neiPatch,
00353 polyTopoChange& meshMod
00354 ) const;
00355
00356
00357
00358
00359
00360 void markBoundaryFace
00361 (
00362 const label faceI,
00363 boolList& isBoundaryFace,
00364 boolList& isBoundaryEdge,
00365 boolList& isBoundaryPoint
00366 ) const;
00367
00368 void findNearest
00369 (
00370 const labelList& meshFaces,
00371 List<pointIndexHit>& nearestInfo,
00372 labelList& nearestSurface,
00373 labelList& nearestRegion,
00374 vectorField& nearestNormal
00375 ) const;
00376
00377 Map<label> findEdgeConnectedProblemCells
00378 (
00379 const scalarField& perpendicularAngle,
00380 const labelList&
00381 ) const;
00382
00383 bool isCollapsedFace
00384 (
00385 const pointField&,
00386 const pointField& neiCc,
00387 const scalar minFaceArea,
00388 const scalar maxNonOrtho,
00389 const label faceI
00390 ) const;
00391
00392 bool isCollapsedCell
00393 (
00394 const pointField&,
00395 const scalar volFraction,
00396 const label cellI
00397 ) const;
00398
00399
00400
00401
00402 labelList markFacesOnProblemCells
00403 (
00404 const dictionary& motionDict,
00405 const bool removeEdgeConnectedCells,
00406 const scalarField& perpendicularAngle,
00407 const labelList& globalToPatch
00408 ) const;
00409
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421 List<labelPair> filterDuplicateFaces(const List<labelPair>&) const;
00422
00423
00424
00425
00426
00427
00428
00429
00430 void findCellZoneGeometric
00431 (
00432 const labelList& closedNamedSurfaces,
00433 labelList& namedSurfaceIndex,
00434 const labelList& surfaceToCellZone,
00435 labelList& cellToZone
00436 ) const;
00437
00438
00439 bool calcRegionToZone
00440 (
00441 const label surfZoneI,
00442 const label ownRegion,
00443 const label neiRegion,
00444
00445 labelList& regionToCellZone
00446 ) const;
00447
00448
00449
00450 void findCellZoneTopo
00451 (
00452 const point& keepPoint,
00453 const labelList& namedSurfaceIndex,
00454 const labelList& surfaceToCellZone,
00455 labelList& cellToZone
00456 ) const;
00457
00458 void makeConsistentFaceIndex
00459 (
00460 const labelList& cellToZone,
00461 labelList& namedSurfaceIndex
00462 ) const;
00463
00464
00465
00466 meshRefinement(const meshRefinement&);
00467
00468
00469 void operator=(const meshRefinement&);
00470
00471 public:
00472
00473
00474 ClassName("meshRefinement");
00475
00476
00477
00478
00479
00480 meshRefinement
00481 (
00482 fvMesh& mesh,
00483 const scalar mergeDistance,
00484 const bool overwrite,
00485 const refinementSurfaces&,
00486 const shellSurfaces&
00487 );
00488
00489
00490
00491
00492
00493
00494
00495 const fvMesh& mesh() const
00496 {
00497 return mesh_;
00498 }
00499 fvMesh& mesh()
00500 {
00501 return mesh_;
00502 }
00503
00504 scalar mergeDistance() const
00505 {
00506 return mergeDistance_;
00507 }
00508
00509
00510 bool overwrite() const
00511 {
00512 return overwrite_;
00513 }
00514
00515
00516 const word& oldInstance() const
00517 {
00518 return oldInstance_;
00519 }
00520
00521
00522 const refinementSurfaces& surfaces() const
00523 {
00524 return surfaces_;
00525 }
00526
00527
00528 const shellSurfaces& shells() const
00529 {
00530 return shells_;
00531 }
00532
00533
00534 const hexRef8& meshCutter() const
00535 {
00536 return meshCutter_;
00537 }
00538
00539
00540 const labelList& surfaceIndex() const
00541 {
00542 return surfaceIndex_;
00543 }
00544
00545 labelList& surfaceIndex()
00546 {
00547 return surfaceIndex_;
00548 }
00549
00550
00551
00552
00553
00554 const List<Tuple2<mapType, labelList> >& userFaceData() const
00555 {
00556 return userFaceData_;
00557 }
00558
00559 List<Tuple2<mapType, labelList> >& userFaceData()
00560 {
00561 return userFaceData_;
00562 }
00563
00564
00565
00566
00567
00568 label countHits() const;
00569
00570
00571
00572
00573
00574
00575 labelList decomposeCombineRegions
00576 (
00577 const boolList& blockedFace,
00578 const List<labelPair>& explicitConnections,
00579 decompositionMethod&
00580 ) const;
00581
00582
00583
00584
00585
00586 autoPtr<mapDistributePolyMesh> balance
00587 (
00588 const bool keepZoneFaces,
00589 const bool keepBaffles,
00590 decompositionMethod& decomposer,
00591 fvMeshDistribute& distributor
00592 );
00593
00594
00595 labelList intersectedFaces() const;
00596
00597
00598 labelList intersectedPoints() const;
00599
00600
00601 static autoPtr<indirectPrimitivePatch> makePatch
00602 (
00603 const polyMesh&,
00604 const labelList&
00605 );
00606
00607
00608
00609
00610
00611
00612
00613 static tmp<pointVectorField> makeDisplacementField
00614 (
00615 const pointMesh& pMesh,
00616 const labelList& adaptPatchIDs
00617 );
00618
00619
00620 static void checkCoupledFaceZones(const polyMesh&);
00621
00622
00623
00624
00625
00626 labelList refineCandidates
00627 (
00628 const point& keepPoint,
00629 const scalar curvature,
00630
00631 const PtrList<featureEdgeMesh>& featureMeshes,
00632 const labelList& featureLevels,
00633
00634 const bool featureRefinement,
00635 const bool internalRefinement,
00636 const bool surfaceRefinement,
00637 const bool curvatureRefinement,
00638 const label maxGlobalCells,
00639 const label maxLocalCells
00640 ) const;
00641
00642
00643 autoPtr<mapPolyMesh> refine(const labelList& cellsToRefine);
00644
00645
00646 autoPtr<mapDistributePolyMesh> refineAndBalance
00647 (
00648 const string& msg,
00649 decompositionMethod& decomposer,
00650 fvMeshDistribute& distributor,
00651 const labelList& cellsToRefine
00652 );
00653
00654
00655
00656
00657
00658 void baffleAndSplitMesh
00659 (
00660 const bool handleSnapProblems,
00661 const bool removeEdgeConnectedCells,
00662 const scalarField& perpendicularAngle,
00663 const bool mergeFreeStanding,
00664 const dictionary& motionDict,
00665 Time& runTime,
00666 const labelList& globalToPatch,
00667 const point& keepPoint
00668 );
00669
00670
00671
00672 autoPtr<mapPolyMesh> splitMesh
00673 (
00674 const label nBufferLayers,
00675 const labelList& globalToPatch,
00676 const point& keepPoint
00677 );
00678
00679
00680
00681 autoPtr<mapPolyMesh> dupNonManifoldPoints();
00682
00683
00684
00685
00686 autoPtr<mapPolyMesh> createBaffles
00687 (
00688 const labelList& ownPatch,
00689 const labelList& neiPatch
00690 );
00691
00692
00693
00694 List<labelPair> getDuplicateFaces(const labelList& testFaces) const;
00695
00696
00697 autoPtr<mapPolyMesh> mergeBaffles(const List<labelPair>&);
00698
00699
00700
00701
00702 autoPtr<mapPolyMesh> zonify(const point& keepPoint);
00703
00704
00705
00706
00707
00708
00709 static label addPatch(fvMesh&, const word& name, const word& type);
00710
00711
00712 label addMeshedPatch(const word& name, const word& type);
00713
00714
00715 labelList meshedPatches() const;
00716
00717
00718 autoPtr<mapPolyMesh> splitMeshRegions(const point& keepPoint);
00719
00720
00721 void distribute(const mapDistributePolyMesh&);
00722
00723
00724
00725 void updateMesh
00726 (
00727 const mapPolyMesh&,
00728 const labelList& changedFaces
00729 );
00730
00731
00732
00733
00734
00735 void storeData
00736 (
00737 const labelList& pointsToStore,
00738 const labelList& facesToStore,
00739 const labelList& cellsToStore
00740 );
00741
00742
00743
00744
00745 void updateMesh
00746 (
00747 const mapPolyMesh&,
00748 const labelList& changedFaces,
00749 const Map<label>& pointsToRestore,
00750 const Map<label>& facesToRestore,
00751 const Map<label>& cellsToRestore
00752 );
00753
00754
00755
00756
00757 label mergePatchFaces
00758 (
00759 const scalar minCos,
00760 const scalar concaveCos,
00761 const labelList& patchIDs
00762 );
00763
00764
00765
00766 autoPtr<mapPolyMesh> mergeEdges(const scalar minCos);
00767
00768
00769
00770
00771
00772 void checkData();
00773
00774
00775 template<class T>
00776 void testSyncBoundaryFaceList
00777 (
00778 const scalar mergeDistance,
00779 const string&,
00780 const UList<T>&,
00781 const UList<T>&
00782 ) const;
00783
00784
00785 void printMeshInfo(const bool, const string&) const;
00786
00787
00788
00789 word timeName() const;
00790
00791
00792 void setInstance(const fileName&);
00793
00794
00795 bool write() const;
00796
00797
00798 void dumpRefinementLevel() const;
00799
00800
00801 void dumpIntersections(const fileName& prefix) const;
00802
00803
00804
00805 void write(const label flag, const fileName&) const;
00806 };
00807
00808
00809
00810
00811 }
00812
00813
00814
00815 #ifdef NoRepository
00816 # include "meshRefinementTemplates.C"
00817 #endif
00818
00819
00820
00821 #endif
00822
00823