polyMeshFromShapeMesh.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-2016, 2020 OpenFOAM Foundation
9  Copyright (C) 2018-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 "polyMesh.H"
30 #include "Time.H"
31 #include "primitiveMesh.H"
32 #include "DynamicList.H"
33 #include "indexedOctree.H"
34 #include "treeDataCell.H"
35 #include "globalMeshData.H"
36 
37 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
38 
39 Foam::labelListList Foam::polyMesh::cellShapePointCells
40 (
41  const cellShapeList& c
42 ) const
43 {
44  List<DynamicList<label>> pc(points().size());
45 
46  // For each cell
47  forAll(c, i)
48  {
49  // For each vertex
50  const labelList& labels = c[i];
51 
52  forAll(labels, j)
53  {
54  // Set working point label
55  label curPoint = labels[j];
56  DynamicList<label>& curPointCells = pc[curPoint];
57 
58  // Enter the cell label in the point's cell list
59  curPointCells.append(i);
60  }
61  }
62 
63  labelListList pointCellAddr(pc.size());
64 
65  forAll(pc, pointi)
66  {
67  pointCellAddr[pointi].transfer(pc[pointi]);
68  }
69 
70  return pointCellAddr;
71 }
72 
73 
74 Foam::labelList Foam::polyMesh::facePatchFaceCells
75 (
76  const faceList& patchFaces,
77  const labelListList& pointCells,
78  const faceListList& cellsFaceShapes,
79  const label patchID
80 ) const
81 {
82  bool found;
83 
84  labelList FaceCells(patchFaces.size());
85 
86  forAll(patchFaces, fI)
87  {
88  found = false;
89 
90  const face& curFace = patchFaces[fI];
91  const labelList& facePoints = patchFaces[fI];
92 
93  forAll(facePoints, pointi)
94  {
95  const labelList& facePointCells = pointCells[facePoints[pointi]];
96 
97  forAll(facePointCells, celli)
98  {
99  faceList cellFaces = cellsFaceShapes[facePointCells[celli]];
100 
101  forAll(cellFaces, cellFace)
102  {
103  if (face::sameVertices(cellFaces[cellFace], curFace))
104  {
105  // Found the cell corresponding to this face
106  FaceCells[fI] = facePointCells[celli];
107 
108  found = true;
109  }
110  if (found) break;
111  }
112  if (found) break;
113  }
114  if (found) break;
115  }
116 
117  if (!found)
118  {
120  << "face " << fI << " in patch " << patchID
121  << " vertices " << UIndirectList<point>(points(), curFace)
122  << " does not have neighbour cell"
123  << " face: " << patchFaces[fI]
124  << abort(FatalError);
125  }
126  }
127 
128  return FaceCells;
129 }
130 
131 
132 void Foam::polyMesh::setTopology
133 (
134  const cellShapeList& cellsAsShapes,
135  const faceListList& boundaryFaces,
136  const wordList& boundaryPatchNames,
137  labelList& patchSizes,
138  labelList& patchStarts,
139  label& defaultPatchStart,
140  label& nFaces,
141  cellList& cells
142 )
143 {
144  // Calculate the faces of all cells
145  // Initialise maximum possible number of mesh faces to 0
146  label maxFaces = 0;
147 
148  // Set up a list of face shapes for each cell
149  faceListList cellsFaceShapes(cellsAsShapes.size());
150  cells.setSize(cellsAsShapes.size());
151 
152  forAll(cellsFaceShapes, celli)
153  {
154  cellsFaceShapes[celli] = cellsAsShapes[celli].faces();
155 
156  cells[celli].setSize(cellsFaceShapes[celli].size());
157 
158  // Initialise cells to -1 to flag undefined faces
159  static_cast<labelList&>(cells[celli]) = -1;
160 
161  // Count maximum possible number of mesh faces
162  maxFaces += cellsFaceShapes[celli].size();
163  }
164 
165  // Set size of faces array to maximum possible number of mesh faces
166  faces_.setSize(maxFaces);
167 
168  // Initialise number of faces to 0
169  nFaces = 0;
170 
171  // Set reference to point-cell addressing
172  labelListList PointCells = cellShapePointCells(cellsAsShapes);
173 
174  bool found = false;
175 
176  forAll(cells, celli)
177  {
178  // Note:
179  // Insertion cannot be done in one go as the faces need to be
180  // added into the list in the increasing order of neighbour
181  // cells. Therefore, all neighbours will be detected first
182  // and then added in the correct order.
183 
184  const faceList& curFaces = cellsFaceShapes[celli];
185 
186  // Record the neighbour cell
187  labelList neiCells(curFaces.size(), -1);
188 
189  // Record the face of neighbour cell
190  labelList faceOfNeiCell(curFaces.size(), -1);
191 
192  label nNeighbours = 0;
193 
194  // For all faces ...
195  forAll(curFaces, facei)
196  {
197  // Skip faces that have already been matched
198  if (cells[celli][facei] >= 0) continue;
199 
200  found = false;
201 
202  const face& curFace = curFaces[facei];
203 
204  // Get the list of labels
205  const labelList& curPoints = curFace;
206 
207  // For all points
208  forAll(curPoints, pointi)
209  {
210  // Get the list of cells sharing this point
211  const labelList& curNeighbours =
212  PointCells[curPoints[pointi]];
213 
214  // For all neighbours
215  forAll(curNeighbours, neiI)
216  {
217  label curNei = curNeighbours[neiI];
218 
219  // Reject neighbours with the lower label
220  if (curNei > celli)
221  {
222  // Get the list of search faces
223  const faceList& searchFaces = cellsFaceShapes[curNei];
224 
225  forAll(searchFaces, neiFacei)
226  {
227  if (searchFaces[neiFacei] == curFace)
228  {
229  // Match!!
230  found = true;
231 
232  // Record the neighbour cell and face
233  neiCells[facei] = curNei;
234  faceOfNeiCell[facei] = neiFacei;
235  nNeighbours++;
236 
237  break;
238  }
239  }
240  if (found) break;
241  }
242  if (found) break;
243  }
244  if (found) break;
245  } // End of current points
246  } // End of current faces
247 
248  // Add the faces in the increasing order of neighbours
249  for (label neiSearch = 0; neiSearch < nNeighbours; neiSearch++)
250  {
251  // Find the lowest neighbour which is still valid
252  label nextNei = -1;
253  label minNei = cells.size();
254 
255  forAll(neiCells, ncI)
256  {
257  if (neiCells[ncI] > -1 && neiCells[ncI] < minNei)
258  {
259  nextNei = ncI;
260  minNei = neiCells[ncI];
261  }
262  }
263 
264  if (nextNei > -1)
265  {
266  // Add the face to the list of faces
267  faces_[nFaces] = curFaces[nextNei];
268 
269  // Set cell-face and cell-neighbour-face to current face label
270  cells[celli][nextNei] = nFaces;
271  cells[neiCells[nextNei]][faceOfNeiCell[nextNei]] = nFaces;
272 
273  // Stop the neighbour from being used again
274  neiCells[nextNei] = -1;
275 
276  // Increment number of faces counter
277  nFaces++;
278  }
279  else
280  {
282  << "Error in internal face insertion"
283  << abort(FatalError);
284  }
285  }
286  }
287 
288  // Do boundary faces
289  const label nInternalFaces = nFaces;
290 
291  patchSizes.setSize(boundaryFaces.size(), -1);
292  patchStarts.setSize(boundaryFaces.size(), -1);
293 
294  forAll(boundaryFaces, patchi)
295  {
296  const faceList& patchFaces = boundaryFaces[patchi];
297 
298  labelList curPatchFaceCells =
299  facePatchFaceCells
300  (
301  patchFaces,
302  PointCells,
303  cellsFaceShapes,
304  patchi
305  );
306 
307  // Grab the start label
308  label curPatchStart = nFaces;
309 
310  // Suppress multiple warnings per patch
311  bool patchWarned = false;
312 
313  forAll(patchFaces, facei)
314  {
315  const face& curFace = patchFaces[facei];
316 
317  const label cellInside = curPatchFaceCells[facei];
318 
319  // Get faces of the cell inside
320  const faceList& facesOfCellInside = cellsFaceShapes[cellInside];
321 
322  bool found = false;
323 
324  forAll(facesOfCellInside, cellFacei)
325  {
326  if (face::sameVertices(facesOfCellInside[cellFacei], curFace))
327  {
328  found = true;
329 
330  const label meshFacei = cells[cellInside][cellFacei];
331 
332  if (meshFacei >= 0)
333  {
334  // Already have mesh face for this side of the
335  // cellshape. This can happen for duplicate faces.
336  // It might be
337  // an error or explicitly desired (e.g. duplicate
338  // baffles or acmi). We could have a special 7-faced
339  // hex shape instead so we can have additional patches
340  // but that would be unworkable.
341  // So now either
342  // - exit with error
343  // - or warn and append face to addressing
344  // Note that duplicate baffles
345  // - cannot be on an internal faces
346  // - cannot be on the same patch (for now?)
347 
348  if
349  (
350  meshFacei < nInternalFaces
351  || meshFacei >= curPatchStart
352  )
353  {
355  << "Trying to specify a boundary face "
356  << curFace
357  << " on the face on cell " << cellInside
358  << " which is either an internal face"
359  << " or already belongs to the same patch."
360  << " This is face " << facei << " of patch "
361  << patchi << " named "
362  << boundaryPatchNames[patchi] << "."
363  << exit(FatalError);
364  }
365 
366 
367  if (!patchWarned)
368  {
370  << "Trying to specify a boundary face "
371  << curFace
372  << " on the face on cell " << cellInside
373  << " which is either an internal face"
374  << " or already belongs to some other patch."
375  << " This is face " << facei << " of patch "
376  << patchi << " named "
377  << boundaryPatchNames[patchi] << "."
378  //<< abort(FatalError);
379  << endl;
380  patchWarned = true;
381  }
382 
383  faces_.setSize(faces_.size()+1);
384 
385  // Set the patch face to corresponding cell-face
386  faces_[nFaces] = facesOfCellInside[cellFacei];
387 
388  cells[cellInside].append(nFaces);
389  }
390  else
391  {
392  // Set the patch face to corresponding cell-face
393  faces_[nFaces] = facesOfCellInside[cellFacei];
394 
395  cells[cellInside][cellFacei] = nFaces;
396  }
397 
398  break;
399  }
400  }
401 
402  if (!found)
403  {
405  << "face " << facei << " of patch " << patchi
406  << " does not seem to belong to cell " << cellInside
407  << " which, according to the addressing, "
408  << "should be next to it."
409  << abort(FatalError);
410  }
411 
412  // Increment the counter of faces
413  nFaces++;
414  }
415 
416  patchSizes[patchi] = nFaces - curPatchStart;
417  patchStarts[patchi] = curPatchStart;
418  }
419 
420  // Grab "non-existing" faces and put them into a default patch
421 
422  defaultPatchStart = nFaces;
423 
424  forAll(cells, celli)
425  {
426  labelList& curCellFaces = cells[celli];
427 
428  forAll(curCellFaces, facei)
429  {
430  if (curCellFaces[facei] == -1) // "non-existent" face
431  {
432  curCellFaces[facei] = nFaces;
433  faces_[nFaces] = cellsFaceShapes[celli][facei];
434 
435  nFaces++;
436  }
437  }
438  }
440  // Reset the size of the face list
441  faces_.setSize(nFaces);
442 }
443 
444 
445 Foam::polyMesh::polyMesh
446 (
447  const IOobject& io,
448  pointField&& points,
449  const cellShapeList& cellsAsShapes,
450  const faceListList& boundaryFaces,
451  const wordList& boundaryPatchNames,
452  const wordList& boundaryPatchTypes,
453  const word& defaultBoundaryPatchName,
454  const word& defaultBoundaryPatchType,
455  const wordList& boundaryPatchPhysicalTypes,
456  const bool syncPar
457 )
458 :
460  primitiveMesh(),
461  points_
462  (
463  IOobject
464  (
465  "points",
466  instance(),
467  meshSubDir,
468  *this,
469  IOobject::NO_READ,
470  IOobject::AUTO_WRITE
471  ),
472  std::move(points)
473  ),
474  faces_
475  (
476  IOobject
477  (
478  "faces",
479  instance(),
480  meshSubDir,
481  *this,
482  IOobject::NO_READ,
483  IOobject::AUTO_WRITE
484  ),
485  0
486  ),
487  owner_
488  (
489  IOobject
490  (
491  "owner",
492  instance(),
493  meshSubDir,
494  *this,
495  IOobject::NO_READ,
496  IOobject::AUTO_WRITE
497  ),
498  0
499  ),
500  neighbour_
501  (
502  IOobject
503  (
504  "neighbour",
505  instance(),
506  meshSubDir,
507  *this,
508  IOobject::NO_READ,
509  IOobject::AUTO_WRITE
510  ),
511  0
512  ),
513  clearedPrimitives_(false),
514  boundary_
515  (
516  IOobject
517  (
518  "boundary",
519  instance(),
520  meshSubDir,
521  *this,
522  IOobject::NO_READ,
523  IOobject::AUTO_WRITE
524  ),
525  *this,
526  boundaryFaces.size() + 1 // Add room for a default patch
527  ),
528  bounds_(points_, syncPar),
529  comm_(UPstream::worldComm),
530  geometricD_(Zero),
531  solutionD_(Zero),
532  tetBasePtIsPtr_(nullptr),
533  cellTreePtr_(nullptr),
534  pointZones_
535  (
536  IOobject
537  (
538  "pointZones",
539  instance(),
540  meshSubDir,
541  *this,
542  IOobject::NO_READ,
543  IOobject::NO_WRITE
544  ),
545  *this,
546  0
547  ),
548  faceZones_
549  (
550  IOobject
551  (
552  "faceZones",
553  instance(),
554  meshSubDir,
555  *this,
556  IOobject::NO_READ,
557  IOobject::NO_WRITE
558  ),
559  *this,
560  0
561  ),
562  cellZones_
563  (
564  IOobject
565  (
566  "cellZones",
567  instance(),
568  meshSubDir,
569  *this,
570  IOobject::NO_READ,
571  IOobject::NO_WRITE
572  ),
573  *this,
574  0
575  ),
576  globalMeshDataPtr_(nullptr),
577  moving_(false),
578  topoChanging_(false),
579  storeOldCellCentres_(false),
580  curMotionTimeIndex_(time().timeIndex()),
581  oldPointsPtr_(nullptr),
582  oldCellCentresPtr_(nullptr)
583 {
584  DebugInfo
585  << "Constructing polyMesh from cell and boundary shapes." << endl;
586 
587  // Calculate faces and cells
588  labelList patchSizes;
589  labelList patchStarts;
590  label defaultPatchStart;
591  label nFaces;
592  cellList cells;
593  setTopology
594  (
595  cellsAsShapes,
596  boundaryFaces,
597  boundaryPatchNames,
598  patchSizes,
599  patchStarts,
600  defaultPatchStart,
601  nFaces,
602  cells
603  );
604 
605  // Warning: Patches can only be added once the face list is
606  // completed, as they hold a subList of the face list
607  forAll(boundaryFaces, patchi)
608  {
609  // Add the patch to the list
610  boundary_.set
611  (
612  patchi,
614  (
615  boundaryPatchTypes[patchi],
616  boundaryPatchNames[patchi],
617  patchSizes[patchi],
618  patchStarts[patchi],
619  patchi,
620  boundary_
621  )
622  );
623 
624  if
625  (
626  boundaryPatchPhysicalTypes.size()
627  && boundaryPatchPhysicalTypes[patchi].size()
628  )
629  {
630  boundary_[patchi].physicalType() =
631  boundaryPatchPhysicalTypes[patchi];
632  }
633  }
634 
635  label nAllPatches = boundaryFaces.size();
636 
637  label nDefaultFaces = nFaces - defaultPatchStart;
638  if (syncPar)
639  {
640  reduce(nDefaultFaces, sumOp<label>());
641  }
642 
643  if (nDefaultFaces > 0)
644  {
646  << "Found " << nDefaultFaces
647  << " undefined faces in mesh; adding to default patch "
648  << defaultBoundaryPatchName << endl;
649 
650  // Check if there already exists a defaultFaces patch as last patch
651  // and reuse it.
652  label patchi = boundaryPatchNames.find(defaultBoundaryPatchName);
653 
654  if (patchi != -1)
655  {
656  if (patchi != boundaryFaces.size()-1 || boundary_[patchi].size())
657  {
659  << "Default patch " << boundary_[patchi].name()
660  << " already has faces in it or is not"
661  << " last in list of patches." << exit(FatalError);
662  }
663 
665  << "Reusing existing patch " << patchi
666  << " for undefined faces." << endl;
667 
668  boundary_.set
669  (
670  patchi,
672  (
673  boundaryPatchTypes[patchi],
674  boundaryPatchNames[patchi],
675  nFaces - defaultPatchStart,
676  defaultPatchStart,
677  patchi,
678  boundary_
679  )
680  );
681  }
682  else
683  {
684  boundary_.set
685  (
686  nAllPatches,
688  (
689  defaultBoundaryPatchType,
690  defaultBoundaryPatchName,
691  nFaces - defaultPatchStart,
692  defaultPatchStart,
693  boundary_.size() - 1,
694  boundary_
695  )
696  );
697 
698  nAllPatches++;
699  }
700  }
701 
702  // Reset the size of the boundary
703  boundary_.setSize(nAllPatches);
704 
705  // Set the primitive mesh
706  initMesh(cells);
707 
708  if (syncPar)
709  {
710  // Calculate topology for the patches (processor-processor comms etc.)
711  boundary_.updateMesh();
712 
713  // Calculate the geometry for the patches (transformation tensors etc.)
714  boundary_.calcGeometry();
715  }
716 
717  if (debug)
718  {
719  if (checkMesh())
720  {
721  Info<< "Mesh OK" << endl;
722  }
723  }
724 }
725 
726 
727 Foam::polyMesh::polyMesh
728 (
729  const IOobject& io,
730  pointField&& points,
731  const cellShapeList& cellsAsShapes,
732  const faceListList& boundaryFaces,
733  const wordList& boundaryPatchNames,
734  const PtrList<dictionary>& boundaryDicts,
735  const word& defaultBoundaryPatchName,
736  const word& defaultBoundaryPatchType,
737  const bool syncPar
738 )
739 :
740  objectRegistry(io),
741  primitiveMesh(),
742  points_
743  (
744  IOobject
745  (
746  "points",
747  instance(),
748  meshSubDir,
749  *this,
750  IOobject::NO_READ,
751  IOobject::AUTO_WRITE
752  ),
753  std::move(points)
754  ),
755  faces_
756  (
757  IOobject
758  (
759  "faces",
760  instance(),
761  meshSubDir,
762  *this,
763  IOobject::NO_READ,
764  IOobject::AUTO_WRITE
765  ),
766  0
767  ),
768  owner_
769  (
770  IOobject
771  (
772  "owner",
773  instance(),
774  meshSubDir,
775  *this,
776  IOobject::NO_READ,
777  IOobject::AUTO_WRITE
778  ),
779  0
780  ),
781  neighbour_
782  (
783  IOobject
784  (
785  "neighbour",
786  instance(),
787  meshSubDir,
788  *this,
789  IOobject::NO_READ,
790  IOobject::AUTO_WRITE
791  ),
792  0
793  ),
794  clearedPrimitives_(false),
795  boundary_
796  (
797  IOobject
798  (
799  "boundary",
800  instance(),
801  meshSubDir,
802  *this,
803  IOobject::NO_READ,
804  IOobject::AUTO_WRITE
805  ),
806  *this,
807  boundaryFaces.size() + 1 // Add room for a default patch
808  ),
809  bounds_(points_, syncPar),
810  comm_(UPstream::worldComm),
811  geometricD_(Zero),
812  solutionD_(Zero),
813  tetBasePtIsPtr_(nullptr),
814  cellTreePtr_(nullptr),
815  pointZones_
816  (
817  IOobject
818  (
819  "pointZones",
820  instance(),
821  meshSubDir,
822  *this,
823  IOobject::NO_READ,
824  IOobject::NO_WRITE
825  ),
826  *this,
827  0
828  ),
829  faceZones_
830  (
831  IOobject
832  (
833  "faceZones",
834  instance(),
835  meshSubDir,
836  *this,
837  IOobject::NO_READ,
838  IOobject::NO_WRITE
839  ),
840  *this,
841  0
842  ),
843  cellZones_
844  (
845  IOobject
846  (
847  "cellZones",
848  instance(),
849  meshSubDir,
850  *this,
851  IOobject::NO_READ,
852  IOobject::NO_WRITE
853  ),
854  *this,
855  0
856  ),
857  globalMeshDataPtr_(nullptr),
858  moving_(false),
859  topoChanging_(false),
860  storeOldCellCentres_(false),
861  curMotionTimeIndex_(time().timeIndex()),
862  oldPointsPtr_(nullptr),
863  oldCellCentresPtr_(nullptr)
864 {
865  DebugInfo
866  << "Constructing polyMesh from cell and boundary shapes." << endl;
867 
868  // Calculate faces and cells
869  labelList patchSizes;
870  labelList patchStarts;
871  label defaultPatchStart;
872  label nFaces;
873  cellList cells;
874  setTopology
875  (
876  cellsAsShapes,
877  boundaryFaces,
878  boundaryPatchNames,
879  patchSizes,
880  patchStarts,
881  defaultPatchStart,
882  nFaces,
883  cells
884  );
885 
886  // Warning: Patches can only be added once the face list is
887  // completed, as they hold a subList of the face list
888  forAll(boundaryDicts, patchi)
889  {
890  dictionary patchDict(boundaryDicts[patchi]);
891 
892  patchDict.set("nFaces", patchSizes[patchi]);
893  patchDict.set("startFace", patchStarts[patchi]);
894 
895  // Add the patch to the list
896  boundary_.set
897  (
898  patchi,
900  (
901  boundaryPatchNames[patchi],
902  patchDict,
903  patchi,
904  boundary_
905  )
906  );
907  }
908 
909  label nAllPatches = boundaryFaces.size();
910 
911  label nDefaultFaces = nFaces - defaultPatchStart;
912  if (syncPar)
913  {
914  reduce(nDefaultFaces, sumOp<label>());
915  }
916 
917  if (nDefaultFaces > 0)
918  {
920  << "Found " << nDefaultFaces
921  << " undefined faces in mesh; adding to default patch "
922  << defaultBoundaryPatchName << endl;
923 
924  // Check if there already exists a defaultFaces patch as last patch
925  // and reuse it.
926  label patchi = boundaryPatchNames.find(defaultBoundaryPatchName);
927 
928  if (patchi != -1)
929  {
930  if (patchi != boundaryFaces.size()-1 || boundary_[patchi].size())
931  {
933  << "Default patch " << boundary_[patchi].name()
934  << " already has faces in it or is not"
935  << " last in list of patches." << exit(FatalError);
936  }
937 
939  << "Reusing existing patch " << patchi
940  << " for undefined faces." << endl;
941 
942  boundary_.set
943  (
944  patchi,
946  (
947  boundary_[patchi].type(),
948  boundary_[patchi].name(),
949  nFaces - defaultPatchStart,
950  defaultPatchStart,
951  patchi,
952  boundary_
953  )
954  );
955  }
956  else
957  {
958  boundary_.set
959  (
960  nAllPatches,
962  (
963  defaultBoundaryPatchType,
964  defaultBoundaryPatchName,
965  nFaces - defaultPatchStart,
966  defaultPatchStart,
967  boundary_.size() - 1,
968  boundary_
969  )
970  );
971 
972  nAllPatches++;
973  }
974  }
975 
976  // Reset the size of the boundary
977  boundary_.setSize(nAllPatches);
978 
979  // Set the primitive mesh
980  initMesh(cells);
981 
982  if (syncPar)
983  {
984  // Calculate topology for the patches (processor-processor comms etc.)
985  boundary_.updateMesh();
986 
987  // Calculate the geometry for the patches (transformation tensors etc.)
988  boundary_.calcGeometry();
989  }
990 
991  if (debug)
992  {
993  if (checkMesh())
994  {
995  Info<< "Mesh OK" << endl;
996  }
997  }
998 }
999 
1000 
1001 // ************************************************************************* //
List< labelList > labelListList
A List of labelList.
Definition: labelList.H:51
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:118
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
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
void append(const T &val)
Append an element at the end of the list.
Definition: List.H:491
label find(const T &val, label pos=0) const
Find index of the first occurrence of the value.
Definition: UList.C:204
const word & name() const noexcept
Return the object name.
Definition: IOobjectI.H:150
Cell-face mesh analysis engine.
Definition: primitiveMesh.H:75
List< face > faceList
A List of faces.
Definition: faceListFwd.H:41
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:487
label size() const noexcept
The number of elements in table.
Definition: HashTableI.H:45
const cellList & cells() const
label nFaces() const noexcept
Number of mesh faces.
List< faceList > faceListList
A List of faceList.
Definition: faceListFwd.H:43
virtual const pointField & points() const
Return raw points.
Definition: polyMesh.C:1066
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:413
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: POSIX.C:752
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:38
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
void setSize(const label n)
Alias for resize()
Definition: List.H:289
List< cellShape > cellShapeList
List of cellShapes and PtrList of List of cellShape.
Definition: cellShapeList.H:39
const cellShapeList & cells
const pointField & points
A class for handling words, derived from Foam::string.
Definition: word.H:63
label size() const noexcept
The number of elements in the list.
Definition: UPtrListI.H:99
virtual bool checkMesh(const bool report=false) const
Check mesh for correctness. Returns false for no error.
errorManip< error > abort(error &err)
Definition: errorManip.H:139
const T * set(const label i) const
Return const pointer to element (can be nullptr), or nullptr for out-of-range access (ie...
Definition: PtrList.H:163
#define DebugInfo
Report an information message using Foam::Info.
int debug
Static debugging option.
void updateMesh()
Correct polyBoundaryMesh after topology update.
void setSize(const label newLen)
Same as resize()
Definition: PtrList.H:183
Info<< "Creating cells"<< endl;cellShapes=b.shapes();Info<< "Creating boundary faces"<< endl;boundary.setSize(b.boundaryPatches().size());forAll(boundary, patchi) { faceList faces(b.boundaryPatches()[patchi].size());forAll(faces, facei) { faces[facei]=face(b.boundaryPatches()[patchi][facei]);} boundary[patchi].transfer(faces);} points.transfer(const_cast< pointField & >b.points()));}Info<< "Creating patch dictionaries"<< endl;wordList patchNames(boundary.size());forAll(patchNames, patchi){ patchNames[patchi]=polyPatch::defaultName(patchi);}PtrList< dictionary > boundaryDicts(boundary.size())
List< word > wordList
A List of words.
Definition: fileName.H:58
#define WarningInFunction
Report a warning using Foam::Warning.
const dimensionedScalar c
Speed of light in a vacuum.
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
Reduce inplace (cf. MPI Allreduce) using specified communication schedule.
messageStream Info
Information stream (stdout output on master, null elsewhere)
static autoPtr< polyPatch > New(const word &patchType, const word &name, const label size, const label start, const label index, const polyBoundaryMesh &bm)
Return pointer to a new patch created on freestore from components.
Definition: polyPatchNew.C:28
List< label > labelList
A List of labels.
Definition: List.H:62
Registry of regIOobjects.
static bool sameVertices(const face &a, const face &b)
True if the faces have all the same vertices.
Definition: face.C:374
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:166
bool found
List< cell > cellList
A List of cells.
Definition: cellListFwd.H:41
Inter-processor communications stream.
Definition: UPstream.H:54
label timeIndex
Definition: getTimeIndex.H:24
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:157