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