createShellMesh.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 "createShellMesh.H"
27 #include "polyTopoChange.H"
28 #include "meshTools.H"
29 #include "polyTopoChangeMap.H"
30 #include "labelPair.H"
31 #include "indirectPrimitivePatch.H"
32 #include "distributionMap.H"
33 #include "globalMeshData.H"
34 #include "PatchTools.H"
35 #include "globalIndex.H"
36 
37 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
38 
39 namespace Foam
40 {
42 
43 template<>
45 {
46 public:
47  void operator()(labelPair& x, const labelPair& y) const
48  {
49  x[0] = min(x[0], y[0]);
50  x[1] = min(x[1], y[1]);
51  }
52 };
53 }
54 
55 
56 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
57 
58 // Synchronise edges
59 void Foam::createShellMesh::syncEdges
60 (
61  const globalMeshData& globalData,
62 
63  const labelList& patchEdges,
64  const labelList& coupledEdges,
65  const PackedBoolList& sameEdgeOrientation,
66  const bool syncNonCollocated,
67 
68  PackedBoolList& isChangedEdge,
69  DynamicList<label>& changedEdges,
70  labelPairList& allEdgeData
71 )
72 {
73  const distributionMap& map = globalData.globalEdgeSlavesMap();
74  const PackedBoolList& cppOrientation = globalData.globalEdgeOrientation();
75 
76  // Convert patch-edge data into cpp-edge data
77  labelPairList cppEdgeData
78  (
79  map.constructSize(),
81  );
82 
83  forAll(patchEdges, i)
84  {
85  label patchEdgeI = patchEdges[i];
86  label coupledEdgeI = coupledEdges[i];
87 
88  if (isChangedEdge[patchEdgeI])
89  {
90  const labelPair& data = allEdgeData[patchEdgeI];
91 
92  // Patch-edge data needs to be converted into coupled-edge data
93  // (optionally flipped) and consistent in orientation with
94  // other coupled edge (optionally flipped)
95  if (sameEdgeOrientation[i] == cppOrientation[coupledEdgeI])
96  {
97  cppEdgeData[coupledEdgeI] = data;
98  }
99  else
100  {
101  cppEdgeData[coupledEdgeI] = labelPair(data[1], data[0]);
102  }
103  }
104  }
105 
106  // Synchronise
107  globalData.syncData
108  (
109  cppEdgeData,
110  globalData.globalEdgeSlaves(),
111  (
112  syncNonCollocated
113  ? globalData.globalEdgeTransformedSlaves()
114  : labelListList(globalData.globalEdgeSlaves().size())
115  ),
116  map,
117  minEqOp<labelPair>()
118  );
119 
120  // Back from cpp-edge to patch-edge data
121  forAll(patchEdges, i)
122  {
123  label patchEdgeI = patchEdges[i];
124  label coupledEdgeI = coupledEdges[i];
125 
126  if (cppEdgeData[coupledEdgeI] != labelPair(labelMax, labelMax))
127  {
128  const labelPair& data = cppEdgeData[coupledEdgeI];
129 
130  if (sameEdgeOrientation[i] == cppOrientation[coupledEdgeI])
131  {
132  allEdgeData[patchEdgeI] = data;
133  }
134  else
135  {
136  allEdgeData[patchEdgeI] = labelPair(data[1], data[0]);
137  }
138 
139  if (!isChangedEdge[patchEdgeI])
140  {
141  changedEdges.append(patchEdgeI);
142  isChangedEdge[patchEdgeI] = true;
143  }
144  }
145  }
146 }
147 
148 
150 (
151  const globalMeshData& globalData,
152  const primitiveFacePatch& patch,
153  const PackedBoolList& nonManifoldEdge,
154  const bool syncNonCollocated,
155 
156  faceList& pointGlobalRegions,
157  faceList& pointLocalRegions,
158  labelList& localToGlobalRegion
159 )
160 {
161  const indirectPrimitivePatch& cpp = globalData.coupledPatch();
162 
163  // Calculate correspondence between patch and globalData.coupledPatch.
164  labelList patchEdges;
165  labelList coupledEdges;
166  PackedBoolList sameEdgeOrientation;
168  (
169  cpp,
170  patch,
171 
172  coupledEdges,
173  patchEdges,
174  sameEdgeOrientation
175  );
176 
177 
178  // Initial unique regions
179  // ~~~~~~~~~~~~~~~~~~~~~~
180  // These get merged later on across connected edges.
181 
182  // 1. Count
183  label nMaxRegions = 0;
184  forAll(patch.localFaces(), facei)
185  {
186  const face& f = patch.localFaces()[facei];
187  nMaxRegions += f.size();
188  }
189 
190  const globalIndex globalRegions(nMaxRegions);
191 
192  // 2. Assign unique regions
193  label nRegions = 0;
194 
195  pointGlobalRegions.setSize(patch.size());
196  forAll(pointGlobalRegions, facei)
197  {
198  const face& f = patch.localFaces()[facei];
199  labelList& pRegions = pointGlobalRegions[facei];
200  pRegions.setSize(f.size());
201  forAll(pRegions, fp)
202  {
203  pRegions[fp] = globalRegions.toGlobal(nRegions++);
204  }
205  }
206 
207 
208  DynamicList<label> changedEdges(patch.nEdges());
209  labelPairList allEdgeData(patch.nEdges(), labelPair(labelMax, labelMax));
210  PackedBoolList isChangedEdge(patch.nEdges());
211 
212 
213  // Fill initial seed
214  // ~~~~~~~~~~~~~~~~~
215 
216  forAll(patch.edgeFaces(), edgeI)
217  {
218  if (!nonManifoldEdge[edgeI])
219  {
220  // Take over value from one face only.
221  const edge& e = patch.edges()[edgeI];
222  label facei = patch.edgeFaces()[edgeI][0];
223  const face& f = patch.localFaces()[facei];
224 
225  label fp0 = findIndex(f, e[0]);
226  label fp1 = findIndex(f, e[1]);
227  allEdgeData[edgeI] = labelPair
228  (
229  pointGlobalRegions[facei][fp0],
230  pointGlobalRegions[facei][fp1]
231  );
232  if (!isChangedEdge[edgeI])
233  {
234  changedEdges.append(edgeI);
235  isChangedEdge[edgeI] = true;
236  }
237  }
238  }
239 
240 
241  syncEdges
242  (
243  globalData,
244 
245  patchEdges,
246  coupledEdges,
247  sameEdgeOrientation,
248  syncNonCollocated,
249 
250  isChangedEdge,
251  changedEdges,
252  allEdgeData
253  );
254 
255 
256  // Edge-Face-Edge walk across patch
257  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
258  // Across edge minimum regions win
259 
260  while (true)
261  {
262  // From edge to face
263  // ~~~~~~~~~~~~~~~~~
264 
265  DynamicList<label> changedFaces(patch.size());
266  PackedBoolList isChangedFace(patch.size());
267 
268  forAll(changedEdges, changedI)
269  {
270  label edgeI = changedEdges[changedI];
271  const labelPair& edgeData = allEdgeData[edgeI];
272 
273  const edge& e = patch.edges()[edgeI];
274  const labelList& eFaces = patch.edgeFaces()[edgeI];
275 
276  forAll(eFaces, i)
277  {
278  label facei = eFaces[i];
279  const face& f = patch.localFaces()[facei];
280 
281  // Combine edgeData with face data
282  label fp0 = findIndex(f, e[0]);
283  if (pointGlobalRegions[facei][fp0] > edgeData[0])
284  {
285  pointGlobalRegions[facei][fp0] = edgeData[0];
286  if (!isChangedFace[facei])
287  {
288  isChangedFace[facei] = true;
289  changedFaces.append(facei);
290  }
291  }
292 
293  label fp1 = findIndex(f, e[1]);
294  if (pointGlobalRegions[facei][fp1] > edgeData[1])
295  {
296  pointGlobalRegions[facei][fp1] = edgeData[1];
297  if (!isChangedFace[facei])
298  {
299  isChangedFace[facei] = true;
300  changedFaces.append(facei);
301  }
302  }
303  }
304  }
305 
306 
307  label nChangedFaces = returnReduce(changedFaces.size(), sumOp<label>());
308  if (nChangedFaces == 0)
309  {
310  break;
311  }
312 
313 
314  // From face to edge
315  // ~~~~~~~~~~~~~~~~~
316 
317  isChangedEdge = false;
318  changedEdges.clear();
319 
320  forAll(changedFaces, i)
321  {
322  label facei = changedFaces[i];
323  const face& f = patch.localFaces()[facei];
324  const labelList& fEdges = patch.faceEdges()[facei];
325 
326  forAll(fEdges, fp)
327  {
328  label edgeI = fEdges[fp];
329 
330  if (!nonManifoldEdge[edgeI])
331  {
332  const edge& e = patch.edges()[edgeI];
333  label fp0 = findIndex(f, e[0]);
334  label region0 = pointGlobalRegions[facei][fp0];
335  label fp1 = findIndex(f, e[1]);
336  label region1 = pointGlobalRegions[facei][fp1];
337 
338  if
339  (
340  (allEdgeData[edgeI][0] > region0)
341  || (allEdgeData[edgeI][1] > region1)
342  )
343  {
344  allEdgeData[edgeI] = labelPair(region0, region1);
345  if (!isChangedEdge[edgeI])
346  {
347  changedEdges.append(edgeI);
348  isChangedEdge[edgeI] = true;
349  }
350  }
351  }
352  }
353  }
354 
355  syncEdges
356  (
357  globalData,
358 
359  patchEdges,
360  coupledEdges,
361  sameEdgeOrientation,
362  syncNonCollocated,
363 
364  isChangedEdge,
365  changedEdges,
366  allEdgeData
367  );
368 
369 
370  label nChangedEdges = returnReduce(changedEdges.size(), sumOp<label>());
371  if (nChangedEdges == 0)
372  {
373  break;
374  }
375  }
376 
377 
378 
379  // Assign local regions
380  // ~~~~~~~~~~~~~~~~~~~~
381 
382  // Calculate addressing from global region back to local region
383  pointLocalRegions.setSize(patch.size());
384  Map<label> globalToLocalRegion(globalRegions.localSize()/4);
385  DynamicList<label> dynLocalToGlobalRegion(globalToLocalRegion.size());
386  forAll(patch.localFaces(), facei)
387  {
388  const face& f = patch.localFaces()[facei];
389  face& pRegions = pointLocalRegions[facei];
390  pRegions.setSize(f.size());
391  forAll(f, fp)
392  {
393  label globalRegionI = pointGlobalRegions[facei][fp];
394 
395  Map<label>::iterator fnd = globalToLocalRegion.find(globalRegionI);
396 
397  if (fnd != globalToLocalRegion.end())
398  {
399  // Already encountered this global region. Assign same local one
400  pRegions[fp] = fnd();
401  }
402  else
403  {
404  // Region not yet seen. Create new one
405  label localRegionI = globalToLocalRegion.size();
406  pRegions[fp] = localRegionI;
407  globalToLocalRegion.insert(globalRegionI, localRegionI);
408  dynLocalToGlobalRegion.append(globalRegionI);
409  }
410  }
411  }
412  localToGlobalRegion.transfer(dynLocalToGlobalRegion);
413 }
414 
415 
416 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
417 
419 (
420  const primitiveFacePatch& patch,
421  const faceList& pointRegions,
422  const labelList& regionPoints
423 )
424 :
425  patch_(patch),
426  pointRegions_(pointRegions),
427  regionPoints_(regionPoints)
428 {
429  if (pointRegions_.size() != patch_.size())
430  {
432  << "nFaces:" << patch_.size()
433  << " pointRegions:" << pointRegions.size()
434  << exit(FatalError);
435  }
436 }
437 
438 
439 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
440 
442 (
443  const pointField& firstLayerDisp,
444  const scalar expansionRatio,
445  const label nLayers,
446  const labelList& topPatchID,
447  const labelList& bottomPatchID,
448  const labelListList& extrudeEdgePatches,
449  polyTopoChange& meshMod
450 )
451 {
452  if (firstLayerDisp.size() != regionPoints_.size())
453  {
455  << "nRegions:" << regionPoints_.size()
456  << " firstLayerDisp:" << firstLayerDisp.size()
457  << exit(FatalError);
458  }
459 
460  if
461  (
462  topPatchID.size() != patch_.size()
463  && bottomPatchID.size() != patch_.size()
464  )
465  {
467  << "nFaces:" << patch_.size()
468  << " topPatchID:" << topPatchID.size()
469  << " bottomPatchID:" << bottomPatchID.size()
470  << exit(FatalError);
471  }
472 
473  if (extrudeEdgePatches.size() != patch_.nEdges())
474  {
476  << "nEdges:" << patch_.nEdges()
477  << " extrudeEdgePatches:" << extrudeEdgePatches.size()
478  << exit(FatalError);
479  }
480 
481 
482 
483  // From cell to patch (trivial)
484  DynamicList<label> cellToFaceMap(nLayers*patch_.size());
485  // From face to patch+turning index
486  DynamicList<label> faceToFaceMap
487  (
488  (nLayers+1)*(patch_.size()+patch_.nEdges())
489  );
490  // From face to patch edge index
491  DynamicList<label> faceToEdgeMap(nLayers*(patch_.nEdges()+patch_.nEdges()));
492  // From point to patch point index
493  DynamicList<label> pointToPointMap((nLayers+1)*patch_.nPoints());
494 
495 
496  // Introduce new cell for every face
497  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
498 
499  labelList addedCells(nLayers*patch_.size());
500  forAll(patch_, facei)
501  {
502  for (label layerI = 0; layerI < nLayers; layerI++)
503  {
504  addedCells[nLayers*facei+layerI] = meshMod.addCell
505  (
506  cellToFaceMap.size() // masterCellID
507  );
508  cellToFaceMap.append(facei);
509  }
510  }
511 
512 
513  // Introduce original points
514  // ~~~~~~~~~~~~~~~~~~~~~~~~~
515 
516  // Original point numbers in local point ordering so no need to store.
517  forAll(patch_.localPoints(), pointi)
518  {
519  // label addedPointi =
520  meshMod.addPoint
521  (
522  patch_.localPoints()[pointi], // point
523  pointToPointMap.size(), // masterPointID
524  true // inCell
525  );
526  pointToPointMap.append(pointi);
527 
528  // Pout<< "Added bottom point " << addedPointi
529  // << " at " << patch_.localPoints()[pointi]
530  // << " from point " << pointi
531  // << endl;
532  }
533 
534 
535  // Introduce new points (one for every region)
536  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
537 
538  labelList addedPoints(nLayers*regionPoints_.size());
539  forAll(regionPoints_, regionI)
540  {
541  label pointi = regionPoints_[regionI];
542 
543  point pt = patch_.localPoints()[pointi];
544  point disp = firstLayerDisp[regionI];
545  for (label layerI = 0; layerI < nLayers; layerI++)
546  {
547  pt += disp;
548 
549  addedPoints[nLayers*regionI+layerI] = meshMod.addPoint
550  (
551  pt, // point
552  pointToPointMap.size(), // masterPointID - used only addressing
553  true // inCell
554  );
555  pointToPointMap.append(pointi);
556 
557  disp *= expansionRatio;
558  }
559  }
560 
561 
562  // Add face on bottom side
563  forAll(patch_.localFaces(), facei)
564  {
565  meshMod.addFace
566  (
567  patch_.localFaces()[facei].reverseFace(),// vertices
568  addedCells[nLayers*facei], // own
569  -1, // nei
570  faceToFaceMap.size(), // masterFaceID : current facei
571  true, // flipFaceFlux
572  bottomPatchID[facei] // patchID
573  );
574 
575  faceToFaceMap.append(-facei-1); // points to flipped original face
576  faceToEdgeMap.append(-1);
577  }
578 
579  // Add in between faces and face on top
580  forAll(patch_.localFaces(), facei)
581  {
582  // Get face in original ordering
583  const face& f = patch_.localFaces()[facei];
584 
585  face newF(f.size());
586 
587  for (label layerI = 0; layerI < nLayers; layerI++)
588  {
589  // Pick up point based on region and layer
590  forAll(f, fp)
591  {
592  label region = pointRegions_[facei][fp];
593  newF[fp] = addedPoints[region*nLayers+layerI];
594  }
595 
596  label own = addedCells[facei*nLayers+layerI];
597  label nei;
598  label patchi;
599  if (layerI == nLayers-1)
600  {
601  nei = -1;
602  patchi = topPatchID[facei];
603  }
604  else
605  {
606  nei = addedCells[facei*nLayers+layerI+1];
607  patchi = -1;
608  }
609 
610  meshMod.addFace
611  (
612  newF, // vertices
613  own, // own
614  nei, // nei
615  faceToFaceMap.size(), // masterFaceID : current facei
616  false, // flipFaceFlux
617  patchi // patchID
618  );
619 
620  faceToFaceMap.append(facei+1); // unflipped
621  faceToEdgeMap.append(-1);
622  }
623  }
624 
625 
626  // Add side faces
627  // ~~~~~~~~~~~~~~
628  // Note that we loop over edges multiple times so for edges with
629  // two cyclic faces they get added in two passes (for correct ordering)
630 
631  // Pass1. Internal edges and first face of other edges
632  forAll(extrudeEdgePatches, edgeI)
633  {
634  const labelList& eFaces = patch_.edgeFaces()[edgeI];
635  const labelList& ePatches = extrudeEdgePatches[edgeI];
636 
637  if (ePatches.size() == 0)
638  {
639  // Internal face
640  if (eFaces.size() != 2)
641  {
643  << "edge:" << edgeI
644  << " not internal but does not have side-patches defined."
645  << exit(FatalError);
646  }
647  }
648  else
649  {
650  if (eFaces.size() != ePatches.size())
651  {
653  << "external/feature edge:" << edgeI
654  << " has " << eFaces.size() << " connected extruded faces "
655  << " but only " << ePatches.size()
656  << " boundary faces defined." << exit(FatalError);
657  }
658  }
659 
660 
661 
662  // Make face pointing in to eFaces[0] so out of new master face
663  const face& f = patch_.localFaces()[eFaces[0]];
664  const edge& e = patch_.edges()[edgeI];
665 
666  label fp0 = findIndex(f, e[0]);
667  label fp1 = f.fcIndex(fp0);
668 
669  if (f[fp1] != e[1])
670  {
671  fp1 = fp0;
672  fp0 = f.rcIndex(fp1);
673  }
674 
675  face newF(4);
676 
677  for (label layerI = 0; layerI < nLayers; layerI++)
678  {
679  label region0 = pointRegions_[eFaces[0]][fp0];
680  label region1 = pointRegions_[eFaces[0]][fp1];
681 
682  // Pick up points with correct normal
683  if (layerI == 0)
684  {
685  newF[0] = f[fp0];
686  newF[1] = f[fp1];
687  newF[2] = addedPoints[nLayers*region1+layerI];
688  newF[3] = addedPoints[nLayers*region0+layerI];
689  }
690  else
691  {
692  newF[0] = addedPoints[nLayers*region0+layerI-1];
693  newF[1] = addedPoints[nLayers*region1+layerI-1];
694  newF[2] = addedPoints[nLayers*region1+layerI];
695  newF[3] = addedPoints[nLayers*region0+layerI];
696  }
697 
698  // Optionally rotate so e[0] is always 0th vertex. Note that
699  // this normally is automatically done by coupled face ordering
700  // but with NOORDERING we have to do it ourselves.
701  if (f[fp0] != e[0])
702  {
703  // rotate one back to get newF[1] (originating from e[0])
704  // into newF[0]
705  label v0 = newF[0];
706  for (label i = 0; i < newF.size()-1; i++)
707  {
708  newF[i] = newF[newF.fcIndex(i)];
709  }
710  newF.last() = v0;
711  }
712 
713 
714  label minCelli = addedCells[nLayers*eFaces[0]+layerI];
715  label maxCelli;
716  label patchi;
717  if (ePatches.size() == 0)
718  {
719  maxCelli = addedCells[nLayers*eFaces[1]+layerI];
720  if (minCelli > maxCelli)
721  {
722  // Swap
723  Swap(minCelli, maxCelli);
724  newF = newF.reverseFace();
725  }
726  patchi = -1;
727  }
728  else
729  {
730  maxCelli = -1;
731  patchi = ePatches[0];
732  }
733 
734  // newF already outwards pointing.
735  meshMod.addFace
736  (
737  newF, // vertices
738  minCelli, // own
739  maxCelli, // nei
740  faceToFaceMap.size(), // masterFaceID
741  false, // flipFaceFlux
742  patchi // patchID
743  );
744 
745  faceToFaceMap.append(0);
746  faceToEdgeMap.append(edgeI);
747  }
748  }
749 
750  // Pass2. Other faces of boundary edges
751  forAll(extrudeEdgePatches, edgeI)
752  {
753  const labelList& eFaces = patch_.edgeFaces()[edgeI];
754  const labelList& ePatches = extrudeEdgePatches[edgeI];
755 
756  if (ePatches.size() >= 2)
757  {
758  for (label i = 1; i < ePatches.size(); i++)
759  {
760  // Extrude eFaces[i]
761  label minFacei = eFaces[i];
762 
763  // Make face pointing in to eFaces[0] so out of new master face
764  const face& f = patch_.localFaces()[minFacei];
765 
766  const edge& e = patch_.edges()[edgeI];
767  label fp0 = findIndex(f, e[0]);
768  label fp1 = f.fcIndex(fp0);
769 
770  if (f[fp1] != e[1])
771  {
772  fp1 = fp0;
773  fp0 = f.rcIndex(fp1);
774  }
775 
776  face newF(4);
777  for (label layerI = 0; layerI < nLayers; layerI++)
778  {
779  label region0 = pointRegions_[minFacei][fp0];
780  label region1 = pointRegions_[minFacei][fp1];
781 
782  if (layerI == 0)
783  {
784  newF[0] = f[fp0];
785  newF[1] = f[fp1];
786  newF[2] = addedPoints[nLayers*region1+layerI];
787  newF[3] = addedPoints[nLayers*region0+layerI];
788  }
789  else
790  {
791  newF[0] = addedPoints[nLayers*region0+layerI-1];
792  newF[1] = addedPoints[nLayers*region1+layerI-1];
793  newF[2] = addedPoints[nLayers*region1+layerI];
794  newF[3] = addedPoints[nLayers*region0+layerI];
795  }
796 
797 
798  // Optionally rotate so e[0] is always 0th vertex. Note that
799  // this normally is automatically done by coupled face
800  // ordering but with NOORDERING we have to do it ourselves.
801  if (f[fp0] != e[0])
802  {
803  // rotate one back to get newF[1] (originating
804  // from e[0]) into newF[0].
805  label v0 = newF[0];
806  for (label i = 0; i < newF.size()-1; i++)
807  {
808  newF[i] = newF[newF.fcIndex(i)];
809  }
810  newF.last() = v0;
811  }
812 
813  // newF already outwards pointing.
814  meshMod.addFace
815  (
816  newF, // vertices
817  addedCells[nLayers*minFacei+layerI], // own
818  -1, // nei
819  faceToFaceMap.size(), // masterFaceID
820  false, // flipFaceFlux
821  ePatches[i] // patchID
822  );
823  faceToFaceMap.append(0);
824  faceToEdgeMap.append(edgeI);
825  }
826  }
827  }
828  }
829 
830 
831  cellToFaceMap_.transfer(cellToFaceMap);
832  faceToFaceMap_.transfer(faceToFaceMap);
833  faceToEdgeMap_.transfer(faceToEdgeMap);
834  pointToPointMap_.transfer(pointToPointMap);
835 }
836 
837 
839 {
840  inplaceReorder(map.reverseCellMap(), cellToFaceMap_);
841  inplaceReorder(map.reverseFaceMap(), faceToFaceMap_);
842  inplaceReorder(map.reverseFaceMap(), faceToEdgeMap_);
843  inplaceReorder(map.reversePointMap(), pointToPointMap_);
844 }
845 
846 
847 // ************************************************************************* //
scalar y
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
Definition: DynamicListI.H:296
void clear()
Clear the addressed list, i.e. set the size to zero.
Definition: DynamicListI.H:236
label size() const
Return number of elements in table.
Definition: HashTableI.H:65
bool insert(const Key &, const T &newElmt)
Insert a new hashedEntry.
Definition: HashTableI.H:80
iterator find(const Key &)
Find and return an iterator set at the hashedEntry.
Definition: HashTable.C:167
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
Definition: List.C:342
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
void setSize(const label)
Reset size of List.
Definition: List.C:281
A bit-packed bool list.
static void matchEdges(const PrimitivePatch< FaceList1, PointField1 > &p1, const PrimitivePatch< FaceList2, PointField2 > &p2, labelList &p1EdgeLabels, labelList &p2EdgeLabels, PackedBoolList &sameOrientation)
Find corresponding edges on patches sharing the same points.
A list of faces which address into the list of points.
label nEdges() const
Return number of edges in patch.
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
const List< FaceType > & localFaces() const
Return patch faces addressing into local point list.
const labelListList & edgeFaces() const
Return edge-face addressing.
const labelListList & faceEdges() const
Return face-edge addressing.
label rcIndex(const label i) const
Return the reverse circular index, i.e. the previous index.
Definition: UListI.H:65
label fcIndex(const label i) const
Return the forward circular index, i.e. the next index.
Definition: UListI.H:58
T & last()
Return the last element of the list.
Definition: UListI.H:128
Creates mesh by extruding a patch.
void topoChange(const polyTopoChangeMap &)
Update any locally stored mesh information.
createShellMesh(const primitiveFacePatch &patch, const faceList &pointRegions, const labelList &regionPoints)
Construct from mesh.
static void calcPointRegions(const globalMeshData &globalData, const primitiveFacePatch &patch, const PackedBoolList &nonManifoldEdge, const bool syncNonCollocated, faceList &pointGlobalRegions, faceList &pointLocalRegions, labelList &localToGlobalRegion)
Helper: calculate point regions. The point region is the.
void setRefinement(const pointField &firstLayerThickness, const scalar expansionRatio, const label nLayers, const labelList &topPatchID, const labelList &bottomPatchID, const labelListList &extrudeEdgePatches, polyTopoChange &meshMod)
Play commands into polyTopoChange to create layer mesh.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:61
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:76
face reverseFace() const
Return face with reverse direction.
Definition: face.C:256
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
Definition: globalIndex.H:64
label localSize() const
My local size.
Definition: globalIndexI.H:60
label toGlobal(const label i) const
From local to global.
Definition: globalIndexI.H:82
Various mesh related information for a parallel run. Upon construction, constructs all info using par...
const indirectPrimitivePatch & coupledPatch() const
Return patch of all coupled faces.
void operator()(labelPair &x, const labelPair &y) const
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
const labelList & reversePointMap() const
Reverse point map.
const labelList & reverseCellMap() const
Reverse cell map.
const labelList & reverseFaceMap() const
Reverse face map.
Direct mesh changes based on v1.3 polyTopoChange syntax.
label addCell(const label masterCellID)
Add cell and return new cell index.
label addPoint(const point &, const label masterPointID, const bool inCell)
Add point and return new point index.
label addFace(const face &f, const label own, const label nei, const label masterFaceID, const bool flipFaceFlux, const label patchID)
Add face to cells and return new face index.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
label patchi
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
List< labelPair > labelPairList
List of labelPairs.
Definition: labelPair.H:49
Pair< label > labelPair
Label pair.
Definition: labelPair.H:48
const doubleScalar e
Definition: doubleScalar.H:106
List< label > labelList
A List of labels.
Definition: labelList.H:56
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
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
List< labelList > labelListList
A List of labelList.
Definition: labelList.H:57
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
defineTypeNameAndDebug(combustionModel, 0)
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
error FatalError
void Swap(T &a, T &b)
Definition: Swap.H:43
static const label labelMax
Definition: label.H:62
void inplaceReorder(const labelUList &oldToNew, ListType &)
Inplace reorder the elements of a list.
labelList f(nPoints)
static iteratorEnd end()
iteratorEnd set to beyond the end of any HashTable
Definition: HashTable.H:112