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