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 #ifndef primitiveMesh_H
00055 #define primitiveMesh_H
00056
00057 #include "DynamicList.H"
00058 #include "edgeList.H"
00059 #include "pointField.H"
00060 #include "SubField.H"
00061 #include "SubList.H"
00062 #include "faceList.H"
00063 #include "cellList.H"
00064 #include "cellShapeList.H"
00065 #include "labelList.H"
00066 #include "boolList.H"
00067 #include "HashSet.H"
00068 #include "Map.H"
00069 #include "EdgeMap.H"
00070
00071
00072
00073 namespace Foam
00074 {
00075
00076
00077
00078
00079
00080 class primitiveMesh
00081 {
00082
00083
00084
00085
00086
00087 label nInternalPoints_;
00088
00089
00090 label nPoints_;
00091
00092
00093 mutable label nInternal0Edges_;
00094
00095
00096 mutable label nInternal1Edges_;
00097
00098
00099 mutable label nInternalEdges_;
00100
00101
00102 mutable label nEdges_;
00103
00104
00105 label nInternalFaces_;
00106
00107
00108 label nFaces_;
00109
00110
00111 label nCells_;
00112
00113
00114
00115
00116
00117 mutable cellShapeList* cellShapesPtr_;
00118
00119
00120 mutable edgeList* edgesPtr_;
00121
00122
00123
00124
00125
00126 mutable labelListList* ccPtr_;
00127
00128
00129 mutable labelListList* ecPtr_;
00130
00131
00132 mutable labelListList* pcPtr_;
00133
00134
00135 mutable cellList* cfPtr_;
00136
00137
00138 mutable labelListList* efPtr_;
00139
00140
00141 mutable labelListList* pfPtr_;
00142
00143
00144 mutable labelListList* cePtr_;
00145
00146
00147 mutable labelListList* fePtr_;
00148
00149
00150 mutable labelListList* pePtr_;
00151
00152
00153 mutable labelListList* ppPtr_;
00154
00155
00156 mutable labelListList* cpPtr_;
00157
00158
00159
00160
00161
00162 mutable DynamicList<label> labels_;
00163
00164
00165 mutable labelHashSet labelSet_;
00166
00167
00168
00169
00170
00171 mutable vectorField* cellCentresPtr_;
00172
00173
00174 mutable vectorField* faceCentresPtr_;
00175
00176
00177 mutable scalarField* cellVolumesPtr_;
00178
00179
00180 mutable vectorField* faceAreasPtr_;
00181
00182
00183
00184
00185
00186 primitiveMesh(const primitiveMesh&);
00187
00188
00189 void operator=(const primitiveMesh&);
00190
00191
00192
00193
00194
00195 void calcCellShapes() const;
00196
00197
00198 void calcCellCells() const;
00199
00200
00201 void calcPointCells() const;
00202
00203
00204 void calcCells() const;
00205
00206
00207 void calcCellEdges() const;
00208
00209
00210 void calcPointPoints() const;
00211
00212
00213
00214
00215 void calcEdges(const bool doFaceEdges) const;
00216 void clearOutEdges();
00217
00218 static label getEdge
00219 (
00220 List<DynamicList<label> >&,
00221 DynamicList<edge>&,
00222 const label,
00223 const label
00224 );
00225
00226 static label findFirstCommonElementFromSortedLists
00227 (
00228 const labelList&,
00229 const labelList&
00230 );
00231
00232
00233
00234
00235
00236 void calcFaceCentresAndAreas() const;
00237 void makeFaceCentresAndAreas
00238 (
00239 const pointField& p,
00240 vectorField& fCtrs,
00241 vectorField& fAreas
00242 ) const;
00243
00244
00245 void calcCellCentresAndVols() const;
00246 void makeCellCentresAndVols
00247 (
00248 const vectorField& fCtrs,
00249 const vectorField& fAreas,
00250 vectorField& cellCtrs,
00251 scalarField& cellVols
00252 ) const;
00253
00254
00255 void calcEdgeVectors() const;
00256
00257
00258
00259
00260
00261 bool checkDuplicateFaces
00262 (
00263 const label,
00264 const Map<label>&,
00265 label& nBaffleFaces,
00266 labelHashSet*
00267 ) const;
00268
00269
00270 bool checkCommonOrder
00271 (
00272 const label,
00273 const Map<label>&,
00274 labelHashSet*
00275 ) const;
00276
00277
00278
00279
00280
00281
00282
00283
00284 static scalar closedThreshold_;
00285
00286
00287 static scalar aspectThreshold_;
00288
00289
00290 static scalar nonOrthThreshold_;
00291
00292
00293 static scalar skewThreshold_;
00294
00295
00296 protected:
00297
00298
00299 primitiveMesh();
00300
00301
00302 public:
00303
00304
00305
00306 ClassName("primitiveMesh");
00307
00308
00309 static const unsigned cellsPerEdge_ = 4;
00310
00311
00312 static const unsigned cellsPerPoint_ = 8;
00313
00314
00315 static const unsigned facesPerCell_ = 6;
00316
00317
00318 static const unsigned facesPerEdge_ = 4;
00319
00320
00321 static const unsigned facesPerPoint_ = 12;
00322
00323
00324 static const unsigned edgesPerCell_ = 12;
00325
00326
00327 static const unsigned edgesPerFace_ = 4;
00328
00329
00330 static const unsigned edgesPerPoint_ = 6;
00331
00332
00333 static const unsigned pointsPerCell_ = 8;
00334
00335
00336 static const unsigned pointsPerFace_ = 4;
00337
00338
00339
00340
00341
00342 primitiveMesh
00343 (
00344 const label nPoints,
00345 const label nInternalFaces,
00346 const label nFaces,
00347 const label nCells
00348 );
00349
00350
00351
00352
00353 virtual ~primitiveMesh();
00354
00355
00356
00357
00358
00359 void reset
00360 (
00361 const label nPoints,
00362 const label nInternalFaces,
00363 const label nFaces,
00364 const label nCells
00365 );
00366
00367
00368 void reset
00369 (
00370 const label nPoints,
00371 const label nInternalFaces,
00372 const label nFaces,
00373 const label nCells,
00374 cellList& cells
00375 );
00376
00377
00378
00379 void reset
00380 (
00381 const label nPoints,
00382 const label nInternalFaces,
00383 const label nFaces,
00384 const label nCells,
00385 const Xfer<cellList>& cells
00386 );
00387
00388
00389
00390
00391
00392
00393 inline label nPoints() const;
00394 inline label nEdges() const;
00395 inline label nInternalFaces() const;
00396 inline label nFaces() const;
00397 inline label nCells() const;
00398
00399
00400
00401
00402 inline label nInternalPoints() const;
00403
00404
00405
00406 inline label nInternal0Edges() const;
00407
00408 inline label nInternal1Edges() const;
00409
00410 inline label nInternalEdges() const;
00411
00412
00413
00414
00415
00416 virtual const pointField& points() const = 0;
00417
00418
00419 virtual const faceList& faces() const = 0;
00420
00421
00422 virtual const labelList& faceOwner() const = 0;
00423
00424
00425 virtual const labelList& faceNeighbour() const = 0;
00426
00427
00428 virtual const pointField& oldPoints() const = 0;
00429
00430
00431
00432
00433
00434 const cellShapeList& cellShapes() const;
00435
00436
00437 const edgeList& edges() const;
00438
00439
00440
00441
00442 static void calcCells
00443 (
00444 cellList&,
00445 const unallocLabelList& own,
00446 const unallocLabelList& nei,
00447 const label nCells = -1
00448 );
00449
00450
00451
00452
00453
00454 static bool calcPointOrder
00455 (
00456 label& nInternalPoints,
00457 labelList& pointMap,
00458 const faceList&,
00459 const label nInternalFaces,
00460 const label nPoints
00461 );
00462
00463
00464
00465 const labelListList& cellCells() const;
00466
00467 const labelListList& edgeCells() const;
00468 const labelListList& pointCells() const;
00469
00470 const cellList& cells() const;
00471
00472 const labelListList& edgeFaces() const;
00473 const labelListList& pointFaces() const;
00474
00475 const labelListList& cellEdges() const;
00476 const labelListList& faceEdges() const;
00477
00478 const labelListList& pointEdges() const;
00479 const labelListList& pointPoints() const;
00480 const labelListList& cellPoints() const;
00481
00482
00483
00484
00485 const vectorField& cellCentres() const;
00486 const vectorField& faceCentres() const;
00487 const scalarField& cellVolumes() const;
00488 const vectorField& faceAreas() const;
00489
00490
00491
00492
00493
00494 tmp<scalarField> movePoints
00495 (
00496 const pointField& p,
00497 const pointField& oldP
00498 );
00499
00500
00501
00502 inline bool isInternalFace(const label faceIndex) const;
00503
00504
00505
00506
00507
00508 bool checkCellsZipUp
00509 (
00510 const bool report = false,
00511 labelHashSet* setPtr = NULL
00512 ) const;
00513
00514
00515 bool checkFaceVertices
00516 (
00517 const bool report = false,
00518 labelHashSet* setPtr = NULL
00519 ) const;
00520
00521
00522 bool checkFaceFaces
00523 (
00524 const bool report = false,
00525 labelHashSet* setPtr = NULL
00526 ) const;
00527
00528
00529 bool checkUpperTriangular
00530 (
00531 const bool report = false,
00532 labelHashSet* setPtr = NULL
00533 ) const;
00534
00535
00536
00537
00538
00539 bool checkClosedBoundary(const bool report = false) const;
00540
00541
00542 bool checkClosedCells
00543 (
00544 const bool report = false,
00545 labelHashSet* setPtr = NULL,
00546 labelHashSet* highAspectSetPtr = NULL
00547 ) const;
00548
00549
00550 bool checkFaceAreas
00551 (
00552 const bool report = false,
00553 labelHashSet* setPtr = NULL
00554 ) const;
00555
00556
00557 bool checkCellVolumes
00558 (
00559
00560 const bool report = false,
00561 labelHashSet* setPtr = NULL
00562 ) const;
00563
00564
00565 bool checkFaceOrthogonality
00566 (
00567 const bool report = false,
00568 labelHashSet* setPtr = NULL
00569 ) const;
00570
00571
00572 bool checkFacePyramids
00573 (
00574 const bool report = false,
00575 const scalar minPyrVol = -SMALL,
00576 labelHashSet* setPtr = NULL
00577 ) const;
00578
00579
00580 bool checkFaceSkewness
00581 (
00582 const bool report = false,
00583 labelHashSet* setPtr = NULL
00584 ) const;
00585
00586
00587 bool checkFaceAngles
00588 (
00589 const bool report = false,
00590 const scalar maxSin = 10,
00591 labelHashSet* setPtr = NULL
00592 ) const;
00593
00594
00595
00596
00597 bool checkFaceFlatness
00598 (
00599 const bool report,
00600 const scalar warnFlatness,
00601 labelHashSet* setPtr
00602 ) const;
00603
00604
00605 bool checkEdgeAlignment
00606 (
00607 const bool report,
00608 const Vector<label>& directions,
00609 labelHashSet* setPtr = NULL
00610 ) const;
00611
00612
00613 bool checkPoints
00614 (
00615 const bool report = false,
00616 labelHashSet* setPtr = NULL
00617 ) const;
00618
00619
00620
00621 bool checkPointNearness
00622 (
00623 const bool report,
00624 const scalar reportDistSqr,
00625 labelHashSet* setPtr = NULL
00626 ) const;
00627
00628
00629 bool checkEdgeLength
00630 (
00631 const bool report,
00632 const scalar minLenSqr,
00633 labelHashSet* setPtr = NULL
00634 ) const;
00635
00636
00637 bool checkCellDeterminant
00638 (
00639 const bool report = false,
00640 labelHashSet* setPtr = NULL
00641 ) const;
00642
00643
00644
00645
00646 bool checkTopology(const bool report = false) const;
00647
00648
00649
00650 bool checkGeometry(const bool report = false) const;
00651
00652
00653 bool checkMesh(const bool report = false) const;
00654
00655
00656 bool checkMeshMotion
00657 (
00658 const pointField& newPoints,
00659 const bool report = false
00660 ) const;
00661
00662
00663
00664 static scalar setClosedThreshold(const scalar);
00665
00666
00667 static scalar setAspectThreshold(const scalar);
00668
00669
00670 static scalar setNonOrthThreshold(const scalar);
00671
00672
00673
00674 static scalar setSkewThreshold(const scalar);
00675
00676
00677
00678
00679
00680 bool pointInCellBB(const point& p, label celli) const;
00681
00682
00683 bool pointInCell(const point& p, label celli) const;
00684
00685
00686 label findNearestCell(const point& location) const;
00687
00688
00689 label findCell(const point& location) const;
00690
00691
00692
00693
00694
00695 void printAllocated() const;
00696
00697
00698 inline bool hasCellShapes() const;
00699 inline bool hasEdges() const;
00700 inline bool hasCellCells() const;
00701 inline bool hasEdgeCells() const;
00702 inline bool hasPointCells() const;
00703 inline bool hasCells() const;
00704 inline bool hasEdgeFaces() const;
00705 inline bool hasPointFaces() const;
00706 inline bool hasCellEdges() const;
00707 inline bool hasFaceEdges() const;
00708 inline bool hasPointEdges() const;
00709 inline bool hasPointPoints() const;
00710 inline bool hasCellPoints() const;
00711 inline bool hasCellCentres() const;
00712 inline bool hasFaceCentres() const;
00713 inline bool hasCellVolumes() const;
00714 inline bool hasFaceAreas() const;
00715
00716
00717
00718
00719
00720
00721
00722
00723 const labelList& cellCells
00724 (
00725 const label cellI,
00726 DynamicList<label>&
00727 ) const;
00728
00729 const labelList& cellCells(const label cellI) const;
00730
00731
00732 const labelList& cellPoints
00733 (
00734 const label cellI,
00735 DynamicList<label>&
00736 ) const;
00737
00738 const labelList& cellPoints(const label cellI) const;
00739
00740
00741 const labelList& pointCells
00742 (
00743 const label pointI,
00744 DynamicList<label>&
00745 ) const;
00746
00747 const labelList& pointCells(const label pointI) const;
00748
00749
00750 const labelList& pointPoints
00751 (
00752 const label pointI,
00753 DynamicList<label>&
00754 ) const;
00755
00756 const labelList& pointPoints(const label pointI) const;
00757
00758
00759 const labelList& faceEdges
00760 (
00761 const label faceI,
00762 DynamicList<label>&
00763 ) const;
00764
00765 const labelList& faceEdges(const label faceI) const;
00766
00767
00768 const labelList& edgeFaces
00769 (
00770 const label edgeI,
00771 DynamicList<label>&
00772 ) const;
00773
00774 const labelList& edgeFaces(const label edgeI) const;
00775
00776
00777 const labelList& edgeCells
00778 (
00779 const label edgeI,
00780 DynamicList<label>&
00781 ) const;
00782
00783 const labelList& edgeCells(const label edgeI) const;
00784
00785
00786 const labelList& cellEdges
00787 (
00788 const label cellI,
00789 DynamicList<label>&
00790 ) const;
00791
00792 const labelList& cellEdges(const label cellI) const;
00793
00794
00795
00796 void clearGeom();
00797
00798
00799 void clearAddressing();
00800
00801
00802 void clearOut();
00803 };
00804
00805
00806
00807
00808 }
00809
00810
00811
00812 #include "primitiveMeshI.H"
00813
00814
00815
00816 #endif
00817
00818