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