faMesh.C
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) 2020-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 \*---------------------------------------------------------------------------*/
28 
29 #include "faMesh.H"
30 #include "faMeshBoundaryHalo.H"
31 #include "faGlobalMeshData.H"
32 #include "Time.H"
33 #include "polyMesh.H"
34 #include "primitiveMesh.H"
35 #include "demandDrivenData.H"
36 #include "IndirectList.H"
37 #include "areaFields.H"
38 #include "edgeFields.H"
39 #include "faMeshLduAddressing.H"
40 #include "processorFaPatch.H"
41 #include "wedgeFaPatch.H"
42 #include "faPatchData.H"
43 #include "registerSwitch.H"
44 
45 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49  defineTypeNameAndDebug(faMesh, 0);
50 
52  (
53  debug::optimisationSwitch("fa:geometryOrder", 2)
54  );
56  (
57  "fa:geometryOrder",
58  int,
60  );
61 }
62 
63 
64 const Foam::word Foam::faMesh::prefix("finite-area");
65 
67 
68 const int Foam::faMesh::quadricsFit_ = 0; // Tuning (experimental)
69 
70 
71 // * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
72 
73 namespace Foam
74 {
75 
76 // Convert patch names to face labels. Preserve patch order
78 (
79  const polyBoundaryMesh& pbm,
80  const wordRes& polyPatchNames
81 )
82 {
83  const labelList patchIDs
84  (
86  (
88  false, // warnNotFound
89  true // useGroups
90  ).sortedToc()
91  );
92 
93  if (patchIDs.empty())
94  {
96  << "No matching patches: " << polyPatchNames << nl
97  << exit(FatalError);
98  }
99 
100  label nFaceLabels = 0;
101  for (const label patchi : patchIDs)
102  {
103  nFaceLabels += pbm[patchi].size();
104  }
105 
107 
108  nFaceLabels = 0;
109  for (const label patchi : patchIDs)
110  {
111  for (const label facei : pbm[patchi].range())
112  {
113  faceLabels[nFaceLabels] = facei;
114  ++nFaceLabels;
115  }
116  }
117 
118  return faceLabels;
119 }
120 
121 } // End namespace Foam
122 
123 
124 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
125 
126 void Foam::faMesh::checkBoundaryEdgeLabelRange
127 (
128  const labelUList& edgeLabels
129 ) const
130 {
131  label nErrors = 0;
132 
133  for (const label edgei : edgeLabels)
134  {
135  if (edgei < nInternalEdges_ || edgei >= nEdges_)
136  {
137  if (!nErrors++)
138  {
140  << "Boundary edge label out of range "
141  << nInternalEdges_ << ".." << (nEdges_-1) << nl
142  << " ";
143  }
144 
145  FatalError<< ' ' << edgei;
146  }
147  }
148 
149  if (nErrors)
150  {
151  FatalError << nl << exit(FatalError);
152  }
153 }
154 
155 
156 void Foam::faMesh::initPatch() const
157 {
158  patchPtr_.reset
159  (
161  (
162  UIndirectList<face>(mesh().faces(), faceLabels_),
163  mesh().points()
164  )
165  );
166  // Could set some basic primitive data here...
167  // nEdges_ = patchPtr_->nEdges();
168  // nInternalEdges_ = patchPtr_->nInternalEdges();
169  // nFaces_ = patchPtr_->size();
170  // nPoints_ = patchPtr_->nPoints();
171  bndConnectPtr_.reset(nullptr);
172  haloMapPtr_.reset(nullptr);
173  haloFaceCentresPtr_.reset(nullptr);
174  haloFaceNormalsPtr_.reset(nullptr);
175 }
176 
177 
178 void Foam::faMesh::setPrimitiveMeshData()
179 {
180  DebugInFunction << "Setting primitive data" << endl;
181 
182  const uindirectPrimitivePatch& bp = patch();
183  const labelListList& edgeFaces = bp.edgeFaces();
184 
185  // Dimensions
186 
187  nEdges_ = bp.nEdges();
188  nInternalEdges_ = bp.nInternalEdges();
189  nFaces_ = bp.size();
190  nPoints_ = bp.nPoints();
191 
192  edges_.resize(nEdges_);
193  edgeOwner_.resize(nEdges_);
194  edgeNeighbour_.resize(nInternalEdges_);
195 
196  // Internal edges
197  for (label edgei = 0; edgei < nInternalEdges_; ++edgei)
198  {
199  edges_[edgei] = bp.edges()[edgei];
200 
201  edgeOwner_[edgei] = edgeFaces[edgei][0];
202 
203  edgeNeighbour_[edgei] = edgeFaces[edgei][1];
204  }
205 
206  // Continue with boundary edges
207  label edgei = nInternalEdges_;
208 
209  for (const faPatch& p : boundary())
210  {
211  for (const label patchEdgei : p.edgeLabels())
212  {
213  edges_[edgei] = bp.edges()[patchEdgei];
214 
215  edgeOwner_[edgei] = edgeFaces[patchEdgei][0];
216 
217  ++edgei;
218  }
219  }
220 }
221 
222 
223 void Foam::faMesh::clearHalo() const
224 {
225  DebugInFunction << "Clearing halo information" << endl;
226 
227  haloMapPtr_.reset(nullptr);
228  haloFaceCentresPtr_.reset(nullptr);
229  haloFaceNormalsPtr_.reset(nullptr);
230 }
231 
232 
233 void Foam::faMesh::clearGeomNotAreas() const
234 {
235  DebugInFunction << "Clearing geometry" << endl;
236 
237  clearHalo();
238  patchPtr_.reset(nullptr);
239  polyPatchFacesPtr_.reset(nullptr);
240  polyPatchIdsPtr_.reset(nullptr);
241  bndConnectPtr_.reset(nullptr);
242  deleteDemandDrivenData(SPtr_);
243  deleteDemandDrivenData(patchStartsPtr_);
244  deleteDemandDrivenData(LePtr_);
245  deleteDemandDrivenData(magLePtr_);
246  deleteDemandDrivenData(faceCentresPtr_);
247  deleteDemandDrivenData(edgeCentresPtr_);
248  deleteDemandDrivenData(faceAreaNormalsPtr_);
249  deleteDemandDrivenData(edgeAreaNormalsPtr_);
250  pointAreaNormalsPtr_.reset(nullptr);
251  deleteDemandDrivenData(faceCurvaturesPtr_);
252  deleteDemandDrivenData(edgeTransformTensorsPtr_);
253 }
254 
255 
256 void Foam::faMesh::clearGeom() const
257 {
258  DebugInFunction << "Clearing geometry" << endl;
259 
260  clearGeomNotAreas();
261  deleteDemandDrivenData(S0Ptr_);
262  deleteDemandDrivenData(S00Ptr_);
263  deleteDemandDrivenData(correctPatchPointNormalsPtr_);
264 }
265 
266 
267 void Foam::faMesh::clearAddressing() const
268 {
269  DebugInFunction << "Clearing addressing" << endl;
270 
271  deleteDemandDrivenData(lduPtr_);
272 }
273 
274 
275 void Foam::faMesh::clearOut() const
276 {
277  clearGeom();
278  clearAddressing();
279  globalMeshDataPtr_.reset(nullptr);
280 }
281 
282 
283 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
284 
286 {
287  if (UPstream::parRun())
288  {
289  // areaCentres()
290  if (faceCentresPtr_)
291  {
292  faceCentresPtr_->boundaryFieldRef()
293  .evaluateCoupled<processorFaPatch>();
294  }
295 
296  // faceAreaNormals()
297  if (faceAreaNormalsPtr_)
298  {
299  faceAreaNormalsPtr_->boundaryFieldRef()
300  .evaluateCoupled<processorFaPatch>();
301  }
302  }
303 }
304 
305 
306 bool Foam::faMesh::init(const bool doInit)
307 {
308  if (doInit)
309  {
310  setPrimitiveMeshData();
311  }
312 
313  // Create global mesh data
314  if (UPstream::parRun())
315  {
316  (void)globalData();
317  }
318 
319  // Calculate topology for the patches (processor-processor comms etc.)
320  boundary_.updateMesh();
321 
322  // Calculate the geometry for the patches (transformation tensors etc.)
323  boundary_.calcGeometry();
325  syncGeom();
326 
327  return false;
328 }
329 
331 Foam::faMesh::faMesh(const polyMesh& pMesh, const Foam::zero)
332 :
333  faMesh(pMesh, labelList(), static_cast<const IOobject&>(pMesh))
334 {}
335 
336 
337 Foam::faMesh::faMesh(const faMesh& baseMesh, const Foam::zero)
338 :
339  faMesh(baseMesh, labelList())
340 {}
341 
342 
343 Foam::faMesh::faMesh
344 (
345  const polyMesh& pMesh,
346  const bool doInit
347 )
348 :
350  faSchemes(mesh()),
351  edgeInterpolation(*this),
352  faSolution(mesh()),
353  data(faMesh::thisDb()), // Always NO_READ, NO_WRITE
354  faceLabels_
355  (
356  IOobject
357  (
358  "faceLabels",
359  time().findInstance(meshDir(), "faceLabels"),
360  faMesh::meshSubDir,
361  faMesh::thisDb(),
362  IOobject::MUST_READ,
363  IOobject::NO_WRITE
364  )
365  ),
366  boundary_
367  (
368  IOobject
369  (
370  "faBoundary",
371  // Allow boundary file that is newer than faceLabels
372  time().findInstance
373  (
374  meshDir(),
375  "faBoundary",
376  IOobject::MUST_READ,
377  faceLabels_.instance()
378  ),
379  faMesh::meshSubDir,
380  faMesh::thisDb(),
381  IOobject::MUST_READ,
382  IOobject::NO_WRITE
383  ),
384  *this
385  ),
386  comm_(UPstream::worldComm),
387  curTimeIndex_(time().timeIndex()),
388 
389  patchPtr_(nullptr),
390  polyPatchFacesPtr_(nullptr),
391  polyPatchIdsPtr_(nullptr),
392  bndConnectPtr_(nullptr),
393  lduPtr_(nullptr),
394 
395  SPtr_(nullptr),
396  S0Ptr_(nullptr),
397  S00Ptr_(nullptr),
398  patchStartsPtr_(nullptr),
399  LePtr_(nullptr),
400  magLePtr_(nullptr),
401  faceCentresPtr_(nullptr),
402  edgeCentresPtr_(nullptr),
403  faceAreaNormalsPtr_(nullptr),
404  edgeAreaNormalsPtr_(nullptr),
405  pointAreaNormalsPtr_(nullptr),
406  faceCurvaturesPtr_(nullptr),
407  edgeTransformTensorsPtr_(nullptr),
408  correctPatchPointNormalsPtr_(nullptr),
409  globalMeshDataPtr_(nullptr),
410 
411  haloMapPtr_(nullptr),
412  haloFaceCentresPtr_(nullptr),
413  haloFaceNormalsPtr_(nullptr)
414 {
415  DebugInFunction << "Creating from IOobject" << endl;
416 
417  setPrimitiveMeshData();
418 
419  if (doInit)
420  {
421  faMesh::init(false); // do not init lower levels
422  }
423 
424  if (doInit)
425  {
426  // Read some optional fields
427  // - logic as per fvMesh
428 
429  IOobject rio
430  (
431  "name",
432  time().timeName(),
434  faMesh::thisDb(),
438  );
439 
440  // Read old surface areas (if present)
441  rio.resetHeader("S0");
442  if (returnReduceOr(rio.typeHeaderOk<regIOobject>(false)))
443  {
444  S0Ptr_ = new DimensionedField<scalar, areaMesh>
445  (
446  rio,
447  *this,
449  );
450  }
451  }
452 }
453 
454 
455 Foam::faMesh::faMesh
456 (
457  const polyMesh& pMesh,
459 )
460 :
461  faMesh(pMesh, std::move(faceLabels), static_cast<const IOobject&>(pMesh))
462 {}
463 
464 
465 Foam::faMesh::faMesh
466 (
467  const polyMesh& pMesh,
469  const IOobject& io
470 )
471 :
473  faSchemes(mesh(), io.readOpt()),
474  edgeInterpolation(*this),
475  faSolution(mesh(), io.readOpt()),
476  data(faMesh::thisDb()), // Always NO_READ, NO_WRITE
477  faceLabels_
478  (
479  IOobject
480  (
481  "faceLabels",
482  mesh().facesInstance(),
483  faMesh::meshSubDir,
484  faMesh::thisDb(),
485  IOobject::NO_READ,
486  IOobject::NO_WRITE
487  ),
488  std::move(faceLabels)
489  ),
490  boundary_
491  (
492  IOobject
493  (
494  "faBoundary",
495  mesh().facesInstance(),
496  faMesh::meshSubDir,
497  faMesh::thisDb(),
498  IOobject::NO_READ,
499  IOobject::NO_WRITE
500  ),
501  *this,
502  label(0)
503  ),
504  comm_(UPstream::worldComm),
505  curTimeIndex_(time().timeIndex()),
506 
507  patchPtr_(nullptr),
508  polyPatchFacesPtr_(nullptr),
509  polyPatchIdsPtr_(nullptr),
510  bndConnectPtr_(nullptr),
511  lduPtr_(nullptr),
512 
513  SPtr_(nullptr),
514  S0Ptr_(nullptr),
515  S00Ptr_(nullptr),
516  patchStartsPtr_(nullptr),
517  LePtr_(nullptr),
518  magLePtr_(nullptr),
519  faceCentresPtr_(nullptr),
520  edgeCentresPtr_(nullptr),
521  faceAreaNormalsPtr_(nullptr),
522  edgeAreaNormalsPtr_(nullptr),
523  pointAreaNormalsPtr_(nullptr),
524  faceCurvaturesPtr_(nullptr),
525  edgeTransformTensorsPtr_(nullptr),
526  correctPatchPointNormalsPtr_(nullptr),
527  globalMeshDataPtr_(nullptr),
528 
529  haloMapPtr_(nullptr),
530  haloFaceCentresPtr_(nullptr),
531  haloFaceNormalsPtr_(nullptr)
532 {
533  // Not yet much for primitive mesh data possible...
534  nPoints_ = 0;
535  nEdges_ = 0;
536  nInternalEdges_ = 0;
537  nFaces_ = faceLabels_.size();
538 }
539 
540 
541 Foam::faMesh::faMesh
542 (
543  const faMesh& baseMesh,
545 )
546 :
548  faSchemes
549  (
550  mesh(),
551  static_cast<const faSchemes&>(baseMesh)
552  ),
553  edgeInterpolation(*this),
554  faSolution
555  (
556  mesh(),
557  static_cast<const faSolution&>(baseMesh)
558  ),
559  data
560  (
561  faMesh::thisDb(),
562  static_cast<const data&>(baseMesh)
563  ),
564  faceLabels_
565  (
566  IOobject
567  (
568  "faceLabels",
569  mesh().facesInstance(),
570  faMesh::meshSubDir,
571  faMesh::thisDb(),
572  IOobject::NO_READ,
573  IOobject::NO_WRITE
574  ),
575  std::move(faceLabels)
576  ),
577  boundary_
578  (
579  IOobject
580  (
581  "faBoundary",
582  mesh().facesInstance(),
583  faMesh::meshSubDir,
584  faMesh::thisDb(),
585  IOobject::NO_READ,
586  IOobject::NO_WRITE
587  ),
588  *this,
589  label(0)
590  ),
591  comm_(UPstream::worldComm),
592  curTimeIndex_(time().timeIndex()),
593 
594  patchPtr_(nullptr),
595  polyPatchFacesPtr_(nullptr),
596  polyPatchIdsPtr_(nullptr),
597  bndConnectPtr_(nullptr),
598  lduPtr_(nullptr),
599 
600  SPtr_(nullptr),
601  S0Ptr_(nullptr),
602  S00Ptr_(nullptr),
603  patchStartsPtr_(nullptr),
604  LePtr_(nullptr),
605  magLePtr_(nullptr),
606  faceCentresPtr_(nullptr),
607  edgeCentresPtr_(nullptr),
608  faceAreaNormalsPtr_(nullptr),
609  edgeAreaNormalsPtr_(nullptr),
610  pointAreaNormalsPtr_(nullptr),
611  faceCurvaturesPtr_(nullptr),
612  edgeTransformTensorsPtr_(nullptr),
613  correctPatchPointNormalsPtr_(nullptr),
614  globalMeshDataPtr_(nullptr),
615 
616  haloMapPtr_(nullptr),
617  haloFaceCentresPtr_(nullptr),
618  haloFaceNormalsPtr_(nullptr)
619 {
620  // Not yet much for primitive mesh data possible...
621  nPoints_ = 0;
622  nEdges_ = 0;
623  nInternalEdges_ = 0;
624  nFaces_ = faceLabels_.size();
625 }
626 
627 
628 Foam::faMesh::faMesh(const polyPatch& pp, const bool doInit)
629 :
630  faMesh
631  (
632  pp.boundaryMesh().mesh(),
633  identity(pp.range())
634  )
635 {
636  DebugInFunction << "Creating from polyPatch:" << pp.name() << endl;
637 
638  // Add single faPatch "default", but with processor connections
639  faPatchList newPatches
640  (
641  createOnePatch("default")
642  );
643 
644  addFaPatches(newPatches);
645 
646  setPrimitiveMeshData();
647 
648  if (doInit)
649  {
650  faMesh::init(false); // do not init lower levels
651  }
652 }
653 
654 
655 Foam::faMesh::faMesh
656 (
657  const polyMesh& pMesh,
658  const dictionary& faMeshDefinition,
659  const bool doInit
660 )
661 :
662  faMesh
663  (
664  pMesh,
666  (
667  pMesh.boundaryMesh(),
668  faMeshDefinition.get<wordRes>("polyMeshPatches")
669  )
670  )
671 {
672  DebugInFunction << "Creating from definition (dictionary)" << endl;
673 
674  faPatchList newPatches
675  (
676  createPatchList
677  (
678  faMeshDefinition.subDict("boundary"),
679 
680  // Optional 'empty' patch
681  faMeshDefinition.getOrDefault<word>("emptyPatch", word::null),
682 
683  // Optional specification for default patch
684  faMeshDefinition.findDict("defaultPatch")
685  )
686  );
687 
688  addFaPatches(newPatches);
689 
690  if (doInit)
691  {
692  faMesh::init(false); // do not init lower levels
693  }
694 
695  if (doInit)
696  {
697  // Read old surface areas (if present)
698  // - logic as per fvMesh
699 
700  IOobject rio
701  (
702  "name",
703  time().timeName(),
705  faMesh::thisDb(),
709  );
710 
711  // Read old surface areas (if present)
712  rio.resetHeader("S0");
713  if (returnReduceOr(rio.typeHeaderOk<regIOobject>(false)))
714  {
715  S0Ptr_ = new DimensionedField<scalar, areaMesh>
716  (
717  rio,
718  *this,
720  );
721  }
722  }
723 }
724 
725 
726 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
727 
729 {
730  clearOut();
731 }
732 
733 
734 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
737 {
738  return mesh().dbDir()/faMesh::meshSubDir;
739 }
740 
742 const Foam::Time& Foam::faMesh::time() const
743 {
744  return mesh().time();
745 }
746 
749 {
750  return mesh().pointsInstance();
751 }
752 
755 {
756  return mesh().facesInstance();
757 }
758 
760 bool Foam::faMesh::hasDb() const
761 {
762  return true;
763 }
764 
767 {
768  return mesh().thisDb();
769 }
770 
773 {
774  return polyMesh::regionName(thisDb().name());
775 }
776 
777 
779 {
780  const labelList& faceOwner = this->mesh().faceOwner();
781 
782  labelList list(faceLabels_);
783 
784  for (label& val : list)
785  {
786  // Transcribe from faceId to cellId (owner)
787  val = faceOwner[val];
788  }
789 
790  return list;
791 }
792 
793 
794 void Foam::faMesh::removeFiles(const fileName& instanceDir) const
795 {
796  fileName meshFilesPath = thisDb().time().path()/instanceDir/meshDir();
797 
798  Foam::rm(meshFilesPath/"faceLabels");
799  Foam::rm(meshFilesPath/"faBoundary");
800 }
801 
803 void Foam::faMesh::removeFiles() const
804 {
805  removeFiles(mesh().instance());
806 }
807 
808 
810 {
811  if (!patchStartsPtr_)
812  {
813  calcPatchStarts();
814  }
815 
816  return *patchStartsPtr_;
817 }
818 
819 
821 {
822  if (!LePtr_)
823  {
824  calcLe();
825  }
826 
827  return *LePtr_;
828 }
829 
830 
832 {
833  if (!magLePtr_)
834  {
835  calcMagLe();
836  }
837 
838  return *magLePtr_;
839 }
840 
841 
843 {
844  if (!faceCentresPtr_)
845  {
846  calcFaceCentres();
847  }
848 
849  return *faceCentresPtr_;
850 }
851 
852 
854 {
855  if (!edgeCentresPtr_)
856  {
857  calcEdgeCentres();
858  }
859 
860  return *edgeCentresPtr_;
861 }
862 
863 
865 Foam::faMesh::S() const
866 {
867  if (!SPtr_)
868  {
869  calcS();
870  }
871 
872  return *SPtr_;
873 }
874 
875 
877 Foam::faMesh::S0() const
878 {
879  if (!S0Ptr_)
880  {
882  << "S0 is not available"
883  << abort(FatalError);
884  }
885 
886  return *S0Ptr_;
887 }
888 
889 
891 Foam::faMesh::S00() const
892 {
893  if (!S00Ptr_)
894  {
895  S00Ptr_ = new DimensionedField<scalar, areaMesh>
896  (
897  IOobject
898  (
899  "S00",
900  time().timeName(),
901  faMesh::thisDb(),
904  ),
905  S0()
906  );
907 
908  S0Ptr_->writeOpt(IOobject::AUTO_WRITE);
909  }
910 
911  return *S00Ptr_;
912 }
913 
914 
916 {
917  if (!faceAreaNormalsPtr_)
918  {
919  calcFaceAreaNormals();
920  }
921 
922  return *faceAreaNormalsPtr_;
923 }
924 
925 
927 {
928  if (!edgeAreaNormalsPtr_)
929  {
930  calcEdgeAreaNormals();
931  }
932 
933  return *edgeAreaNormalsPtr_;
934 }
935 
936 
938 {
939  if (!pointAreaNormalsPtr_)
940  {
941  pointAreaNormalsPtr_.reset(new vectorField(nPoints()));
942 
943  calcPointAreaNormals(*pointAreaNormalsPtr_);
944 
945  if (quadricsFit_ > 0)
946  {
947  calcPointAreaNormalsByQuadricsFit(*pointAreaNormalsPtr_);
948  }
949  }
950 
951  return *pointAreaNormalsPtr_;
952 }
953 
954 
956 {
957  if (!faceCurvaturesPtr_)
958  {
959  calcFaceCurvatures();
960  }
961 
962  return *faceCurvaturesPtr_;
963 }
964 
965 
968 {
969  if (!edgeTransformTensorsPtr_)
970  {
971  calcEdgeTransformTensors();
972  }
973 
974  return *edgeTransformTensorsPtr_;
975 }
976 
977 
979 {
980  if (!globalMeshDataPtr_)
981  {
982  globalMeshDataPtr_.reset(new faGlobalMeshData(*this));
983  }
984 
985  return *globalMeshDataPtr_;
986 }
987 
988 
990 {
991  if (!lduPtr_)
992  {
993  calcLduAddressing();
994  }
995 
996  return *lduPtr_;
997 }
998 
999 
1001 {
1002  // Grab point motion from polyMesh
1003  const vectorField& newPoints = mesh().points();
1004 
1005  // Grab old time areas if the time has been incremented
1006  if (curTimeIndex_ < time().timeIndex())
1007  {
1008  if (S00Ptr_ && S0Ptr_)
1009  {
1010  DebugInfo<< "Copy old-old S" << endl;
1011  *S00Ptr_ = *S0Ptr_;
1012  }
1013 
1014  if (S0Ptr_)
1015  {
1016  DebugInfo<< "Copy old S" << endl;
1017  *S0Ptr_ = S();
1018  }
1019  else
1020  {
1021  DebugInfo<< "Creating old cell volumes." << endl;
1022 
1023  S0Ptr_ = new DimensionedField<scalar, areaMesh>
1024  (
1025  IOobject
1026  (
1027  "S0",
1028  time().timeName(),
1029  faMesh::thisDb(),
1033  ),
1034  S()
1035  );
1036  }
1037 
1038  curTimeIndex_ = time().timeIndex();
1039  }
1040 
1041  clearGeomNotAreas();
1042 
1043  if (patchPtr_)
1044  {
1045  patchPtr_->movePoints(newPoints);
1046  }
1047 
1048  // Move boundary points
1049  boundary_.movePoints(newPoints);
1050 
1051  // Move interpolation
1053 
1054  // Note: Fluxes were dummy?
1056  syncGeom();
1057 
1058  return true;
1059 }
1060 
1061 
1062 bool Foam::faMesh::correctPatchPointNormals(const label patchID) const
1063 {
1064  if
1065  (
1066  bool(correctPatchPointNormalsPtr_)
1067  && patchID >= 0 && patchID < boundary().size()
1068  )
1069  {
1070  return (*correctPatchPointNormalsPtr_)[patchID];
1071  }
1072 
1073  return false;
1074 }
1075 
1076 
1078 {
1079  if (!correctPatchPointNormalsPtr_)
1080  {
1081  correctPatchPointNormalsPtr_ = new boolList(boundary().size(), false);
1082  }
1083 
1084  return *correctPatchPointNormalsPtr_;
1085 }
1086 
1087 
1088 bool Foam::faMesh::write(const bool writeOnProc) const
1089 {
1090  faceLabels_.write();
1091  boundary_.write();
1093  return false;
1094 }
1095 
1096 
1097 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
1099 bool Foam::faMesh::operator!=(const faMesh& m) const
1100 {
1101  return &m != this;
1102 }
1103 
1104 
1105 bool Foam::faMesh::operator==(const faMesh& m) const
1106 {
1107  return &m == this;
1108 }
1109 
1110 
1111 // ************************************************************************* //
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
PtrList< faPatch > faPatchList
Store lists of faPatch as a PtrList.
Definition: faPatch.H:59
registerOptSwitch("fa:geometryOrder", int, faMesh::geometryOrder_)
Finite area mesh (used for 2-D non-Euclidian finite area method) defined using a patch of faces on a ...
Definition: faMesh.H:88
faceListList boundary
const polyBoundaryMesh & pbm
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:116
const labelList patchIDs(pbm.patchSet(polyPatchNames, false, true).sortedToc())
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
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
const DimensionedField< scalar, areaMesh > & S00() const
Return old-old-time face areas.
Definition: faMesh.C:884
const fileName & facesInstance() const
Return the current instance directory for faces.
Definition: polyMesh.C:854
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:578
const word & regionName() const
The mesh region name or word::null if polyMesh::defaultRegion.
Definition: polyMesh.C:842
const Time & time() const
Return reference to time.
Definition: faMesh.C:735
void syncGeom()
Processor/processor synchronisation for geometry fields.
Definition: faMesh.C:278
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:49
bool empty() const noexcept
True if List is empty (ie, size() is zero)
Definition: UList.H:632
regIOobject(const IOobject &io, const bool isTimeObject=false)
Construct from IOobject. The optional flag adds special handling if the object is the top-level regIO...
Definition: regIOobject.C:43
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface...
Definition: boundaryMesh.H:58
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:487
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
static bool & parRun() noexcept
Test if this a parallel run.
Definition: UPstream.H:1004
Various mesh related information for a parallel run.
Generic GeometricField class.
Definition: areaFieldsFwd.H:50
const faGlobalMeshData & globalData() const
Return parallel info.
Definition: faMesh.C:971
virtual const fileName & dbDir() const
Override the objectRegistry dbDir for a single-region case.
Definition: polyMesh.C:825
static std::string path(const std::string &str)
Return directory path name (part before last /)
Definition: fileNameI.H:169
const labelList & patchStarts() const
Return patch starts.
Definition: faMesh.C:802
Ignore writing from objectRegistry::writeObject()
bool movePoints() const
Do what is necessary if the mesh has moved.
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:362
const word & regionName() const
The mesh region name or word::null if polyMesh::defaultRegion.
Definition: faMesh.C:765
const areaVectorField & areaCentres() const
Return face centres as areaVectorField.
Definition: faMesh.C:835
labelList faceLabels(nFaceLabels)
List< labelList > labelListList
List of labelList.
Definition: labelList.H:38
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
scalar range
UList< label > labelUList
A UList of labels.
Definition: UList.H:78
virtual const objectRegistry & thisDb() const
Return the object registry - resolve conflict polyMesh/lduMesh.
Definition: fvMesh.H:378
virtual const pointField & points() const
Return raw points.
Definition: polyMesh.C:1073
Templated abstract base-class for optional mesh objects used to automate their allocation to the mesh...
Definition: MeshObject.H:85
virtual bool hasDb() const
Return true if thisDb() is a valid DB.
Definition: faMesh.C:753
word timeName
Definition: getTimeIndex.H:3
const fileName & pointsInstance() const
Return the current instance directory for points.
Definition: polyMesh.C:848
dynamicFvMesh & mesh
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:52
const pointField & points
virtual ~faMesh()
Destructor.
Definition: faMesh.C:721
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i)
Definition: labelList.C:31
A class for handling words, derived from Foam::string.
Definition: word.H:63
label nPoints
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
#define DebugInFunction
Report an information message using Foam::Info.
wordRes polyPatchNames
const edgeVectorField & Le() const
Return edge length vectors.
Definition: faMesh.C:813
label nFaceLabels
label size() const noexcept
The number of entries in the list.
Definition: UPtrListI.H:113
static const word prefix
The prefix to local: finite-area.
Definition: faMesh.H:698
virtual const labelList & faceOwner() const
Return face owner.
Definition: polyMesh.C:1111
static const word null
An empty word.
Definition: word.H:84
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:53
errorManip< error > abort(error &err)
Definition: errorManip.H:139
#define DebugInfo
Report an information message using Foam::Info.
const FieldField< Field, tensor > & edgeTransformTensors() const
Return edge transformation tensors.
Definition: faMesh.C:960
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO...
static labelList selectPatchFaces(const polyBoundaryMesh &pbm, const wordRes &polyPatchNames)
Definition: faMesh.C:71
virtual bool movePoints()
Update after mesh motion.
Definition: faMesh.C:993
int optimisationSwitch(const char *name, const int deflt=0)
Lookup optimisation switch or add default value.
Definition: debug.C:234
virtual bool write(const bool writeOnProc=true) const
Write mesh.
Definition: faMesh.C:1081
defineTypeNameAndDebug(combustionModel, 0)
Database for solution data, solver performance and other reduced data.
Definition: data.H:52
const areaScalarField & faceCurvatures() const
Return face curvatures.
Definition: faMesh.C:948
boolList & correctPatchPointNormals() const
Set whether point normals should be corrected for a patch.
Definition: faMesh.C:1070
Template functions to aid in the implementation of demand driven data.
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.
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
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
Definition: List.H:55
List< Key > sortedToc() const
The table of contents (the keys) in sorted order.
Definition: HashTable.C:130
IOobject(const IOobject &)=default
Copy construct.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: areaFieldsFwd.H:42
Nothing to be read.
Automatically write from objectRegistry::writeObject()
const std::string patch
OpenFOAM patch number as a std::string.
const fileName & pointsInstance() const
Return the current instance directory for points.
Definition: faMesh.C:741
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
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:57
labelHashSet patchSet(const UList< wordRe > &patchNames, const bool warnNotFound=true, const bool useGroups=true) const
Return the set of patch IDs corresponding to the given names.
labelList faceCells() const
The volume (owner) cells associated with the area-mesh.
Definition: faMesh.C:771
Reading is optional [identical to READ_IF_PRESENT].
Field< vector > vectorField
Specialisation of Field<T> for vector.
static int geometryOrder_
Geometry treatment.
Definition: faMesh.H:687
The class contains the addressing required by the lduMatrix: upper, lower and losort.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:73
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)
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
bool returnReduceOr(const bool value, const label comm=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
void deleteDemandDrivenData(DataPtr &dataPtr)
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
List< bool > boolList
A List of bools.
Definition: List.H:60
Inter-processor communications stream.
Definition: UPstream.H:62
Do not request registration (bool: false)
const dimensionSet dimArea(sqr(dimLength))
Definition: dimensionSets.H:57
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
label timeIndex
Definition: getTimeIndex.H:24
Processor patch.
bool rm(const fileName &file)
Remove a file (or its gz equivalent), returning true if successful.
Definition: POSIX.C:1404
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:133