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-2022 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
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  (
85  pbm.patchSet
86  (
87  polyPatchNames,
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 
106  labelList faceLabels(nFaceLabels);
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  bndConnectPtr_.reset(nullptr);
167  haloMapPtr_.reset(nullptr);
168  haloFaceCentresPtr_.reset(nullptr);
169  haloFaceNormalsPtr_.reset(nullptr);
170 }
171 
172 
173 void Foam::faMesh::setPrimitiveMeshData()
174 {
175  DebugInFunction << "Setting primitive data" << endl;
176 
177  const uindirectPrimitivePatch& bp = patch();
178  const labelListList& edgeFaces = bp.edgeFaces();
179 
180  // Dimensions
181 
182  nEdges_ = bp.nEdges();
183  nInternalEdges_ = bp.nInternalEdges();
184  nFaces_ = bp.size();
185  nPoints_ = bp.nPoints();
186 
187  edges_.resize(nEdges_);
188  edgeOwner_.resize(nEdges_);
189  edgeNeighbour_.resize(nInternalEdges_);
190 
191  // Internal edges
192  for (label edgei = 0; edgei < nInternalEdges_; ++edgei)
193  {
194  edges_[edgei] = bp.edges()[edgei];
195 
196  edgeOwner_[edgei] = edgeFaces[edgei][0];
197 
198  edgeNeighbour_[edgei] = edgeFaces[edgei][1];
199  }
200 
201  // Continue with boundary edges
202  label edgei = nInternalEdges_;
203 
204  for (const faPatch& p : boundary())
205  {
206  for (const label patchEdgei : p.edgeLabels())
207  {
208  edges_[edgei] = bp.edges()[patchEdgei];
209 
210  edgeOwner_[edgei] = edgeFaces[patchEdgei][0];
211 
212  ++edgei;
213  }
214  }
215 }
216 
217 
218 void Foam::faMesh::clearHalo() const
219 {
220  DebugInFunction << "Clearing halo information" << endl;
221 
222  haloMapPtr_.reset(nullptr);
223  haloFaceCentresPtr_.reset(nullptr);
224  haloFaceNormalsPtr_.reset(nullptr);
225 }
226 
227 
228 void Foam::faMesh::clearGeomNotAreas() const
229 {
230  DebugInFunction << "Clearing geometry" << endl;
231 
232  clearHalo();
233  patchPtr_.reset(nullptr);
234  polyPatchFacesPtr_.reset(nullptr);
235  polyPatchIdsPtr_.reset(nullptr);
236  bndConnectPtr_.reset(nullptr);
237  deleteDemandDrivenData(SPtr_);
238  deleteDemandDrivenData(patchStartsPtr_);
239  deleteDemandDrivenData(LePtr_);
240  deleteDemandDrivenData(magLePtr_);
241  deleteDemandDrivenData(faceCentresPtr_);
242  deleteDemandDrivenData(edgeCentresPtr_);
243  deleteDemandDrivenData(faceAreaNormalsPtr_);
244  deleteDemandDrivenData(edgeAreaNormalsPtr_);
245  pointAreaNormalsPtr_.reset(nullptr);
246  deleteDemandDrivenData(faceCurvaturesPtr_);
247  deleteDemandDrivenData(edgeTransformTensorsPtr_);
248 }
249 
250 
251 void Foam::faMesh::clearGeom() const
252 {
253  DebugInFunction << "Clearing geometry" << endl;
254 
255  clearGeomNotAreas();
256  deleteDemandDrivenData(S0Ptr_);
257  deleteDemandDrivenData(S00Ptr_);
258  deleteDemandDrivenData(correctPatchPointNormalsPtr_);
259 }
260 
261 
262 void Foam::faMesh::clearAddressing() const
263 {
264  DebugInFunction << "Clearing addressing" << endl;
265 
266  deleteDemandDrivenData(lduPtr_);
267 }
268 
269 
270 void Foam::faMesh::clearOut() const
271 {
272  clearGeom();
273  clearAddressing();
274  globalMeshDataPtr_.reset(nullptr);
275 }
276 
277 
278 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
279 
280 bool Foam::faMesh::init(const bool doInit)
281 {
282  if (doInit)
283  {
284  setPrimitiveMeshData();
285  }
286 
287  // Create global mesh data
288  if (Pstream::parRun())
289  {
290  (void)globalData();
291  }
292 
293  // Calculate topology for the patches (processor-processor comms etc.)
294  boundary_.updateMesh();
295 
296  // Calculate the geometry for the patches (transformation tensors etc.)
297  boundary_.calcGeometry();
298 
299  // Ensure processor/processor information is properly synchronised
300  if (Pstream::parRun())
301  {
302  const_cast<areaVectorField&>(areaCentres()).boundaryFieldRef()
303  .evaluateCoupled<processorFaPatch>();
304 
305  // This roughly corresponds to what OpenFOAM-v2112 (and earlier) had,
306  // but should nominally be unnecessary.
307  //
310  }
311 
312  return false;
313 }
314 
316 Foam::faMesh::faMesh(const polyMesh& pMesh, const Foam::zero)
317 :
318  faMesh(pMesh, labelList(), static_cast<const IOobject&>(pMesh))
319 {}
320 
321 
322 Foam::faMesh::faMesh(const faMesh& baseMesh, const Foam::zero)
323 :
324  faMesh(baseMesh, labelList())
325 {}
326 
327 
328 Foam::faMesh::faMesh
329 (
330  const polyMesh& pMesh,
331  const bool doInit
332 )
333 :
335  faSchemes(mesh()),
336  edgeInterpolation(*this),
337  faSolution(mesh()),
338  data(mesh()), // Always NO_READ, NO_WRITE
339  faceLabels_
340  (
341  IOobject
342  (
343  "faceLabels",
344  time().findInstance(meshDir(), "faceLabels"),
345  faMesh::meshSubDir,
346  mesh(),
347  IOobject::MUST_READ,
348  IOobject::NO_WRITE
349  )
350  ),
351  boundary_
352  (
353  IOobject
354  (
355  "faBoundary",
356  // Allow boundary file that is newer than faceLabels
357  time().findInstance
358  (
359  meshDir(),
360  "faBoundary",
361  IOobject::MUST_READ,
362  faceLabels_.instance()
363  ),
364  faMesh::meshSubDir,
365  mesh(),
366  IOobject::MUST_READ,
367  IOobject::NO_WRITE
368  ),
369  *this
370  ),
371  comm_(Pstream::worldComm),
372  curTimeIndex_(time().timeIndex()),
373 
374  patchPtr_(nullptr),
375  polyPatchFacesPtr_(nullptr),
376  polyPatchIdsPtr_(nullptr),
377  bndConnectPtr_(nullptr),
378  lduPtr_(nullptr),
379 
380  SPtr_(nullptr),
381  S0Ptr_(nullptr),
382  S00Ptr_(nullptr),
383  patchStartsPtr_(nullptr),
384  LePtr_(nullptr),
385  magLePtr_(nullptr),
386  faceCentresPtr_(nullptr),
387  edgeCentresPtr_(nullptr),
388  faceAreaNormalsPtr_(nullptr),
389  edgeAreaNormalsPtr_(nullptr),
390  pointAreaNormalsPtr_(nullptr),
391  faceCurvaturesPtr_(nullptr),
392  edgeTransformTensorsPtr_(nullptr),
393  correctPatchPointNormalsPtr_(nullptr),
394  globalMeshDataPtr_(nullptr),
395 
396  haloMapPtr_(nullptr),
397  haloFaceCentresPtr_(nullptr),
398  haloFaceNormalsPtr_(nullptr)
399 {
400  DebugInFunction << "Creating from IOobject" << endl;
401 
402  setPrimitiveMeshData();
403 
404  if (doInit)
405  {
406  faMesh::init(false); // do not init lower levels
407  }
408 
409  if (doInit && fileHandler().isFile(pMesh.time().timePath()/"S0"))
410  {
411  S0Ptr_ = new DimensionedField<scalar, areaMesh>
412  (
413  IOobject
414  (
415  "S0",
416  time().timeName(),
418  mesh(),
421  ),
422  *this
423  );
424  }
425 }
426 
427 
428 Foam::faMesh::faMesh
429 (
430  const polyMesh& pMesh,
431  labelList&& faceLabels
432 )
433 :
434  faMesh(pMesh, std::move(faceLabels), static_cast<const IOobject&>(pMesh))
435 {}
436 
437 
438 Foam::faMesh::faMesh
439 (
440  const polyMesh& pMesh,
441  labelList&& faceLabels,
442  const IOobject& io
443 )
444 :
446  faSchemes(mesh(), io.readOpt()),
447  edgeInterpolation(*this),
448  faSolution(mesh(), io.readOpt()),
449  data(mesh()), // Always NO_READ, NO_WRITE
450  faceLabels_
451  (
452  IOobject
453  (
454  "faceLabels",
455  mesh().facesInstance(),
456  faMesh::meshSubDir,
457  mesh(),
458  IOobject::NO_READ,
459  IOobject::NO_WRITE
460  ),
461  std::move(faceLabels)
462  ),
463  boundary_
464  (
465  IOobject
466  (
467  "faBoundary",
468  mesh().facesInstance(),
469  faMesh::meshSubDir,
470  mesh(),
471  IOobject::NO_READ,
472  IOobject::NO_WRITE
473  ),
474  *this,
475  label(0)
476  ),
477  comm_(Pstream::worldComm),
478  curTimeIndex_(time().timeIndex()),
479 
480  patchPtr_(nullptr),
481  polyPatchFacesPtr_(nullptr),
482  polyPatchIdsPtr_(nullptr),
483  bndConnectPtr_(nullptr),
484  lduPtr_(nullptr),
485 
486  SPtr_(nullptr),
487  S0Ptr_(nullptr),
488  S00Ptr_(nullptr),
489  patchStartsPtr_(nullptr),
490  LePtr_(nullptr),
491  magLePtr_(nullptr),
492  faceCentresPtr_(nullptr),
493  edgeCentresPtr_(nullptr),
494  faceAreaNormalsPtr_(nullptr),
495  edgeAreaNormalsPtr_(nullptr),
496  pointAreaNormalsPtr_(nullptr),
497  faceCurvaturesPtr_(nullptr),
498  edgeTransformTensorsPtr_(nullptr),
499  correctPatchPointNormalsPtr_(nullptr),
500  globalMeshDataPtr_(nullptr),
501 
502  haloMapPtr_(nullptr),
503  haloFaceCentresPtr_(nullptr),
504  haloFaceNormalsPtr_(nullptr)
505 {}
506 
507 
508 Foam::faMesh::faMesh
509 (
510  const faMesh& baseMesh,
511  labelList&& faceLabels
512 )
513 :
515  faSchemes
516  (
517  mesh(),
518  static_cast<const faSchemes&>(baseMesh)
519  ),
520  edgeInterpolation(*this),
521  faSolution
522  (
523  mesh(),
524  static_cast<const faSolution&>(baseMesh)
525  ),
526  data
527  (
528  mesh(),
529  static_cast<const data&>(baseMesh)
530  ),
531  faceLabels_
532  (
533  IOobject
534  (
535  "faceLabels",
536  mesh().facesInstance(),
537  faMesh::meshSubDir,
538  mesh(),
539  IOobject::NO_READ,
540  IOobject::NO_WRITE
541  ),
542  std::move(faceLabels)
543  ),
544  boundary_
545  (
546  IOobject
547  (
548  "faBoundary",
549  mesh().facesInstance(),
550  faMesh::meshSubDir,
551  mesh(),
552  IOobject::NO_READ,
553  IOobject::NO_WRITE
554  ),
555  *this,
556  label(0)
557  ),
558  comm_(Pstream::worldComm),
559  curTimeIndex_(time().timeIndex()),
560 
561  patchPtr_(nullptr),
562  polyPatchFacesPtr_(nullptr),
563  polyPatchIdsPtr_(nullptr),
564  bndConnectPtr_(nullptr),
565  lduPtr_(nullptr),
566 
567  SPtr_(nullptr),
568  S0Ptr_(nullptr),
569  S00Ptr_(nullptr),
570  patchStartsPtr_(nullptr),
571  LePtr_(nullptr),
572  magLePtr_(nullptr),
573  faceCentresPtr_(nullptr),
574  edgeCentresPtr_(nullptr),
575  faceAreaNormalsPtr_(nullptr),
576  edgeAreaNormalsPtr_(nullptr),
577  pointAreaNormalsPtr_(nullptr),
578  faceCurvaturesPtr_(nullptr),
579  edgeTransformTensorsPtr_(nullptr),
580  correctPatchPointNormalsPtr_(nullptr),
581  globalMeshDataPtr_(nullptr),
583  haloMapPtr_(nullptr),
584  haloFaceCentresPtr_(nullptr),
585  haloFaceNormalsPtr_(nullptr)
586 {}
587 
588 
589 Foam::faMesh::faMesh(const polyPatch& pp, const bool doInit)
590 :
591  faMesh
592  (
593  pp.boundaryMesh().mesh(),
594  identity(pp.range())
595  )
596 {
597  DebugInFunction << "Creating from polyPatch:" << pp.name() << endl;
598 
599  // Add single faPatch "default", but with processor connections
600  faPatchList newPatches
601  (
602  createOnePatch("default")
603  );
604 
605  addFaPatches(newPatches);
606 
607  setPrimitiveMeshData();
608 
609  if (doInit)
610  {
611  faMesh::init(false); // do not init lower levels
612  }
613 }
614 
615 
616 Foam::faMesh::faMesh
617 (
618  const polyMesh& pMesh,
619  const dictionary& faMeshDefinition,
620  const bool doInit
621 )
622 :
623  faMesh
624  (
625  pMesh,
627  (
628  pMesh.boundaryMesh(),
629  faMeshDefinition.get<wordRes>("polyMeshPatches")
630  )
631  )
632 {
633  DebugInFunction << "Creating from definition (dictionary)" << endl;
634 
635  faPatchList newPatches
636  (
637  createPatchList
638  (
639  faMeshDefinition.subDict("boundary"),
640 
641  // Optional 'empty' patch
642  faMeshDefinition.getOrDefault<word>("emptyPatch", word::null),
643 
644  // Optional specification for default patch
645  faMeshDefinition.findDict("defaultPatch")
646  )
647  );
648 
649  addFaPatches(newPatches);
650 
651  if (doInit)
652  {
653  faMesh::init(false); // do not init lower levels
654  }
655 
656  if (doInit && fileHandler().isFile(pMesh.time().timePath()/"S0"))
657  {
658  S0Ptr_ = new DimensionedField<scalar, areaMesh>
659  (
660  IOobject
661  (
662  "S0",
663  time().timeName(),
665  mesh(),
668  ),
669  *this
670  );
671  }
672 }
673 
674 
675 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
676 
678 {
679  clearOut();
680 }
681 
682 
683 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
686 {
687  return mesh().dbDir()/faMesh::meshSubDir;
688 }
689 
691 const Foam::Time& Foam::faMesh::time() const
692 {
693  return mesh().time();
694 }
695 
698 {
699  return mesh().pointsInstance();
700 }
701 
704 {
705  return mesh().facesInstance();
706 }
707 
709 bool Foam::faMesh::hasDb() const
710 {
711  return true;
712 }
713 
716 {
717  return mesh().thisDb();
718 }
719 
722 {
723  return polyMesh::regionName(thisDb().name());
724 }
725 
726 
728 {
729  const labelList& faceOwner = this->mesh().faceOwner();
730 
731  labelList list(faceLabels_);
732 
733  for (label& val : list)
734  {
735  // Transcribe from faceId to cellId (owner)
736  val = faceOwner[val];
737  }
738 
739  return list;
740 }
741 
742 
743 void Foam::faMesh::removeFiles(const fileName& instanceDir) const
744 {
745  fileName meshFilesPath = thisDb().time().path()/instanceDir/meshDir();
746 
747  Foam::rm(meshFilesPath/"faceLabels");
748  Foam::rm(meshFilesPath/"faBoundary");
749 }
750 
752 void Foam::faMesh::removeFiles() const
753 {
754  removeFiles(mesh().instance());
755 }
756 
757 
759 {
760  if (!patchStartsPtr_)
761  {
762  calcPatchStarts();
763  }
764 
765  return *patchStartsPtr_;
766 }
767 
768 
770 {
771  if (!LePtr_)
772  {
773  calcLe();
774  }
775 
776  return *LePtr_;
777 }
778 
779 
781 {
782  if (!magLePtr_)
783  {
784  calcMagLe();
785  }
786 
787  return *magLePtr_;
788 }
789 
790 
792 {
793  if (!faceCentresPtr_)
794  {
795  calcFaceCentres();
796  }
797 
798  return *faceCentresPtr_;
799 }
800 
801 
803 {
804  if (!edgeCentresPtr_)
805  {
806  calcEdgeCentres();
807  }
808 
809  return *edgeCentresPtr_;
810 }
811 
812 
814 Foam::faMesh::S() const
815 {
816  if (!SPtr_)
817  {
818  calcS();
819  }
820 
821  return *SPtr_;
822 }
823 
824 
826 Foam::faMesh::S0() const
827 {
828  if (!S0Ptr_)
829  {
831  << "S0 is not available"
832  << abort(FatalError);
833  }
834 
835  return *S0Ptr_;
836 }
837 
838 
840 Foam::faMesh::S00() const
841 {
842  if (!S00Ptr_)
843  {
844  S00Ptr_ = new DimensionedField<scalar, areaMesh>
845  (
846  IOobject
847  (
848  "S00",
849  time().timeName(),
850  mesh(),
853  ),
854  S0()
855  );
856 
857  S0Ptr_->writeOpt(IOobject::AUTO_WRITE);
858  }
859 
860  return *S00Ptr_;
861 }
862 
863 
865 {
866  if (!faceAreaNormalsPtr_)
867  {
868  calcFaceAreaNormals();
869  }
870 
871  return *faceAreaNormalsPtr_;
872 }
873 
874 
876 {
877  if (!edgeAreaNormalsPtr_)
878  {
879  calcEdgeAreaNormals();
880  }
881 
882  return *edgeAreaNormalsPtr_;
883 }
884 
885 
887 {
888  if (!pointAreaNormalsPtr_)
889  {
890  pointAreaNormalsPtr_.reset(new vectorField(nPoints()));
891 
892  calcPointAreaNormals(*pointAreaNormalsPtr_);
893 
894  if (quadricsFit_ > 0)
895  {
896  calcPointAreaNormalsByQuadricsFit(*pointAreaNormalsPtr_);
897  }
898  }
899 
900  return *pointAreaNormalsPtr_;
901 }
902 
903 
905 {
906  if (!faceCurvaturesPtr_)
907  {
908  calcFaceCurvatures();
909  }
910 
911  return *faceCurvaturesPtr_;
912 }
913 
914 
917 {
918  if (!edgeTransformTensorsPtr_)
919  {
920  calcEdgeTransformTensors();
921  }
922 
923  return *edgeTransformTensorsPtr_;
924 }
925 
926 
928 {
929  if (!globalMeshDataPtr_)
930  {
931  globalMeshDataPtr_.reset(new faGlobalMeshData(*this));
932  }
933 
934  return *globalMeshDataPtr_;
935 }
936 
937 
939 {
940  if (!lduPtr_)
941  {
942  calcLduAddressing();
943  }
944 
945  return *lduPtr_;
946 }
947 
948 
950 {
951  // Grab point motion from polyMesh
952  const vectorField& newPoints = mesh().points();
953 
954  // Grab old time areas if the time has been incremented
955  if (curTimeIndex_ < time().timeIndex())
956  {
957  if (S00Ptr_ && S0Ptr_)
958  {
959  DebugInfo<< "Copy old-old S" << endl;
960  *S00Ptr_ = *S0Ptr_;
961  }
962 
963  if (S0Ptr_)
964  {
965  DebugInfo<< "Copy old S" << endl;
966  *S0Ptr_ = S();
967  }
968  else
969  {
970  DebugInfo<< "Creating old cell volumes." << endl;
971 
972  S0Ptr_ = new DimensionedField<scalar, areaMesh>
973  (
974  IOobject
975  (
976  "S0",
977  time().timeName(),
978  mesh(),
982  ),
983  S()
984  );
985  }
986 
987  curTimeIndex_ = time().timeIndex();
988  }
989 
990  clearGeomNotAreas();
991 
992  // To satisfy the motion interface for MeshObject, const cast is needed
993  if (patchPtr_)
994  {
995  patchPtr_->movePoints(newPoints);
996  }
997 
998  // Move boundary points
999  boundary_.movePoints(newPoints);
1000 
1001  // Move interpolation
1004  // Note: Fluxes were dummy?
1005 
1006  return true;
1007 }
1008 
1009 
1010 bool Foam::faMesh::correctPatchPointNormals(const label patchID) const
1011 {
1012  if
1013  (
1014  bool(correctPatchPointNormalsPtr_)
1015  && patchID >= 0 && patchID < boundary().size()
1016  )
1017  {
1018  return (*correctPatchPointNormalsPtr_)[patchID];
1019  }
1020 
1021  return false;
1022 }
1023 
1024 
1026 {
1027  if (!correctPatchPointNormalsPtr_)
1028  {
1029  correctPatchPointNormalsPtr_ = new boolList(boundary().size(), false);
1030  }
1031 
1032  return *correctPatchPointNormalsPtr_;
1033 }
1034 
1035 
1036 bool Foam::faMesh::write(const bool valid) const
1037 {
1038  faceLabels_.write();
1039  boundary_.write();
1041  return false;
1042 }
1043 
1044 
1045 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
1047 bool Foam::faMesh::operator!=(const faMesh& m) const
1048 {
1049  return &m != this;
1050 }
1051 
1052 
1053 bool Foam::faMesh::operator==(const faMesh& m) const
1054 {
1055  return &m == this;
1056 }
1057 
1058 
1059 // ************************************************************************* //
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
List< labelList > labelListList
A List of labelList.
Definition: labelList.H:51
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:118
void addFaPatches(faPatchList &plist, const bool validBoundary=true)
Add boundary patches. Constructor helper.
Definition: faMeshPatches.C:31
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:833
const fileName & facesInstance() const
Return the current instance directory for faces.
Definition: polyMesh.C:853
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
fileName timePath() const
Return current time path.
Definition: Time.H:470
const word & regionName() const
The mesh region name or word::null if polyMesh::defaultRegion.
Definition: polyMesh.C:841
virtual bool write(const bool valid=true) const
Write mesh.
Definition: faMesh.C:1029
const Time & time() const
Return reference to time.
Definition: faMesh.C:684
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:49
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:807
Face to edge interpolation scheme. Included in faMesh.
bool operator!=(const faMesh &m) const
Definition: faMesh.C:1040
static bool & parRun() noexcept
Test if this a parallel run.
Definition: UPstream.H:639
Various mesh related information for a parallel run.
autoPtr< fileOperation > fileHandler(std::nullptr_t)
Delete current file handler.
Generic GeometricField class.
Definition: areaFieldsFwd.H:50
const faGlobalMeshData & globalData() const
Return parallel info.
Definition: faMesh.C:920
virtual const fileName & dbDir() const
Override the objectRegistry dbDir for a single-region case.
Definition: polyMesh.C:824
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:751
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:361
const word & regionName() const
The mesh region name or word::null if polyMesh::defaultRegion.
Definition: faMesh.C:714
const areaVectorField & areaCentres() const
Return face centres as areaVectorField.
Definition: faMesh.C:784
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:708
const edgeScalarField & magLe() const
Return edge length magnitudes.
Definition: faMesh.C:773
scalar range
UList< label > labelUList
A UList of labels.
Definition: UList.H:80
virtual const objectRegistry & thisDb() const
Return the object registry - resolve conflict polyMesh/lduMesh.
Definition: fvMesh.H:377
virtual const pointField & points() const
Return raw points.
Definition: polyMesh.C:1066
Templated abstract base-class for optional mesh objects used to automate their allocation to the mesh...
Definition: MeshObject.H:84
virtual bool hasDb() const
Return true if thisDb() is a valid DB.
Definition: faMesh.C:702
word timeName
Definition: getTimeIndex.H:3
const fileName & pointsInstance() const
Return the current instance directory for points.
Definition: polyMesh.C:847
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
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:670
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:678
bool operator==(const faMesh &m) const
Definition: faMesh.C:1046
virtual const lduAddressing & lduAddr() const
Return ldu addressing.
Definition: faMesh.C:931
const Time & time() const noexcept
Return time registry.
#define DebugInFunction
Report an information message using Foam::Info.
const edgeVectorField & Le() const
Return edge length vectors.
Definition: faMesh.C:762
Inter-processor communications stream.
Definition: Pstream.H:56
label size() const noexcept
The number of elements in the list.
Definition: UPtrListI.H:99
static const word prefix
The prefix to local: finite-area.
Definition: faMesh.H:693
virtual const labelList & faceOwner() const
Return face owner.
Definition: polyMesh.C:1104
static const word null
An empty word.
Definition: word.H:84
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:47
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:909
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
const word & name() const noexcept
The patch name.
virtual bool movePoints()
Update after mesh motion.
Definition: faMesh.C:942
int optimisationSwitch(const char *name, const int deflt=0)
Lookup optimisation switch or add default value.
Definition: debug.C:234
defineTypeNameAndDebug(combustionModel, 0)
Database for solution data, solver performance and other reduced data.
Definition: data.H:51
const polyMesh & mesh() const
Return access to polyMesh.
Definition: faMeshI.H:24
const areaScalarField & faceCurvatures() const
Return face curvatures.
Definition: faMesh.C:897
boolList & correctPatchPointNormals() const
Set whether point normals should be corrected for a patch.
Definition: faMesh.C:1018
bool isFile(const fileName &name, const bool checkGzip=true, const bool followLink=true)
Does the name exist as a FILE in the file system?
Definition: POSIX.C:830
Template functions to aid in the implementation of demand driven data.
static word meshSubDir
The mesh sub-directory name (usually "faMesh")
Definition: faMesh.H:698
const fileName & facesInstance() const
Return the current instance directory for faces.
Definition: faMesh.C:696
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:795
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:690
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:868
bool init(const bool doInit)
Initialise non-demand-driven data etc.
Definition: faMesh.C:273
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:58
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:720
Field< vector > vectorField
Specialisation of Field<T> for vector.
static int geometryOrder_
Geometry treatment.
Definition: faMesh.H:682
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
void removeFiles() const
Remove all files from mesh instance()
Definition: faMesh.C:745
Registry of regIOobjects.
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:69
void deleteDemandDrivenData(DataPtr &dataPtr)
const vectorField & pointAreaNormals() const
Return point area normals.
Definition: faMesh.C:879
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:166
const areaVectorField & faceAreaNormals() const
Return face area normals.
Definition: faMesh.C:857
List< bool > boolList
A List of bools.
Definition: List.H:60
GeometricField< vector, faPatchField, areaMesh > areaVectorField
Definition: areaFieldsFwd.H:81
Do not request registration (bool: false)
Namespace for OpenFOAM.
const DimensionedField< scalar, areaMesh > & S0() const
Return old-time face areas.
Definition: faMesh.C:819
label timeIndex
Definition: getTimeIndex.H:24
bool rm(const fileName &file)
Remove a file (or its gz equivalent), returning true if successful.
Definition: POSIX.C:1357