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-2023 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  // Geometrical calculations
226 
227  //- Calculate face centres and areas
228  void calcFaceCentresAndAreas() const;
229 
231  (
232  const pointField& p,
233  vectorField& fCtrs,
234  vectorField& fAreas,
235  scalarField& magfAreas
236  ) const;
237 
238  //- Calculate cell centres and volumes
239  void calcCellCentresAndVols() const;
240 
242  (
243  const vectorField& fCtrs,
244  const vectorField& fAreas,
245  vectorField& cellCtrs,
247  ) const;
248 
249  //- Calculate edge vectors
250  void calcEdgeVectors() const;
251 
252 
253  // Mesh checking
254 
255  //- Check if all points on face are shared with another face.
257  (
258  const label,
259  const Map<label>&,
260  label& nBaffleFaces,
261  labelHashSet*
262  ) const;
263 
264  //- Check that shared points are in consecutive order.
265  bool checkCommonOrder
266  (
267  const label,
268  const Map<label>&,
269  labelHashSet*
270  ) const;
271 
272  //- Check boundary for closedness
274  (
275  const vectorField&,
276  const bool,
277  const PackedBoolList&
278  ) const;
279 
280  //- Check cells for closedness
281  bool checkClosedCells
282  (
283  const vectorField& faceAreas,
284  const scalarField& cellVolumes,
285  const bool report,
286  labelHashSet* setPtr,
287  labelHashSet* aspectSetPtr,
288  const Vector<label>& meshD
289  ) const;
290 
291  //- Check for negative face areas
292  bool checkFaceAreas
293  (
294  const vectorField& faceAreas,
295  const bool report,
296  const bool detailedReport,
297  labelHashSet* setPtr
298  ) const;
299 
300  //- Check for negative cell volumes
301  bool checkCellVolumes
302  (
303  const scalarField& vols,
304  const bool report,
305  const bool detailedReport,
306  labelHashSet* setPtr
307  ) const;
308 
309  //- Check for non-orthogonality
311  (
312  const vectorField& fAreas,
313  const vectorField& cellCtrs,
314  const bool report,
315  labelHashSet* setPtr
316  ) const;
317 
318  //- Check face pyramid volume
319  bool checkFacePyramids
320  (
321  const pointField& points,
322  const vectorField& ctrs,
323  const bool report,
324  const bool detailedReport,
325  const scalar minPyrVol,
326  labelHashSet* setPtr
327  ) const;
328 
329  //- Check face skewness
330  bool checkFaceSkewness
331  (
332  const pointField& points,
333  const vectorField& fCtrs,
334  const vectorField& fAreas,
335  const vectorField& cellCtrs,
336  const bool report,
337  labelHashSet* setPtr
338  ) const;
339 
340  //- Check face angles
341  // Allows a slight non-convexity. E.g. maxDeg = 10 allows for
342  // angles < 190 (or 10 degrees concavity) (if truly concave and
343  // points not visible from face centre the face-pyramid check in
344  // checkMesh will fail)
345  bool checkFaceAngles
346  (
347  const pointField& points,
348  const vectorField& faceAreas,
349  const bool report,
350  const scalar maxDeg,
351  labelHashSet* setPtr
352  ) const;
353 
354  //- Check face warpage
355  bool checkFaceFlatness
356  (
357  const pointField& points,
358  const vectorField& faceCentres,
359  const vectorField& faceAreas,
360  const bool report,
361  const scalar warnFlatness,
362  labelHashSet* setPtr
363  ) const;
364 
365  //- Check for concave cells by the planes of faces
366  bool checkConcaveCells
367  (
368  const vectorField& fAreas,
369  const pointField& fCentres,
370  const bool report,
371  labelHashSet* setPtr
372  ) const;
373 
374 
375  //- Construct null
376  primitiveMesh();
377 
378 
379 public:
380 
381  // Static data
382 
383  ClassName("primitiveMesh");
384 
385  //- Estimated number of cells per edge
386  static const unsigned cellsPerEdge_ = 4;
387 
388  //- Estimated number of cells per point
389  static const unsigned cellsPerPoint_ = 8;
390 
391  //- Estimated number of faces per cell
392  static const unsigned facesPerCell_ = 6;
393 
394  //- Estimated number of faces per edge
395  static const unsigned facesPerEdge_ = 4;
396 
397  //- Estimated number of faces per point
398  static const unsigned facesPerPoint_ = 12;
399 
400  //- Estimated number of edges per cell
401  static const unsigned edgesPerCell_ = 12;
402 
403  //- Estimated number of edges per cell
404  static const unsigned edgesPerFace_ = 4;
405 
406  //- Estimated number of edges per point
407  static const unsigned edgesPerPoint_ = 6;
408 
409  //- Estimated number of points per cell
410  static const unsigned pointsPerCell_ = 8;
411 
412  //- Estimated number of points per face
413  static const unsigned pointsPerFace_ = 4;
414 
415 
416  // Constructors
417 
418  //- Construct from components
420  (
421  const label nPoints,
422  const label nInternalFaces,
423  const label nFaces,
424  const label nCells
425  );
426 
427  //- Move constructor
428  primitiveMesh(primitiveMesh&&) = default;
429 
430  //- Disallow default bitwise copy construction
431  primitiveMesh(const primitiveMesh&) = delete;
432 
433 
434  //- Destructor
435  virtual ~primitiveMesh();
436 
437 
438  // Member Functions
439 
440  //- Reset this primitiveMesh given the primitive array sizes
441  void reset
442  (
443  const label nPoints,
444  const label nInternalFaces,
445  const label nFaces,
446  const label nCells
447  );
448 
449  //- Reset this primitiveMesh given the primitive array sizes and cells
450  void reset
451  (
452  const label nPoints,
453  const label nInternalFaces,
454  const label nFaces,
455  const label nCells,
456  cellList& cells
457  );
458 
459  //- Reset this primitiveMesh given the primitive array sizes and cells
460  void reset
461  (
462  const label nPoints,
463  const label nInternalFaces,
464  const label nFaces,
465  const label nCells,
466  cellList&& cells
467  );
468 
469 
470  // Access
471 
472  // Mesh size parameters
473 
474  inline label nPoints() const;
475  inline label nEdges() const;
476  inline label nInternalFaces() const;
477  inline label nFaces() const;
478  inline label nCells() const;
479 
480  // If points are ordered (nInternalPoints != -1):
481 
482  //- Points not on boundary
483  inline label nInternalPoints() const;
484 
485  //- Internal edges (i.e. not on boundary face) using
486  // no boundary point
487  inline label nInternal0Edges() const;
488 
489  //- Internal edges using 0 or 1 boundary point
490  inline label nInternal1Edges() const;
491 
492  //- Internal edges using 0,1 or 2 boundary points
493  inline label nInternalEdges() const;
494 
495 
496  // Primitive mesh data
497 
498  //- Return mesh points
499  virtual const pointField& points() const = 0;
500 
501  //- Return faces
502  virtual const faceList& faces() const = 0;
503 
504  //- Face face-owner addressing
505  virtual const labelList& faceOwner() const = 0;
506 
507  //- Face face-neighbour addressing
508  virtual const labelList& faceNeighbour() const = 0;
509 
510  //- Return old points for mesh motion
511  virtual const pointField& oldPoints() const = 0;
512 
513  //- Return old cell centres for mesh motion
514  virtual const pointField& oldCellCentres() const = 0;
515 
516 
517  // Derived mesh data
518 
519  //- Return cell shapes
520  const cellShapeList& cellShapes() const;
521 
522  //- Return mesh edges. Uses calcEdges.
523  const edgeList& edges() const;
524 
525  //- Helper function to calculate cell-face addressing from
526  // face-cell addressing. If nCells is not provided it will
527  // scan for the maximum.
528  static void calcCells
529  (
530  cellList&,
531  const labelUList& own,
532  const labelUList& nei,
533  const label nCells = -1
534  );
535 
536  //- Helper function to calculate point ordering. Returns true
537  // if points already ordered, false and fills pointMap (old to
538  // new). Map splits points into those not used by any boundary
539  // face and those that are.
540  static bool calcPointOrder
541  (
543  labelList& pointMap,
544  const faceList&,
545  const label nInternalFaces,
546  const label nPoints
547  );
548 
549  // Return mesh connectivity
550 
551  const labelListList& cellCells() const;
552  // faceCells given as owner and neighbour
553  const labelListList& edgeCells() const;
554  const labelListList& pointCells() const;
555 
556  const cellList& cells() const;
557  // faceFaces considered unnecessary
558  const labelListList& edgeFaces() const;
559  const labelListList& pointFaces() const;
560 
561  const labelListList& cellEdges() const;
562  const labelListList& faceEdges() const;
563  // edgeEdges considered unnecessary
564  const labelListList& pointEdges() const;
565  const labelListList& pointPoints() const;
566  const labelListList& cellPoints() const;
567 
568 
569  // Geometric data (raw!)
570 
571  const vectorField& cellCentres() const;
572  const vectorField& faceCentres() const;
573  const scalarField& cellVolumes() const;
574  const vectorField& faceAreas() const;
575  const scalarField& magFaceAreas() const;
576 
577 
578  // Mesh motion
579 
580  //- Move points, returns volumes swept by faces in motion
582  (
583  const pointField& p,
584  const pointField& oldP
585  );
586 
587 
588  //- Return true if given face label is internal to the mesh
589  inline bool isInternalFace(const label faceIndex) const;
590 
591 
592  // Topological checks
593 
594  //- Check face ordering
595  virtual bool checkUpperTriangular
596  (
597  const bool report = false,
598  labelHashSet* setPtr = nullptr
599  ) const;
600 
601  //- Check cell zip-up
602  virtual bool checkCellsZipUp
603  (
604  const bool report = false,
605  labelHashSet* setPtr = nullptr
606  ) const;
607 
608  //- Check uniqueness of face vertices
609  virtual bool checkFaceVertices
610  (
611  const bool report = false,
612  labelHashSet* setPtr = nullptr
613  ) const;
614 
615  //- Check for unused points
616  virtual bool checkPoints
617  (
618  const bool report = false,
619  labelHashSet* setPtr = nullptr
620  ) const;
621 
622  //- Check face-face connectivity
623  virtual bool checkFaceFaces
624  (
625  const bool report = false,
626  labelHashSet* setPtr = nullptr
627  ) const;
628 
629 
630  // Geometric checks
631 
632  //- Check boundary for closedness
633  virtual bool checkClosedBoundary(const bool report = false)
634  const;
635 
636  //- Check cells for closedness
637  virtual bool checkClosedCells
638  (
639  const bool report = false,
640  labelHashSet* setPtr = nullptr,
641  labelHashSet* highAspectSetPtr = nullptr,
642  const Vector<label>& solutionD = Vector<label>::one
643  ) const;
644 
645  //- Check for negative face areas
646  virtual bool checkFaceAreas
647  (
648  const bool report = false,
649  labelHashSet* setPtr = nullptr
650  ) const;
651 
652  //- Check for negative cell volumes
653  virtual bool checkCellVolumes
654  (
655  const bool report = false,
656  labelHashSet* setPtr = nullptr
657  ) const;
658 
659  //- Check for non-orthogonality
660  virtual bool checkFaceOrthogonality
661  (
662  const bool report = false,
663  labelHashSet* setPtr = nullptr
664  ) const;
665 
666  //- Check face pyramid volume
667  virtual bool checkFacePyramids
668  (
669  const bool report = false,
670  const scalar minPyrVol = -small,
671  labelHashSet* setPtr = nullptr
672  ) const;
673 
674  //- Check face skewness
675  virtual bool checkFaceSkewness
676  (
677  const bool report = false,
678  labelHashSet* setPtr = nullptr
679  ) const;
680 
681  //- Check face angles
682  virtual bool checkFaceAngles
683  (
684  const bool report = false,
685  const scalar maxSin = 10, // In degrees
686  labelHashSet* setPtr = nullptr
687  ) const;
688 
689  //- Check face warpage: decompose face and check ratio between
690  // magnitude of sum of triangle areas and sum of magnitude of
691  // triangle areas.
692  virtual bool checkFaceFlatness
693  (
694  const bool report,
695  const scalar warnFlatness, // When to include in set.
696  labelHashSet* setPtr
697  ) const;
698 
699  //- Check for point-point-nearness,
700  // e.g. colocated points which may be part of baffles.
701  virtual bool checkPointNearness
702  (
703  const bool report,
704  const scalar reportDistSqr,
705  labelHashSet* setPtr = nullptr
706  ) const;
707 
708  //- Check edge length
709  virtual bool checkEdgeLength
710  (
711  const bool report,
712  const scalar minLenSqr,
713  labelHashSet* setPtr = nullptr
714  ) const;
715 
716  //- Check for concave cells by the planes of faces
717  virtual bool checkConcaveCells
718  (
719  const bool report = false,
720  labelHashSet* setPtr = nullptr
721  ) const;
722 
723 
724  //- Check mesh topology for correctness.
725  // Returns false for no error.
726  virtual bool checkTopology(const bool report = false) const;
727 
728  //- Check mesh geometry (& implicitly topology) for correctness.
729  // Returns false for no error.
730  virtual bool checkGeometry(const bool report = false) const;
731 
732  //- Check mesh for correctness. Returns false for no error.
733  virtual bool checkMesh(const bool report = false) const;
734 
735 
736  // Useful derived info
737 
738  //- Return true if the point in the cell bounding box.
739  // The bounding box may be isotropically inflated by the fraction
740  // inflationFraction
741  bool pointInCellBB
742  (
743  const point& p,
744  label celli,
745  scalar inflationFraction = 0
746  ) const;
747 
748  //- Return true if the point is in the cell
749  bool pointInCell(const point& p, label celli) const;
750 
751  //- Find the cell with the nearest cell centre to location
752  label findNearestCell(const point& location) const;
753 
754  //- Find cell enclosing this location (-1 if not in mesh)
755  label findCell(const point& location) const;
756 
757 
758  // Storage management
759 
760  //- Print a list of all the currently allocated mesh data
761  void printAllocated() const;
762 
763  // Per storage whether allocated
764  inline bool hasCellShapes() const;
765  inline bool hasEdges() const;
766  inline bool hasCellCells() const;
767  inline bool hasEdgeCells() const;
768  inline bool hasPointCells() const;
769  inline bool hasCells() const;
770  inline bool hasEdgeFaces() const;
771  inline bool hasPointFaces() const;
772  inline bool hasCellEdges() const;
773  inline bool hasFaceEdges() const;
774  inline bool hasPointEdges() const;
775  inline bool hasPointPoints() const;
776  inline bool hasCellPoints() const;
777  inline bool hasCellCentres() const;
778  inline bool hasFaceCentres() const;
779  inline bool hasCellVolumes() const;
780  inline bool hasFaceAreas() const;
781 
782  // On-the-fly addressing calculation. These functions return either
783  // a reference to the full addressing (if already calculated) or
784  // a reference to the supplied storage. The one-argument ones
785  // use member DynamicList labels_ so be careful when not storing
786  // result.
787 
788  //- cellCells using cells.
789  const labelList& cellCells
790  (
791  const label celli,
793  ) const;
794 
795  const labelList& cellCells(const label celli) const;
796 
797  //- cellPoints using cells
798  const labelList& cellPoints
799  (
800  const label celli,
802  ) const;
803 
804  const labelList& cellPoints(const label celli) const;
805 
806  //- pointCells using pointFaces
807  const labelList& pointCells
808  (
809  const label pointi,
811  ) const;
812 
813  const labelList& pointCells(const label pointi) const;
814 
815  //- pointPoints using edges, pointEdges
816  const labelList& pointPoints
817  (
818  const label pointi,
820  ) const;
821 
822  const labelList& pointPoints(const label pointi) const;
823 
824  //- faceEdges using pointFaces, edges, pointEdges
825  const labelList& faceEdges
826  (
827  const label facei,
829  ) const;
830 
831  const labelList& faceEdges(const label facei) const;
832 
833  //- edgeFaces using pointFaces, edges, pointEdges
834  const labelList& edgeFaces
835  (
836  const label edgeI,
838  ) const;
839 
840  const labelList& edgeFaces(const label edgeI) const;
841 
842  //- edgeCells using pointFaces, edges, pointEdges
843  const labelList& edgeCells
844  (
845  const label edgeI,
847  ) const;
848 
849  const labelList& edgeCells(const label edgeI) const;
850 
851  //- cellEdges using cells, pointFaces, edges, pointEdges
852  const labelList& cellEdges
853  (
854  const label celli,
856  ) const;
857 
858  const labelList& cellEdges(const label celli) const;
859 
860 
861  //- Clear geometry
862  void clearGeom();
863 
864  //- Clear topological data
865  void clearAddressing();
866 
867  //- Clear all geometry and addressing unnecessary for CFD
868  void clearOut();
869 
870 
871  // Member Operators
872 
873  //- Disallow default bitwise assignment
874  void operator=(const primitiveMesh&) = delete;
875 };
876 
877 
878 namespace primitiveMeshCheck
879 {
880  //- Data to control mesh checking
881 
882  //- Cell closedness warning threshold
883  // set as the fraction of un-closed area to closed area
884  extern scalar closedThreshold;
885 
886  //- Aspect ratio warning threshold
887  extern scalar aspectThreshold;
888 
889  //- Non-orthogonality warning threshold in deg
890  extern scalar nonOrthThreshold;
891 
892  //- Skewness warning threshold
893  extern scalar skewThreshold;
894 
895  //- Threshold where faces are considered coplanar
896  extern scalar planarCosAngle;
897 }
898 
899 
900 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
901 
902 } // End namespace Foam
903 
904 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
905 
906 #include "primitiveMeshI.H"
907 
908 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
909 
910 #endif
911 
912 // ************************************************************************* //
A bit-packed bool list.
Cell-face mesh analysis engine.
Definition: primitiveMesh.H:75
bool checkFaceOrthogonality(const vectorField &fAreas, const vectorField &cellCtrs, const bool report, labelHashSet *setPtr) const
Check for non-orthogonality.
label nEdges() const
label nCells() const
static bool calcPointOrder(label &nInternalPoints, labelList &pointMap, const faceList &, const label nInternalFaces, const label nPoints)
Helper function to calculate point ordering. Returns true.
label findNearestCell(const point &location) const
Find the cell with the nearest cell centre to location.
bool hasCellCells() const
bool hasCellShapes() const
primitiveMesh()
Construct null.
Definition: primitiveMesh.C:39
bool hasPointFaces() const
label nPoints() const
bool hasCellEdges() const
bool hasCellVolumes() const
const labelListList & pointEdges() const
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
const labelListList & cellEdges() const
bool pointInCell(const point &p, label celli) const
Return true if the point is in the cell.
bool hasPointPoints() const
const vectorField & faceCentres() const
virtual const faceList & faces() const =0
Return faces.
virtual bool checkEdgeLength(const bool report, const scalar minLenSqr, labelHashSet *setPtr=nullptr) const
Check edge length.
virtual bool checkCellsZipUp(const bool report=false, labelHashSet *setPtr=nullptr) const
Check cell zip-up.
const labelListList & pointCells() const
static const unsigned facesPerEdge_
Estimated number of faces per edge.
const scalarField & cellVolumes() const
void clearGeom()
Clear geometry.
virtual bool checkMesh(const bool report=false) const
Check mesh for correctness. Returns false for no error.
virtual bool checkTopology(const bool report=false) const
Check mesh topology for correctness.
bool hasFaceAreas() const
bool checkCommonOrder(const label, const Map< label > &, labelHashSet *) const
Check that shared points are in consecutive order.
bool pointInCellBB(const point &p, label celli, scalar inflationFraction=0) const
Return true if the point in the cell bounding box.
bool hasEdges() const
label nInternal1Edges() const
Internal edges using 0 or 1 boundary point.
bool hasFaceCentres() const
virtual bool checkUpperTriangular(const bool report=false, labelHashSet *setPtr=nullptr) const
Check face ordering.
void makeCellCentresAndVols(const vectorField &fCtrs, const vectorField &fAreas, vectorField &cellCtrs, scalarField &cellVols) const
static const unsigned edgesPerCell_
Estimated number of edges per cell.
const vectorField & cellCentres() const
bool checkFacePyramids(const pointField &points, const vectorField &ctrs, const bool report, const bool detailedReport, const scalar minPyrVol, labelHashSet *setPtr) const
Check face pyramid volume.
bool checkFaceAngles(const pointField &points, const vectorField &faceAreas, const bool report, const scalar maxDeg, labelHashSet *setPtr) const
Check face angles.
bool hasPointCells() const
virtual ~primitiveMesh()
Destructor.
const cellShapeList & cellShapes() const
Return cell shapes.
bool checkClosedBoundary(const vectorField &, const bool, const PackedBoolList &) const
Check boundary for closedness.
static const unsigned facesPerPoint_
Estimated number of faces per point.
void calcCellCentresAndVols() const
Calculate cell centres and volumes.
virtual const labelList & faceOwner() const =0
Face face-owner addressing.
bool checkDuplicateFaces(const label, const Map< label > &, label &nBaffleFaces, labelHashSet *) const
Check if all points on face are shared with another face.
label findCell(const point &location) const
Find cell enclosing this location (-1 if not in mesh)
void calcEdgeVectors() const
Calculate edge vectors.
static const unsigned pointsPerFace_
Estimated number of points per face.
ClassName("primitiveMesh")
virtual bool checkFaceVertices(const bool report=false, labelHashSet *setPtr=nullptr) const
Check uniqueness of face vertices.
bool checkCellVolumes(const scalarField &vols, const bool report, const bool detailedReport, labelHashSet *setPtr) const
Check for negative cell volumes.
const labelListList & cellCells() const
const labelListList & cellPoints() const
label nInternalFaces() const
bool checkFaceAreas(const vectorField &faceAreas, const bool report, const bool detailedReport, labelHashSet *setPtr) const
Check for negative face areas.
void clearAddressing()
Clear topological data.
static const unsigned cellsPerPoint_
Estimated number of cells per point.
virtual bool checkPoints(const bool report=false, labelHashSet *setPtr=nullptr) const
Check for unused points.
bool hasCellCentres() const
bool hasCellPoints() const
static const unsigned cellsPerEdge_
Estimated number of cells per edge.
bool checkFaceSkewness(const pointField &points, const vectorField &fCtrs, const vectorField &fAreas, const vectorField &cellCtrs, const bool report, labelHashSet *setPtr) const
Check face skewness.
label nInternal0Edges() const
Internal edges (i.e. not on boundary face) using.
label nFaces() const
void operator=(const primitiveMesh &)=delete
Disallow default bitwise assignment.
virtual bool checkPointNearness(const bool report, const scalar reportDistSqr, labelHashSet *setPtr=nullptr) const
Check for point-point-nearness,.
label nInternalEdges() const
Internal edges using 0,1 or 2 boundary points.
const scalarField & magFaceAreas() const
void printAllocated() const
Print a list of all the currently allocated mesh data.
void reset(const label nPoints, const label nInternalFaces, const label nFaces, const label nCells)
Reset this primitiveMesh given the primitive array sizes.
static const unsigned edgesPerPoint_
Estimated number of edges per point.
bool checkFaceFlatness(const pointField &points, const vectorField &faceCentres, const vectorField &faceAreas, const bool report, const scalar warnFlatness, labelHashSet *setPtr) const
Check face warpage.
const labelListList & pointFaces() const
bool hasCells() const
virtual const labelList & faceNeighbour() const =0
Face face-neighbour addressing.
tmp< scalarField > movePoints(const pointField &p, const pointField &oldP)
Move points, returns volumes swept by faces in motion.
virtual const pointField & oldCellCentres() const =0
Return old cell centres for mesh motion.
static const unsigned pointsPerCell_
Estimated number of points per cell.
static const unsigned facesPerCell_
Estimated number of faces per cell.
bool hasFaceEdges() const
virtual const pointField & points() const =0
Return mesh points.
const labelListList & edgeFaces() const
const labelListList & pointPoints() const
const labelListList & faceEdges() const
const labelListList & edgeCells() const
const vectorField & faceAreas() const
bool checkConcaveCells(const vectorField &fAreas, const pointField &fCentres, const bool report, labelHashSet *setPtr) const
Check for concave cells by the planes of faces.
bool hasEdgeCells() const
bool isInternalFace(const label faceIndex) const
Return true if given face label is internal to the mesh.
void calcFaceCentresAndAreas() const
Calculate face centres and areas.
label nInternalPoints() const
Points not on boundary.
virtual bool checkFaceFaces(const bool report=false, labelHashSet *setPtr=nullptr) const
Check face-face connectivity.
static const unsigned edgesPerFace_
Estimated number of edges per cell.
bool hasEdgeFaces() 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.
const cellList & cells() const
void clearOut()
Clear all geometry and addressing unnecessary for CFD.
void makeFaceCentresAndAreas(const pointField &p, vectorField &fCtrs, vectorField &fAreas, scalarField &magfAreas) const
bool hasPointEdges() const
virtual bool checkGeometry(const bool report=false) const
Check mesh geometry (& implicitly topology) for correctness.
virtual const pointField & oldPoints() const =0
Return old points for mesh motion.
A class for managing temporary objects.
Definition: tmp.H:55
scalar closedThreshold
Data to control mesh checking.
scalar skewThreshold
Skewness warning threshold.
scalar aspectThreshold
Aspect ratio warning threshold.
scalar planarCosAngle
Threshold where faces are considered coplanar.
scalar nonOrthThreshold
Non-orthogonality warning threshold in deg.
Namespace for OpenFOAM.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
volScalarField & p
const scalarField & cellVols