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