faMesh.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) 2016-2017 Wikki Ltd
9  Copyright (C) 2021-2023 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::faMesh
29 
30 Description
31  Finite area mesh (used for 2-D non-Euclidian finite area method)
32  defined using a \em patch of faces on a polyMesh
33  (ie, uindirectPrimitivePatch).
34 
35  The ordering of faces and points on the faMesh corresponds to
36  the localFaces and localPoints as per Foam::PrimitivePatch but
37  the edge addressing is handled slightly differently.
38  The internal edges of the faMesh will generally correspond identically
39  to the internalEdges of the PrimitivePatch (may change in the future)
40  but the boundaryEdges will be reordered compared to the PrimitivePatch
41  to allow edge boundary slices to be obtained.
42 
43 SourceFiles
44  faMesh.C
45  faMeshDemandDrivenData.C
46  faMeshPatches.C
47  faMeshTopology.C
48  faMeshUpdate.C
49 
50 Author
51  Zeljko Tukovic, FMENA
52  Hrvoje Jasak, Wikki Ltd.
53 
54 \*---------------------------------------------------------------------------*/
55 
56 #ifndef Foam_faMesh_H
57 #define Foam_faMesh_H
58 
59 #include "MeshObject.H"
60 #include "polyMesh.H"
61 #include "lduMesh.H"
62 #include "faBoundaryMesh.H"
63 #include "edgeList.H"
64 #include "faceList.H"
65 #include "primitiveFieldsFwd.H"
66 #include "DimensionedField.H"
67 #include "areaFieldsFwd.H"
68 #include "edgeFieldsFwd.H"
69 #include "indirectPrimitivePatch.H"
70 #include "edgeInterpolation.H"
71 #include "labelIOList.H"
72 #include "FieldFields.H"
73 #include "faGlobalMeshData.H"
74 #include "faSchemes.H"
75 #include "faSolution.H"
76 #include "data.H"
77 
78 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
79 
80 namespace Foam
81 {
82 
83 // Forward Declarations
84 class faMeshBoundaryHalo;
85 class faMeshLduAddressing;
86 class faMeshMapper;
87 class faPatchData;
88 
89 /*---------------------------------------------------------------------------*\
90  Class faMesh Declaration
91 \*---------------------------------------------------------------------------*/
92 
93 class faMesh
94 :
95  public MeshObject<polyMesh, Foam::UpdateableMeshObject, faMesh>,
96  public lduMesh,
97  public faSchemes,
98  public edgeInterpolation, // may need input from faSchemes
99  public faSolution,
100  public data
101 {
102  // Private (internal) classes/structures
103 
104  //- A (proc, patchi, patchEdgei, meshFacei) tuple used internally
105  //- for managing patch/patch bookkeeping during construction.
106  // Finite-area patches are stored with negated indices (offset -2),
107  // which makes them readily identifiable and always sort before normal
108  // patches.
109  struct patchTuple
110  :
111  public FixedList<label, 4>
112  {
113 
114  // Constructors
115 
116  // Inherit constructors
118 
119  //- Default construct as 'invalid'
120  patchTuple()
121  {
122  clear();
123  }
124 
125 
126  // Static Member Functions
127 
128  // Globally consistent ordering
129  //
130  // 1. sort left/right as lower/higher processor connection
131  // 2. sort by proc/patch/patch index
132  static void sort(UList<Pair<patchTuple>>& list)
133  {
134  for (auto& tuples : list)
135  {
136  tuples.sort();
137  }
138  Foam::stableSort(list);
139  }
140 
141 
142  // Member Functions
143 
144  //- Reset to 'invalid'
145  void clear()
146  {
147  procNo(-1);
148  patchi(labelMax);
149  patchEdgei(-1);
150  meshFacei(-1);
151  }
152 
153  //- Valid if proc and patch (or patch edge) are non-negative
154  bool valid() const
155  {
156  return (procNo() >= 0 && patchi() != -1);
157  }
158 
159  // Processor is the first sort index
160  label procNo() const { return (*this)[0]; }
161  void procNo(label val) { (*this)[0] = val; }
162 
163  // PatchId is the second sort index (finiteArea patches are < -1)
164  label patchi() const { return (*this)[1]; }
165  void patchi(label val) { (*this)[1] = val; }
166 
167  // The patch edge index (on the finiteArea patch)
168  // is the third sort index
169  label patchEdgei() const { return (*this)[2]; }
170  void patchEdgei(label val) { (*this)[2] = val; }
171 
172  // The processor-local mesh face is the fourth sort index
173  label meshFacei() const { return (*this)[3]; }
174  void meshFacei(label val) { (*this)[3] = val; }
175 
176  //- Return the real patchId
177  label realPatchi() const
178  {
179  const label id = patchi();
180  return (id < -1 ? -(id + 2) : id);
181  }
182 
183  //- Set patchId as finiteArea
184  void faPatchi(label val)
185  {
186  patchi(-(val + 2));
187  }
188 
189  //- Considered to be finiteArea if (patchi < -1)
190  bool is_finiteArea() const noexcept
191  {
192  return (patchi() < -1);
193  }
194 
195  //- Considered to be processor local
196  bool is_localProc() const
197  {
198  return (procNo() == UPstream::myProcNo());
199  }
200  };
201 
202 
203  // Private Data
204 
205  //- Face labels
206  labelIOList faceLabels_;
207 
208  //- Boundary mesh
209  faBoundaryMesh boundary_;
210 
211 
212  // Primitive mesh data
213 
214  //- Edges, addressing into local point list
215  edgeList edges_;
216 
217  //- Edge owner
218  labelList edgeOwner_;
219 
220  //- Edge neighbour
221  labelList edgeNeighbour_;
222 
223 
224  // Primitive size data
225 
226  //- Total number of points
227  mutable label nPoints_;
228 
229  //- Total number of edges
230  mutable label nEdges_;
231 
232  //- Number of internal edges
233  mutable label nInternalEdges_;
234 
235  //- Number of faces
236  mutable label nFaces_;
237 
238 
239  // Communication support, updating
240 
241  //- Communicator used for parallel communication
242  label comm_;
243 
244  //- Current time index for motion
245  // Note. The whole mechanism will be replaced once the
246  // dimensionedField is created and the dimensionedField
247  // will take care of the old-time levels.
248  mutable label curTimeIndex_;
249 
250 
251  // Demand-driven data
252 
253  //- Primitive patch
254  mutable std::unique_ptr<uindirectPrimitivePatch> patchPtr_;
255 
256  //- List of poly patch/patch-face for faceLabels
257  mutable std::unique_ptr<List<labelPair>> polyPatchFacesPtr_;
258 
259  //- List of polyPatch ids used by the area mesh
260  mutable std::unique_ptr<labelList> polyPatchIdsPtr_;
261 
262  //- List of proc/mesh-face for boundary edge neighbours
263  mutable std::unique_ptr<List<labelPair>> bndConnectPtr_;
264 
265  //- Ldu addressing data
266  mutable faMeshLduAddressing* lduPtr_;
267 
268 
269  // Geometric Data
270 
271  //- Face areas
272  mutable DimensionedField<scalar, areaMesh>* SPtr_;
273 
274  //- Face areas old time level
275  mutable DimensionedField<scalar, areaMesh>* S0Ptr_;
276 
277  //- Face areas old-old time level
278  mutable DimensionedField<scalar, areaMesh>* S00Ptr_;
279 
280  //- Patch starts in the edge list
281  mutable labelList* patchStartsPtr_;
282 
283  //- Edge length vectors
284  mutable edgeVectorField* LePtr_;
285 
286  //- Mag edge length vectors
287  mutable edgeScalarField* magLePtr_;
288 
289  //- Face centres
290  mutable areaVectorField* faceCentresPtr_;
291 
292  //- Edge centres
293  mutable edgeVectorField* edgeCentresPtr_;
294 
295  //- Face area normals
296  mutable areaVectorField* faceAreaNormalsPtr_;
297 
298  //- Edge area normals
299  mutable edgeVectorField* edgeAreaNormalsPtr_;
300 
301  //- Point area normals
302  mutable std::unique_ptr<vectorField> pointAreaNormalsPtr_;
303 
304  //- Face curvatures
305  mutable areaScalarField* faceCurvaturesPtr_;
306 
307  //- Edge transformation tensors
308  mutable FieldField<Field, tensor>* edgeTransformTensorsPtr_;
309 
310  //- Whether point normals must be corrected for a patch
311  mutable boolList* correctPatchPointNormalsPtr_;
312 
313 
314  // Other mesh-related data
315 
316  //- Parallel info
317  mutable autoPtr<faGlobalMeshData> globalMeshDataPtr_;
318 
319  //- Mapping/swapping for boundary edge halo neighbours
320  mutable std::unique_ptr<faMeshBoundaryHalo> haloMapPtr_;
321 
322  //- Face centres for boundary edge halo neighbours
323  mutable std::unique_ptr<pointField> haloFaceCentresPtr_;
324 
325  //- Face normals for boundary edge halo neighbours
326  mutable std::unique_ptr<vectorField> haloFaceNormalsPtr_;
327 
328 
329  // Static Private Data
330 
331  //- Quadrics fit for pointAreaNormals (experimental)
332  static const int quadricsFit_;
333 
334 
335  // Private Member Functions
336 
337  //- No copy construct
338  faMesh(const faMesh&) = delete;
339 
340  //- No copy assignment
341  void operator=(const faMesh&) = delete;
342 
343  //- Set indirect patch, removing any old one.
344  // No communication
345  void initPatch() const;
346 
347  //- Set primitive mesh data.
348  // No communication
349  void setPrimitiveMeshData();
350 
351  //- Get list of (proc/patchi/patchEdgei/meshFacei) tuple pairs in an
352  //- globally consistent ordering
353  List<Pair<patchTuple>> getBoundaryEdgeConnections() const;
354 
355  //- Determine the boundary edge neighbour connections
356  void calcBoundaryConnections() const;
357 
358  //- Define boundary edge neighbours (proc/face) based on
359  //- gathered topology information
360  void setBoundaryConnections
361  (
362  const List<Pair<patchTuple>>& bndEdgeConnections
363  ) const;
364 
365 
366  // Private member functions to calculate demand driven data
367 
368  //- Calculate ldu addressing
369  void calcLduAddressing() const;
370 
371  //- Calculate patch starts in the edge list
372  void calcPatchStarts() const;
373 
374  //- Calculate which polyPatches, polyPatch/local-face
375  //- are related to the areaMesh
376  void calcWhichPatchFaces() const;
377 
378  //- Calculate the edge normals (direct calculation)
379  //- with flat boundary addressing
380  // Possible communication
381  tmp<vectorField> calcRawEdgeNormals(int calcType) const;
382 
383  //- Calculate edge lengths
384  // Triggers communication via calcEdgeAreaNormals
385  void calcLe() const;
386 
387  //- Calculate mag edge lengths
388  // No communication
389  void calcMagLe() const;
390 
391  //- Calculate face centres
392  // No communication
393  void calcFaceCentres() const;
394 
395  //- Calculate edge centres
396  // No communication
397  void calcEdgeCentres() const;
398 
399  //- Calculate face areas
400  // No communication
401  void calcS() const;
402 
403  //- Calculate face area normals
404  // Triggers communication via calcEdgeAreaNormals
405  void calcFaceAreaNormals() const;
406 
407  //- Calculate edge area normals
408  // Triggers communication via pointAreaNormals
409  void calcEdgeAreaNormals() const;
410 
411  //- Calculate point area normals
412  // Triggers communication for processor patches
413  void calcPointAreaNormals(vectorField& result) const;
414 
415  //- Calculate point area normals by quadrics fit
416  void calcPointAreaNormalsByQuadricsFit(vectorField& result) const;
417 
418  //- Calculate face curvatures
419  // Triggers communication via edgeLengthCorrection
420  void calcFaceCurvatures() const;
421 
422  //- Calculate edge transformation tensors
423  void calcEdgeTransformTensors() const;
424 
425  //- Clear geometry but not the face areas
426  void clearGeomNotAreas() const;
427 
428  //- Has halo face centers/normals
429  bool hasHaloFaceGeometry() const noexcept;
430 
431  //- Clear boundary halo information
432  void clearHalo() const;
433 
434  //- Clear geometry
435  void clearGeom() const;
436 
437  //- Clear addressing
438  void clearAddressing() const;
439 
440  //- Clear demand-driven data
441  void clearOut() const;
442 
443 
444  // Halo handling
445 
446  //- Calculate halo centres/normals
447  void calcHaloFaceGeometry() const;
448 
449 
450  // Helpers
451 
452  //- Create a single patch
453  faPatchList createOnePatch
454  (
455  const word& patchName,
456  const word& patchType = ""
457  ) const;
458 
459  //- Create list of patches from boundary definition
460  faPatchList createPatchList
461  (
462  const dictionary& bndDict,
463  const word& emptyPatchName = "",
464  const dictionary* defaultPatchDefinition = nullptr
465  ) const;
466 
467 
468  //- Fatal error if edge labels are out of range
469  void checkBoundaryEdgeLabelRange(const labelUList& edgeLabels) const;
470 
471  //- Extract list from contiguous (unordered) boundary data
472  //- to the locally sorted order.
473  template<class T>
474  List<T> boundarySubset
475  (
476  const UList<T>& bndField,
477  const labelUList& edgeLabels
478  ) const
479  {
480  #ifdef FULLDEBUG
481  checkBoundaryEdgeLabelRange(edgeLabels);
482  #endif
483  // Like UIndirectList but with an offset
484  List<T> result(edgeLabels.size());
485  forAll(edgeLabels, i)
486  {
487  result[i] = bndField[edgeLabels[i] - nInternalEdges_];
488  }
489  return result;
490  }
491 
492 
493  // Static Functions
494 
495  //- Test if faSchemes/faSolution files are available
496  static bool hasSystemFiles(const polyMesh& pMesh);
497 
498  //- Test if all files needed for read construction are available
499  static bool hasFiles(const polyMesh& pMesh);
500 
501 
502 public:
503 
504  // Public Typedefs
505 
506  //- The mesh type
507  typedef faMesh Mesh;
508 
509  //- The boundary type associated with the mesh
511 
512 
513  // Tuning switches
514 
515  //- Geometry treatment
516  static int geometryOrder_;
517 
518 
519  //- Runtime type information
520  TypeName("faMesh");
521 
522  //- The prefix to local: %finite-area
523  static const word prefix;
524 
525  //- The mesh sub-directory name (usually "faMesh")
526  static word meshSubDir;
527 
528 
529  // Constructors
530 
531  //- Read construct from polyMesh, using its IOobject properties
532  explicit faMesh(const polyMesh& pMesh, const bool doInit = true);
533 
534  //- Construct zero-sized from polyMesh
535  // Boundary is added using addFaPatches() member function
536  faMesh(const polyMesh& pMesh, const Foam::zero);
537 
538  //- Construct as copy (for dictionaries) and zero-sized
539  //- without boundary, using IOobject properties from polyMesh.
540  // Boundary is added using addFaPatches() member function
541  faMesh(const faMesh& baseMesh, const Foam::zero);
542 
543  //- Construct as copy (for dictionaries) and faceLabels
544  //- without boundary, using IOobject properties from polyMesh.
545  // Boundary is added using addFaPatches() member function
546  faMesh(const faMesh& baseMesh, labelList&& faceLabels);
547 
548  //- Construct from components (face labels) without boundary,
549  //- using IOobject properties from polyMesh.
550  // Boundary is added using addFaPatches() member function.
551  faMesh(const polyMesh& pMesh, labelList&& faceLabels);
552 
553  //- Construct from components (face labels) without boundary,
554  //- using alternative IOobject properties
555  //- (primarily the readOption).
556  // Boundary is added using addFaPatches() member function.
557  faMesh
558  (
559  const polyMesh& pMesh,
561  const IOobject& io
562  );
563 
564  //- Construct from single polyPatch
565  explicit faMesh(const polyPatch& pp, const bool doInit = true);
566 
567  //- Construct from definition
568  faMesh
569  (
570  const polyMesh& pMesh,
571  const dictionary& faMeshDefinition,
572  const bool doInit = true
573  );
574 
575 
576  //- Destructor
577  virtual ~faMesh();
578 
579 
580  // Static Functions
581 
582  //- Return the current geometry treatment
583  // A zero level or negative is with restricted neighbour information
584  static int geometryOrder() noexcept
585  {
586  return geometryOrder_;
587  }
588 
589  //- Set the preferred geometry treatment
590  // \return the previous value
591  static int geometryOrder(int order) noexcept
592  {
593  int old(geometryOrder_);
594  geometryOrder_ = order;
595  return old;
596  }
597 
598  //- Read construction from polyMesh if all files are available
599  static autoPtr<faMesh> TryNew(const polyMesh& pMesh);
600 
601 
602  // Member Functions
603 
604  // Topological Change
605 
606  //- Add boundary patches. Constructor helper
607  void addFaPatches
608  (
609  faPatchList& plist,
610  const bool validBoundary = true
611  );
612 
613  //- Add boundary patches. Constructor helper
614  void addFaPatches
615  (
616  const List<faPatch*>& p,
617  const bool validBoundary = true
618  );
619 
620  //- Initialise non-demand-driven data etc
621  bool init(const bool doInit);
622 
623  //- Processor/processor synchronisation for geometry fields.
624  // Largely internal use only (slightly hacky).
625  void syncGeom();
626 
627 
628  // Database
629 
630  //- Return access to polyMesh
631  inline const polyMesh& mesh() const;
632 
633  //- Interface to referenced polyMesh (similar to GeoMesh)
634  const polyMesh& operator()() const { return mesh(); }
635 
636  //- Return the local mesh directory (dbDir()/meshSubDir)
637  fileName meshDir() const;
638 
639  //- Return reference to time
640  const Time& time() const;
641 
642  //- Return the current instance directory for points
643  // Used in the construction of geometric mesh data dependent
644  // on points
645  const fileName& pointsInstance() const;
646 
647  //- Return the current instance directory for faces
648  const fileName& facesInstance() const;
649 
650 
651  // Communication support
652 
653  //- Return communicator used for parallel communication
654  inline label comm() const noexcept;
655 
656  //- Return communicator used for parallel communication
657  inline label& comm() noexcept;
658 
659 
660  // Access: Mesh size parameters
661 
662  //- Number of local mesh points
663  inline label nPoints() const noexcept;
664 
665  //- Number of local mesh edges
666  inline label nEdges() const noexcept;
667 
668  //- Number of internal faces
669  inline label nInternalEdges() const noexcept;
670 
671  //- Number of boundary edges (== nEdges - nInternalEdges)
672  inline label nBoundaryEdges() const noexcept;
673 
674  //- Number of patch faces
675  inline label nFaces() const noexcept;
676 
677 
678  // Access: Primitive mesh data
680  //- Return local points
681  inline const pointField& points() const;
682 
683  //- Return local edges with reordered boundary
684  inline const edgeList& edges() const noexcept;
685 
686  //- Sub-list of local internal edges
687  inline const edgeList::subList internalEdges() const;
688 
689  //- Return local faces
690  inline const faceList& faces() const;
691 
692  //- Edge owner addressing
693  inline const labelList& edgeOwner() const noexcept;
694 
695  //- Edge neighbour addressing
696  inline const labelList& edgeNeighbour() const noexcept;
697 
698  //- True if the internalEdges use an ordering that does not
699  //- correspond 1-to-1 with the patch internalEdges.
700  inline bool hasInternalEdgeLabels() const noexcept;
701 
702 
703  // Database
704 
705  //- Return true if thisDb() is a valid DB
706  virtual bool hasDb() const;
707 
708  //- Return reference to the mesh database
709  virtual const objectRegistry& thisDb() const;
710 
711  //- Name function is needed to disambiguate those inherited
712  //- from base classes
713  const word& name() const
714  {
715  return thisDb().name();
716  }
717 
718  //- The mesh region name or word::null if polyMesh::defaultRegion
719  const word& regionName() const;
720 
721 
722  // Access
723 
724  //- Return constant reference to boundary mesh
725  inline const faBoundaryMesh& boundary() const noexcept;
726 
727  //- Return the underlying polyMesh face labels
728  inline const labelList& faceLabels() const noexcept;
729 
730  //- The area-face corresponding to the mesh-face, -1 if not found
731  inline label whichFace(const label meshFacei) const;
732 
733  //- The polyPatches related to the areaMesh, in sorted order
734  inline const labelList& whichPolyPatches() const;
735 
736  //- The polyPatch/local-face for each faceLabels()
737  inline const List<labelPair>& whichPatchFaces() const;
738 
739  //- Return parallel info
740  const faGlobalMeshData& globalData() const;
741 
742  //- Return ldu addressing
743  virtual const lduAddressing& lduAddr() const;
744 
745  //- Return a list of pointers for each patch
746  // with only those pointing to interfaces being set
747  virtual lduInterfacePtrsList interfaces() const
748  {
749  return boundary().interfaces();
750  }
751 
752  //- Internal face owner
753  const labelUList& owner() const
754  {
755  return lduAddr().lowerAddr();
756  }
757 
758  //- Internal face neighbour
759  const labelUList& neighbour() const
760  {
761  return lduAddr().upperAddr();
762  }
763 
764  //- True if given edge label is internal to the mesh
765  bool isInternalEdge(const label edgeIndex) const noexcept
766  {
767  return (edgeIndex < nInternalEdges_);
768  }
769 
770  //- List of proc/face for the boundary edge neighbours
771  //- using primitive patch edge numbering.
772  inline const List<labelPair>& boundaryConnections() const;
773 
774  //- Boundary edge neighbour processors
775  //- (does not include own proc)
776  labelList boundaryProcs() const;
777 
778  //- List of proc/size for the boundary edge neighbour processors
779  //- (does not include own proc)
780  List<labelPair> boundaryProcSizes() const;
781 
782  //- Mapping/swapping for boundary halo neighbours
783  const faMeshBoundaryHalo& boundaryHaloMap() const;
784 
785  //- Face centres of boundary halo neighbours
786  const pointField& haloFaceCentres() const;
788  //- Face unit-normals of boundary halo neighbours
789  const vectorField& haloFaceNormals() const;
790 
791  //- Face centres of boundary halo neighbours for specified patch
792  tmp<pointField> haloFaceCentres(const label patchi) const;
793 
794  //- Face unit-normals of boundary halo neighbours for specified patch
795  tmp<vectorField> haloFaceNormals(const label patchi) const;
796 
798  // Interfacing
799 
800  //- The volume (owner) cells associated with the area-mesh
801  labelList faceCells() const;
802 
803 
804  // Storage Management
805 
806  //- Remove all files from mesh instance
807  void removeFiles(const fileName& instanceDir) const;
808 
809  //- Remove all files from mesh instance()
810  void removeFiles() const;
811 
812 
813  //- Has face areas: S()
814  bool hasFaceAreas() const noexcept { return bool(SPtr_); }
815 
816  //- Has face centres: areaCentres()
817  bool hasAreaCentres() const noexcept { return bool(faceCentresPtr_); }
818 
819  //- Has edge centres: edgeCentres()
820  bool hasEdgeCentres() const noexcept { return bool(edgeCentresPtr_); }
821 
822  //- Has edge length vectors: Le()
823  bool hasLe() const noexcept { return bool(LePtr_); }
824 
825  //- Has edge length magnitudes: magLe()
826  bool hasMagLe() const noexcept { return bool(magLePtr_); }
827 
828  //- Has face area normals: faceAreaNormals()
829  bool hasFaceAreaNormals() const noexcept
830  {
831  return bool(faceAreaNormalsPtr_);
832  }
833 
834  //- Has edge area normals: edgeAreaNormals()
835  bool hasEdgeAreaNormals() const noexcept
836  {
837  return bool(edgeAreaNormalsPtr_);
838  }
839 
840  //- Has point area normals: pointAreaNormals()
841  bool hasPointAreaNormals() const noexcept
842  {
843  return bool(pointAreaNormalsPtr_);
844  }
845 
846  //- Has face curvatures: faceCurvatures()
847  bool hasFaceCurvatures() const noexcept
848  {
849  return bool(faceCurvaturesPtr_);
850  }
851 
852  //- Has patch point normals corrections
854  {
855  return bool(correctPatchPointNormalsPtr_);
856  }
857 
858 
859  // Mesh motion and morphing
860 
861  //- Is mesh moving
862  bool moving() const
863  {
864  return mesh().moving();
865  }
866 
867  //- Update after mesh motion
868  virtual bool movePoints();
869 
870  //- Update after topo change
871  virtual void updateMesh(const mapPolyMesh&);
872 
873 
874  // Mapping
875 
876  //- Map all fields in time using given map.
877  virtual void mapFields(const faMeshMapper& mapper) const;
878 
879  //- Map face areas in time using given map.
880  virtual void mapOldAreas(const faMeshMapper& mapper) const;
881 
882 
883  // Demand-driven data
884 
885  //- Return constant reference to primitive patch
886  inline const uindirectPrimitivePatch& patch() const;
887 
888  //- Return reference to primitive patch
889  inline uindirectPrimitivePatch& patch();
890 
891  //- Return patch starts
892  const labelList& patchStarts() const;
893 
894  //- Return edge length vectors
895  const edgeVectorField& Le() const;
896 
897  //- Return edge length magnitudes
898  const edgeScalarField& magLe() const;
899 
900  //- Return normalised edge length vectors
901  tmp<edgeVectorField> unitLe() const;
902 
903  //- Return face centres as areaVectorField
904  const areaVectorField& areaCentres() const;
905 
906  //- Return edge centres as edgeVectorField
907  const edgeVectorField& edgeCentres() const;
908 
909  //- Return face areas
910  const DimensionedField<scalar, areaMesh>& S() const;
911 
912  //- Return old-time face areas
913  const DimensionedField<scalar, areaMesh>& S0() const;
914 
915  //- Return old-old-time face areas
916  const DimensionedField<scalar, areaMesh>& S00() const;
917 
918  //- Return face area normals
919  const areaVectorField& faceAreaNormals() const;
920 
921  //- Return edge area normals
922  const edgeVectorField& edgeAreaNormals() const;
923 
924  //- Return point area normals
925  const vectorField& pointAreaNormals() const;
926 
927  //- Return face curvatures
928  const areaScalarField& faceCurvatures() const;
929 
930  //- Return edge transformation tensors
931  const FieldField<Field, tensor>& edgeTransformTensors() const;
932 
933  //- Return internal point labels
934  labelList internalPoints() const;
935 
936  //- Return boundary point labels
937  labelList boundaryPoints() const;
938 
939  //- Return edge length correction
940  tmp<edgeScalarField> edgeLengthCorrection() const;
941 
942  //- Whether point normals should be corrected for a patch
943  bool correctPatchPointNormals(const label patchID) const;
944 
945  //- Set whether point normals should be corrected for a patch
947 
948 
949  // Storage management
950 
951 
952  //- Write mesh
953  virtual bool write(const bool writeOnProc = true) const;
954 
955 
956  // Member Operators
957 
958  bool operator!=(const faMesh& m) const;
959 
960  bool operator==(const faMesh& m) const;
961 };
962 
963 
964 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
965 
966 } // End namespace Foam
967 
968 
969 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
970 
971 #include "faMeshI.H"
972 
973 #ifdef NoRepository
974  #include "faPatchFaMeshTemplates.C"
975 #endif
976 
977 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
978 
979 #endif
980 
981 // ************************************************************************* //
Finite area mesh (used for 2-D non-Euclidian finite area method) defined using a patch of faces on a ...
Definition: faMesh.H:88
labelList internalPoints() const
Return internal point labels.
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:116
virtual void updateMesh(const mapPolyMesh &)
Update after topo change.
Definition: faMeshUpdate.C:31
void addFaPatches(faPatchList &plist, const bool validBoundary=true)
Add boundary patches. Constructor helper.
Definition: faMeshPatches.C:68
A class for handling file names.
Definition: fileName.H:71
tmp< edgeScalarField > edgeLengthCorrection() const
Return edge length correction.
const DimensionedField< scalar, areaMesh > & S00() const
Return old-old-time face areas.
Definition: faMesh.C:884
A 1D vector of objects of type <T> with a fixed length <N>.
Definition: HashTable.H:101
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:120
lduInterfacePtrsList interfaces() const
Return a list of pointers for each patch with only those pointing to interfaces being set...
const Time & time() const
Return reference to time.
Definition: faMesh.C:735
const word & name() const noexcept
Return the object name.
Definition: IOobjectI.H:162
void syncGeom()
Processor/processor synchronisation for geometry fields.
Definition: faMesh.C:278
virtual void mapFields(const faMeshMapper &mapper) const
Map all fields in time using given map.
Definition: faMeshUpdate.C:144
const edgeList::subList internalEdges() const
Sub-list of local internal edges.
Definition: faMeshI.H:91
const pointField & haloFaceCentres() const
Face centres of boundary halo neighbours.
const DimensionedField< scalar, areaMesh > & S() const
Return face areas.
Definition: faMesh.C:858
Face to edge interpolation scheme. Included in faMesh.
bool operator!=(const faMesh &m) const
Definition: faMesh.C:1092
Abstract base class for meshes which provide LDU addressing for the construction of lduMatrix and LDU...
Definition: lduMesh.H:53
label whichFace(const label meshFacei) const
The area-face corresponding to the mesh-face, -1 if not found.
Definition: faMeshI.H:141
Various mesh related information for a parallel run.
void stableSort(UList< T > &list)
Stable sort the list.
Definition: UList.C:362
const labelList & whichPolyPatches() const
The polyPatches related to the areaMesh, in sorted order.
Definition: faMeshI.H:147
Generic GeometricField class.
Definition: areaFieldsFwd.H:50
const faGlobalMeshData & globalData() const
Return parallel info.
Definition: faMesh.C:971
const labelList & patchStarts() const
Return patch starts.
Definition: faMesh.C:802
bool isInternalEdge(const label edgeIndex) const noexcept
True if given edge label is internal to the mesh.
Definition: faMesh.H:1054
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Can be negative if the process i...
Definition: UPstream.H:1029
const word & regionName() const
The mesh region name or word::null if polyMesh::defaultRegion.
Definition: faMesh.C:765
const List< labelPair > & boundaryConnections() const
List of proc/face for the boundary edge neighbours using primitive patch edge numbering.
Definition: faMeshI.H:174
const areaVectorField & areaCentres() const
Return face centres as areaVectorField.
Definition: faMesh.C:835
virtual const labelUList & lowerAddr() const =0
Return lower addressing.
labelList boundaryProcs() const
Boundary edge neighbour processors (does not include own proc)
bool hasMagLe() const noexcept
Has edge length magnitudes: magLe()
Definition: faMesh.H:1147
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:69
virtual const objectRegistry & thisDb() const
Return reference to the mesh database.
Definition: faMesh.C:759
const edgeScalarField & magLe() const
Return edge length magnitudes.
Definition: faMesh.C:824
label nFaces() const noexcept
Number of patch faces.
Definition: faMeshI.H:73
UList< label > labelUList
A UList of labels.
Definition: UList.H:78
label nPoints() const noexcept
Number of local mesh points.
Definition: faMeshI.H:49
A field of fields is a PtrList of fields with reference counting.
Definition: FieldField.H:51
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:414
const uindirectPrimitivePatch & patch() const
Return constant reference to primitive patch.
Definition: faMeshI.H:121
static int geometryOrder() noexcept
Return the current geometry treatment.
Definition: faMesh.H:787
const polyMesh & operator()() const
Interface to referenced polyMesh (similar to GeoMesh)
Definition: faMesh.H:855
Templated abstract base-class for optional mesh objects used to automate their allocation to the mesh...
Definition: MeshObject.H:85
const labelUList & neighbour() const
Internal face neighbour.
Definition: faMesh.H:1046
virtual bool hasDb() const
Return true if thisDb() is a valid DB.
Definition: faMesh.C:753
const faceList & faces() const
Return local faces.
Definition: faMeshI.H:97
List< labelPair > boundaryProcSizes() const
List of proc/size for the boundary edge neighbour processors (does not include own proc) ...
bool hasLe() const noexcept
Has edge length vectors: Le()
Definition: faMesh.H:1142
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:38
Forwards for edge field types.
Forward declarations of the specialisations of Field<T> for scalar, vector and tensor.
An ordered pair of two objects of type <T> with first() and second() elements.
Definition: instant.H:46
const labelList & faceLabels() const noexcept
Return the underlying polyMesh face labels.
Definition: faMeshI.H:115
virtual ~faMesh()
Destructor.
Definition: faMesh.C:721
bool hasEdgeAreaNormals() const noexcept
Has edge area normals: edgeAreaNormals()
Definition: faMesh.H:1160
A class for handling words, derived from Foam::string.
Definition: word.H:63
fileName meshDir() const
Return the local mesh directory (dbDir()/meshSubDir)
Definition: faMesh.C:729
bool operator==(const faMesh &m) const
Definition: faMesh.C:1098
virtual const lduAddressing & lduAddr() const
Return ldu addressing.
Definition: faMesh.C:982
virtual const labelUList & upperAddr() const =0
Return upper addressing.
void sort(UList< T > &list)
Sort the list.
Definition: UList.C:348
const edgeVectorField & Le() const
Return edge length vectors.
Definition: faMesh.C:813
bool hasFaceCurvatures() const noexcept
Has face curvatures: faceCurvatures()
Definition: faMesh.H:1176
GeometricField< vector, faePatchField, edgeMesh > edgeVectorField
Definition: edgeFieldsFwd.H:58
const faMeshBoundaryHalo & boundaryHaloMap() const
Mapping/swapping for boundary halo neighbours.
bool hasPointAreaNormals() const noexcept
Has point area normals: pointAreaNormals()
Definition: faMesh.H:1168
bool hasAreaCentres() const noexcept
Has face centres: areaCentres()
Definition: faMesh.H:1132
static const word prefix
The prefix to local: finite-area.
Definition: faMesh.H:698
bool hasInternalEdgeLabels() const noexcept
True if the internalEdges use an ordering that does not correspond 1-to-1 with the patch internalEdge...
Definition: faMeshI.H:167
const pointField & points() const
Return local points.
Definition: faMeshI.H:79
const vectorField & haloFaceNormals() const
Face unit-normals of boundary halo neighbours.
patchWriters clear()
GeometricField< scalar, faePatchField, edgeMesh > edgeScalarField
Definition: edgeFieldsFwd.H:46
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:99
const FieldField< Field, tensor > & edgeTransformTensors() const
Return edge transformation tensors.
Definition: faMesh.C:960
virtual void mapOldAreas(const faMeshMapper &mapper) const
Map face areas in time using given map.
Definition: faMeshUpdate.C:166
const direction noexcept
Definition: Scalar.H:258
virtual bool movePoints()
Update after mesh motion.
Definition: faMesh.C:993
virtual bool write(const bool writeOnProc=true) const
Write mesh.
Definition: faMesh.C:1081
const edgeList & edges() const noexcept
Return local edges with reordered boundary.
Definition: faMeshI.H:85
faBoundaryMesh BoundaryMesh
The boundary type associated with the mesh.
Definition: faMesh.H:679
Database for solution data, solver performance and other reduced data.
Definition: data.H:52
const polyMesh & mesh() const
Return access to polyMesh.
Definition: faMeshI.H:24
const faBoundaryMesh & boundary() const noexcept
Return constant reference to boundary mesh.
Definition: faMeshI.H:31
const areaScalarField & faceCurvatures() const
Return face curvatures.
Definition: faMesh.C:948
label nEdges() const noexcept
Number of local mesh edges.
Definition: faMeshI.H:55
boolList & correctPatchPointNormals() const
Set whether point normals should be corrected for a patch.
Definition: faMesh.C:1070
const labelUList & owner() const
Internal face owner.
Definition: faMesh.H:1038
label comm() const noexcept
Return communicator used for parallel communication.
Definition: faMeshI.H:37
bool moving() const noexcept
Is mesh moving.
Definition: polyMesh.H:696
labelList boundaryPoints() const
Return boundary point labels.
static word meshSubDir
The mesh sub-directory name (usually "faMesh")
Definition: faMesh.H:703
const fileName & facesInstance() const
Return the current instance directory for faces.
Definition: faMesh.C:747
PrimitivePatch< UIndirectList< face >, const pointField & > uindirectPrimitivePatch
A PrimitivePatch with UIndirectList for the faces, const reference for the point field.
label nInternalEdges() const noexcept
Number of internal faces.
Definition: faMeshI.H:61
Selector class for finite area differencing schemes. faMesh is derived from faSchemes so that all fie...
Definition: faSchemes.H:51
const edgeVectorField & edgeCentres() const
Return edge centres as edgeVectorField.
Definition: faMesh.C:846
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
Definition: List.H:55
bool moving() const
Is mesh moving.
Definition: faMesh.H:1195
bool hasEdgeCentres() const noexcept
Has edge centres: edgeCentres()
Definition: faMesh.H:1137
static autoPtr< faMesh > TryNew(const polyMesh &pMesh)
Read construction from polyMesh if all files are available.
Definition: faMeshNew.C:149
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: areaFieldsFwd.H:42
bool hasFaceAreas() const noexcept
Has face areas: S()
Definition: faMesh.H:1127
const labelList & edgeNeighbour() const noexcept
Edge neighbour addressing.
Definition: faMeshI.H:109
const word & name() const
Name function is needed to disambiguate those inherited from base classes.
Definition: faMesh.H:977
const fileName & pointsInstance() const
Return the current instance directory for points.
Definition: faMesh.C:741
Finite area boundary mesh.
Selector class for finite area solution. faMesh is derived from faSolution so that all fields have ac...
Definition: faSolution.H:51
const edgeVectorField & edgeAreaNormals() const
Return edge area normals.
Definition: faMesh.C:919
bool init(const bool doInit)
Initialise non-demand-driven data etc.
Definition: faMesh.C:299
constexpr label labelMax
Definition: label.H:55
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:57
labelList faceCells() const
The volume (owner) cells associated with the area-mesh.
Definition: faMesh.C:771
Field< vector > vectorField
Specialisation of Field<T> for vector.
static int geometryOrder_
Geometry treatment.
Definition: faMesh.H:687
faMesh Mesh
The mesh type.
Definition: faMesh.H:674
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
The class contains the addressing required by the lduMatrix: upper, lower and losort.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:73
const List< labelPair > & whichPatchFaces() const
The polyPatch/local-face for each faceLabels()
Definition: faMeshI.H:157
List< label > labelList
A List of labels.
Definition: List.H:62
volScalarField & p
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
A class for managing temporary objects.
Definition: HashPtrTable.H:50
TypeName("faMesh")
Runtime type information.
void removeFiles() const
Remove all files from mesh instance()
Definition: faMesh.C:796
Registry of regIOobjects.
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:69
label nBoundaryEdges() const noexcept
Number of boundary edges (== nEdges - nInternalEdges)
Definition: faMeshI.H:67
bool hasFaceAreaNormals() const noexcept
Has face area normals: faceAreaNormals()
Definition: faMesh.H:1152
const vectorField & pointAreaNormals() const
Return point area normals.
Definition: faMesh.C:930
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:171
const areaVectorField & faceAreaNormals() const
Return face area normals.
Definition: faMesh.C:908
bool hasPatchPointNormalsCorrection() const noexcept
Has patch point normals corrections.
Definition: faMesh.H:1184
tmp< edgeVectorField > unitLe() const
Return normalised edge length vectors.
List< bool > boolList
A List of bools.
Definition: List.H:60
GeometricField< vector, faPatchField, areaMesh > areaVectorField
Definition: areaFieldsFwd.H:81
const labelList & edgeOwner() const noexcept
Edge owner addressing.
Definition: faMeshI.H:103
lduAddressing wrapper for faMesh
Forwards and collection of common area field types.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
Namespace for OpenFOAM.
const DimensionedField< scalar, areaMesh > & S0() const
Return old-time face areas.
Definition: faMesh.C:870
GeometricField< scalar, faPatchField, areaMesh > areaScalarField
Definition: areaFieldsFwd.H:80
virtual lduInterfacePtrsList interfaces() const
Return a list of pointers for each patch.
Definition: faMesh.H:1030