meshRefinementMerge.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 "meshRefinement.H"
27 #include "combineFaces.H"
28 #include "polyTopoChange.H"
29 #include "removePoints.H"
30 #include "faceSet.H"
31 #include "Time.H"
32 #include "meshCheck.H"
33 #include "syncTools.H"
34 
35 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
36 
38 //Foam::label Foam::meshRefinement::mergePatchFaces
39 //(
40 // const scalar minCos,
41 // const scalar concaveCos,
42 // const labelList& patchIDs
43 //)
44 //{
45 // // Patch face merging engine
46 // combineFaces faceCombiner(mesh_);
47 //
48 // const polyBoundaryMesh& patches = mesh_.boundaryMesh();
49 //
50 // // Pick up all candidate cells on boundary
51 // labelHashSet boundaryCells(mesh_.nFaces()-mesh_.nInternalFaces());
52 //
53 // forAll(patchIDs, i)
54 // {
55 // label patchi = patchIDs[i];
56 //
57 // const polyPatch& patch = patches[patchi];
58 //
59 // if (!patch.coupled())
60 // {
61 // forAll(patch, i)
62 // {
63 // boundaryCells.insert(mesh_.faceOwner()[patch.start()+i]);
64 // }
65 // }
66 // }
67 //
68 // // Get all sets of faces that can be merged
69 // labelListList mergeSets
70 // (
71 // faceCombiner.getMergeSets
72 // (
73 // minCos,
74 // concaveCos,
75 // boundaryCells
76 // )
77 // );
78 //
79 // label nFaceSets = returnReduce(mergeSets.size(), sumOp<label>());
80 //
81 // Info<< "mergePatchFaces : Merging " << nFaceSets
82 // << " sets of faces." << endl;
83 //
84 // if (nFaceSets > 0)
85 // {
86 // // Topology changes container
87 // polyTopoChange meshMod(mesh_);
88 //
89 // // Merge all faces of a set into the first face of the set. Remove
90 // // unused points.
91 // faceCombiner.setRefinement(mergeSets, meshMod);
92 //
93 // // Change the mesh (without keeping old points)
94 // autoPtr<polyTopoChangeMap> map =
95 // meshMod.changeMesh(mesh_, true);
96 //
97 // // Update fields
98 // mesh_.topoChange(map);
99 //
100 // // Reset the instance for if in overwrite mode
101 // mesh_.setInstance(name());
102 //
103 // faceCombiner.topoChange(map);
104 //
105 // // Get the kept faces that need to be recalculated.
106 // // Merging two boundary faces might shift the cell centre
107 // // (unless the faces are absolutely planar)
108 // labelHashSet retestFaces(6*mergeSets.size());
109 //
110 // forAll(mergeSets, seti)
111 // {
112 // label oldMasterI = mergeSets[seti][0];
113 //
114 // label facei = map().reverseFaceMap()[oldMasterI];
115 //
116 // // facei is always uncoupled boundary face
117 // const cell& cFaces = mesh_.cells()[mesh_.faceOwner()[facei]];
118 //
119 // forAll(cFaces, i)
120 // {
121 // retestFaces.insert(cFaces[i]);
122 // }
123 // }
124 // topoChange(map, retestFaces.toc());
125 // }
126 //
127 //
128 // return nFaceSets;
129 //}
130 //
131 //
134 //Foam::autoPtr<Foam::polyTopoChangeMap> Foam::meshRefinement::mergeEdges
135 //(
136 // const scalar minCos
137 //)
138 //{
139 // // Point removal analysis engine
140 // removePoints pointRemover(mesh_);
141 //
142 // // Count usage of points
143 // boolList pointCanBeDeleted;
144 // label nRemove = pointRemover.countPointUsage(minCos, pointCanBeDeleted);
145 //
146 // Info<< "Removing " << nRemove
147 // << " straight edge points." << endl;
148 //
149 // autoPtr<polyTopoChangeMap> map;
150 //
151 // if (nRemove > 0)
152 // {
153 // // Save my local faces that will change. These changed faces might
154 // // cause a shift in the cell centre which needs to be retested.
155 // // Have to do this before changing mesh since point will be removed.
156 // labelHashSet retestOldFaces(nRemove / Pstream::nProcs());
157 //
158 // {
159 // const faceList& faces = mesh_.faces();
160 //
161 // forAll(faces, facei)
162 // {
163 // const face& f = faces[facei];
164 //
165 // forAll(f, fp)
166 // {
167 // if (pointCanBeDeleted[f[fp]])
168 // {
169 // retestOldFaces.insert(facei);
170 // break;
171 // }
172 // }
173 // }
174 // }
175 //
176 // // Topology changes container
177 // polyTopoChange meshMod(mesh_);
178 //
179 // pointRemover.setRefinement(pointCanBeDeleted, meshMod);
180 //
181 // // Change the mesh (without keeping old points)
182 // map = meshMod.changeMesh(mesh_, true);
183 //
184 // // Update fields
185 // mesh_.topoChange(map);
186 //
187 // // Reset the instance for if in overwrite mode
188 // mesh_.setInstance(name());
189 //
190 // pointRemover.topoChange(map);
191 //
192 // // Get the kept faces that need to be recalculated.
193 // labelHashSet retestFaces(6*retestOldFaces.size());
194 //
195 // const cellList& cells = mesh_.cells();
196 //
197 // forAllConstIter(labelHashSet, retestOldFaces, iter)
198 // {
199 // label facei = map().reverseFaceMap()[iter.key()];
200 //
201 // const cell& ownFaces = cells[mesh_.faceOwner()[facei]];
202 //
203 // forAll(ownFaces, i)
204 // {
205 // retestFaces.insert(ownFaces[i]);
206 // }
207 //
208 // if (mesh_.isInternalFace(facei))
209 // {
210 // const cell& neiFaces = cells[mesh_.faceNeighbour()[facei]];
211 //
212 // forAll(neiFaces, i)
213 // {
214 // retestFaces.insert(neiFaces[i]);
215 // }
216 // }
217 // }
218 // topoChange(map, retestFaces.toc());
219 // }
220 //
221 // return map;
222 //}
223 
224 
226 (
227  const scalar minCos,
228  const scalar concaveCos,
229  const labelHashSet& patchIDs,
230  const dictionary& motionDict,
231  const labelList& preserveFaces
232 )
233 {
234  // Patch face merging engine
235  combineFaces faceCombiner(mesh_, true);
236 
237  // Get all sets of faces that can be merged. Since only faces on the same
238  // patch get merged there is no risk of e.g. patchID faces getting merged
239  // with original patches (or even processor patches). There is a risk
240  // though of original patch faces getting merged if they make a small
241  // angle. Would be pretty weird starting mesh though.
242  labelListList allFaceSets
243  (
244  faceCombiner.getMergeSets(minCos, concaveCos, patchIDs)
245  );
246 
247  // Filter out any set that contains any preserveFace
248  label compactI = 0;
249  forAll(allFaceSets, i)
250  {
251  const labelList& set = allFaceSets[i];
252 
253  bool keep = true;
254  forAll(set, j)
255  {
256  if (preserveFaces[set[j]] != -1)
257  {
258  keep = false;
259  break;
260  }
261  }
262 
263  if (keep)
264  {
265  if (compactI != i)
266  {
267  allFaceSets[compactI] = set;
268  }
269 
270  compactI++;
271  }
272  }
273  allFaceSets.setSize(compactI);
274 
275  label nFaceSets = returnReduce(allFaceSets.size(), sumOp<label>());
276 
277  Info<< "Merging " << nFaceSets << " sets of faces." << nl << endl;
278 
279  if (nFaceSets > 0)
280  {
281  if (debug&meshRefinement::MESH)
282  {
283  faceSet allSets(mesh_, "allFaceSets", allFaceSets.size());
284  forAll(allFaceSets, seti)
285  {
286  forAll(allFaceSets[seti], i)
287  {
288  allSets.insert(allFaceSets[seti][i]);
289  }
290  }
291  Pout<< "Writing all faces to be merged to set "
292  << allSets.objectPath() << endl;
293  allSets.instance() = name();
294  allSets.write();
295 
296  const_cast<Time&>(mesh_.time())++;
297  }
298 
299 
300  // Topology changes container
301  polyTopoChange meshMod(mesh_);
302 
303  // Merge all faces of a set into the first face of the set.
304  faceCombiner.setRefinement(allFaceSets, meshMod);
305 
306  // Experimental: store data for all the points that have been deleted
307  storeData
308  (
309  faceCombiner.savedPointLabels(), // points to store
310  labelList(0), // faces to store
311  labelList(0) // cells to store
312  );
313 
314  // Change the mesh
315  autoPtr<polyTopoChangeMap> map = meshMod.changeMesh(mesh_, true);
316 
317  // Update fields
318  mesh_.topoChange(map);
319 
320  // Reset the instance for if in overwrite mode
321  mesh_.setInstance(name());
322 
323  faceCombiner.topoChange(map);
324 
325  // Get the kept faces that need to be recalculated.
326  // Merging two boundary faces might shift the cell centre
327  // (unless the faces are absolutely planar)
328  labelHashSet retestFaces(2*allFaceSets.size());
329 
330  forAll(allFaceSets, seti)
331  {
332  const label oldMasterI = allFaceSets[seti][0];
333  retestFaces.insert(map().reverseFaceMap()[oldMasterI]);
334  }
335  topoChange(map, growFaceCellFace(retestFaces));
336 
337  if (debug&meshRefinement::MESH)
338  {
339  // Check sync
340  Pout<< "Checking sync after initial merging " << nFaceSets
341  << " faces." << endl;
342  checkData();
343 
344  Pout<< "Writing initial merged-faces mesh to time "
345  << name() << nl << endl;
346  write();
347  }
348 
349  for (label iteration = 0; iteration < 100; iteration++)
350  {
351  Info<< nl
352  << "Undo iteration " << iteration << nl
353  << "----------------" << endl;
354 
355 
356  // Check mesh for errors
357  // ~~~~~~~~~~~~~~~~~~~~~
358 
359  faceSet errorFaces
360  (
361  mesh_,
362  "errorFaces",
363  mesh_.nFaces()-mesh_.nInternalFaces()
364  );
365  bool hasErrors = meshCheck::checkMesh
366  (
367  false, // report
368  mesh_,
369  motionDict,
370  errorFaces
371  );
372 
373  // if (checkEdgeConnectivity)
374  //{
375  // Info<< "Checking edge-face connectivity (duplicate faces"
376  // << " or non-consecutive shared vertices)" << endl;
377  //
378  // label nOldSize = errorFaces.size();
379  //
380  // hasErrors =
381  // mesh_.checkFaceFaces
382  // (
383  // false,
384  // &errorFaces
385  // )
386  // || hasErrors;
387  //
388  // Info<< "Detected additional "
389  // << returnReduce
390  // (
391  // errorFaces.size() - nOldSize,
392  // sumOp<label>()
393  // )
394  // << " faces with illegal face-face connectivity"
395  // << endl;
396  //}
397 
398  if (!hasErrors)
399  {
400  break;
401  }
402 
403 
404  if (debug&meshRefinement::MESH)
405  {
406  errorFaces.instance() = name();
407  Pout<< "Writing all faces in error to faceSet "
408  << errorFaces.objectPath() << nl << endl;
409  errorFaces.write();
410  }
411 
412 
413  // Check any master cells for using any of the error faces
414  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
415 
416  DynamicList<label> mastersToRestore(allFaceSets.size());
417 
418  forAll(allFaceSets, seti)
419  {
420  const label masterFacei = faceCombiner.masterFace()[seti];
421 
422  if (masterFacei != -1)
423  {
424  const label masterCellII = mesh_.faceOwner()[masterFacei];
425 
426  const cell& cFaces = mesh_.cells()[masterCellII];
427 
428  forAll(cFaces, i)
429  {
430  if (errorFaces.found(cFaces[i]))
431  {
432  mastersToRestore.append(masterFacei);
433  break;
434  }
435  }
436  }
437  }
438  mastersToRestore.shrink();
439 
440  const label nRestore = returnReduce
441  (
442  mastersToRestore.size(),
443  sumOp<label>()
444  );
445 
446  Info<< "Masters that need to be restored:"
447  << nRestore << endl;
448 
449  if (debug&meshRefinement::MESH)
450  {
451  faceSet restoreSet(mesh_, "mastersToRestore", mastersToRestore);
452  restoreSet.instance() = name();
453  Pout<< "Writing all " << mastersToRestore.size()
454  << " masterfaces to be restored to set "
455  << restoreSet.objectPath() << endl;
456  restoreSet.write();
457  }
458 
459 
460  if (nRestore == 0)
461  {
462  break;
463  }
464 
465 
466  // Undo
467  // ~~~~
468 
469  if (debug)
470  {
471  const_cast<Time&>(mesh_.time())++;
472  }
473 
474  // Topology changes container
475  polyTopoChange meshMod(mesh_);
476 
477  // Merge all faces of a set into the first face of the set.
478  // Experimental:mark all points/faces/cells that have been restored.
479  Map<label> restoredPoints(0);
480  Map<label> restoredFaces(0);
481  Map<label> restoredCells(0);
482 
483  faceCombiner.setUnrefinement
484  (
485  mastersToRestore,
486  meshMod,
487  restoredPoints,
488  restoredFaces,
489  restoredCells
490  );
491 
492  // Change the mesh (without keeping old points)
493  autoPtr<polyTopoChangeMap> map = meshMod.changeMesh(mesh_, true);
494 
495  // Update fields
496  mesh_.topoChange(map);
497 
498  // Reset the instance for if in overwrite mode
499  mesh_.setInstance(name());
500 
501  faceCombiner.topoChange(map);
502 
503  // Renumber restore maps
504  inplaceMapKey(map().reversePointMap(), restoredPoints);
505  inplaceMapKey(map().reverseFaceMap(), restoredFaces);
506  inplaceMapKey(map().reverseCellMap(), restoredCells);
507 
508 
509  // Get the kept faces that need to be recalculated.
510  // Merging two boundary faces might shift the cell centre
511  // (unless the faces are absolutely planar)
512  labelHashSet retestFaces(2*restoredFaces.size());
513 
514  forAllConstIter(Map<label>, restoredFaces, iter)
515  {
516  retestFaces.insert(iter.key());
517  }
518 
519  // Experimental:restore all points/face/cells in maps
520  topoChange
521  (
522  map,
523  growFaceCellFace(retestFaces),
524  restoredPoints,
525  restoredFaces,
526  restoredCells
527  );
528 
529  if (debug&meshRefinement::MESH)
530  {
531  // Check sync
532  Pout<< "Checking sync after restoring " << retestFaces.size()
533  << " faces." << endl;
534  checkData();
535 
536  Pout<< "Writing merged-faces mesh to time "
537  << name() << nl << endl;
538  write();
539  }
540 
541  Info<< endl;
542  }
543  }
544  else
545  {
546  Info<< "No faces merged ..." << endl;
547  }
548 
549  return nFaceSets;
550 }
551 
552 
553 // Remove points. pointCanBeDeleted is parallel synchronised.
555 (
556  removePoints& pointRemover,
557  const boolList& pointCanBeDeleted
558 )
559 {
560  // Topology changes container
561  polyTopoChange meshMod(mesh_);
562 
563  pointRemover.setRefinement(pointCanBeDeleted, meshMod);
564 
565  // Change the mesh
566  autoPtr<polyTopoChangeMap> map = meshMod.changeMesh(mesh_, true);
567 
568  // Update fields
569  mesh_.topoChange(map);
570 
571  // Reset the instance for if in overwrite mode
572  mesh_.setInstance(name());
573 
574  pointRemover.topoChange(map);
575 
576 
577  // Retest all affected faces and all the cells using them
578  labelHashSet retestFaces(pointRemover.savedFaceLabels().size());
579  forAll(pointRemover.savedFaceLabels(), i)
580  {
581  const label facei = pointRemover.savedFaceLabels()[i];
582  if (facei >= 0)
583  {
584  retestFaces.insert(facei);
585  }
586  }
587  topoChange(map, growFaceCellFace(retestFaces));
588 
589  if (debug)
590  {
591  // Check sync
592  Pout<< "Checking sync after removing points." << endl;
593  checkData();
594  }
595 
596  return map;
597 }
598 
599 
601 (
602  removePoints& pointRemover,
603  const labelList& facesToRestore
604 )
605 {
606  // Topology changes container
607  polyTopoChange meshMod(mesh_);
608 
609  // Determine sets of points and faces to restore
610  labelList localFaces, localPoints;
611  pointRemover.getUnrefimentSet
612  (
613  facesToRestore,
614  localFaces,
615  localPoints
616  );
617 
618  // Undo the changes on the faces that are in error.
619  pointRemover.setUnrefinement
620  (
621  localFaces,
622  localPoints,
623  meshMod
624  );
625 
626  // Change the mesh
627  autoPtr<polyTopoChangeMap> map = meshMod.changeMesh(mesh_, true);
628 
629  // Update fields
630  mesh_.topoChange(map);
631 
632  // Reset the instance for if in overwrite mode
633  mesh_.setInstance(name());
634 
635  pointRemover.topoChange(map);
636 
637  labelHashSet retestFaces(2*facesToRestore.size());
638  forAll(facesToRestore, i)
639  {
640  const label facei = map().reverseFaceMap()[facesToRestore[i]];
641  if (facei >= 0)
642  {
643  retestFaces.insert(facei);
644  }
645  }
646  topoChange(map, growFaceCellFace(retestFaces));
647 
648  if (debug)
649  {
650  // Check sync
651  Pout<< "Checking sync after restoring points on "
652  << facesToRestore.size() << " faces." << endl;
653  checkData();
654  }
655 
656  return map;
657 }
658 
659 
660 // Collect all faces that are both in candidateFaces and in the set.
661 // If coupled face also collects the coupled face.
663 (
664  const labelList& candidateFaces,
665  const labelHashSet& set
666 ) const
667 {
668  // Has face been selected?
669  boolList selected(mesh_.nFaces(), false);
670 
671  forAll(candidateFaces, i)
672  {
673  const label facei = candidateFaces[i];
674 
675  if (set.found(facei))
676  {
677  selected[facei] = true;
678  }
679  }
681  (
682  mesh_,
683  selected,
684  orEqOp<bool>() // combine operator
685  );
686 
687  labelList selectedFaces(findIndices(selected, true));
688 
689  return selectedFaces;
690 }
691 
692 
693 // Pick up faces of cells of faces in set.
695 (
696  const labelHashSet& set
697 ) const
698 {
699  boolList selected(mesh_.nFaces(), false);
700 
701  forAllConstIter(faceSet, set, iter)
702  {
703  const label facei = iter.key();
704  const label own = mesh_.faceOwner()[facei];
705 
706  const cell& ownFaces = mesh_.cells()[own];
707  forAll(ownFaces, ownFacei)
708  {
709  selected[ownFaces[ownFacei]] = true;
710  }
711 
712  if (mesh_.isInternalFace(facei))
713  {
714  const label nbr = mesh_.faceNeighbour()[facei];
715 
716  const cell& nbrFaces = mesh_.cells()[nbr];
717  forAll(nbrFaces, nbrFacei)
718  {
719  selected[nbrFaces[nbrFacei]] = true;
720  }
721  }
722  }
724  (
725  mesh_,
726  selected,
727  orEqOp<bool>() // combine operator
728  );
729  return findIndices(selected, true);
730 }
731 
732 
733 // Remove points not used by any face or points used by only two faces where
734 // the edges are in line
736 (
737  const scalar minCos,
738  const dictionary& motionDict
739 )
740 {
741  Info<< nl
742  << "Merging all points on surface that" << nl
743  << "- are used by only two boundary faces and" << nl
744  << "- make an angle with a cosine of more than " << minCos
745  << "." << nl << endl;
746 
747  // Point removal analysis engine with undo
748  removePoints pointRemover(mesh_, true);
749 
750  // Count usage of points
751  boolList pointCanBeDeleted;
752  label nRemove = pointRemover.countPointUsage(minCos, pointCanBeDeleted);
753 
754  if (nRemove > 0)
755  {
756  Info<< "Removing " << nRemove
757  << " straight edge points ..." << nl << endl;
758 
759  // Remove points
760  // ~~~~~~~~~~~~~
761 
762  doRemovePoints(pointRemover, pointCanBeDeleted);
763 
764 
765  for (label iteration = 0; iteration < 100; iteration++)
766  {
767  Info<< nl
768  << "Undo iteration " << iteration << nl
769  << "----------------" << endl;
770 
771 
772  // Check mesh for errors
773  // ~~~~~~~~~~~~~~~~~~~~~
774 
775  faceSet errorFaces
776  (
777  mesh_,
778  "errorFaces",
779  mesh_.nFaces()-mesh_.nInternalFaces()
780  );
781  bool hasErrors = meshCheck::checkMesh
782  (
783  false, // report
784  mesh_,
785  motionDict,
786  errorFaces
787  );
788  // if (checkEdgeConnectivity)
789  //{
790  // Info<< "Checking edge-face connectivity (duplicate faces"
791  // << " or non-consecutive shared vertices)" << endl;
792  //
793  // label nOldSize = errorFaces.size();
794  //
795  // hasErrors =
796  // mesh_.checkFaceFaces
797  // (
798  // false,
799  // &errorFaces
800  // )
801  // || hasErrors;
802  //
803  // Info<< "Detected additional "
804  // << returnReduce(errorFaces.size()-nOldSize,sumOp<label>())
805  // << " faces with illegal face-face connectivity"
806  // << endl;
807  //}
808 
809  if (!hasErrors)
810  {
811  break;
812  }
813 
814  if (debug&meshRefinement::MESH)
815  {
816  errorFaces.instance() = name();
817  Pout<< "**Writing all faces in error to faceSet "
818  << errorFaces.objectPath() << nl << endl;
819  errorFaces.write();
820  }
821 
822  labelList masterErrorFaces
823  (
824  collectFaces
825  (
826  pointRemover.savedFaceLabels(),
827  errorFaces
828  )
829  );
830 
831  const label n = returnReduce
832  (
833  masterErrorFaces.size(),
834  sumOp<label>()
835  );
836 
837  Info<< "Detected " << n
838  << " error faces on boundaries that have been merged."
839  << " These will be restored to their original faces." << nl
840  << endl;
841 
842  if (n == 0)
843  {
844  if (hasErrors)
845  {
846  Info<< "Detected "
847  << returnReduce(errorFaces.size(), sumOp<label>())
848  << " error faces in mesh."
849  << " Restoring neighbours of faces in error." << nl
850  << endl;
851 
852  labelList expandedErrorFaces
853  (
854  growFaceCellFace
855  (
856  errorFaces
857  )
858  );
859 
860  doRestorePoints(pointRemover, expandedErrorFaces);
861  }
862 
863  break;
864  }
865 
866  doRestorePoints(pointRemover, masterErrorFaces);
867  }
868 
869  if (debug&meshRefinement::MESH)
870  {
871  const_cast<Time&>(mesh_.time())++;
872  Pout<< "Writing merged-edges mesh to time "
873  << name() << nl << endl;
874  write();
875  }
876  }
877  else
878  {
879  Info<< "No straight edges simplified and no points removed ..." << endl;
880  }
881 
882  return nRemove;
883 }
884 
885 
886 // ************************************************************************* //
label n
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
Definition: UList.H:477
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
Definition: DynamicListI.H:296
DynamicList< T, SizeInc, SizeMult, SizeDiv > & shrink()
Shrink the allocated space to the number of elements used.
Definition: DynamicListI.H:252
bool insert(const Key &key)
Insert a new entry.
Definition: HashSet.H:109
label size() const
Return number of elements in table.
Definition: HashTableI.H:65
bool found(const Key &) const
Return true if hashedEntry is found in table.
Definition: HashTable.C:138
fileName & instance() const
Return the instance directory, constant, system, <time> etc.
Definition: IOobject.C:355
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
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
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 cell is defined as a list of faces with extra functionality.
Definition: cell.H:60
Combines boundary faces into single face. The faces get the patch of the first face ('the master')
Definition: combineFaces.H:56
const labelList & savedPointLabels() const
If undoable: set of original point labels of stored points.
Definition: combineFaces.H:143
labelListList getMergeSets(const scalar featureCos, const scalar minConcaveCos, const labelHashSet &patchIDs, const labelHashSet &boundaryCells) const
Extract lists of all (non-coupled) boundary faces on selected.
Definition: combineFaces.C:300
void topoChange(const polyTopoChangeMap &)
Force recalculation of locally stored data on topological change.
Definition: combineFaces.C:766
void setUnrefinement(const labelList &masterFaces, polyTopoChange &meshMod, Map< label > &restoredPoints, Map< label > &restoredFaces, Map< label > &restoredCells)
Play commands into polyTopoChange to reinsert original faces.
Definition: combineFaces.C:815
void setRefinement(const labelListList &, polyTopoChange &)
Play commands into polyTopoChange to combine faces. Gets.
Definition: combineFaces.C:558
const labelList & masterFace() const
If undoable: masterface for every set.
Definition: combineFaces.H:137
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
A list of face labels.
Definition: faceSet.H:51
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:418
virtual void topoChange(const polyTopoChangeMap &map)
Update mesh corresponding to the given map.
Definition: fvMesh.C:1264
autoPtr< polyTopoChangeMap > doRestorePoints(removePoints &pointRemover, const labelList &facesToRestore)
label mergeEdgesUndo(const scalar minCos, const dictionary &motionDict)
Merge edges, maintain mesh quality. Return global number.
void checkData()
Debugging: check that all faces still obey start()>end()
void topoChange(const polyTopoChangeMap &, const labelList &changedFaces)
Update for external change to mesh. changedFaces are in new mesh.
word name() const
Replacement for Time::name() : return oldInstance (if.
label mergePatchFacesUndo(const scalar minCos, const scalar concaveCos, const labelHashSet &patchIDs, const dictionary &motionDict, const labelList &preserveFaces)
Merge coplanar faces. preserveFaces is != -1 for faces.
autoPtr< polyTopoChangeMap > doRemovePoints(removePoints &pointRemover, const boolList &pointCanBeDeleted)
labelList collectFaces(const labelList &candidateFaces, const labelHashSet &set) const
void storeData(const labelList &pointsToStore, const labelList &facesToStore, const labelList &cellsToStore)
Signal points/face/cells for which to store data.
bool write() const
Write mesh and all data.
labelList growFaceCellFace(const labelHashSet &set) const
virtual const labelList & faceOwner() const
Return face owner.
Definition: polyMesh.C:1339
void setInstance(const fileName &)
Set the instance for mesh files.
Definition: polyMeshIO.C:78
Direct mesh changes based on v1.3 polyTopoChange syntax.
autoPtr< polyTopoChangeMap > changeMesh(polyMesh &mesh, const bool syncParallel=true, const bool orderCells=false, const bool orderPoints=false)
Inplace changes mesh without change of patches.
label nInternalFaces() const
label nFaces() const
const cellList & cells() const
fileName objectPath() const
Return complete path + object name.
Definition: regIOobject.H:158
virtual bool write(const bool write=true) const
Write using setting from DB.
Removes selected points from mesh and updates faces using these points.
Definition: removePoints.H:59
label countPointUsage(const scalar minCos, boolList &pointCanBeDeleted) const
Mark in pointCanBeDeleted the points that can be deleted.
Definition: removePoints.C:125
void setUnrefinement(const labelList &localFaces, const labelList &localPoints, polyTopoChange &)
Restore selected faces and vertices.
Definition: removePoints.C:750
void topoChange(const polyTopoChangeMap &)
Force recalculation of locally stored data on topological change.
Definition: removePoints.C:436
void setRefinement(const boolList &, polyTopoChange &)
Play commands into polyTopoChange to remove points. Gets.
Definition: removePoints.C:276
const labelList & savedFaceLabels() const
If undoable: affected face labels. Already restored faces.
Definition: removePoints.H:111
void getUnrefimentSet(const labelList &undoFaces, labelList &localFaces, labelList &localPoints) const
Given set of faces to restore calculates a consistent set of.
Definition: removePoints.C:538
static void syncFaceList(const polyMesh &mesh, UList< T > &l, const CombineOp &cop)
Synchronise values on all mesh faces.
Definition: syncTools.H:387
Functions for checking mesh topology and geometry.
bool checkMesh(const bool report, const polyMesh &mesh, const dictionary &dict, const labelList &checkFaces, const List< labelPair > &baffles, labelHashSet &wrongFaces)
Check (subset of mesh including baffles) with mesh settings in dict.
Definition: checkMesh.C:33
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
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
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
labelList findIndices(const ListType &, typename ListType::const_reference, const label start=0)
Find all occurrences of given element. Linear search.
void inplaceMapKey(const labelUList &oldToNew, Container &)
Recreate with mapped keys. Do not map elements with negative key.
messageStream Info
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
prefixOSstream Pout(cout, "Pout")
Definition: IOstreams.H:53
static const char nl
Definition: Ostream.H:266