fvMesh.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) 2011-2017 OpenFOAM Foundation
9  Copyright (C) 2016-2021 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 "fvMesh.H"
30 #include "volFields.H"
31 #include "surfaceFields.H"
32 #include "slicedVolFields.H"
33 #include "slicedSurfaceFields.H"
34 #include "SubField.H"
35 #include "demandDrivenData.H"
36 #include "fvMeshLduAddressing.H"
37 #include "mapPolyMesh.H"
38 #include "MapFvFields.H"
39 #include "fvMeshMapper.H"
40 #include "mapClouds.H"
41 #include "MeshObject.H"
42 #include "fvMatrix.H"
43 
44 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48  defineTypeNameAndDebug(fvMesh, 0);
49 }
50 
51 
52 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
53 
55 {
57  <
58  fvMesh,
61  >(*this);
62 
64  <
65  lduMesh,
68  >(*this);
69 
73  VPtr_ = nullptr;
74 
79 }
80 
81 
83 {
84  bool haveV = (VPtr_ != nullptr);
85  bool haveSf = (SfPtr_ != nullptr);
86  bool haveMagSf = (magSfPtr_ != nullptr);
87  bool haveCP = (CPtr_ != nullptr);
88  bool haveCf = (CfPtr_ != nullptr);
89 
90  clearGeomNotOldVol();
91 
92  // Now recreate the fields
93  if (haveV)
94  {
95  (void)V();
96  }
97  if (haveSf)
98  {
99  (void)Sf();
100  }
101  if (haveMagSf)
102  {
103  (void)magSf();
104  }
105  if (haveCP)
106  {
107  (void)C();
108  }
109  if (haveCf)
110  {
111  (void)Cf();
112  }
113 }
114 
115 
117 {
118  clearGeomNotOldVol();
119 
120  deleteDemandDrivenData(V0Ptr_);
121  deleteDemandDrivenData(V00Ptr_);
122 
123  // Mesh motion flux cannot be deleted here because the old-time flux
124  // needs to be saved.
125 }
126 
127 
128 void Foam::fvMesh::clearAddressing(const bool isMeshUpdate)
129 {
130  DebugInFunction << "isMeshUpdate: " << isMeshUpdate << endl;
131 
132  if (isMeshUpdate)
133  {
134  // Part of a mesh update. Keep meshObjects that have an updateMesh
135  // callback
137  <
138  fvMesh,
141  >
142  (
143  *this
144  );
146  <
147  lduMesh,
150  >
151  (
152  *this
153  );
154  }
155  else
156  {
157  meshObject::clear<fvMesh, TopologicalMeshObject>(*this);
158  meshObject::clear<lduMesh, TopologicalMeshObject>(*this);
159  }
160  deleteDemandDrivenData(lduPtr_);
161 }
162 
163 
165 {
166  if (curTimeIndex_ < time().timeIndex())
167  {
169  << " Storing old time volumes since from time " << curTimeIndex_
170  << " and time now " << time().timeIndex()
171  << " V:" << V.size() << endl;
172 
173  if (V00Ptr_ && V0Ptr_)
174  {
175  // Copy V0 into V00 storage
176  *V00Ptr_ = *V0Ptr_;
177  }
178 
179  if (V0Ptr_)
180  {
181  // Copy V into V0 storage
182  V0Ptr_->scalarField::operator=(V);
183  }
184  else
185  {
186  // Allocate V0 storage, fill with V
188  (
189  IOobject
190  (
191  "V0",
192  time().timeName(),
193  *this,
196  false
197  ),
198  *this,
199  dimVolume
200  );
201  scalarField& V0 = *V0Ptr_;
202  // Note: V0 now sized with current mesh, not with (potentially
203  // different size) V.
204  V0.setSize(V.size());
205  V0 = V;
206  }
207 
208  curTimeIndex_ = time().timeIndex();
209 
210  if (debug)
211  {
213  << " Stored old time volumes V0:" << V0Ptr_->size()
214  << endl;
215 
216  if (V00Ptr_)
217  {
219  << " Stored oldold time volumes V00:" << V00Ptr_->size()
220  << endl;
221  }
222  }
223  }
224 }
225 
226 
228 {
229  clearGeom();
231 
232  clearAddressing();
233 
234  // Clear mesh motion flux
235  deleteDemandDrivenData(phiPtr_);
236 }
237 
238 
240 {
241  clearOutLocal();
243 }
244 
245 
246 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
247 
248 Foam::fvMesh::fvMesh(const IOobject& io, const bool doInit)
249 :
250  polyMesh(io, doInit),
251  fvSchemes(static_cast<const objectRegistry&>(*this)),
252  surfaceInterpolation(*this),
253  fvSolution(static_cast<const objectRegistry&>(*this)),
254  data(static_cast<const objectRegistry&>(*this)),
255  boundary_(*this, boundaryMesh()),
256  lduPtr_(nullptr),
257  curTimeIndex_(time().timeIndex()),
258  VPtr_(nullptr),
259  V0Ptr_(nullptr),
260  V00Ptr_(nullptr),
261  SfPtr_(nullptr),
262  magSfPtr_(nullptr),
263  CPtr_(nullptr),
264  CfPtr_(nullptr),
265  phiPtr_(nullptr)
266 {
267  DebugInFunction << "Constructing fvMesh from IOobject" << endl;
268 
269  if (doInit)
270  {
271  fvMesh::init(false); // do not initialise lower levels
272  }
273 }
274 
275 
276 bool Foam::fvMesh::init(const bool doInit)
277 {
278  if (doInit)
279  {
280  // Construct basic geometry calculation engine. Note: do before
281  // doing anything with primitiveMesh::cellCentres etc.
282  (void)geometry();
283 
284  // Intialise my data
285  polyMesh::init(doInit);
286  }
287 
288  // Check the existence of the cell volumes and read if present
289  // and set the storage of V00
290  if (fileHandler().isFile(time().timePath()/dbDir()/"V0"))
291  {
293  (
294  IOobject
295  (
296  "V0",
297  time().timeName(),
298  *this,
301  false
302  ),
303  *this
304  );
305 
306  V00();
307  }
308 
309  // Check the existence of the mesh fluxes, read if present and set the
310  // mesh to be moving
311  if (fileHandler().isFile(time().timePath()/dbDir()/"meshPhi"))
312  {
313  phiPtr_ = new surfaceScalarField
314  (
315  IOobject
316  (
317  "meshPhi",
318  time().timeName(),
319  *this,
322  false
323  ),
324  *this
325  );
326 
327  // The mesh is now considered moving so the old-time cell volumes
328  // will be required for the time derivatives so if they haven't been
329  // read initialise to the current cell volumes
330  if (!V0Ptr_)
331  {
333  (
334  IOobject
335  (
336  "V0",
337  time().timeName(),
338  *this,
341  false
342  ),
343  V()
344  );
345  }
346 
347  moving(true);
348  }
349 
350  // Assume something changed
351  return true;
352 }
353 
354 
356 (
357  const IOobject& io,
358  pointField&& points,
359  faceList&& faces,
360  labelList&& allOwner,
361  labelList&& allNeighbour,
362  const bool syncPar
363 )
364 :
365  polyMesh
366  (
367  io,
368  std::move(points),
369  std::move(faces),
370  std::move(allOwner),
371  std::move(allNeighbour),
372  syncPar
373  ),
374  fvSchemes(static_cast<const objectRegistry&>(*this)),
375  surfaceInterpolation(*this),
376  fvSolution(static_cast<const objectRegistry&>(*this)),
377  data(static_cast<const objectRegistry&>(*this)),
378  boundary_(*this),
379  lduPtr_(nullptr),
380  curTimeIndex_(time().timeIndex()),
381  VPtr_(nullptr),
382  V0Ptr_(nullptr),
383  V00Ptr_(nullptr),
384  SfPtr_(nullptr),
385  magSfPtr_(nullptr),
386  CPtr_(nullptr),
387  CfPtr_(nullptr),
388  phiPtr_(nullptr)
389 {
390  DebugInFunction << "Constructing fvMesh from components" << endl;
391 }
392 
393 
395 (
396  const IOobject& io,
397  pointField&& points,
398  faceList&& faces,
399  cellList&& cells,
400  const bool syncPar
401 )
402 :
403  polyMesh
404  (
405  io,
406  std::move(points),
407  std::move(faces),
408  std::move(cells),
409  syncPar
410  ),
411  fvSchemes(static_cast<const objectRegistry&>(*this)),
412  surfaceInterpolation(*this),
413  fvSolution(static_cast<const objectRegistry&>(*this)),
414  data(static_cast<const objectRegistry&>(*this)),
415  boundary_(*this),
416  lduPtr_(nullptr),
417  curTimeIndex_(time().timeIndex()),
418  VPtr_(nullptr),
419  V0Ptr_(nullptr),
420  V00Ptr_(nullptr),
421  SfPtr_(nullptr),
422  magSfPtr_(nullptr),
423  CPtr_(nullptr),
424  CfPtr_(nullptr),
425  phiPtr_(nullptr)
426 {
427  DebugInFunction << "Constructing fvMesh from components" << endl;
428 }
429 
430 
431 Foam::fvMesh::fvMesh(const IOobject& io, const zero, const bool syncPar)
432 :
433  fvMesh(io, pointField(), faceList(), labelList(), labelList(), syncPar)
434 {}
435 
436 
438 (
439  const IOobject& io,
440  const fvMesh& baseMesh,
441  pointField&& points,
442  faceList&& faces,
443  labelList&& allOwner,
444  labelList&& allNeighbour,
445  const bool syncPar
446 )
447 :
448  polyMesh
449  (
450  io,
451  std::move(points),
452  std::move(faces),
453  std::move(allOwner),
454  std::move(allNeighbour),
455  syncPar
456  ),
457  fvSchemes
458  (
459  static_cast<const objectRegistry&>(*this),
460  static_cast<const fvSchemes&>(baseMesh)
461  ),
462  surfaceInterpolation(*this),
463  fvSolution
464  (
465  static_cast<const objectRegistry&>(*this),
466  static_cast<const fvSolution&>(baseMesh)
467  ),
468  data
469  (
470  static_cast<const objectRegistry&>(*this),
471  static_cast<const data&>(baseMesh)
472  ),
473  boundary_(*this),
474  lduPtr_(nullptr),
475  curTimeIndex_(time().timeIndex()),
476  VPtr_(nullptr),
477  V0Ptr_(nullptr),
478  V00Ptr_(nullptr),
479  SfPtr_(nullptr),
480  magSfPtr_(nullptr),
481  CPtr_(nullptr),
482  CfPtr_(nullptr),
483  phiPtr_(nullptr)
484 {
485  DebugInFunction << "Constructing fvMesh as copy and primitives" << endl;
486 }
487 
488 
490 (
491  const IOobject& io,
492  const fvMesh& baseMesh,
493  pointField&& points,
494  faceList&& faces,
495  cellList&& cells,
496  const bool syncPar
497 )
498 :
499  polyMesh
500  (
501  io,
502  std::move(points),
503  std::move(faces),
504  std::move(cells),
505  syncPar
506  ),
507  fvSchemes
508  (
509  static_cast<const objectRegistry&>(*this),
510  static_cast<const fvSchemes&>(baseMesh)
511  ),
512  surfaceInterpolation(*this),
513  fvSolution
514  (
515  static_cast<const objectRegistry&>(*this),
516  static_cast<const fvSolution&>(baseMesh)
517  ),
518  data
519  (
520  static_cast<const objectRegistry&>(*this),
521  static_cast<const data&>(baseMesh)
522  ),
523  boundary_(*this),
524  lduPtr_(nullptr),
525  curTimeIndex_(time().timeIndex()),
526  VPtr_(nullptr),
527  V0Ptr_(nullptr),
528  V00Ptr_(nullptr),
529  SfPtr_(nullptr),
530  magSfPtr_(nullptr),
531  CPtr_(nullptr),
532  CfPtr_(nullptr),
533  phiPtr_(nullptr)
534 {
535  DebugInFunction << "Constructing fvMesh as copy and primitives" << endl;
536 }
537 
538 
539 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
540 
542 {
543  clearOut();
544 }
545 
546 
547 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
548 
550 (
551  fvMatrix<scalar>& m,
552  const dictionary& dict
553 ) const
554 {
555  // Redirect to fvMatrix solver
556  return m.solveSegregatedOrCoupled(dict);
557 }
558 
559 
561 (
562  fvMatrix<vector>& m,
563  const dictionary& dict
564 ) const
565 {
566  // Redirect to fvMatrix solver
567  return m.solveSegregatedOrCoupled(dict);
568 }
569 
570 
572 (
574  const dictionary& dict
575 ) const
576 {
577  // Redirect to fvMatrix solver
578  return m.solveSegregatedOrCoupled(dict);
579 }
580 
581 
583 (
585  const dictionary& dict
586 ) const
587 {
588  // Redirect to fvMatrix solver
589  return m.solveSegregatedOrCoupled(dict);
590 }
591 
592 
594 (
595  fvMatrix<tensor>& m,
596  const dictionary& dict
597 ) const
598 {
599  // Redirect to fvMatrix solver
600  return m.solveSegregatedOrCoupled(dict);
601 }
602 
603 
605 (
606  PtrList<polyPatch>& plist,
607  const bool validBoundary
608 )
609 {
610  if (boundary().size())
611  {
613  << " boundary already exists"
614  << abort(FatalError);
615  }
616 
617  addPatches(plist, validBoundary);
618  boundary_.addPatches(boundaryMesh());
619 }
620 
621 
623 (
624  const List<polyPatch*>& p,
625  const bool validBoundary
626 )
627 {
628  // Acquire ownership of the pointers
629  PtrList<polyPatch> plist(const_cast<List<polyPatch*>&>(p));
630 
631  addFvPatches(plist, validBoundary);
632 }
633 
634 
636 {
637  DebugInFunction << "Removing boundary patches." << endl;
638 
639  // Remove fvBoundaryMesh data first.
640  boundary_.clear();
641  boundary_.setSize(0);
643 
644  clearOut();
645 }
646 
647 
649 {
650  DebugInFunction << "Updating fvMesh. ";
651 
653 
654  if (state == polyMesh::TOPO_PATCH_CHANGE)
655  {
656  DebugInfo << "Boundary and topological update" << endl;
657 
658  boundary_.readUpdate(boundaryMesh());
659 
660  clearOut();
661 
662  }
663  else if (state == polyMesh::TOPO_CHANGE)
664  {
665  DebugInfo << "Topological update" << endl;
666 
667  // fvMesh::clearOut() but without the polyMesh::clearOut
668  clearOutLocal();
669  }
670  else if (state == polyMesh::POINTS_MOVED)
671  {
672  DebugInfo << "Point motion update" << endl;
673 
674  clearGeom();
675  }
676  else
677  {
678  DebugInfo << "No update" << endl;
679  }
680 
681  return state;
682 }
683 
684 
686 {
687  return boundary_;
688 }
689 
690 
692 {
693  if (!lduPtr_)
694  {
696  << "Calculating fvMeshLduAddressing from nFaces:"
697  << nFaces() << endl;
698 
699  lduPtr_ = new fvMeshLduAddressing(*this);
700 
701  return *lduPtr_;
702  }
703 
704  return *lduPtr_;
705 }
706 
707 
709 {
710  return boundary().interfaces();
711 }
712 
713 
715 {
717  << " nOldCells:" << meshMap.nOldCells()
718  << " nCells:" << nCells()
719  << " nOldFaces:" << meshMap.nOldFaces()
720  << " nFaces:" << nFaces()
721  << endl;
722 
723  // We require geometric properties valid for the old mesh
724  if
725  (
726  meshMap.cellMap().size() != nCells()
727  || meshMap.faceMap().size() != nFaces()
728  )
729  {
731  << "mapPolyMesh does not correspond to the old mesh."
732  << " nCells:" << nCells()
733  << " cellMap:" << meshMap.cellMap().size()
734  << " nOldCells:" << meshMap.nOldCells()
735  << " nFaces:" << nFaces()
736  << " faceMap:" << meshMap.faceMap().size()
737  << " nOldFaces:" << meshMap.nOldFaces()
738  << exit(FatalError);
739  }
740 
741  // Create a mapper
742  const fvMeshMapper mapper(*this, meshMap);
743 
744  // Map all the volFields in the objectRegistry
745  MapGeometricFields<scalar, fvPatchField, fvMeshMapper, volMesh>
746  (mapper);
747  MapGeometricFields<vector, fvPatchField, fvMeshMapper, volMesh>
748  (mapper);
749  MapGeometricFields<sphericalTensor, fvPatchField, fvMeshMapper, volMesh>
750  (mapper);
751  MapGeometricFields<symmTensor, fvPatchField, fvMeshMapper, volMesh>
752  (mapper);
753  MapGeometricFields<tensor, fvPatchField, fvMeshMapper, volMesh>
754  (mapper);
755 
756  // Map all the surfaceFields in the objectRegistry
757  MapGeometricFields<scalar, fvsPatchField, fvMeshMapper, surfaceMesh>
758  (mapper);
759  MapGeometricFields<vector, fvsPatchField, fvMeshMapper, surfaceMesh>
760  (mapper);
761  MapGeometricFields<symmTensor, fvsPatchField, fvMeshMapper, surfaceMesh>
762  (mapper);
763  MapGeometricFields<symmTensor, fvsPatchField, fvMeshMapper, surfaceMesh>
764  (mapper);
765  MapGeometricFields<tensor, fvsPatchField, fvMeshMapper, surfaceMesh>
766  (mapper);
767 
768  // Map all the dimensionedFields in the objectRegistry
769  MapDimensionedFields<scalar, fvMeshMapper, volMesh>(mapper);
770  MapDimensionedFields<vector, fvMeshMapper, volMesh>(mapper);
771  MapDimensionedFields<sphericalTensor, fvMeshMapper, volMesh>(mapper);
772  MapDimensionedFields<symmTensor, fvMeshMapper, volMesh>(mapper);
773  MapDimensionedFields<tensor, fvMeshMapper, volMesh>(mapper);
774 
775  // Map all the clouds in the objectRegistry
776  mapClouds(*this, meshMap);
777 
778 
779  const labelList& cellMap = meshMap.cellMap();
780 
781  // Map the old volume. Just map to new cell labels.
782  if (V0Ptr_)
783  {
784  scalarField& V0 = *V0Ptr_;
785 
786  scalarField savedV0(V0);
787  V0.setSize(nCells());
788 
789  forAll(V0, i)
790  {
791  if (cellMap[i] > -1)
792  {
793  V0[i] = savedV0[cellMap[i]];
794  }
795  else
796  {
797  V0[i] = 0.0;
798  }
799  }
800 
801  // Inject volume of merged cells
802  label nMerged = 0;
803  forAll(meshMap.reverseCellMap(), oldCelli)
804  {
805  label index = meshMap.reverseCellMap()[oldCelli];
806 
807  if (index < -1)
808  {
809  label celli = -index-2;
810 
811  V0[celli] += savedV0[oldCelli];
812 
813  nMerged++;
814  }
815  }
816 
817  DebugInfo
818  << "Mapping old time volume V0. Merged "
819  << nMerged << " out of " << nCells() << " cells" << endl;
820  }
821 
822 
823  // Map the old-old volume. Just map to new cell labels.
824  if (V00Ptr_)
825  {
826  scalarField& V00 = *V00Ptr_;
827 
828  scalarField savedV00(V00);
829  V00.setSize(nCells());
830 
831  forAll(V00, i)
832  {
833  if (cellMap[i] > -1)
834  {
835  V00[i] = savedV00[cellMap[i]];
836  }
837  else
838  {
839  V00[i] = 0.0;
840  }
841  }
842 
843  // Inject volume of merged cells
844  label nMerged = 0;
845  forAll(meshMap.reverseCellMap(), oldCelli)
846  {
847  label index = meshMap.reverseCellMap()[oldCelli];
848 
849  if (index < -1)
850  {
851  label celli = -index-2;
852 
853  V00[celli] += savedV00[oldCelli];
854  nMerged++;
855  }
856  }
857 
858  DebugInfo
859  << "Mapping old time volume V00. Merged "
860  << nMerged << " out of " << nCells() << " cells" << endl;
861  }
862 }
863 
864 
866 {
868 
869  // Grab old time volumes if the time has been incremented
870  // This will update V0, V00
871  if (curTimeIndex_ < time().timeIndex())
872  {
873  storeOldVol(V());
874  }
875 
876 
877  // Move the polyMesh and set the mesh motion fluxes to the swept-volumes
878 
879  scalar rDeltaT = 1.0/time().deltaTValue();
880 
882  scalarField& sweptVols = tsweptVols.ref();
883 
884  if (!phiPtr_)
885  {
886  // Create mesh motion flux
887  phiPtr_ = new surfaceScalarField
888  (
889  IOobject
890  (
891  "meshPhi",
892  this->time().timeName(),
893  *this,
896  false
897  ),
898  *this,
900  );
901  }
902  else
903  {
904  // Grab old time mesh motion fluxes if the time has been incremented
905  if (phiPtr_->timeIndex() != time().timeIndex())
906  {
907  phiPtr_->oldTime();
908  }
909  }
910 
911  surfaceScalarField& phi = *phiPtr_;
913  scalarField::subField(sweptVols, nInternalFaces());
914  phi.primitiveFieldRef() *= rDeltaT;
915 
916  const fvPatchList& patches = boundary();
917 
918  surfaceScalarField::Boundary& phibf = phi.boundaryFieldRef();
919  forAll(patches, patchi)
920  {
921  phibf[patchi] = patches[patchi].patchSlice(sweptVols);
922  phibf[patchi] *= rDeltaT;
923  }
924 
925  // Update or delete the local geometric properties as early as possible so
926  // they can be used if necessary. These get recreated here instead of
927  // demand driven since they might do parallel transfers which can conflict
928  // with when they're actually being used.
929  // Note that between above "polyMesh::movePoints(p)" and here nothing
930  // should use the local geometric properties.
931  updateGeomNotOldVol();
932 
933 
934  // Update other local data
935  boundary_.movePoints();
937 
938  meshObject::movePoints<fvMesh>(*this);
939  meshObject::movePoints<lduMesh>(*this);
940 
941  return tsweptVols;
942 }
943 
944 
946 {
947  // Let surfaceInterpolation handle geometry calculation. Note: this does
948  // lower levels updateGeom
950 }
951 
952 
954 {
956 
957  // Update polyMesh. This needs to keep volume existent!
959 
960  // Our slice of the addressing is no longer valid
961  deleteDemandDrivenData(lduPtr_);
962 
963  if (VPtr_)
964  {
965  // Grab old time volumes if the time has been incremented
966  // This will update V0, V00
967  storeOldVol(mpm.oldCellVolumes());
968 
969  // Few checks
970  if (VPtr_ && (V().size() != mpm.nOldCells()))
971  {
973  << "V:" << V().size()
974  << " not equal to the number of old cells "
975  << mpm.nOldCells()
976  << exit(FatalError);
977  }
978  if (V0Ptr_ && (V0Ptr_->size() != mpm.nOldCells()))
979  {
981  << "V0:" << V0Ptr_->size()
982  << " not equal to the number of old cells "
983  << mpm.nOldCells()
984  << exit(FatalError);
985  }
986  if (V00Ptr_ && (V00Ptr_->size() != mpm.nOldCells()))
987  {
989  << "V0:" << V00Ptr_->size()
990  << " not equal to the number of old cells "
991  << mpm.nOldCells()
992  << exit(FatalError);
993  }
994  }
995 
996 
997  // Clear mesh motion flux (note: could instead save & map like volumes)
998  deleteDemandDrivenData(phiPtr_);
999 
1000  // Clear the sliced fields
1001  clearGeomNotOldVol();
1002 
1003  // Map all fields
1004  mapFields(mpm);
1005 
1006  // Clear the current volume and other geometry factors
1008 
1009  // Clear any non-updateable addressing
1010  clearAddressing(true);
1011 
1012  meshObject::updateMesh<fvMesh>(*this, mpm);
1013  meshObject::updateMesh<lduMesh>(*this, mpm);
1014 }
1015 
1016 
1019  IOstreamOption streamOpt,
1020  const bool valid
1021 ) const
1022 {
1023  bool ok = true;
1024  if (phiPtr_)
1025  {
1026  ok = phiPtr_->write(valid);
1027  // NOTE: The old old time mesh phi might be necessary for certain
1028  // solver smooth restart using second order time schemes.
1029  //ok = phiPtr_->oldTime().write();
1030  }
1031  if (V0Ptr_ && V0Ptr_->writeOpt() == IOobject::AUTO_WRITE)
1032  {
1033  // For second order restarts we need to write V0
1034  ok = V0Ptr_->write(valid);
1035  }
1036 
1037  return ok && polyMesh::writeObject(streamOpt, valid);
1038 }
1039 
1040 
1041 bool Foam::fvMesh::write(const bool valid) const
1042 {
1043  return polyMesh::write(valid);
1044 }
1045 
1046 
1047 template<>
1049 Foam::fvMesh::validComponents<Foam::sphericalTensor>() const
1050 {
1052 }
1053 
1054 
1055 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
1056 
1057 bool Foam::fvMesh::operator!=(const fvMesh& rhs) const
1058 {
1059  return &rhs != this;
1060 }
1061 
1062 
1063 bool Foam::fvMesh::operator==(const fvMesh& rhs) const
1064 {
1065  return &rhs == this;
1066 }
1067 
1068 
1069 // ************************************************************************* //
Foam::expressions::patchExpr::debug
int debug
Static debugging option.
Foam::lduAddressing
The class contains the addressing required by the lduMatrix: upper, lower and losort.
Definition: lduAddressing.H:114
Foam::IOobject::NO_WRITE
Definition: IOobject.H:195
Foam::surfaceInterpolation::clearOut
void clearOut()
Clear all geometry and addressing.
Definition: surfaceInterpolation.C:49
Foam::fvMesh::storeOldVol
void storeOldVol(const scalarField &)
Preserve old volume(s)
Definition: fvMesh.C:164
volFields.H
Foam::fvMesh::~fvMesh
virtual ~fvMesh()
Destructor.
Definition: fvMesh.C:541
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
InfoInFunction
#define InfoInFunction
Report an information message using Foam::Info.
Definition: messageStream.H:350
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::IOobject::AUTO_WRITE
Definition: IOobject.H:194
SubField.H
Foam::fvMesh::write
virtual bool write(const bool valid=true) const
Write mesh using IO settings from time.
Definition: fvMesh.C:1041
Foam::polyMesh::POINTS_MOVED
Definition: polyMesh.H:93
Foam::primitiveMesh::clearAddressing
void clearAddressing()
Clear topological data.
Definition: primitiveMeshClear.C:157
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::fvMesh::updateGeomNotOldVol
void updateGeomNotOldVol()
Clear geometry like clearGeomNotOldVol but recreate any.
Definition: fvMesh.C:82
Foam::polyMesh::movePoints
virtual tmp< scalarField > movePoints(const pointField &)
Move points, returns volumes swept by faces in motion.
Definition: polyMesh.C:1160
Foam::fvMesh::clearOutLocal
void clearOutLocal()
Clear local-only storage (geometry, addressing etc)
Definition: fvMesh.C:227
Foam::fvMatrix::solveSegregatedOrCoupled
SolverPerformance< Type > solveSegregatedOrCoupled(const dictionary &)
Solve segregated or coupled returning the solution statistics.
Definition: fvMatrixSolve.C:62
Foam::fvSchemes
Selector class for finite volume differencing schemes. fvMesh is derived from fvSchemes so that all f...
Definition: fvSchemes.H:52
slicedVolFields.H
demandDrivenData.H
Template functions to aid in the implementation of demand driven data.
Foam::GeometricMeshObject
Definition: MeshObject.H:201
mapPolyMesh.H
Foam::fvMesh::VPtr_
void * VPtr_
Cell volumes old time level.
Definition: fvMesh.H:112
Foam::fvMesh::mapFields
virtual void mapFields(const mapPolyMesh &mpm)
Map all fields in time using given map.
Definition: fvMesh.C:714
Foam::fvMesh::clearGeomNotOldVol
void clearGeomNotOldVol()
Clear geometry but not the old-time cell volumes.
Definition: fvMesh.C:54
Foam::fvMesh::clearGeom
void clearGeom()
Clear local geometry.
Definition: fvMesh.C:116
Foam::mapPolyMesh::nOldFaces
label nOldFaces() const
Number of old faces.
Definition: mapPolyMesh.H:381
Foam::MoveableMeshObject
Definition: MeshObject.H:220
Foam::fvMesh::removeFvBoundary
void removeFvBoundary()
Definition: fvMesh.C:635
Foam::isFile
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: MSwindows.C:658
Foam::fileHandler
const fileOperation & fileHandler()
Get current file handler.
Definition: fileOperation.C:1485
fvMatrix.H
Foam::polyMesh::clearOut
void clearOut()
Clear all geometry and addressing unnecessary for CFD.
Definition: polyMeshClear.C:222
Foam::polyMesh::init
virtual bool init(const bool doInit)
Initialise all non-demand-driven data.
Definition: polyMesh.C:367
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
surfaceFields.H
Foam::surfaceFields.
Foam::fvMesh::operator!=
bool operator!=(const fvMesh &rhs) const
Compares addresses.
Definition: fvMesh.C:1057
Foam::fvMesh::operator==
bool operator==(const fvMesh &rhs) const
Compares addresses.
Definition: fvMesh.C:1063
Foam::UpdateableMeshObject
Definition: MeshObject.H:241
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
C
volScalarField & C
Definition: readThermalProperties.H:102
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
mapClouds.H
Generic Geometric field mapper. For "real" mapping, add template specialisations for mapping of inter...
Foam::fvMeshLduAddressing
Foam::fvMeshLduAddressing.
Definition: fvMeshLduAddressing.H:52
Foam::fvMesh::magSfPtr_
surfaceScalarField * magSfPtr_
Mag face area vectors.
Definition: fvMesh.H:124
Foam::fvBoundaryMesh
Foam::fvBoundaryMesh.
Definition: fvBoundaryMesh.H:57
Foam::fvMesh::SfPtr_
slicedSurfaceVectorField * SfPtr_
Face area vectors.
Definition: fvMesh.H:121
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:60
Foam::fvMesh::readUpdate
virtual readUpdateState readUpdate()
Update the mesh based on the mesh files saved in time.
Definition: fvMesh.C:648
Foam::deleteDemandDrivenData
void deleteDemandDrivenData(DataPtr &dataPtr)
Definition: demandDrivenData.H:42
Foam::polyMesh::TOPO_PATCH_CHANGE
Definition: polyMesh.H:95
Foam::fvMesh::solve
virtual SolverPerformance< scalar > solve(fvMatrix< scalar > &, const dictionary &) const
Definition: fvMesh.C:550
Foam::fvMesh::CfPtr_
slicedSurfaceVectorField * CfPtr_
Face centres.
Definition: fvMesh.H:130
Foam::fvMesh::updateGeom
virtual void updateGeom()
Definition: fvMesh.C:945
Foam::dimTime
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:53
Foam::tmp::ref
T & ref() const
Definition: tmpI.H:227
fvMeshMapper.H
Foam::Field< scalar >
Foam::regIOobject::write
virtual bool write(const bool valid=true) const
Write using setting from DB.
Definition: regIOobjectWrite.C:132
Foam::fvMesh::interfaces
virtual lduInterfacePtrsList interfaces() const
Return a list of pointers for each patch.
Definition: fvMesh.C:708
DebugInFunction
#define DebugInFunction
Report an information message using Foam::Info.
Definition: messageStream.H:388
Foam::fvMesh::lduAddr
virtual const lduAddressing & lduAddr() const
Return ldu addressing.
Definition: fvMesh.C:691
Foam::polyMesh::updateMesh
virtual void updateMesh(const mapPolyMesh &mpm)
Update the mesh corresponding to given map.
Definition: polyMeshUpdate.C:42
Foam::fvSolution
Selector class for finite volume solution solution. fvMesh is derived from fvSolution so that all fie...
Definition: fvSolution.H:50
Foam::IOstreamOption
The IOstreamOption is a simple container for options an IOstream can normally have.
Definition: IOstreamOption.H:63
Foam::fvMesh::updateMesh
virtual void updateMesh(const mapPolyMesh &mpm)
Update mesh corresponding to the given map.
Definition: fvMesh.C:953
Foam::UPtrList< const lduInterface >
Foam::PtrList
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: List.H:59
phi
surfaceScalarField & phi
Definition: setRegionFluidFields.H:8
Foam::polyMesh::TOPO_CHANGE
Definition: polyMesh.H:94
timeName
word timeName
Definition: getTimeIndex.H:3
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::objectRegistry::writeObject
virtual bool writeObject(IOstreamOption streamOpt, const bool valid) const
Write the objects using stream options.
Definition: objectRegistry.C:479
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::fvMesh::addFvPatches
void addFvPatches(PtrList< polyPatch > &plist, const bool validBoundary=true)
Add boundary patches. Constructor helper.
Definition: fvMesh.C:605
Foam::surfaceInterpolation::movePoints
virtual bool movePoints()
Do what is necessary if the mesh has moved.
Definition: surfaceInterpolation.C:151
MapFvFields.H
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
fvMesh.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:144
Foam::fvMesh::fvMesh
fvMesh(const fvMesh &)=delete
No copy construct.
Foam::mapPolyMesh::oldCellVolumes
const scalarField & oldCellVolumes() const
Definition: mapPolyMesh.H:651
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::polyMesh::removeBoundary
void removeBoundary()
Remove boundary patches.
Definition: polyMeshClear.C:39
Foam::GeometricField::primitiveFieldRef
Internal::FieldType & primitiveFieldRef(const bool updateAccessTime=true)
Return a reference to the internal field.
Definition: GeometricField.C:766
Foam::polyMesh::readUpdateState
readUpdateState
Enumeration defining the state of the mesh after a read update.
Definition: polyMesh.H:90
Foam::fvMesh::boundary
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
Definition: fvMesh.C:685
Foam::fvMesh::CPtr_
slicedVolVectorField * CPtr_
Cell centres.
Definition: fvMesh.H:127
Foam::mapPolyMesh::reverseCellMap
const labelList & reverseCellMap() const
Reverse cell map.
Definition: mapPolyMesh.H:532
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Foam::fvMesh::init
virtual bool init(const bool doInit)
Initialise all non-demand-driven data.
Definition: fvMesh.C:276
DebugInfo
#define DebugInfo
Report an information message using Foam::Info.
Definition: messageStream.H:382
Foam::surfaceScalarField
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
Definition: surfaceFieldsFwd.H:54
Foam::fvMeshMapper
Class holds all the necessary information for mapping fields associated with fvMesh.
Definition: fvMeshMapper.H:57
Foam::GeometricField::boundaryFieldRef
Boundary & boundaryFieldRef(const bool updateAccessTime=true)
Return a reference to the boundary field.
Definition: GeometricField.C:783
Foam::List< face >
Foam::pTraits
A traits class, which is primarily used for primitives.
Definition: pTraits.H:56
Foam::mapClouds
void mapClouds(const objectRegistry &db, const mapPolyMesh &mapper)
Generic Geometric field mapper.
Definition: mapClouds.H:51
Foam::mapPolyMesh::nOldCells
label nOldCells() const
Number of old cells.
Definition: mapPolyMesh.H:387
Foam::meshObject::clearUpto
static void clearUpto(objectRegistry &obr)
Definition: MeshObject.C:217
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::surfaceInterpolation::updateGeom
virtual void updateGeom()
Update all geometric data.
Definition: surfaceInterpolation.C:172
patches
const polyBoundaryMesh & patches
Definition: convertProcessorPatches.H:65
Foam::mapPolyMesh::faceMap
const labelList & faceMap() const
Old face map.
Definition: mapPolyMesh.H:410
Foam::surfaceInterpolation
Cell to surface interpolation scheme. Included in fvMesh.
Definition: surfaceInterpolation.H:58
Foam::SlicedGeometricField::Internal
The internalField of a SlicedGeometricField.
Definition: SlicedGeometricField.H:196
Foam::fvMatrix
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvPatchField.H:68
Foam::TopologicalMeshObject
Definition: MeshObject.H:182
slicedSurfaceFields.H
MeshObject.H
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:161
Foam::boundaryMesh
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface....
Definition: boundaryMesh.H:62
Foam::Field< scalar >::subField
SubField< scalar > subField
Declare type of subField.
Definition: Field.H:89
timeIndex
label timeIndex
Definition: getTimeIndex.H:30
cells
const cellShapeList & cells
Definition: gmvOutputHeader.H:3
Foam::dimVolume
const dimensionSet dimVolume(pow3(dimLength))
Definition: dimensionSets.H:60
Foam::GeometricField< scalar, fvsPatchField, surfaceMesh >
Foam::IOobject::NO_READ
Definition: IOobject.H:188
Foam::SolverPerformance
SolverPerformance is the class returned by the LduMatrix solver containing performance statistics.
Definition: SolverPerformance.H:52
fvMeshLduAddressing.H
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::data
Database for solution data, solver performance and other reduced data.
Definition: data.H:55
boundary
faceListList boundary
Definition: createBlockMesh.H:4
Foam::mapPolyMesh::cellMap
const labelList & cellMap() const
Old cell map.
Definition: mapPolyMesh.H:435
Foam::lduMesh
Abstract base class for meshes which provide LDU addressing for the construction of lduMatrix and LDU...
Definition: lduMesh.H:62
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54
Foam::fvMesh::clearOut
void clearOut()
Clear all geometry and addressing.
Definition: fvMesh.C:239
Foam::polyMesh::readUpdate
virtual readUpdateState readUpdate()
Update the mesh based on the mesh files saved in.
Definition: polyMeshIO.C:75
Foam::zero
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:62
Foam::IOobject::MUST_READ
Definition: IOobject.H:185
Foam::fvMesh::writeObject
virtual bool writeObject(IOstreamOption streamOpt, const bool valid) const
Write the underlying polyMesh and other data.
Definition: fvMesh.C:1018