primitiveMesh.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::primitiveMesh
26 
27 Description
28  Cell-face mesh analysis engine
29 
30 SourceFiles
31  primitiveMeshI.H
32  primitiveMesh.C
33  primitiveMeshClear.C
34  primitiveMeshCellCells.C
35  primitiveMeshEdgeCells.C
36  primitiveMeshPointCells.C
37  primitiveMeshCells.C
38  primitiveMeshEdgeFaces.C
39  primitiveMeshPointFaces.C
40  primitiveMeshCellEdges.C
41  primitiveMeshPointEdges.C
42  primitiveMeshPointPoints.C
43  primitiveMeshEdges.C
44  primitiveMeshCellCentresAndVols.C
45  primitiveMeshFaceCentresAndAreas.C
46  primitiveMeshFindCell.C
47 
48 \*---------------------------------------------------------------------------*/
49 
50 #ifndef primitiveMesh_H
51 #define primitiveMesh_H
52 
53 #include "DynamicList.H"
54 #include "edgeList.H"
55 #include "pointField.H"
56 #include "faceList.H"
57 #include "cellList.H"
58 #include "cellShapeList.H"
59 #include "labelList.H"
60 #include "boolList.H"
61 #include "HashSet.H"
62 #include "Map.H"
63 
64 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
65 
66 namespace Foam
67 {
68 
69 class PackedBoolList;
70 
71 /*---------------------------------------------------------------------------*\
72  Class primitiveMesh Declaration
73 \*---------------------------------------------------------------------------*/
74 
75 class primitiveMesh
76 {
77  // Permanent data
78 
79  // Primitive size data
80 
81  //- Number of internal points (or -1 if points not sorted)
82  label nInternalPoints_;
83 
84  //- Number of points
85  label nPoints_;
86 
87  //- Number of internal edges using 0 boundary points
88  mutable label nInternal0Edges_;
89 
90  //- Number of internal edges using 0 or 1 boundary points
91  mutable label nInternal1Edges_;
92 
93  //- Number of internal edges using 0,1 or 2boundary points
94  mutable label nInternalEdges_;
95 
96  //- Number of edges
97  mutable label nEdges_;
98 
99  //- Number of internal faces
100  label nInternalFaces_;
101 
102  //- Number of faces
103  label nFaces_;
104 
105  //- Number of cells
106  label nCells_;
107 
108 
109  // Shapes
110 
111  //- Cell shapes
112  mutable cellShapeList* cellShapesPtr_;
113 
114  //- Edges
115  mutable edgeList* edgesPtr_;
116 
117 
118  // Connectivity
119 
120  //- Cell-cells
121  mutable labelListList* ccPtr_;
122 
123  //- Edge-cells
124  mutable labelListList* ecPtr_;
125 
126  //- Point-cells
127  mutable labelListList* pcPtr_;
128 
129  //- Cell-faces
130  mutable cellList* cfPtr_;
131 
132  //- Edge-faces
133  mutable labelListList* efPtr_;
134 
135  //- Point-faces
136  mutable labelListList* pfPtr_;
137 
138  //- Cell-edges
139  mutable labelListList* cePtr_;
140 
141  //- Face-edges
142  mutable labelListList* fePtr_;
143 
144  //- Point-edges
145  mutable labelListList* pePtr_;
146 
147  //- Point-points
148  mutable labelListList* ppPtr_;
149 
150  //- Cell-points
151  mutable labelListList* cpPtr_;
152 
153 
154  // On-the-fly edge addressing storage
155 
156  //- Temporary storage for addressing.
157  mutable DynamicList<label> labels_;
158 
159  //- Temporary storage for addressing
160  mutable labelHashSet labelSet_;
161 
162 
163  // Geometric data
164 
165  //- Cell centres
166  mutable vectorField* cellCentresPtr_;
167 
168  //- Face centres
169  mutable vectorField* faceCentresPtr_;
170 
171  //- Cell volumes
172  mutable scalarField* cellVolumesPtr_;
173 
174  //- Face areas
175  mutable vectorField* faceAreasPtr_;
176 
177  //- Face area magnitudes
178  mutable scalarField* magFaceAreasPtr_;
179 
180 
181  // Topological calculations
182 
183  //- Calculate cell shapes
184  void calcCellShapes() const;
185 
186  //- Calculate cell-cell addressing
187  void calcCellCells() const;
188 
189  //- Calculate point-cell addressing
190  void calcPointCells() const;
191 
192  //- Calculate cell-face addressing
193  void calcCells() const;
194 
195  //- Calculate edge list
196  void calcCellEdges() const;
197 
198  //- Calculate point-point addressing
199  void calcPointPoints() const;
200 
201  //- Calculate edges, pointEdges and faceEdges (if doFaceEdges=true)
202  // During edge calculation, a larger set of data is assembled.
203  // Create and destroy as a set, using clearOutEdges()
204  void calcEdges(const bool doFaceEdges) const;
205  void clearOutEdges();
206  //- Helper: return (after optional creation) edge between two points
207  static label getEdge
208  (
211  const label,
212  const label
213  );
214  //- For on-the-fly addressing calculation
215  static label findFirstCommonElementFromSortedLists
216  (
217  const labelList&,
218  const labelList&
219  );
220 
221 protected:
222 
223  // Static Data Members
224 
225  //- Static data to control mesh checking
226 
227  //- Cell closedness warning threshold
228  // set as the fraction of un-closed area to closed area
229  static scalar closedThreshold_;
230 
231  //- Aspect ratio warning threshold
232  static scalar aspectThreshold_;
233 
234  //- Non-orthogonality warning threshold in deg
235  static scalar nonOrthThreshold_;
236 
237  //- Skewness warning threshold
238  static scalar skewThreshold_;
239 
240  //- Threshold where faces are considered coplanar
241  static scalar planarCosAngle_;
242 
243 
244  // Geometrical calculations
245 
246  //- Calculate face centres and areas
247  void calcFaceCentresAndAreas() const;
248 
250  (
251  const pointField& p,
252  vectorField& fCtrs,
253  vectorField& fAreas,
254  scalarField& magfAreas
255  ) const;
256 
257  //- Calculate cell centres and volumes
258  void calcCellCentresAndVols() const;
259 
261  (
262  const vectorField& fCtrs,
263  const vectorField& fAreas,
264  vectorField& cellCtrs,
266  ) const;
267 
268  //- Calculate edge vectors
269  void calcEdgeVectors() const;
270 
271 
272  // Mesh checking
273 
274  //- Check if all points on face are shared with another face.
276  (
277  const label,
278  const Map<label>&,
279  label& nBaffleFaces,
280  labelHashSet*
281  ) const;
282 
283  //- Check that shared points are in consecutive order.
284  bool checkCommonOrder
285  (
286  const label,
287  const Map<label>&,
288  labelHashSet*
289  ) const;
290 
291  //- Check boundary for closedness
293  (
294  const vectorField&,
295  const bool,
296  const PackedBoolList&
297  ) const;
298 
299  //- Check cells for closedness
300  bool checkClosedCells
301  (
302  const vectorField& faceAreas,
303  const scalarField& cellVolumes,
304  const bool report,
305  labelHashSet* setPtr,
306  labelHashSet* aspectSetPtr,
307  const Vector<label>& meshD
308  ) const;
309 
310  //- Check for negative face areas
311  bool checkFaceAreas
312  (
313  const vectorField& faceAreas,
314  const bool report,
315  const bool detailedReport,
316  labelHashSet* setPtr
317  ) const;
318 
319  //- Check for negative cell volumes
320  bool checkCellVolumes
321  (
322  const scalarField& vols,
323  const bool report,
324  const bool detailedReport,
325  labelHashSet* setPtr
326  ) const;
327 
328  //- Check for non-orthogonality
330  (
331  const vectorField& fAreas,
332  const vectorField& cellCtrs,
333  const bool report,
334  labelHashSet* setPtr
335  ) const;
336 
337  //- Check face pyramid volume
338  bool checkFacePyramids
339  (
340  const pointField& points,
341  const vectorField& ctrs,
342  const bool report,
343  const bool detailedReport,
344  const scalar minPyrVol,
345  labelHashSet* setPtr
346  ) const;
347 
348  //- Check face skewness
349  bool checkFaceSkewness
350  (
351  const pointField& points,
352  const vectorField& fCtrs,
353  const vectorField& fAreas,
354  const vectorField& cellCtrs,
355  const bool report,
356  labelHashSet* setPtr
357  ) const;
358 
359  //- Check face angles
360  // Allows a slight non-convexity. E.g. maxDeg = 10 allows for
361  // angles < 190 (or 10 degrees concavity) (if truly concave and
362  // points not visible from face centre the face-pyramid check in
363  // checkMesh will fail)
364  bool checkFaceAngles
365  (
366  const pointField& points,
367  const vectorField& faceAreas,
368  const bool report,
369  const scalar maxDeg,
370  labelHashSet* setPtr
371  ) const;
372 
373  //- Check face warpage
374  bool checkFaceFlatness
375  (
376  const pointField& points,
377  const vectorField& faceCentres,
378  const vectorField& faceAreas,
379  const bool report,
380  const scalar warnFlatness,
381  labelHashSet* setPtr
382  ) const;
383 
384  //- Check for concave cells by the planes of faces
385  bool checkConcaveCells
386  (
387  const vectorField& fAreas,
388  const pointField& fCentres,
389  const bool report,
390  labelHashSet* setPtr
391  ) const;
392 
393 
394  //- Construct null
395  primitiveMesh();
396 
397 
398 public:
399 
400  // Static data
401 
402  ClassName("primitiveMesh");
403 
404  //- Estimated number of cells per edge
405  static const unsigned cellsPerEdge_ = 4;
406 
407  //- Estimated number of cells per point
408  static const unsigned cellsPerPoint_ = 8;
409 
410  //- Estimated number of faces per cell
411  static const unsigned facesPerCell_ = 6;
412 
413  //- Estimated number of faces per edge
414  static const unsigned facesPerEdge_ = 4;
415 
416  //- Estimated number of faces per point
417  static const unsigned facesPerPoint_ = 12;
418 
419  //- Estimated number of edges per cell
420  static const unsigned edgesPerCell_ = 12;
421 
422  //- Estimated number of edges per cell
423  static const unsigned edgesPerFace_ = 4;
424 
425  //- Estimated number of edges per point
426  static const unsigned edgesPerPoint_ = 6;
427 
428  //- Estimated number of points per cell
429  static const unsigned pointsPerCell_ = 8;
430 
431  //- Estimated number of points per face
432  static const unsigned pointsPerFace_ = 4;
433 
434 
435  // Constructors
436 
437  //- Construct from components
439  (
440  const label nPoints,
441  const label nInternalFaces,
442  const label nFaces,
443  const label nCells
444  );
445 
446  //- Disallow default bitwise copy construction
448 
449 
450  //- Destructor
451  virtual ~primitiveMesh();
452 
453 
454  // Member Functions
455 
456  //- Reset this primitiveMesh given the primitive array sizes
457  void reset
458  (
459  const label nPoints,
460  const label nInternalFaces,
461  const label nFaces,
462  const label nCells
463  );
464 
465  //- Reset this primitiveMesh given the primitive array sizes and cells
466  void reset
467  (
468  const label nPoints,
469  const label nInternalFaces,
470  const label nFaces,
471  const label nCells,
472  cellList& cells
473  );
474 
475  //- Reset this primitiveMesh given the primitive array sizes and cells
476  void reset
477  (
478  const label nPoints,
479  const label nInternalFaces,
480  const label nFaces,
481  const label nCells,
482  cellList&& cells
483  );
484 
485 
486  // Access
487 
488  // Mesh size parameters
489 
490  inline label nPoints() const;
491  inline label nEdges() const;
492  inline label nInternalFaces() const;
493  inline label nFaces() const;
494  inline label nCells() const;
495 
496  // If points are ordered (nInternalPoints != -1):
497 
498  //- Points not on boundary
499  inline label nInternalPoints() const;
500 
501  //- Internal edges (i.e. not on boundary face) using
502  // no boundary point
503  inline label nInternal0Edges() const;
504 
505  //- Internal edges using 0 or 1 boundary point
506  inline label nInternal1Edges() const;
507 
508  //- Internal edges using 0,1 or 2 boundary points
509  inline label nInternalEdges() const;
510 
511 
512  // Primitive mesh data
513 
514  //- Return mesh points
515  virtual const pointField& points() const = 0;
516 
517  //- Return faces
518  virtual const faceList& faces() const = 0;
519 
520  //- Face face-owner addressing
521  virtual const labelList& faceOwner() const = 0;
522 
523  //- Face face-neighbour addressing
524  virtual const labelList& faceNeighbour() const = 0;
525 
526  //- Return old points for mesh motion
527  virtual const pointField& oldPoints() const = 0;
528 
529  //- Return old cell centres for mesh motion
530  virtual const pointField& oldCellCentres() const = 0;
531 
532 
533  // Derived mesh data
534 
535  //- Return cell shapes
536  const cellShapeList& cellShapes() const;
537 
538  //- Return mesh edges. Uses calcEdges.
539  const edgeList& edges() const;
540 
541  //- Helper function to calculate cell-face addressing from
542  // face-cell addressing. If nCells is not provided it will
543  // scan for the maximum.
544  static void calcCells
545  (
546  cellList&,
547  const labelUList& own,
548  const labelUList& nei,
549  const label nCells = -1
550  );
551 
552  //- Helper function to calculate point ordering. Returns true
553  // if points already ordered, false and fills pointMap (old to
554  // new). Map splits points into those not used by any boundary
555  // face and those that are.
556  static bool calcPointOrder
557  (
559  labelList& pointMap,
560  const faceList&,
561  const label nInternalFaces,
562  const label nPoints
563  );
564 
565  // Return mesh connectivity
566 
567  const labelListList& cellCells() const;
568  // faceCells given as owner and neighbour
569  const labelListList& edgeCells() const;
570  const labelListList& pointCells() const;
571 
572  const cellList& cells() const;
573  // faceFaces considered unnecessary
574  const labelListList& edgeFaces() const;
575  const labelListList& pointFaces() const;
576 
577  const labelListList& cellEdges() const;
578  const labelListList& faceEdges() const;
579  // edgeEdges considered unnecessary
580  const labelListList& pointEdges() const;
581  const labelListList& pointPoints() const;
582  const labelListList& cellPoints() const;
583 
584 
585  // Geometric data (raw!)
586 
587  const vectorField& cellCentres() const;
588  const vectorField& faceCentres() const;
589  const scalarField& cellVolumes() const;
590  const vectorField& faceAreas() const;
591  const scalarField& magFaceAreas() const;
592 
593 
594  // Mesh motion
595 
596  //- Move points, returns volumes swept by faces in motion
598  (
599  const pointField& p,
600  const pointField& oldP
601  );
602 
603 
604  //- Return true if given face label is internal to the mesh
605  inline bool isInternalFace(const label faceIndex) const;
606 
607 
608  // Topological checks
609 
610  //- Check face ordering
611  virtual bool checkUpperTriangular
612  (
613  const bool report = false,
614  labelHashSet* setPtr = nullptr
615  ) const;
616 
617  //- Check cell zip-up
618  virtual bool checkCellsZipUp
619  (
620  const bool report = false,
621  labelHashSet* setPtr = nullptr
622  ) const;
623 
624  //- Check uniqueness of face vertices
625  virtual bool checkFaceVertices
626  (
627  const bool report = false,
628  labelHashSet* setPtr = nullptr
629  ) const;
630 
631  //- Check for unused points
632  virtual bool checkPoints
633  (
634  const bool report = false,
635  labelHashSet* setPtr = nullptr
636  ) const;
637 
638  //- Check face-face connectivity
639  virtual bool checkFaceFaces
640  (
641  const bool report = false,
642  labelHashSet* setPtr = nullptr
643  ) const;
644 
645 
646  // Geometric checks
647 
648  //- Check boundary for closedness
649  virtual bool checkClosedBoundary(const bool report = false)
650  const;
651 
652  //- Check cells for closedness
653  virtual bool checkClosedCells
654  (
655  const bool report = false,
656  labelHashSet* setPtr = nullptr,
657  labelHashSet* highAspectSetPtr = nullptr,
658  const Vector<label>& solutionD = Vector<label>::one
659  ) const;
660 
661  //- Check for negative face areas
662  virtual bool checkFaceAreas
663  (
664  const bool report = false,
665  labelHashSet* setPtr = nullptr
666  ) const;
667 
668  //- Check for negative cell volumes
669  virtual bool checkCellVolumes
670  (
671  const bool report = false,
672  labelHashSet* setPtr = nullptr
673  ) const;
674 
675  //- Check for non-orthogonality
676  virtual bool checkFaceOrthogonality
677  (
678  const bool report = false,
679  labelHashSet* setPtr = nullptr
680  ) const;
681 
682  //- Check face pyramid volume
683  virtual bool checkFacePyramids
684  (
685  const bool report = false,
686  const scalar minPyrVol = -small,
687  labelHashSet* setPtr = nullptr
688  ) const;
689 
690  //- Check face skewness
691  virtual bool checkFaceSkewness
692  (
693  const bool report = false,
694  labelHashSet* setPtr = nullptr
695  ) const;
696 
697  //- Check face angles
698  virtual bool checkFaceAngles
699  (
700  const bool report = false,
701  const scalar maxSin = 10, // In degrees
702  labelHashSet* setPtr = nullptr
703  ) const;
704 
705  //- Check face warpage: decompose face and check ratio between
706  // magnitude of sum of triangle areas and sum of magnitude of
707  // triangle areas.
708  virtual bool checkFaceFlatness
709  (
710  const bool report,
711  const scalar warnFlatness, // When to include in set.
712  labelHashSet* setPtr
713  ) const;
714 
715  //- Check for point-point-nearness,
716  // e.g. colocated points which may be part of baffles.
717  virtual bool checkPointNearness
718  (
719  const bool report,
720  const scalar reportDistSqr,
721  labelHashSet* setPtr = nullptr
722  ) const;
723 
724  //- Check edge length
725  virtual bool checkEdgeLength
726  (
727  const bool report,
728  const scalar minLenSqr,
729  labelHashSet* setPtr = nullptr
730  ) const;
731 
732  //- Check for concave cells by the planes of faces
733  virtual bool checkConcaveCells
734  (
735  const bool report = false,
736  labelHashSet* setPtr = nullptr
737  ) const;
738 
739 
740  //- Check mesh topology for correctness.
741  // Returns false for no error.
742  virtual bool checkTopology(const bool report = false) const;
743 
744  //- Check mesh geometry (& implicitly topology) for correctness.
745  // Returns false for no error.
746  virtual bool checkGeometry(const bool report = false) const;
747 
748  //- Check mesh for correctness. Returns false for no error.
749  virtual bool checkMesh(const bool report = false) const;
750 
751  //- Set the closedness ratio warning threshold
752  static scalar setClosedThreshold(const scalar);
753 
754  //- Set the aspect ratio warning threshold
755  static scalar setAspectThreshold(const scalar);
756 
757  //- Set the non-orthogonality warning threshold in degrees
758  static scalar setNonOrthThreshold(const scalar);
759 
760  //- Set the skewness warning threshold as percentage
761  // of the face area vector
762  static scalar setSkewThreshold(const scalar);
763 
764 
765  // Useful derived info
766 
767  //- Return true if the point in the cell bounding box.
768  // The bounding box may be isotropically inflated by the fraction
769  // inflationFraction
770  bool pointInCellBB
771  (
772  const point& p,
773  label celli,
774  scalar inflationFraction = 0
775  ) const;
776 
777  //- Return true if the point is in the cell
778  bool pointInCell(const point& p, label celli) const;
779 
780  //- Find the cell with the nearest cell centre to location
781  label findNearestCell(const point& location) const;
782 
783  //- Find cell enclosing this location (-1 if not in mesh)
784  label findCell(const point& location) const;
785 
786 
787  // Storage management
788 
789  //- Print a list of all the currently allocated mesh data
790  void printAllocated() const;
791 
792  // Per storage whether allocated
793  inline bool hasCellShapes() const;
794  inline bool hasEdges() const;
795  inline bool hasCellCells() const;
796  inline bool hasEdgeCells() const;
797  inline bool hasPointCells() const;
798  inline bool hasCells() const;
799  inline bool hasEdgeFaces() const;
800  inline bool hasPointFaces() const;
801  inline bool hasCellEdges() const;
802  inline bool hasFaceEdges() const;
803  inline bool hasPointEdges() const;
804  inline bool hasPointPoints() const;
805  inline bool hasCellPoints() const;
806  inline bool hasCellCentres() const;
807  inline bool hasFaceCentres() const;
808  inline bool hasCellVolumes() const;
809  inline bool hasFaceAreas() const;
810 
811  // On-the-fly addressing calculation. These functions return either
812  // a reference to the full addressing (if already calculated) or
813  // a reference to the supplied storage. The one-argument ones
814  // use member DynamicList labels_ so be careful when not storing
815  // result.
816 
817  //- cellCells using cells.
818  const labelList& cellCells
819  (
820  const label celli,
822  ) const;
823 
824  const labelList& cellCells(const label celli) const;
825 
826  //- cellPoints using cells
827  const labelList& cellPoints
828  (
829  const label celli,
831  ) const;
832 
833  const labelList& cellPoints(const label celli) const;
834 
835  //- pointCells using pointFaces
836  const labelList& pointCells
837  (
838  const label pointi,
840  ) const;
841 
842  const labelList& pointCells(const label pointi) const;
843 
844  //- pointPoints using edges, pointEdges
845  const labelList& pointPoints
846  (
847  const label pointi,
849  ) const;
850 
851  const labelList& pointPoints(const label pointi) const;
852 
853  //- faceEdges using pointFaces, edges, pointEdges
854  const labelList& faceEdges
855  (
856  const label facei,
858  ) const;
859 
860  const labelList& faceEdges(const label facei) const;
861 
862  //- edgeFaces using pointFaces, edges, pointEdges
863  const labelList& edgeFaces
864  (
865  const label edgeI,
867  ) const;
868 
869  const labelList& edgeFaces(const label edgeI) const;
870 
871  //- edgeCells using pointFaces, edges, pointEdges
872  const labelList& edgeCells
873  (
874  const label edgeI,
876  ) const;
877 
878  const labelList& edgeCells(const label edgeI) const;
879 
880  //- cellEdges using cells, pointFaces, edges, pointEdges
881  const labelList& cellEdges
882  (
883  const label celli,
885  ) const;
886 
887  const labelList& cellEdges(const label celli) const;
888 
889 
890  //- Clear geometry
891  void clearGeom();
892 
893  //- Clear topological data
894  void clearAddressing();
895 
896  //- Clear all geometry and addressing unnecessary for CFD
897  void clearOut();
898 
899 
900  // Member Operators
901 
902  //- Disallow default bitwise assignment
903  void operator=(const primitiveMesh&) = delete;
904 };
905 
906 
907 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
908 
909 } // End namespace Foam
910 
911 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
912 
913 #include "primitiveMeshI.H"
914 
915 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
916 
917 #endif
918 
919 // ************************************************************************* //
bool hasEdgeFaces() const
bool checkFaceAreas(const vectorField &faceAreas, const bool report, const bool detailedReport, labelHashSet *setPtr) const
Check for negative face areas.
static const unsigned cellsPerEdge_
Estimated number of cells per edge.
static scalar aspectThreshold_
Aspect ratio warning threshold.
const labelListList & cellEdges() const
ClassName("primitiveMesh")
bool checkFaceAngles(const pointField &points, const vectorField &faceAreas, const bool report, const scalar maxDeg, labelHashSet *setPtr) const
Check face angles.
void clearAddressing()
Clear topological data.
void makeFaceCentresAndAreas(const pointField &p, vectorField &fCtrs, vectorField &fAreas, scalarField &magfAreas) const
label findCell(const point &location) const
Find cell enclosing this location (-1 if not in mesh)
bool hasCellCentres() const
bool hasCellPoints() const
const labelListList & faceEdges() const
label nInternalFaces() const
void operator=(const primitiveMesh &)=delete
Disallow default bitwise assignment.
const labelListList & pointEdges() const
Cell-face mesh analysis engine.
Definition: primitiveMesh.H:74
label nFaces() const
label nInternalPoints() const
Points not on boundary.
const cellShapeList & cellShapes() const
Return cell shapes.
bool hasCellCells() const
label nCells() const
static scalar setClosedThreshold(const scalar)
Set the closedness ratio warning threshold.
void printAllocated() const
Print a list of all the currently allocated mesh data.
virtual const pointField & oldCellCentres() const =0
Return old cell centres for mesh motion.
virtual bool checkPointNearness(const bool report, const scalar reportDistSqr, labelHashSet *setPtr=nullptr) const
Check for point-point-nearness,.
label nInternal0Edges() const
Internal edges (i.e. not on boundary face) using.
virtual const pointField & points() const =0
Return mesh points.
primitiveMesh()
Construct null.
Definition: primitiveMesh.C:39
bool hasCellShapes() const
const cellList & cells() const
bool pointInCell(const point &p, label celli) const
Return true if the point is in the cell.
static const unsigned edgesPerPoint_
Estimated number of edges per point.
bool hasFaceAreas() const
static const unsigned pointsPerCell_
Estimated number of points per cell.
static const unsigned edgesPerFace_
Estimated number of edges per cell.
virtual const pointField & oldPoints() const =0
Return old points for mesh motion.
static const unsigned facesPerPoint_
Estimated number of faces per point.
static scalar setAspectThreshold(const scalar)
Set the aspect ratio warning threshold.
static scalar setSkewThreshold(const scalar)
Set the skewness warning threshold as percentage.
static const unsigned pointsPerFace_
Estimated number of points per face.
bool checkFaceSkewness(const pointField &points, const vectorField &fCtrs, const vectorField &fAreas, const vectorField &cellCtrs, const bool report, labelHashSet *setPtr) const
Check face skewness.
const scalarField & magFaceAreas() const
bool checkClosedCells(const vectorField &faceAreas, const scalarField &cellVolumes, const bool report, labelHashSet *setPtr, labelHashSet *aspectSetPtr, const Vector< label > &meshD) const
Check cells for closedness.
bool hasEdges() const
const labelListList & edgeCells() const
virtual const labelList & faceNeighbour() const =0
Face face-neighbour addressing.
bool checkFacePyramids(const pointField &points, const vectorField &ctrs, const bool report, const bool detailedReport, const scalar minPyrVol, labelHashSet *setPtr) const
Check face pyramid volume.
static const unsigned facesPerCell_
Estimated number of faces per cell.
void clearGeom()
Clear geometry.
tmp< scalarField > movePoints(const pointField &p, const pointField &oldP)
Move points, returns volumes swept by faces in motion.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
Definition: DynamicList.H:56
bool checkFaceOrthogonality(const vectorField &fAreas, const vectorField &cellCtrs, const bool report, labelHashSet *setPtr) const
Check for non-orthogonality.
Pre-declare SubField and related Field type.
Definition: Field.H:56
static scalar closedThreshold_
Static data to control mesh checking.
void clearOut()
Clear all geometry and addressing unnecessary for CFD.
static const unsigned cellsPerPoint_
Estimated number of cells per point.
label nInternal1Edges() const
Internal edges using 0 or 1 boundary point.
void calcCellCentresAndVols() const
Calculate cell centres and volumes.
bool hasCells() const
virtual bool checkMesh(const bool report=false) const
Check mesh for correctness. Returns false for no error.
bool hasFaceCentres() const
virtual bool checkEdgeLength(const bool report, const scalar minLenSqr, labelHashSet *setPtr=nullptr) const
Check edge length.
void makeCellCentresAndVols(const vectorField &fCtrs, const vectorField &fAreas, vectorField &cellCtrs, scalarField &cellVols) const
static scalar setNonOrthThreshold(const scalar)
Set the non-orthogonality warning threshold in degrees.
const vectorField & cellCentres() const
static const unsigned facesPerEdge_
Estimated number of faces per edge.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:60
const labelListList & pointCells() const
bool checkCellVolumes(const scalarField &vols, const bool report, const bool detailedReport, labelHashSet *setPtr) const
Check for negative cell volumes.
bool hasCellEdges() const
void reset(const label nPoints, const label nInternalFaces, const label nFaces, const label nCells)
Reset this primitiveMesh given the primitive array sizes.
bool isInternalFace(const label faceIndex) const
Return true if given face label is internal to the mesh.
Templated 3D Vector derived from VectorSpace adding construction from 3 components, element access using x(), y() and z() member functions and the inner-product (dot-product) and cross product operators.
Definition: Vector.H:57
static scalar planarCosAngle_
Threshold where faces are considered coplanar.
static const unsigned edgesPerCell_
Estimated number of edges per cell.
void calcEdgeVectors() const
Calculate edge vectors.
const scalarField & cellVols
bool hasPointFaces() const
label nEdges() const
virtual bool checkFaceVertices(const bool report=false, labelHashSet *setPtr=nullptr) const
Check uniqueness of face vertices.
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
const vectorField & faceCentres() const
virtual ~primitiveMesh()
Destructor.
A bit-packed bool list.
virtual bool checkTopology(const bool report=false) const
Check mesh topology for correctness.
bool checkConcaveCells(const vectorField &fAreas, const pointField &fCentres, const bool report, labelHashSet *setPtr) const
Check for concave cells by the planes of faces.
bool checkCommonOrder(const label, const Map< label > &, labelHashSet *) const
Check that shared points are in consecutive order.
void calcFaceCentresAndAreas() const
Calculate face centres and areas.
const vectorField & faceAreas() const
virtual const faceList & faces() const =0
Return faces.
label findNearestCell(const point &location) const
Find the cell with the nearest cell centre to location.
bool checkDuplicateFaces(const label, const Map< label > &, label &nBaffleFaces, labelHashSet *) const
Check if all points on face are shared with another face.
bool hasEdgeCells() const
bool hasPointPoints() const
const labelListList & pointPoints() const
const labelListList & pointFaces() const
virtual const labelList & faceOwner() const =0
Face face-owner addressing.
virtual bool checkCellsZipUp(const bool report=false, labelHashSet *setPtr=nullptr) const
Check cell zip-up.
virtual bool checkUpperTriangular(const bool report=false, labelHashSet *setPtr=nullptr) const
Check face ordering.
virtual bool checkPoints(const bool report=false, labelHashSet *setPtr=nullptr) const
Check for unused points.
virtual bool checkGeometry(const bool report=false) const
Check mesh geometry (& implicitly topology) for correctness.
label nPoints() const
bool checkFaceFlatness(const pointField &points, const vectorField &faceCentres, const vectorField &faceAreas, const bool report, const scalar warnFlatness, labelHashSet *setPtr) const
Check face warpage.
bool hasCellVolumes() const
virtual bool checkFaceFaces(const bool report=false, labelHashSet *setPtr=nullptr) const
Check face-face connectivity.
static scalar skewThreshold_
Skewness warning threshold.
static scalar nonOrthThreshold_
Non-orthogonality warning threshold in deg.
volScalarField & p
A class for managing temporary objects.
Definition: PtrList.H:53
bool checkClosedBoundary(const vectorField &, const bool, const PackedBoolList &) const
Check boundary for closedness.
static bool calcPointOrder(label &nInternalPoints, labelList &pointMap, const faceList &, const label nInternalFaces, const label nPoints)
Helper function to calculate point ordering. Returns true.
bool hasPointEdges() const
label nInternalEdges() const
Internal edges using 0,1 or 2 boundary points.
const labelListList & cellCells() const
const labelListList & edgeFaces() const
const labelListList & cellPoints() const
Namespace for OpenFOAM.
const scalarField & cellVolumes() const
bool pointInCellBB(const point &p, label celli, scalar inflationFraction=0) const
Return true if the point in the cell bounding box.
bool hasPointCells() const
bool hasFaceEdges() const