polyMesh.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "polyMesh.H"
27 #include "Time.H"
28 #include "cellIOList.H"
29 #include "wedgePolyPatch.H"
30 #include "emptyPolyPatch.H"
31 #include "globalMeshData.H"
32 #include "processorPolyPatch.H"
34 #include "indexedOctree.H"
35 #include "treeDataCell.H"
36 #include "meshObjects.H"
37 #include "pointMesh.H"
38 
39 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
40 
41 namespace Foam
42 {
44 }
45 
48 
49 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
50 
51 void Foam::polyMesh::calcDirections() const
52 {
53  for (direction cmpt=0; cmpt<vector::nComponents; cmpt++)
54  {
55  solutionD_[cmpt] = 1;
56  }
57 
58  // Knock out empty and wedge directions. Note:they will be present on all
59  // domains.
60 
61  label nEmptyPatches = 0;
62  label nWedgePatches = 0;
63 
64  vector emptyDirVec = Zero;
65  vector wedgeDirVec = Zero;
66 
68  {
69  if (boundaryMesh()[patchi].size())
70  {
71  if (isA<emptyPolyPatch>(boundaryMesh()[patchi]))
72  {
73  nEmptyPatches++;
74  emptyDirVec += sum(cmptMag(boundaryMesh()[patchi].faceAreas()));
75  }
76  else if (isA<wedgePolyPatch>(boundaryMesh()[patchi]))
77  {
78  const wedgePolyPatch& wpp = refCast<const wedgePolyPatch>
79  (
81  );
82 
83  nWedgePatches++;
84  wedgeDirVec += cmptMag(wpp.centreNormal());
85  }
86  }
87  }
88 
89  reduce(nEmptyPatches, maxOp<label>());
90  reduce(nWedgePatches, maxOp<label>());
91 
92  if (nEmptyPatches)
93  {
94  reduce(emptyDirVec, sumOp<vector>());
95 
96  emptyDirVec /= mag(emptyDirVec);
97 
98  for (direction cmpt=0; cmpt<vector::nComponents; cmpt++)
99  {
100  if (emptyDirVec[cmpt] > 1e-6)
101  {
102  solutionD_[cmpt] = -1;
103  }
104  else
105  {
106  solutionD_[cmpt] = 1;
107  }
108  }
109  }
110 
111 
112  // Knock out wedge directions
113 
114  geometricD_ = solutionD_;
115 
116  if (nWedgePatches)
117  {
118  reduce(wedgeDirVec, sumOp<vector>());
119 
120  wedgeDirVec /= mag(wedgeDirVec);
121 
122  for (direction cmpt=0; cmpt<vector::nComponents; cmpt++)
123  {
124  if (wedgeDirVec[cmpt] > 1e-6)
125  {
126  geometricD_[cmpt] = -1;
127  }
128  else
129  {
130  geometricD_[cmpt] = 1;
131  }
132  }
133  }
134 }
135 
136 
137 Foam::autoPtr<Foam::labelIOList> Foam::polyMesh::readTetBasePtIs() const
138 {
139  typeIOobject<labelIOList> io
140  (
141  "tetBasePtIs",
142  instance(),
143  meshSubDir,
144  *this,
147  );
148 
149  if (io.headerOk())
150  {
151  return autoPtr<labelIOList>(new labelIOList(io));
152  }
153  else
154  {
155  return autoPtr<labelIOList>(nullptr);
156  }
157 }
158 
159 
160 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
161 
163 :
164  objectRegistry(io),
165  primitiveMesh(),
166  points_
167  (
168  IOobject
169  (
170  "points",
171  time().findInstance(meshDir(), "points"),
172  meshSubDir,
173  *this,
174  IOobject::MUST_READ,
175  IOobject::NO_WRITE
176  )
177  ),
178  faces_
179  (
180  IOobject
181  (
182  "faces",
183  time().findInstance(meshDir(), "faces"),
184  meshSubDir,
185  *this,
186  IOobject::MUST_READ,
187  IOobject::NO_WRITE
188  )
189  ),
190  owner_
191  (
192  IOobject
193  (
194  "owner",
195  faces_.instance(),
196  meshSubDir,
197  *this,
198  IOobject::READ_IF_PRESENT,
199  IOobject::NO_WRITE
200  )
201  ),
202  neighbour_
203  (
204  IOobject
205  (
206  "neighbour",
207  faces_.instance(),
208  meshSubDir,
209  *this,
210  IOobject::READ_IF_PRESENT,
211  IOobject::NO_WRITE
212  )
213  ),
214  clearedPrimitives_(false),
215  boundary_
216  (
217  IOobject
218  (
219  "boundary",
220  faces_.instance(),
221  meshSubDir,
222  *this,
223  IOobject::MUST_READ,
224  IOobject::NO_WRITE
225  ),
226  *this
227  ),
228  bounds_(points_),
229  comm_(UPstream::worldComm),
230  geometricD_(Zero),
231  solutionD_(Zero),
232  tetBasePtIsPtr_(readTetBasePtIs()),
233  cellTreePtr_(nullptr),
234  pointZones_
235  (
236  IOobject
237  (
238  "pointZones",
239  time().findInstance
240  (
241  meshDir(),
242  "pointZones",
243  IOobject::READ_IF_PRESENT,
244  faces_.instance()
245  ),
246  meshSubDir,
247  *this,
248  IOobject::NO_READ, // Delay reading
249  IOobject::NO_WRITE
250  ),
251  *this
252  ),
253  faceZones_
254  (
255  IOobject
256  (
257  "faceZones",
258  time().findInstance
259  (
260  meshDir(),
261  "faceZones",
262  IOobject::READ_IF_PRESENT,
263  faces_.instance()
264  ),
265  meshSubDir,
266  *this,
267  IOobject::NO_READ, // Delay reading
268  IOobject::NO_WRITE
269  ),
270  *this
271  ),
272  cellZones_
273  (
274  IOobject
275  (
276  "cellZones",
277  time().findInstance
278  (
279  meshDir(),
280  "cellZones",
281  IOobject::READ_IF_PRESENT,
282  faces_.instance()
283  ),
284  meshSubDir,
285  *this,
286  IOobject::NO_READ, // Delay reading
287  IOobject::NO_WRITE
288  ),
289  *this
290  ),
291  globalMeshDataPtr_(nullptr),
292  curMotionTimeIndex_(-1),
293  oldPointsPtr_(nullptr),
294  oldCellCentresPtr_(nullptr),
295  storeOldCellCentres_(false),
296  moving_(false),
297  topoChanged_(false)
298 {
299  if (!owner_.headerClassName().empty())
300  {
301  initMesh();
302  }
303  else
304  {
305  cellCompactIOList cLst
306  (
307  IOobject
308  (
309  "cells",
310  faces_.instance(),
311  meshSubDir,
312  *this,
315  )
316  );
317 
318  // Set the primitive mesh
319  initMesh(cLst);
320 
321  owner_.write();
322  neighbour_.write();
323  }
324 
325  // Calculate topology for the patches (processor-processor comms etc.)
326  boundary_.topoChange();
327 
328  // Calculate the geometry for the patches (transformation tensors etc.)
329  boundary_.calcGeometry();
330 
331  // Warn if global empty mesh
332  const bool complete = Pstream::parRun() || !time().processorCase();
333  if (complete && returnReduce(nPoints(), sumOp<label>()) == 0)
334  {
336  << "no points in mesh" << endl;
337  }
338  if (complete && returnReduce(nCells(), sumOp<label>()) == 0)
339  {
341  << "no cells in mesh" << endl;
342  }
343 
344  // Initialise demand-driven data
345  calcDirections();
346 
347  // Read the zones now that the mesh geometry is available to construct them
348  pointZones_.readIfPresent();
349  faceZones_.readIfPresent();
350  cellZones_.readIfPresent();
351 }
352 
353 
355 (
356  const IOobject& io,
357  pointField&& points,
358  faceList&& faces,
359  labelList&& owner,
360  labelList&& neighbour,
361  const bool syncPar
362 )
363 :
364  objectRegistry(io),
365  primitiveMesh(),
366  points_
367  (
368  IOobject
369  (
370  "points",
371  instance(),
372  meshSubDir,
373  *this,
374  io.readOpt(),
375  IOobject::AUTO_WRITE
376  ),
377  move(points)
378  ),
379  faces_
380  (
381  IOobject
382  (
383  "faces",
384  instance(),
385  meshSubDir,
386  *this,
387  io.readOpt(),
388  IOobject::AUTO_WRITE
389  ),
390  move(faces)
391  ),
392  owner_
393  (
394  IOobject
395  (
396  "owner",
397  instance(),
398  meshSubDir,
399  *this,
400  io.readOpt(),
401  IOobject::AUTO_WRITE
402  ),
403  move(owner)
404  ),
405  neighbour_
406  (
407  IOobject
408  (
409  "neighbour",
410  instance(),
411  meshSubDir,
412  *this,
413  io.readOpt(),
414  IOobject::AUTO_WRITE
415  ),
416  move(neighbour)
417  ),
418  clearedPrimitives_(false),
419  boundary_
420  (
421  IOobject
422  (
423  "boundary",
424  instance(),
425  meshSubDir,
426  *this,
427  io.readOpt(),
428  IOobject::AUTO_WRITE
429  ),
430  *this,
431  polyPatchList()
432  ),
433  bounds_(points_, syncPar),
434  comm_(UPstream::worldComm),
435  geometricD_(Zero),
436  solutionD_(Zero),
437  tetBasePtIsPtr_(readTetBasePtIs()),
438  cellTreePtr_(nullptr),
439  pointZones_
440  (
441  IOobject
442  (
443  "pointZones",
444  instance(),
445  meshSubDir,
446  *this,
447  io.readOpt(),
448  IOobject::NO_WRITE
449  ),
450  *this
451  ),
452  faceZones_
453  (
454  IOobject
455  (
456  "faceZones",
457  instance(),
458  meshSubDir,
459  *this,
460  io.readOpt(),
461  IOobject::NO_WRITE
462  ),
463  *this
464  ),
465  cellZones_
466  (
467  IOobject
468  (
469  "cellZones",
470  instance(),
471  meshSubDir,
472  *this,
473  io.readOpt(),
474  IOobject::NO_WRITE
475  ),
476  *this
477  ),
478  globalMeshDataPtr_(nullptr),
479  curMotionTimeIndex_(-1),
480  oldPointsPtr_(nullptr),
481  oldCellCentresPtr_(nullptr),
482  storeOldCellCentres_(false),
483  moving_(false),
484  topoChanged_(false)
485 {
486  // Check if the faces and cells are valid
487  forAll(faces_, facei)
488  {
489  const face& curFace = faces_[facei];
490 
491  if (min(curFace) < 0 || max(curFace) > points_.size())
492  {
494  << "Face " << facei << "contains vertex labels out of range: "
495  << curFace << " Max point index = " << points_.size()
496  << abort(FatalError);
497  }
498  }
499 
500  // Set the primitive mesh
501  initMesh();
502 }
503 
504 
505 
507 (
508  const IOobject& io,
509  pointField&& points,
510  faceList&& faces,
511  cellList&& cells,
512  const bool syncPar
513 )
514 :
515  objectRegistry(io),
516  primitiveMesh(),
517  points_
518  (
519  IOobject
520  (
521  "points",
522  instance(),
523  meshSubDir,
524  *this,
525  IOobject::NO_READ,
526  IOobject::AUTO_WRITE
527  ),
528  move(points)
529  ),
530  faces_
531  (
532  IOobject
533  (
534  "faces",
535  instance(),
536  meshSubDir,
537  *this,
538  IOobject::NO_READ,
539  IOobject::AUTO_WRITE
540  ),
541  move(faces)
542  ),
543  owner_
544  (
545  IOobject
546  (
547  "owner",
548  instance(),
549  meshSubDir,
550  *this,
551  IOobject::NO_READ,
552  IOobject::AUTO_WRITE
553  ),
554  label(0)
555  ),
556  neighbour_
557  (
558  IOobject
559  (
560  "neighbour",
561  instance(),
562  meshSubDir,
563  *this,
564  IOobject::NO_READ,
565  IOobject::AUTO_WRITE
566  ),
567  label(0)
568  ),
569  clearedPrimitives_(false),
570  boundary_
571  (
572  IOobject
573  (
574  "boundary",
575  instance(),
576  meshSubDir,
577  *this,
578  IOobject::NO_READ,
579  IOobject::AUTO_WRITE
580  ),
581  *this,
582  0
583  ),
584  bounds_(points_, syncPar),
585  comm_(UPstream::worldComm),
586  geometricD_(Zero),
587  solutionD_(Zero),
588  tetBasePtIsPtr_(readTetBasePtIs()),
589  cellTreePtr_(nullptr),
590  pointZones_
591  (
592  IOobject
593  (
594  "pointZones",
595  instance(),
596  meshSubDir,
597  *this,
598  IOobject::NO_READ,
599  IOobject::NO_WRITE
600  ),
601  *this
602  ),
603  faceZones_
604  (
605  IOobject
606  (
607  "faceZones",
608  instance(),
609  meshSubDir,
610  *this,
611  IOobject::NO_READ,
612  IOobject::NO_WRITE
613  ),
614  *this
615  ),
616  cellZones_
617  (
618  IOobject
619  (
620  "cellZones",
621  instance(),
622  meshSubDir,
623  *this,
624  IOobject::NO_READ,
625  IOobject::NO_WRITE
626  ),
627  *this
628  ),
629  globalMeshDataPtr_(nullptr),
630  curMotionTimeIndex_(-1),
631  oldPointsPtr_(nullptr),
632  oldCellCentresPtr_(nullptr),
633  storeOldCellCentres_(false),
634  moving_(false),
635  topoChanged_(false)
636 {
637  // Check if faces are valid
638  forAll(faces_, facei)
639  {
640  const face& curFace = faces_[facei];
641 
642  if (min(curFace) < 0 || max(curFace) > points_.size())
643  {
645  << "Face " << facei << "contains vertex labels out of range: "
646  << curFace << " Max point index = " << points_.size()
647  << abort(FatalError);
648  }
649  }
650 
651  // transfer in cell list
652  cellList cLst(move(cells));
653 
654  // Check if cells are valid
655  forAll(cLst, celli)
656  {
657  const cell& curCell = cLst[celli];
658 
659  if (min(curCell) < 0 || max(curCell) > faces_.size())
660  {
662  << "Cell " << celli << "contains face labels out of range: "
663  << curCell << " Max face index = " << faces_.size()
664  << abort(FatalError);
665  }
666  }
667 
668  // Set the primitive mesh
669  initMesh(cLst);
670 }
671 
672 
674 :
675  objectRegistry(move(mesh)),
676  primitiveMesh(move(mesh)),
677  points_(move(mesh.points_)),
678  faces_(move(mesh.faces_)),
679  owner_(move(mesh.owner_)),
680  neighbour_(move(mesh.neighbour_)),
681  clearedPrimitives_(mesh.clearedPrimitives_),
682  boundary_(move(mesh.boundary_)),
683  bounds_(move(mesh.bounds_)),
684  comm_(mesh.comm_),
685  geometricD_(mesh.geometricD_),
686  solutionD_(mesh.solutionD_),
687  tetBasePtIsPtr_(move(mesh.tetBasePtIsPtr_)),
688  cellTreePtr_(move(mesh.cellTreePtr_)),
689  pointZones_(move(mesh.pointZones_)),
690  faceZones_(move(mesh.faceZones_)),
691  cellZones_(move(mesh.cellZones_)),
692  globalMeshDataPtr_(move(mesh.globalMeshDataPtr_)),
693  curMotionTimeIndex_(mesh.curMotionTimeIndex_),
694  oldPointsPtr_(move(mesh.oldPointsPtr_)),
695  oldCellCentresPtr_(move(mesh.oldCellCentresPtr_)),
696  storeOldCellCentres_(mesh.storeOldCellCentres_),
697  moving_(mesh.moving_),
698  topoChanged_(mesh.topoChanged_)
699 {}
700 
701 
703 (
704  pointField&& points,
705  faceList&& faces,
706  labelList&& owner,
707  labelList&& neighbour,
708  const labelList& patchSizes,
709  const labelList& patchStarts,
710  const bool validBoundary
711 )
712 {
713  // Clear addressing. Keep geometric props and updateable props for mapping.
714  clearAddressing(true);
715 
716  // Take over new primitive data.
717  // Optimised to avoid overwriting data at all
718  if (notNull(points))
719  {
720  points_ = move(points);
721  bounds_ = boundBox(points_, validBoundary);
722  }
723 
724  if (notNull(faces))
725  {
726  faces_ = move(faces);
727  }
728 
729  if (notNull(owner))
730  {
731  owner_ = move(owner);
732  }
733 
734  if (notNull(neighbour))
735  {
736  neighbour_ = move(neighbour);
737  }
738 
739 
740  // Reset patch sizes and starts
741  forAll(boundary_, patchi)
742  {
743  boundary_[patchi] = polyPatch
744  (
745  boundary_[patchi],
746  boundary_,
747  patchi,
748  patchSizes[patchi],
749  patchStarts[patchi]
750  );
751  }
752 
753 
754  // Flags the mesh files as being changed
755  setInstance(time().name());
756 
757  // Check if the faces and cells are valid
758  forAll(faces_, facei)
759  {
760  const face& curFace = faces_[facei];
761 
762  if (min(curFace) < 0 || max(curFace) > points_.size())
763  {
765  << "Face " << facei << " contains vertex labels out of range: "
766  << curFace << " Max point index = " << points_.size()
767  << abort(FatalError);
768  }
769  }
770 
771 
772  // Set the primitive mesh from the owner_, neighbour_.
773  // Works out from patch end where the active faces stop.
774  initMesh();
775 
776 
777  if (validBoundary)
778  {
779  // Note that we assume that all the patches stay the same and are
780  // correct etc. so we can already use the patches to do
781  // processor-processor comms.
782 
783  // Calculate topology for the patches (processor-processor comms etc.)
784  boundary_.topoChange();
785 
786  // Calculate the geometry for the patches (transformation tensors etc.)
787  boundary_.calcGeometry();
788 
789  // Warn if global empty mesh
790  if
791  (
792  (returnReduce(nPoints(), sumOp<label>()) == 0)
793  || (returnReduce(nCells(), sumOp<label>()) == 0)
794  )
795  {
797  << "no points or no cells in mesh"
798  << exit(FatalError);
799  }
800  }
801 }
802 
803 
805 {
806  // Clear addressing. Keep geometric and updatable properties for mapping.
807  clearAddressing(true);
808  otherMesh.clearAddressing(true);
809 
810  // Swap the primitives
811  points_.swap(otherMesh.points_);
812  bounds_ = boundBox(points_, true);
813  faces_.swap(otherMesh.faces_);
814  owner_.swap(otherMesh.owner_);
815  neighbour_.swap(otherMesh.neighbour_);
816 
817  // Clear the boundary data
818  boundary_.clearGeom();
819  boundary_.clearAddressing();
820  otherMesh.boundary_.clearGeom();
821  otherMesh.boundary_.clearAddressing();
822 
823  // Swap the boundaries
824  auto updatePatches = []
825  (
826  const polyPatchList& otherPatches,
827  polyBoundaryMesh& boundaryMesh
828  )
829  {
830  boundaryMesh.resize(otherPatches.size());
831 
832  forAll(otherPatches, otherPatchi)
833  {
834  // Clone processor patches, as the decomposition may be different
835  // in the other mesh. Just change the size and start of other
836  // patches.
837 
838  if (isA<processorPolyPatch>(otherPatches[otherPatchi]))
839  {
840  boundaryMesh.set
841  (
842  otherPatchi,
843  otherPatches[otherPatchi].clone(boundaryMesh)
844  );
845  }
846  else
847  {
848  boundaryMesh[otherPatchi] = polyPatch
849  (
850  boundaryMesh[otherPatchi],
851  boundaryMesh,
852  otherPatchi,
853  otherPatches[otherPatchi].size(),
854  otherPatches[otherPatchi].start()
855  );
856  }
857  }
858  };
859 
860  {
861  const polyPatchList patches
862  (
863  boundary_,
864  otherMesh.boundary_
865  );
866  const polyPatchList otherPatches
867  (
868  otherMesh.boundary_,
869  boundary_
870  );
871 
872  updatePatches(otherPatches, boundary_);
873  updatePatches(patches, otherMesh.boundary_);
874  }
875 
876  // Parallel data depends on the patch ordering so force recalculation
877  globalMeshDataPtr_.clear();
878  otherMesh.globalMeshDataPtr_.clear();
879 
880  // Flags the mesh files as being changed
881  setInstance(time().name());
882  otherMesh.setInstance(time().name());
883 
884  // Check if the faces and cells are valid
885  auto checkFaces = [](const polyMesh& mesh)
886  {
887  forAll(mesh.faces_, facei)
888  {
889  const face& curFace = mesh.faces_[facei];
890 
891  if (min(curFace) < 0 || max(curFace) > mesh.points_.size())
892  {
894  << "Face " << facei << " contains vertex labels out of "
895  << "range: " << curFace << " Max point index = "
896  << mesh.points_.size() << abort(FatalError);
897  }
898  }
899  };
900 
901  checkFaces(*this);
902  checkFaces(otherMesh);
903 
904  // Set the primitive mesh from the owner_, neighbour_.
905  // Works out from patch end where the active faces stop.
906  initMesh();
907  otherMesh.initMesh();
908 
909  // Calculate topology for the patches (processor-processor comms etc.)
910  boundary_.topoChange();
911  otherMesh.boundary_.topoChange();
912 
913  // Calculate the geometry for the patches (transformation tensors etc.)
914  boundary_.calcGeometry();
915  otherMesh.boundary_.calcGeometry();
916 
917  // Update the optional pointMesh with respect to the updated polyMesh
918  if (foundObject<pointMesh>(pointMesh::typeName))
919  {
920  pointMesh::New(*this).reset();
921  }
922 
923  if (otherMesh.foundObject<pointMesh>(pointMesh::typeName))
924  {
925  pointMesh::New(*this).reset();
926  }
927 
928  // Swap zones
929  pointZones_.swap(otherMesh.pointZones_);
930  faceZones_.swap(otherMesh.faceZones_);
931  cellZones_.swap(otherMesh.cellZones_);
932 }
933 
934 
935 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
936 
938 {
939  clearOut();
940  resetMotion();
941 }
942 
943 
944 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
945 
947 {
948  if (objectRegistry::dbDir() == defaultRegion)
949  {
950  return parent().dbDir();
951  }
952  else
953  {
954  return objectRegistry::dbDir();
955  }
956 }
957 
958 
960 {
961  return dbDir()/meshSubDir;
962 }
963 
964 
966 {
967  return points_.instance();
968 }
969 
970 
972 {
973  return faces_.instance();
974 }
975 
976 
978 {
979  return points_.writeOpt();
980 }
981 
982 
984 {
985  return faces_.writeOpt();
986 }
987 
988 
990 {
991  if (geometricD_.x() == 0)
992  {
993  calcDirections();
994  }
995 
996  return geometricD_;
997 }
998 
999 
1001 {
1002  return cmptSum(geometricD() + Vector<label>::one)/2;
1003 }
1004 
1005 
1007 {
1008  if (solutionD_.x() == 0)
1009  {
1010  calcDirections();
1011  }
1012 
1013  return solutionD_;
1014 }
1015 
1016 
1018 {
1019  return cmptSum(solutionD() + Vector<label>::one)/2;
1020 }
1021 
1022 
1024 {
1025  if (tetBasePtIsPtr_.empty())
1026  {
1027  if (debug)
1028  {
1030  << "Forcing storage of base points."
1031  << endl;
1032  }
1033 
1034  tetBasePtIsPtr_.reset
1035  (
1036  new labelIOList
1037  (
1038  IOobject
1039  (
1040  "tetBasePtIs",
1041  instance(),
1042  meshSubDir,
1043  *this,
1046  ),
1048  )
1049  );
1050  }
1051 
1052  return tetBasePtIsPtr_();
1053 }
1054 
1055 
1058 {
1059  if (cellTreePtr_.empty())
1060  {
1061  cellTreePtr_.reset
1062  (
1064  (
1065  treeDataCell
1066  (
1067  false, // not cache bb
1068  *this,
1069  CELL_TETS // use tet-decomposition for any inside test
1070  ),
1071  treeBoundBox(points()).extend(1e-4),
1072  8, // maxLevel
1073  10, // leafsize
1074  5.0 // duplicity
1075  )
1076  );
1077  }
1078 
1079  return cellTreePtr_();
1080 }
1081 
1082 
1084 (
1085  const List<polyPatch*>& p,
1086  const bool validBoundary
1087 )
1088 {
1089  if (boundaryMesh().size())
1090  {
1092  << "boundary already exists"
1093  << abort(FatalError);
1094  }
1095 
1096  // Reset valid directions
1097  geometricD_ = Zero;
1098  solutionD_ = Zero;
1099 
1100  boundary_.setSize(p.size());
1101 
1102  // Copy the patch pointers
1103  forAll(p, pI)
1104  {
1105  boundary_.set(pI, p[pI]);
1106  }
1107 
1108  // parallelData depends on the processorPatch ordering so force
1109  // recalculation. Problem: should really be done in removeBoundary but
1110  // there is some info in parallelData which might be interesting in between
1111  // removeBoundary and addPatches.
1112  globalMeshDataPtr_.clear();
1113 
1114  if (validBoundary)
1115  {
1116  // Calculate topology for the patches (processor-processor comms etc.)
1117  boundary_.topoChange();
1118 
1119  // Calculate the geometry for the patches (transformation tensors etc.)
1120  boundary_.calcGeometry();
1121 
1122  boundary_.checkDefinition();
1123  }
1124 }
1125 
1126 
1128 (
1129  const List<pointZone*>& pz,
1130  const List<faceZone*>& fz,
1131  const List<cellZone*>& cz
1132 )
1133 {
1134  if (pointZones().size() || faceZones().size() || cellZones().size())
1135  {
1137  << "point, face or cell zone already exists"
1138  << abort(FatalError);
1139  }
1140 
1141  // Point zones
1142  if (pz.size())
1143  {
1144  pointZones_.setSize(pz.size());
1145 
1146  // Copy the zone pointers
1147  forAll(pz, pI)
1148  {
1149  pointZones_.set(pI, pz[pI]->name(), pz[pI]);
1150  }
1151 
1152  pointZones_.writeOpt() = IOobject::AUTO_WRITE;
1153  }
1154 
1155  // Face zones
1156  if (fz.size())
1157  {
1158  faceZones_.setSize(fz.size());
1159 
1160  // Copy the zone pointers
1161  forAll(fz, fI)
1162  {
1163  faceZones_.set(fI, fz[fI]->name(), fz[fI]);
1164  }
1165 
1166  faceZones_.writeOpt() = IOobject::AUTO_WRITE;
1167  }
1168 
1169  // Cell zones
1170  if (cz.size())
1171  {
1172  cellZones_.setSize(cz.size());
1173 
1174  // Copy the zone pointers
1175  forAll(cz, cI)
1176  {
1177  cellZones_.set(cI, cz[cI]->name(), cz[cI]);
1178  }
1179 
1180  cellZones_.writeOpt() = IOobject::AUTO_WRITE;
1181  }
1182 }
1183 
1184 
1186 (
1187  const labelUList& newToOld,
1188  const bool validBoundary
1189 )
1190 {
1191  // Clear local fields and e.g. polyMesh parallelInfo.
1192  // Do not clearGeom to keep RepatchableMeshObjects intact.
1193  boundary_.clearGeom();
1194 
1195  clearAddressing(true);
1196 
1197  // Clear all but RepatchableMeshObjects
1199  <
1200  polyMesh,
1203  >
1204  (
1205  *this
1206  );
1208  <
1209  pointMesh,
1212  >
1213  (
1214  *this
1215  );
1216 
1217  // Update time instance for the mesh
1218  // so that it writes the mesh with the changed boundary
1219  // into a new time directory
1220  setInstance(time().name());
1221 
1222  boundary_.reorderPatches(newToOld, validBoundary);
1223 
1224  // Warn mesh objects
1225  meshObjects::reorderPatches<polyMesh>(*this, newToOld, validBoundary);
1226  meshObjects::reorderPatches<pointMesh>(*this, newToOld, validBoundary);
1227 }
1228 
1229 
1231 (
1232  const label insertPatchi,
1233  const polyPatch& patch,
1234  const dictionary& patchFieldDict,
1235  const word& defaultPatchFieldType,
1236  const bool validBoundary
1237 )
1238 {
1239  const label sz = boundary_.size();
1240 
1241  label startFacei = nFaces();
1242  if (insertPatchi < sz)
1243  {
1244  startFacei = boundary_[insertPatchi].start();
1245  }
1246 
1247  // Create reordering list
1248  // patches before insert position stay as is
1249  // patches after insert position move one up
1250  labelList newToOld(boundary_.size()+1);
1251  for (label i = 0; i < insertPatchi; i++)
1252  {
1253  newToOld[i] = i;
1254  }
1255  for (label i = insertPatchi; i < sz; i++)
1256  {
1257  newToOld[i+1] = i;
1258  }
1259  newToOld[insertPatchi] = -1;
1260 
1261  reorderPatches(newToOld, false);
1262 
1263  // Clear local fields and e.g. polyMesh parallelInfo.
1264  //clearGeom(); // would clear out pointMesh as well
1265  boundary_.clearGeom();
1266  clearAddressing(true);
1267 
1268  // Clear all but RepatchableMeshObjects
1270  <
1271  polyMesh,
1274  >
1275  (
1276  *this
1277  );
1279  <
1280  pointMesh,
1283  >
1284  (
1285  *this
1286  );
1287 
1288 
1289  // Insert polyPatch
1290  boundary_.set
1291  (
1292  insertPatchi,
1293  patch.clone
1294  (
1295  boundary_,
1296  insertPatchi, // index
1297  0, // size
1298  startFacei // start
1299  )
1300  );
1301 
1302  if (validBoundary)
1303  {
1304  boundary_.topoChange();
1305  }
1306 
1307  // Warn mesh objects
1308  meshObjects::addPatch<polyMesh>(*this, insertPatchi);
1309  meshObjects::addPatch<pointMesh>(*this, insertPatchi);
1310 }
1311 
1312 
1314 {
1315  if (clearedPrimitives_)
1316  {
1318  << "points deallocated"
1319  << abort(FatalError);
1320  }
1321 
1322  return points_;
1323 }
1324 
1325 
1327 {
1328  if (clearedPrimitives_)
1329  {
1331  << "faces deallocated"
1332  << abort(FatalError);
1333  }
1334 
1335  return faces_;
1336 }
1337 
1338 
1340 {
1341  return owner_;
1342 }
1343 
1344 
1346 {
1347  return neighbour_;
1348 }
1349 
1350 
1352 {
1353  if (!moving_)
1354  {
1355  return points_;
1356  }
1357 
1358  if (oldPointsPtr_.empty())
1359  {
1361  << "Old points have not been stored"
1362  << exit(FatalError);
1363  }
1364 
1365  return oldPointsPtr_();
1366 }
1367 
1368 
1370 {
1371  storeOldCellCentres_ = true;
1372 
1373  if (!moving_)
1374  {
1375  return cellCentres();
1376  }
1377 
1378  if (oldCellCentresPtr_.empty())
1379  {
1381  << "Old cell centres have not been stored"
1382  << exit(FatalError);
1383  }
1384 
1385  return oldCellCentresPtr_();
1386 }
1387 
1388 
1390 {
1391  return io.upToDate(points_);
1392 }
1393 
1394 
1396 {
1397  io.eventNo() = points_.eventNo()+1;
1398 }
1399 
1400 
1402 {
1403  if (debug)
1404  {
1406  << "Set points for time " << time().value()
1407  << " index " << time().timeIndex() << endl;
1408  }
1409 
1411 
1412  points_ = newPoints;
1413 
1414  setPointsInstance(time().name());
1415 
1416  // Adjust parallel shared points
1417  if (globalMeshDataPtr_.valid())
1418  {
1419  globalMeshDataPtr_().movePoints(points_);
1420  }
1421 
1422  // Force recalculation of all geometric data with new points
1423 
1424  bounds_ = boundBox(points_);
1425  boundary_.movePoints(points_);
1426 
1427  pointZones_.movePoints(points_);
1428  faceZones_.movePoints(points_);
1429  cellZones_.movePoints(points_);
1430 
1431  // Cell tree might become invalid
1432  cellTreePtr_.clear();
1433 
1434  // Reset valid directions (could change with rotation)
1435  geometricD_ = Zero;
1436  solutionD_ = Zero;
1437 
1438  meshObjects::movePoints<polyMesh>(*this);
1439  meshObjects::movePoints<pointMesh>(*this);
1440 }
1441 
1442 
1444 (
1445  const pointField& newPoints
1446 )
1447 {
1448  if (debug)
1449  {
1451  << "Moving points for time " << time().value()
1452  << " index " << time().timeIndex() << endl;
1453  }
1454 
1455  // Pick up old points and cell centres
1456  if (curMotionTimeIndex_ != time().timeIndex())
1457  {
1458  oldPointsPtr_.clear();
1459  oldPointsPtr_.reset(new pointField(points_));
1460  if (storeOldCellCentres_)
1461  {
1462  oldCellCentresPtr_.clear();
1463  oldCellCentresPtr_.reset(new pointField(cellCentres()));
1464  }
1465  curMotionTimeIndex_ = time().timeIndex();
1466  }
1467 
1468  points_ = newPoints;
1469 
1470  setPointsInstance(time().name());
1471 
1473  (
1474  points_,
1475  oldPoints()
1476  );
1477 
1478  // Adjust parallel shared points
1479  if (globalMeshDataPtr_.valid())
1480  {
1481  globalMeshDataPtr_().movePoints(points_);
1482  }
1483 
1484  // Force recalculation of all geometric data with new points
1485 
1486  bounds_ = boundBox(points_);
1487  boundary_.movePoints(points_);
1488 
1489  pointZones_.movePoints(points_);
1490  faceZones_.movePoints(points_);
1491  cellZones_.movePoints(points_);
1492 
1493  // Cell tree might become invalid
1494  cellTreePtr_.clear();
1495 
1496  // Reset valid directions (could change with rotation)
1497  geometricD_ = Zero;
1498  solutionD_ = Zero;
1499 
1500  meshObjects::movePoints<polyMesh>(*this);
1501  meshObjects::movePoints<pointMesh>(*this);
1502 
1503  return sweptVols;
1504 }
1505 
1506 
1508 {
1509  curMotionTimeIndex_ = -1;
1510  oldPointsPtr_.clear();
1511  oldCellCentresPtr_.clear();
1512 }
1513 
1514 
1516 {
1517  if (globalMeshDataPtr_.empty())
1518  {
1519  if (debug)
1520  {
1521  Pout<< "polyMesh::globalData() const : "
1522  << "Constructing parallelData from processor topology"
1523  << endl;
1524  }
1525  // Construct globalMeshData using processorPatch information only.
1526  globalMeshDataPtr_.reset(new globalMeshData(*this));
1527  }
1528 
1529  return globalMeshDataPtr_();
1530 }
1531 
1532 
1534 {
1535  return comm_;
1536 }
1537 
1538 
1540 {
1541  return comm_;
1542 }
1543 
1544 
1545 void Foam::polyMesh::removeFiles(const fileName& instanceDir) const
1546 {
1547  fileName meshFilesPath = thisDb().time().path()/instanceDir/meshDir();
1548 
1549  rm(meshFilesPath/"points");
1550  rm(meshFilesPath/"faces");
1551  rm(meshFilesPath/"owner");
1552  rm(meshFilesPath/"neighbour");
1553  rm(meshFilesPath/"cells");
1554  rm(meshFilesPath/"boundary");
1555  rm(meshFilesPath/"pointZones");
1556  rm(meshFilesPath/"faceZones");
1557  rm(meshFilesPath/"cellZones");
1558  rm(meshFilesPath/"meshModifiers");
1559  rm(meshFilesPath/"parallelData");
1560 
1561  // remove subdirectories
1562  if (isDir(meshFilesPath/"sets"))
1563  {
1564  rmDir(meshFilesPath/"sets");
1565  }
1566 }
1567 
1568 
1570 {
1571  removeFiles(instance());
1572 }
1573 
1574 
1576 (
1577  const point& p,
1578  label& celli,
1579  label& tetFacei,
1580  label& tetPti
1581 ) const
1582 {
1583  celli = -1;
1584  tetFacei = -1;
1585  tetPti = -1;
1586 
1587  const indexedOctree<treeDataCell>& tree = cellTree();
1588 
1589  // Find point inside cell
1590  celli = tree.findInside(p);
1591 
1592  if (celli != -1)
1593  {
1594  // Check the nearest cell to see if the point is inside.
1595  findTetFacePt(celli, p, tetFacei, tetPti);
1596  }
1597 }
1598 
1599 
1601 (
1602  const label celli,
1603  const point& p,
1604  label& tetFacei,
1605  label& tetPti
1606 ) const
1607 {
1608  const polyMesh& mesh = *this;
1609 
1610  tetIndices tet(polyMeshTetDecomposition::findTet(mesh, celli, p));
1611  tetFacei = tet.face();
1612  tetPti = tet.tetPt();
1613 }
1614 
1615 
1617 (
1618  const point& p,
1619  label celli,
1620  const cellDecomposition decompMode
1621 ) const
1622 {
1623  switch (decompMode)
1624  {
1625  case FACE_PLANES:
1626  {
1627  return primitiveMesh::pointInCell(p, celli);
1628  }
1629  break;
1630 
1631  case FACE_CENTRE_TRIS:
1632  {
1633  // only test that point is on inside of plane defined by cell face
1634  // triangles
1635  const cell& cFaces = cells()[celli];
1636 
1637  forAll(cFaces, cFacei)
1638  {
1639  label facei = cFaces[cFacei];
1640  const face& f = faces_[facei];
1641  const point& fc = faceCentres()[facei];
1642  bool isOwn = (owner_[facei] == celli);
1643 
1644  forAll(f, fp)
1645  {
1646  label pointi;
1647  label nextPointi;
1648 
1649  if (isOwn)
1650  {
1651  pointi = f[fp];
1652  nextPointi = f.nextLabel(fp);
1653  }
1654  else
1655  {
1656  pointi = f.nextLabel(fp);
1657  nextPointi = f[fp];
1658  }
1659 
1660  triPointRef faceTri
1661  (
1662  points()[pointi],
1663  points()[nextPointi],
1664  fc
1665  );
1666 
1667  vector proj = p - faceTri.centre();
1668 
1669  if ((faceTri.area() & proj) > 0)
1670  {
1671  return false;
1672  }
1673  }
1674  }
1675  return true;
1676  }
1677  break;
1678 
1679  case FACE_DIAG_TRIS:
1680  {
1681  // only test that point is on inside of plane defined by cell face
1682  // triangles
1683  const cell& cFaces = cells()[celli];
1684 
1685  forAll(cFaces, cFacei)
1686  {
1687  label facei = cFaces[cFacei];
1688  const face& f = faces_[facei];
1689 
1690  for (label tetPti = 1; tetPti < f.size() - 1; tetPti++)
1691  {
1692  // Get tetIndices of face triangle
1693  tetIndices faceTetIs(celli, facei, tetPti);
1694 
1695  triPointRef faceTri = faceTetIs.faceTri(*this);
1696 
1697  vector proj = p - faceTri.centre();
1698 
1699  if ((faceTri.area() & proj) > 0)
1700  {
1701  return false;
1702  }
1703  }
1704  }
1705 
1706  return true;
1707  }
1708  break;
1709 
1710  case CELL_TETS:
1711  {
1712  label tetFacei;
1713  label tetPti;
1714 
1715  findTetFacePt(celli, p, tetFacei, tetPti);
1716 
1717  return tetFacei != -1;
1718  }
1719  break;
1720  }
1721 
1722  return false;
1723 }
1724 
1725 
1727 (
1728  const point& p,
1729  const cellDecomposition decompMode
1730 ) const
1731 {
1732  if
1733  (
1734  Pstream::parRun()
1735  && (decompMode == FACE_DIAG_TRIS || decompMode == CELL_TETS)
1736  )
1737  {
1738  // Force construction of face-diagonal decomposition before testing
1739  // for zero cells.
1740  //
1741  // If parallel running a local domain might have zero cells so never
1742  // construct the face-diagonal decomposition which uses parallel
1743  // transfers.
1744  (void)tetBasePtIs();
1745  }
1746 
1747  if (nCells() == 0)
1748  {
1749  return -1;
1750  }
1751 
1752  if (decompMode == CELL_TETS)
1753  {
1754  // Advanced search method utilising an octree
1755  // and tet-decomposition of the cells
1756 
1757  label celli;
1758  label tetFacei;
1759  label tetPti;
1760 
1761  findCellFacePt(p, celli, tetFacei, tetPti);
1762 
1763  return celli;
1764  }
1765  else
1766  {
1767  // Approximate search avoiding the construction of an octree
1768  // and cell decomposition
1769 
1770  // Find the nearest cell centre to this location
1771  label celli = findNearestCell(p);
1772 
1773  // If point is in the nearest cell return
1774  if (pointInCell(p, celli, decompMode))
1775  {
1776  return celli;
1777  }
1778  else
1779  {
1780  // Point is not in the nearest cell so search all cells
1781 
1782  for (label celli = 0; celli < nCells(); celli++)
1783  {
1784  if (pointInCell(p, celli, decompMode))
1785  {
1786  return celli;
1787  }
1788  }
1789 
1790  return -1;
1791  }
1792  }
1793 }
1794 
1795 
1796 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
A List of objects of type <Type> with automated input and output using a compact storage....
MeshObject types:
Definition: MeshObjects.H:67
static pointMesh & New(const word &name, const polyMesh &mesh)
Construct and return the named DemandDrivenMeshObject.
label size() const
Return number of elements in table.
Definition: HashTableI.H:65
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
fileName & instance() const
Return the instance directory, constant, system, <time> etc.
Definition: IOobject.C:355
const word & headerClassName() const
Return name of the class name read from header.
Definition: IOobject.H:316
writeOption
Enumeration defining the write options.
Definition: IOobject.H:126
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: PtrList.H:75
bool processorCase() const
Return true if this is a processor case.
Definition: TimePaths.H:88
virtual void topoChange(const polyTopoChangeMap &map)=0
Update topology using the given map.
Inter-processor communications stream.
Definition: UPstream.H:59
static bool & parRun()
Is this a parallel run?
Definition: UPstream.H:399
label size() const
Return the number of elements in the UPtrList.
Definition: UPtrListI.H:29
static const direction nComponents
Number of components in this vector space.
Definition: VectorSpace.H:105
Templated 3D Vector derived from VectorSpace adding construction from 3 components,...
Definition: Vector.H:60
bool readIfPresent()
Read zones if the zones file is present.
Definition: ZoneList.C:480
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A bounding box defined in terms of the points at its extremities.
Definition: boundBox.H:59
A cell is defined as a list of faces with extra functionality.
Definition: cell.H:60
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:76
A class for handling file names.
Definition: fileName.H:82
fileName path() const
Return directory path name (part before last /)
Definition: fileName.C:265
Various mesh related information for a parallel run. Upon construction, constructs all info using par...
label findInside(const point &) const
Find shape containing point. Only implemented for certain.
static void clearUpto(objectRegistry &)
Clear all meshObjects derived from FromType up to (but not including)
Registry of regIOobjects.
const Time & time() const
Return time.
virtual const fileName & dbDir() const
Local directory path of this objectRegistry relative to the time.
bool foundObject(const word &name) const
Is the named Type in registry.
Mesh representing a set of points created from polyMesh.
Definition: pointMesh.H:53
void reset()
Reset pointMesh with respect to the updated polyMesh.
Definition: pointMesh.C:190
Foam::polyBoundaryMesh.
void topoChange()
Correct polyBoundaryMesh after topology update.
void clearGeom()
Clear geometry at this level and at patches.
void clearAddressing()
Clear addressing at this level and at patches.
static labelList findFaceBasePts(const polyMesh &mesh, scalar tol=minTetQuality, bool report=false)
Find a suitable base point for each face for decomposition.
static tetIndices findTet(const polyMesh &mesh, label cI, const point &pt)
Find the tet decomposition of the cell containing the given point.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
virtual ~polyMesh()
Destructor.
Definition: polyMesh.C:937
void findCellFacePt(const point &p, label &celli, label &tetFacei, label &tetPti) const
Find the cell, tetFacei and tetPti for point p.
Definition: polyMesh.C:1576
const fileName & facesInstance() const
Return the current instance directory for faces.
Definition: polyMesh.C:971
label nGeometricD() const
Return the number of valid geometric dimensions in the mesh.
Definition: polyMesh.C:1000
static word defaultRegion
Return the default region name.
Definition: polyMesh.H:267
fileName meshDir() const
Return the local mesh directory (dbDir()/meshSubDir)
Definition: polyMesh.C:959
virtual tmp< scalarField > movePoints(const pointField &)
Move points, returns volumes swept by faces in motion.
Definition: polyMesh.C:1444
virtual void addPatch(const label insertPatchi, const polyPatch &patch, const dictionary &patchFieldDict, const word &defaultPatchFieldType, const bool validBoundary)
Add/insert single patch. If validBoundary the new situation.
Definition: polyMesh.C:1231
cellDecomposition
Enumeration defining the decomposition of the cell for.
Definition: polyMesh.H:100
IOobject::writeOption facesWriteOpt() const
Return the points write option.
Definition: polyMesh.C:983
virtual const faceList & faces() const
Return raw faces.
Definition: polyMesh.C:1326
virtual const fileName & dbDir() const
Override the objectRegistry dbDir for a single-region case.
Definition: polyMesh.C:946
label findCell(const point &p, const cellDecomposition=CELL_TETS) const
Find cell enclosing this location and return index.
Definition: polyMesh.C:1727
void resetPrimitives(pointField &&points, faceList &&faces, labelList &&owner, labelList &&neighbour, const labelList &patchSizes, const labelList &patchStarts, const bool validBoundary=true)
Reset mesh primitive data. Assumes all patch info correct.
Definition: polyMesh.C:703
virtual const labelList & faceOwner() const
Return face owner.
Definition: polyMesh.C:1339
const labelIOList & tetBasePtIs() const
Return the tetBasePtIs.
Definition: polyMesh.C:1023
void findTetFacePt(const label celli, const point &p, label &tetFacei, label &tetPti) const
Find the tetFacei and tetPti for point p in celli.
Definition: polyMesh.C:1601
const globalMeshData & globalData() const
Return parallel info.
Definition: polyMesh.C:1515
bool pointInCell(const point &p, label celli, const cellDecomposition=CELL_TETS) const
Test if point p is in the celli.
Definition: polyMesh.C:1617
label nSolutionD() const
Return the number of valid solved-for dimensions in the mesh.
Definition: polyMesh.C:1017
virtual const pointField & oldPoints() const
Return old points for mesh motion.
Definition: polyMesh.C:1351
void swap(polyMesh &)
Swap mesh.
Definition: polyMesh.C:804
const fileName & pointsInstance() const
Return the current instance directory for points.
Definition: polyMesh.C:965
label comm() const
Return communicator used for parallel communication.
Definition: polyMesh.C:1533
polyMesh(const IOobject &io)
Construct from IOobject.
Definition: polyMesh.C:162
void clearAddressing(const bool isMeshUpdate=false)
Clear addressing.
Definition: polyMeshClear.C:77
void resetMotion() const
Reset motion.
Definition: polyMesh.C:1507
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:404
virtual const labelList & faceNeighbour() const
Return face neighbour.
Definition: polyMesh.C:1345
void addPatches(const List< polyPatch * > &, const bool validBoundary=true)
Add boundary patches.
Definition: polyMesh.C:1084
bool upToDatePoints(const regIOobject &io) const
Return true if io is up-to-date with points.
Definition: polyMesh.C:1389
void addZones(const List< pointZone * > &pz, const List< faceZone * > &fz, const List< cellZone * > &cz)
Add mesh zones.
Definition: polyMesh.C:1128
virtual const pointField & points() const
Return raw points.
Definition: polyMesh.C:1313
void setUpToDatePoints(regIOobject &io) const
Set io to be up-to-date with points.
Definition: polyMesh.C:1395
const indexedOctree< treeDataCell > & cellTree() const
Return the cell search tree.
Definition: polyMesh.C:1057
IOobject::writeOption pointsWriteOpt() const
Return the points write option.
Definition: polyMesh.C:977
void removeFiles() const
Remove all files from mesh instance()
Definition: polyMesh.C:1569
virtual const pointField & oldCellCentres() const
Return old cell centres for mesh motion.
Definition: polyMesh.C:1369
virtual void reorderPatches(const labelUList &newToOld, const bool validBoundary)
Reorder and trim existing patches. If validBoundary the new.
Definition: polyMesh.C:1186
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
Definition: polyMesh.H:270
void setInstance(const fileName &)
Set the instance for mesh files.
Definition: polyMeshIO.C:78
virtual void setPoints(const pointField &)
Reset the points.
Definition: polyMesh.C:1401
const Vector< label > & solutionD() const
Return the vector of solved-for directions in mesh.
Definition: polyMesh.C:1006
const Vector< label > & geometricD() const
Return the vector of geometric directions in mesh.
Definition: polyMesh.C:989
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:70
virtual autoPtr< polyPatch > clone(const polyBoundaryMesh &bm) const
Construct and return a clone, resetting the boundary mesh.
Definition: polyPatch.H:215
Cell-face mesh analysis engine.
Definition: primitiveMesh.H:75
label nCells() const
label nPoints() const
bool pointInCell(const point &p, label celli) const
Return true if the point is in the cell.
void clearGeom()
Clear geometry.
tmp< scalarField > movePoints(const pointField &p, const pointField &oldP)
Move points, returns volumes swept by faces in motion.
const vectorField & faceAreas() const
const cellList & cells() const
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:55
bool upToDate(const regIOobject &) const
Return true if up-to-date with respect to given object.
Definition: regIOobject.C:329
virtual bool write(const bool write=true) const
Write using setting from DB.
label eventNo() const
Event number at last update.
Definition: regIOobjectI.H:89
Storage and named access for the indices of a tet which is part of the decomposition of a cell.
Definition: tetIndices.H:82
label face() const
Return the face.
Definition: tetIndicesI.H:43
label tetPt() const
Return the characterising tetPtI.
Definition: tetIndicesI.H:55
triPointRef faceTri(const polyMesh &mesh) const
Return the geometry corresponding to the tri on the face for.
Definition: tetIndicesI.H:123
A class for managing temporary objects.
Definition: tmp.H:55
Standard boundBox + extra functionality for use in octree.
Definition: treeBoundBox.H:90
Encapsulation of data needed to search in/for cells. Used to find the cell containing a point (e....
Definition: treeDataCell.H:55
A triangle primitive used to calculate face areas and swept volumes.
Definition: triangle.H:80
vector area() const
Return vector area.
Definition: triangleI.H:96
Point centre() const
Return centre (centroid)
Definition: triangleI.H:89
A class for handling words, derived from string.
Definition: word.H:62
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
label patchi
const pointField & points
label nPoints
const cellShapeList & cells
const fvPatchList & patches
#define WarningInFunction
Report a warning using Foam::Warning.
#define InfoInFunction
Report an information message using Foam::Info.
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
static const zero Zero
Definition: zero.H:97
const doubleScalar e
Definition: doubleScalar.H:106
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
bool rm(const fileName &)
Remove a file, returning true if successful otherwise false.
Definition: POSIX.C:1017
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:257
word name(const bool)
Return a word representation of a bool.
Definition: boolIO.C:39
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
errorManip< error > abort(error &err)
Definition: errorManip.H:131
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:42
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:49
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
bool notNull(const T &t)
Return true if t is not a reference to the nullObject of type T.
Definition: nullObjectI.H:64
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
dimensioned< scalar > mag(const dimensioned< Type > &)
bool rmDir(const fileName &)
Remove a directory and its contents.
Definition: POSIX.C:1047
defineTypeNameAndDebug(combustionModel, 0)
T clone(const T &t)
Definition: List.H:55
bool isDir(const fileName &, const bool followLink=true)
Does the name exist as a directory in the file system?
Definition: POSIX.C:539
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
IOList< label > labelIOList
Label container classes.
Definition: labelIOList.H:42
dimensionSet cmptMag(const dimensionSet &)
Definition: dimensionSet.C:296
prefixOSstream Pout(cout, "Pout")
Definition: IOstreams.H:53
error FatalError
Cmpt cmptSum(const VectorSpace< Form, Cmpt, Ncmpts > &vs)
Definition: VectorSpaceI.H:507
uint8_t direction
Definition: direction.H:45
label timeIndex
Definition: getTimeIndex.H:4
labelList f(nPoints)
volScalarField & p