snappyHexMesh.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 OpenFOAM Foundation
9  Copyright (C) 2015-2020 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 Application
28  snappyHexMesh
29 
30 Group
31  grpMeshGenerationUtilities
32 
33 Description
34  Automatic split hex mesher. Refines and snaps to surface.
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #include "argList.H"
39 #include "Time.H"
40 #include "fvMesh.H"
41 #include "snappyRefineDriver.H"
42 #include "snappySnapDriver.H"
43 #include "snappyLayerDriver.H"
44 #include "searchableSurfaces.H"
45 #include "refinementSurfaces.H"
46 #include "refinementFeatures.H"
47 #include "shellSurfaces.H"
48 #include "decompositionMethod.H"
49 #include "fvMeshDistribute.H"
50 #include "wallPolyPatch.H"
51 #include "refinementParameters.H"
52 #include "snapParameters.H"
53 #include "layerParameters.H"
54 #include "vtkSetWriter.H"
55 #include "faceSet.H"
56 #include "motionSmoother.H"
57 #include "polyTopoChange.H"
59 #include "surfZoneIdentifierList.H"
60 #include "UnsortedMeshedSurface.H"
61 #include "MeshedSurface.H"
62 #include "globalIndex.H"
63 #include "IOmanip.H"
64 #include "decompositionModel.H"
65 #include "fvMeshTools.H"
66 #include "profiling.H"
67 #include "processorMeshes.H"
68 #include "snappyVoxelMeshDriver.H"
69 
70 using namespace Foam;
71 
72 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
73 
74 // Convert size (as fraction of defaultCellSize) to refinement level
75 label sizeCoeffToRefinement
76 (
77  const scalar level0Coeff, // ratio of hex cell size v.s. defaultCellSize
78  const scalar sizeCoeff
79 )
80 {
81  return round(::log(level0Coeff/sizeCoeff)/::log(2));
82 }
83 
84 
85 autoPtr<refinementSurfaces> createRefinementSurfaces
86 (
87  const searchableSurfaces& allGeometry,
88  const dictionary& surfacesDict,
89  const dictionary& shapeControlDict,
90  const label gapLevelIncrement,
91  const scalar level0Coeff
92 )
93 {
94  autoPtr<refinementSurfaces> surfacePtr;
95 
96  // Count number of surfaces.
97  label surfi = 0;
98  forAll(allGeometry.names(), geomi)
99  {
100  const word& geomName = allGeometry.names()[geomi];
101 
102  if (surfacesDict.found(geomName))
103  {
104  surfi++;
105  }
106  }
107 
108  labelList surfaces(surfi);
109  wordList names(surfi);
110  PtrList<surfaceZonesInfo> surfZones(surfi);
111 
112  labelList regionOffset(surfi);
113 
114  labelList globalMinLevel(surfi, Zero);
115  labelList globalMaxLevel(surfi, Zero);
116  labelList globalLevelIncr(surfi, Zero);
117  PtrList<dictionary> globalPatchInfo(surfi);
118  List<Map<label>> regionMinLevel(surfi);
119  List<Map<label>> regionMaxLevel(surfi);
120  List<Map<label>> regionLevelIncr(surfi);
121  List<Map<scalar>> regionAngle(surfi);
122  List<Map<autoPtr<dictionary>>> regionPatchInfo(surfi);
123 
124  wordHashSet unmatchedKeys(surfacesDict.toc());
125 
126  surfi = 0;
127  forAll(allGeometry.names(), geomi)
128  {
129  const word& geomName = allGeometry.names()[geomi];
130 
131  const entry* ePtr = surfacesDict.findEntry(geomName, keyType::REGEX);
132 
133  if (ePtr)
134  {
135  const dictionary& shapeDict = ePtr->dict();
136  unmatchedKeys.erase(ePtr->keyword());
137 
138  names[surfi] = geomName;
139  surfaces[surfi] = geomi;
140 
141  const searchableSurface& surface = allGeometry[geomi];
142 
143  // Find the index in shapeControlDict
144  // Invert surfaceCellSize to get the refinementLevel
145 
146  const word scsFuncName =
147  shapeDict.get<word>("surfaceCellSizeFunction");
148 
149  const dictionary& scsDict =
150  shapeDict.optionalSubDict(scsFuncName + "Coeffs");
151 
152  const scalar surfaceCellSize =
153  scsDict.get<scalar>("surfaceCellSizeCoeff");
154 
155  const label refLevel = sizeCoeffToRefinement
156  (
157  level0Coeff,
158  surfaceCellSize
159  );
160 
161  globalMinLevel[surfi] = refLevel;
162  globalMaxLevel[surfi] = refLevel;
163  globalLevelIncr[surfi] = gapLevelIncrement;
164 
165  // Surface zones
166  surfZones.set
167  (
168  surfi,
169  new surfaceZonesInfo
170  (
171  surface,
172  shapeDict,
173  allGeometry.regionNames()[surfaces[surfi]]
174  )
175  );
176 
177 
178  // Global perpendicular angle
179  if (shapeDict.found("patchInfo"))
180  {
181  globalPatchInfo.set
182  (
183  surfi,
184  shapeDict.subDict("patchInfo").clone()
185  );
186  }
187 
188 
189  // Per region override of patchInfo
190 
191  if (shapeDict.found("regions"))
192  {
193  const dictionary& regionsDict = shapeDict.subDict("regions");
194  const wordList& regionNames =
195  allGeometry[surfaces[surfi]].regions();
196 
197  forAll(regionNames, regioni)
198  {
199  if (regionsDict.found(regionNames[regioni]))
200  {
201  // Get the dictionary for region
202  const dictionary& regionDict = regionsDict.subDict
203  (
204  regionNames[regioni]
205  );
206 
207  if (regionDict.found("patchInfo"))
208  {
209  regionPatchInfo[surfi].insert
210  (
211  regioni,
212  regionDict.subDict("patchInfo").clone()
213  );
214  }
215  }
216  }
217  }
218 
219  // Per region override of cellSize
220  if (shapeDict.found("regions"))
221  {
222  const dictionary& shapeControlRegionsDict =
223  shapeDict.subDict("regions");
224  const wordList& regionNames =
225  allGeometry[surfaces[surfi]].regions();
226 
227  forAll(regionNames, regioni)
228  {
229  if (shapeControlRegionsDict.found(regionNames[regioni]))
230  {
231  const dictionary& shapeControlRegionDict =
232  shapeControlRegionsDict.subDict
233  (
234  regionNames[regioni]
235  );
236 
237  const word scsFuncName =
238  shapeControlRegionDict.get<word>
239  (
240  "surfaceCellSizeFunction"
241  );
242  const dictionary& scsDict =
243  shapeControlRegionDict.subDict
244  (
245  scsFuncName + "Coeffs"
246  );
247 
248  const scalar surfaceCellSize =
249  scsDict.get<scalar>("surfaceCellSizeCoeff");
250 
251  const label refLevel = sizeCoeffToRefinement
252  (
253  level0Coeff,
254  surfaceCellSize
255  );
256 
257  regionMinLevel[surfi].insert(regioni, refLevel);
258  regionMaxLevel[surfi].insert(regioni, refLevel);
259  regionLevelIncr[surfi].insert(regioni, 0);
260  }
261  }
262  }
263 
264  surfi++;
265  }
266  }
267 
268  // Calculate local to global region offset
269  label nRegions = 0;
270 
271  forAll(surfaces, surfi)
272  {
273  regionOffset[surfi] = nRegions;
274  nRegions += allGeometry[surfaces[surfi]].regions().size();
275  }
276 
277  // Rework surface specific information into information per global region
278  labelList minLevel(nRegions, Zero);
279  labelList maxLevel(nRegions, Zero);
280  labelList gapLevel(nRegions, -1);
281  PtrList<dictionary> patchInfo(nRegions);
282 
283  forAll(globalMinLevel, surfi)
284  {
285  label nRegions = allGeometry[surfaces[surfi]].regions().size();
286 
287  // Initialise to global (i.e. per surface)
288  for (label i = 0; i < nRegions; i++)
289  {
290  label globalRegioni = regionOffset[surfi] + i;
291  minLevel[globalRegioni] = globalMinLevel[surfi];
292  maxLevel[globalRegioni] = globalMaxLevel[surfi];
293  gapLevel[globalRegioni] =
294  maxLevel[globalRegioni]
295  + globalLevelIncr[surfi];
296 
297  if (globalPatchInfo.set(surfi))
298  {
299  patchInfo.set
300  (
301  globalRegioni,
302  globalPatchInfo[surfi].clone()
303  );
304  }
305  }
306 
307  // Overwrite with region specific information
308  forAllConstIters(regionMinLevel[surfi], iter)
309  {
310  label globalRegioni = regionOffset[surfi] + iter.key();
311 
312  minLevel[globalRegioni] = iter();
313  maxLevel[globalRegioni] = regionMaxLevel[surfi][iter.key()];
314  gapLevel[globalRegioni] =
315  maxLevel[globalRegioni]
316  + regionLevelIncr[surfi][iter.key()];
317  }
318 
319  const Map<autoPtr<dictionary>>& localInfo = regionPatchInfo[surfi];
320  forAllConstIters(localInfo, iter)
321  {
322  label globalRegioni = regionOffset[surfi] + iter.key();
323  patchInfo.set(globalRegioni, iter()().clone());
324  }
325  }
326 
327  surfacePtr.reset
328  (
330  (
331  allGeometry,
332  surfaces,
333  names,
334  surfZones,
335  regionOffset,
336  minLevel,
337  maxLevel,
338  gapLevel,
339  scalarField(nRegions, -GREAT), //perpendicularAngle,
340  patchInfo,
341  false //dryRun
342  )
343  );
344 
345 
346  const refinementSurfaces& rf = surfacePtr();
347 
348  // Determine maximum region name length
349  label maxLen = 0;
350  forAll(rf.surfaces(), surfi)
351  {
352  label geomi = rf.surfaces()[surfi];
353  const wordList& regionNames = allGeometry.regionNames()[geomi];
354  forAll(regionNames, regioni)
355  {
356  maxLen = Foam::max(maxLen, label(regionNames[regioni].size()));
357  }
358  }
359 
360 
361  Info<< setw(maxLen) << "Region"
362  << setw(10) << "Min Level"
363  << setw(10) << "Max Level"
364  << setw(10) << "Gap Level" << nl
365  << setw(maxLen) << "------"
366  << setw(10) << "---------"
367  << setw(10) << "---------"
368  << setw(10) << "---------" << endl;
369 
370  forAll(rf.surfaces(), surfi)
371  {
372  label geomi = rf.surfaces()[surfi];
373 
374  Info<< rf.names()[surfi] << ':' << nl;
375 
376  const wordList& regionNames = allGeometry.regionNames()[geomi];
377 
378  forAll(regionNames, regioni)
379  {
380  label globali = rf.globalRegion(surfi, regioni);
381 
382  Info<< setw(maxLen) << regionNames[regioni]
383  << setw(10) << rf.minLevel()[globali]
384  << setw(10) << rf.maxLevel()[globali]
385  << setw(10) << rf.gapLevel()[globali] << endl;
386  }
387  }
388 
389 
390  return surfacePtr;
391 }
392 
393 
394 void extractSurface
395 (
396  const polyMesh& mesh,
397  const Time& runTime,
398  const labelHashSet& includePatches,
399  const fileName& outFileName
400 )
401 {
403 
404  // Collect sizes. Hash on names to handle local-only patches (e.g.
405  // processor patches)
406  HashTable<label> patchSize(1024);
407  label nFaces = 0;
408  for (const label patchi : includePatches)
409  {
410  const polyPatch& pp = bMesh[patchi];
411  patchSize.insert(pp.name(), pp.size());
412  nFaces += pp.size();
413  }
415 
416 
417  // Allocate zone/patch for all patches
418  HashTable<label> compactZoneID(1024);
419  forAllConstIters(patchSize, iter)
420  {
421  label sz = compactZoneID.size();
422  compactZoneID.insert(iter.key(), sz);
423  }
424  Pstream::mapCombineScatter(compactZoneID);
425 
426 
427  // Rework HashTable into labelList just for speed of conversion
428  labelList patchToCompactZone(bMesh.size(), -1);
429  forAllConstIters(compactZoneID, iter)
430  {
431  label patchi = bMesh.findPatchID(iter.key());
432  if (patchi != -1)
433  {
434  patchToCompactZone[patchi] = iter();
435  }
436  }
437 
438  // Collect faces on zones
439  DynamicList<label> faceLabels(nFaces);
440  DynamicList<label> compactZones(nFaces);
441  for (const label patchi : includePatches)
442  {
443  const polyPatch& pp = bMesh[patchi];
444  forAll(pp, i)
445  {
446  faceLabels.append(pp.start()+i);
447  compactZones.append(patchToCompactZone[pp.index()]);
448  }
449  }
450 
451  // Addressing engine for all faces
452  uindirectPrimitivePatch allBoundary
453  (
454  UIndirectList<face>(mesh.faces(), faceLabels),
455  mesh.points()
456  );
457 
458 
459  // Find correspondence to master points
460  labelList pointToGlobal;
461  labelList uniqueMeshPoints;
463  (
464  allBoundary.meshPoints(),
465  allBoundary.meshPointMap(),
466  pointToGlobal,
467  uniqueMeshPoints
468  );
469 
470  // Gather all unique points on master
471  List<pointField> gatheredPoints(Pstream::nProcs());
472  gatheredPoints[Pstream::myProcNo()] = pointField
473  (
474  mesh.points(),
475  uniqueMeshPoints
476  );
477  Pstream::gatherList(gatheredPoints);
478 
479  // Gather all faces
480  List<faceList> gatheredFaces(Pstream::nProcs());
481  gatheredFaces[Pstream::myProcNo()] = allBoundary.localFaces();
482  forAll(gatheredFaces[Pstream::myProcNo()], i)
483  {
484  inplaceRenumber(pointToGlobal, gatheredFaces[Pstream::myProcNo()][i]);
485  }
486  Pstream::gatherList(gatheredFaces);
487 
488  // Gather all ZoneIDs
489  List<labelList> gatheredZones(Pstream::nProcs());
490  gatheredZones[Pstream::myProcNo()].transfer(compactZones);
491  Pstream::gatherList(gatheredZones);
492 
493  // On master combine all points, faces, zones
494  if (Pstream::master())
495  {
496  pointField allPoints = ListListOps::combine<pointField>
497  (
498  gatheredPoints,
500  );
501  gatheredPoints.clear();
502 
503  faceList allFaces = ListListOps::combine<faceList>
504  (
505  gatheredFaces,
507  );
508  gatheredFaces.clear();
509 
510  labelList allZones = ListListOps::combine<labelList>
511  (
512  gatheredZones,
514  );
515  gatheredZones.clear();
516 
517 
518  // Zones
519  surfZoneIdentifierList surfZones(compactZoneID.size());
520  forAllConstIters(compactZoneID, iter)
521  {
522  surfZones[iter()] = surfZoneIdentifier(iter.key(), iter());
523  Info<< "surfZone " << iter() << " : " << surfZones[iter()].name()
524  << endl;
525  }
526 
527  UnsortedMeshedSurface<face> unsortedFace
528  (
529  std::move(allPoints),
530  std::move(allFaces),
531  std::move(allZones),
532  surfZones
533  );
534 
535 
536  MeshedSurface<face> sortedFace(unsortedFace);
537 
538  fileName globalCasePath
539  (
541  ? runTime.globalPath()/outFileName
542  : runTime.path()/outFileName
543  );
544  globalCasePath.clean();
545 
546  Info<< "Writing merged surface to " << globalCasePath << endl;
547 
548  sortedFace.write(globalCasePath);
549  }
550 }
551 
552 
553 label checkAlignment(const polyMesh& mesh, const scalar tol, Ostream& os)
554 {
555  // Check all edges aligned with one of the coordinate axes
556  const faceList& faces = mesh.faces();
557  const pointField& points = mesh.points();
558 
559  label nUnaligned = 0;
560 
561  forAll(faces, facei)
562  {
563  const face& f = faces[facei];
564  forAll(f, fp)
565  {
566  label fp1 = f.fcIndex(fp);
567  const linePointRef e(edge(f[fp], f[fp1]).line(points));
568  const vector v(e.vec());
569  const scalar magV(mag(v));
570  if (magV > ROOTVSMALL)
571  {
572  for
573  (
574  direction dir = 0;
575  dir < pTraits<vector>::nComponents;
576  ++dir
577  )
578  {
579  const scalar s(mag(v[dir]));
580  if (s > magV*tol && s < magV*(1-tol))
581  {
582  ++nUnaligned;
583  break;
584  }
585  }
586  }
587  }
588  }
589 
590  reduce(nUnaligned, sumOp<label>());
591 
592  if (nUnaligned)
593  {
594  os << "Initial mesh has " << nUnaligned
595  << " edges unaligned with any of the coordinate axes" << nl << endl;
596  }
597  return nUnaligned;
598 }
599 
600 
601 // Check writing tolerance before doing any serious work
602 scalar getMergeDistance
603 (
604  const polyMesh& mesh,
605  const scalar mergeTol,
606  const bool dryRun
607 )
608 {
609  const boundBox& meshBb = mesh.bounds();
610  scalar mergeDist = mergeTol * meshBb.mag();
611 
612  Info<< nl
613  << "Overall mesh bounding box : " << meshBb << nl
614  << "Relative tolerance : " << mergeTol << nl
615  << "Absolute matching distance : " << mergeDist << nl
616  << endl;
617 
618  // check writing tolerance
619  if (mesh.time().writeFormat() == IOstream::ASCII && !dryRun)
620  {
621  const scalar writeTol = std::pow
622  (
623  scalar(10),
624  -scalar(IOstream::defaultPrecision())
625  );
626 
627  if (mergeTol < writeTol)
628  {
630  << "Your current settings specify ASCII writing with "
631  << IOstream::defaultPrecision() << " digits precision." << nl
632  << "Your merging tolerance (" << mergeTol
633  << ") is finer than this." << nl
634  << "Change to binary writeFormat, "
635  << "or increase the writePrecision" << endl
636  << "or adjust the merge tolerance (mergeTol)."
637  << exit(FatalError);
638  }
639  }
640 
641  return mergeDist;
642 }
643 
644 
645 void removeZeroSizedPatches(fvMesh& mesh)
646 {
647  // Remove any zero-sized ones. Assumes
648  // - processor patches are already only there if needed
649  // - all other patches are available on all processors
650  // - but coupled ones might still be needed, even if zero-size
651  // (e.g. processorCyclic)
652  // See also logic in createPatch.
653  const polyBoundaryMesh& pbm = mesh.boundaryMesh();
654 
655  labelList oldToNew(pbm.size(), -1);
656  label newPatchi = 0;
657  forAll(pbm, patchi)
658  {
659  const polyPatch& pp = pbm[patchi];
660 
661  if (!isA<processorPolyPatch>(pp))
662  {
663  if
664  (
665  isA<coupledPolyPatch>(pp)
666  || returnReduce(pp.size(), sumOp<label>())
667  )
668  {
669  // Coupled (and unknown size) or uncoupled and used
670  oldToNew[patchi] = newPatchi++;
671  }
672  }
673  }
674 
675  forAll(pbm, patchi)
676  {
677  const polyPatch& pp = pbm[patchi];
678 
679  if (isA<processorPolyPatch>(pp))
680  {
681  oldToNew[patchi] = newPatchi++;
682  }
683  }
684 
685 
686  const label nKeepPatches = newPatchi;
687 
688  // Shuffle unused ones to end
689  if (nKeepPatches != pbm.size())
690  {
691  Info<< endl
692  << "Removing zero-sized patches:" << endl << incrIndent;
693 
694  forAll(oldToNew, patchi)
695  {
696  if (oldToNew[patchi] == -1)
697  {
698  Info<< indent << pbm[patchi].name()
699  << " type " << pbm[patchi].type()
700  << " at position " << patchi << endl;
701  oldToNew[patchi] = newPatchi++;
702  }
703  }
704  Info<< decrIndent;
705 
706  fvMeshTools::reorderPatches(mesh, oldToNew, nKeepPatches, true);
707  Info<< endl;
708  }
709 }
710 
711 
712 // Write mesh and additional information
713 void writeMesh
714 (
715  const string& msg,
716  const meshRefinement& meshRefiner,
717  const meshRefinement::debugType debugLevel,
718  const meshRefinement::writeType writeLevel
719 )
720 {
721  const fvMesh& mesh = meshRefiner.mesh();
722 
723  meshRefiner.printMeshInfo(debugLevel, msg);
724  Info<< "Writing mesh to time " << meshRefiner.timeName() << endl;
725 
727  if (!debugLevel && !(writeLevel&meshRefinement::WRITELAYERSETS))
728  {
730  }
732 
733  meshRefiner.write
734  (
735  debugLevel,
737  mesh.time().path()/meshRefiner.timeName()
738  );
739  Info<< "Wrote mesh in = "
740  << mesh.time().cpuTimeIncrement() << " s." << endl;
741 }
742 
743 
744 int main(int argc, char *argv[])
745 {
747  (
748  "Automatic split hex mesher. Refines and snaps to surface"
749  );
750 
751  #include "addRegionOption.H"
752  #include "addOverwriteOption.H"
753  #include "addProfilingOption.H"
755  (
756  "checkGeometry",
757  "Check all surface geometry for quality"
758  );
760  (
761  "dry-run",
762  "Check case set-up only using a single time step"
763  );
765  (
766  "surfaceSimplify",
767  "boundBox",
768  "Simplify the surface using snappyHexMesh starting from a boundBox"
769  );
771  (
772  "patches",
773  "(patch0 .. patchN)",
774  "Only triangulate selected patches (wildcards supported)"
775  );
777  (
778  "outFile",
779  "file",
780  "Name of the file to save the simplified surface to"
781  );
782  argList::addOption("dict", "file", "Alternative snappyHexMeshDict");
783 
784  argList::noFunctionObjects(); // Never use function objects
785 
786  #include "setRootCase.H"
787  #include "createTime.H"
788 
789  const bool overwrite = args.found("overwrite");
790  const bool checkGeometry = args.found("checkGeometry");
791  const bool surfaceSimplify = args.found("surfaceSimplify");
792  const bool dryRun = args.found("dry-run");
793 
794  if (dryRun)
795  {
796  Info<< "Operating in dry-run mode to detect set-up errors"
797  << nl << endl;
798  }
799 
800 
801  #include "createNamedMesh.H"
802  Info<< "Read mesh in = "
803  << runTime.cpuTimeIncrement() << " s" << endl;
804 
805  // Check patches and faceZones are synchronised
808 
809  if (dryRun)
810  {
811  // Check if mesh aligned with cartesian axes
812  checkAlignment(mesh, 1e-6, Pout); //FatalIOError);
813  }
814 
815 
816 
817  // Read meshing dictionary
818  const word dictName("snappyHexMeshDict");
819  #include "setSystemMeshDictionaryIO.H"
821 
822 
823  // all surface geometry
824  const dictionary& geometryDict =
825  meshRefinement::subDict(meshDict, "geometry", dryRun);
826 
827  // refinement parameters
828  const dictionary& refineDict =
829  meshRefinement::subDict(meshDict, "castellatedMeshControls", dryRun);
830 
831  // mesh motion and mesh quality parameters
832  const dictionary& motionDict =
833  meshRefinement::subDict(meshDict, "meshQualityControls", dryRun);
834 
835  // snap-to-surface parameters
836  const dictionary& snapDict =
837  meshRefinement::subDict(meshDict, "snapControls", dryRun);
838 
839  // layer addition parameters
840  const dictionary& layerDict =
841  meshRefinement::subDict(meshDict, "addLayersControls", dryRun);
842 
843  // absolute merge distance
844  const scalar mergeDist = getMergeDistance
845  (
846  mesh,
847  meshRefinement::get<scalar>
848  (
849  meshDict,
850  "mergeTolerance",
851  dryRun
852  ),
853  dryRun
854  );
855 
856  const bool keepPatches(meshDict.getOrDefault("keepPatches", false));
857 
858  // format to be used for writing lines
859  const word setFormat
860  (
862  (
863  "setFormat",
865  )
866  );
867  const autoPtr<writer<scalar>> setFormatter
868  (
870  );
871 
872  const scalar maxSizeRatio
873  (
874  meshDict.getOrDefault<scalar>("maxSizeRatio", 100)
875  );
876 
877 
878  // Read decomposePar dictionary
879  dictionary decomposeDict;
880  if (Pstream::parRun())
881  {
882  // Ensure demand-driven decompositionMethod finds alternative
883  // decomposeParDict location properly.
884 
885  IOdictionary* dictPtr = new IOdictionary
886  (
888  (
889  IOobject
890  (
892  runTime.system(),
893  runTime,
896  ),
897  args.getOrDefault<fileName>("decomposeParDict", "")
898  )
899  );
900 
901  // Store it on the object registry, but to be found it must also
902  // have the expected "decomposeParDict" name.
903 
905  runTime.store(dictPtr);
906 
907  decomposeDict = *dictPtr;
908  }
909  else
910  {
911  decomposeDict.add("method", "none");
912  decomposeDict.add("numberOfSubdomains", 1);
913  }
914 
915 
916  // Debug
917  // ~~~~~
918 
919  // Set debug level
921  (
922  meshDict.getOrDefault<label>
923  (
924  "debug",
925  0
926  )
927  );
928  {
929  wordList flags;
930  if (meshDict.readIfPresent("debugFlags", flags))
931  {
932  debugLevel = meshRefinement::debugType
933  (
935  (
937  flags
938  )
939  );
940  }
941  }
942  if (debugLevel > 0)
943  {
944  meshRefinement::debug = debugLevel;
945  snappyRefineDriver::debug = debugLevel;
946  snappySnapDriver::debug = debugLevel;
947  snappyLayerDriver::debug = debugLevel;
948  }
949 
950  // Set file writing level
951  {
952  wordList flags;
953  if (meshDict.readIfPresent("writeFlags", flags))
954  {
956  (
958  (
960  (
962  flags
963  )
964  )
965  );
966  }
967  }
968 
970  //{
971  // wordList flags;
972  // if (meshDict.readIfPresent("outputFlags", flags))
973  // {
974  // meshRefinement::outputLevel
975  // (
976  // meshRefinement::outputType
977  // (
978  // meshRefinement::readFlags
979  // (
980  // meshRefinement::outputTypeNames,
981  // flags
982  // )
983  // )
984  // );
985  // }
986  //}
987 
988  // for the impatient who want to see some output files:
990 
991  // Read geometry
992  // ~~~~~~~~~~~~~
993 
994  searchableSurfaces allGeometry
995  (
996  IOobject
997  (
998  "abc", // dummy name
999  mesh.time().constant(), // instance
1000  //mesh.time().findInstance("triSurface", word::null),// instance
1001  "triSurface", // local
1002  mesh.time(), // registry
1005  ),
1006  geometryDict,
1007  meshDict.getOrDefault("singleRegionName", true)
1008  );
1009 
1010 
1011  // Read refinement surfaces
1012  // ~~~~~~~~~~~~~~~~~~~~~~~~
1013 
1014  autoPtr<refinementSurfaces> surfacesPtr;
1015 
1016  Info<< "Reading refinement surfaces." << endl;
1017 
1018  if (surfaceSimplify)
1019  {
1020  addProfiling(surfaceSimplify, "snappyHexMesh::surfaceSimplify");
1021  IOdictionary foamyHexMeshDict
1022  (
1023  IOobject
1024  (
1025  "foamyHexMeshDict",
1026  runTime.system(),
1027  runTime,
1030  )
1031  );
1032 
1033  const dictionary& conformationDict =
1034  foamyHexMeshDict.subDict("surfaceConformation").subDict
1035  (
1036  "geometryToConformTo"
1037  );
1038 
1039  const dictionary& motionDict =
1040  foamyHexMeshDict.subDict("motionControl");
1041 
1042  const dictionary& shapeControlDict =
1043  motionDict.subDict("shapeControlFunctions");
1044 
1045  // Calculate current ratio of hex cells v.s. wanted cell size
1046  const scalar defaultCellSize =
1047  motionDict.get<scalar>("defaultCellSize");
1048 
1049  const scalar initialCellSize = ::pow(mesh.V()[0], 1.0/3.0);
1050 
1051  //Info<< "Wanted cell size = " << defaultCellSize << endl;
1052  //Info<< "Current cell size = " << initialCellSize << endl;
1053  //Info<< "Fraction = " << initialCellSize/defaultCellSize
1054  // << endl;
1055 
1056  surfacesPtr =
1057  createRefinementSurfaces
1058  (
1059  allGeometry,
1060  conformationDict,
1061  shapeControlDict,
1062  refineDict.getOrDefault("gapLevelIncrement", 0),
1063  initialCellSize/defaultCellSize
1064  );
1065 
1067  }
1068  else
1069  {
1070  surfacesPtr.reset
1071  (
1072  new refinementSurfaces
1073  (
1074  allGeometry,
1076  (
1077  refineDict,
1078  "refinementSurfaces",
1079  dryRun
1080  ),
1081  refineDict.getOrDefault("gapLevelIncrement", 0),
1082  dryRun
1083  )
1084  );
1085 
1086  Info<< "Read refinement surfaces in = "
1087  << mesh.time().cpuTimeIncrement() << " s" << nl << endl;
1088  }
1089 
1090  refinementSurfaces& surfaces = surfacesPtr();
1091 
1092 
1093  // Checking only?
1094 
1095  if (checkGeometry)
1096  {
1097  // Check geometry amongst itself (e.g. intersection, size differences)
1098 
1099  // Extract patchInfo
1100  List<wordList> patchTypes(allGeometry.size());
1101 
1102  const PtrList<dictionary>& patchInfo = surfaces.patchInfo();
1103  const labelList& surfaceGeometry = surfaces.surfaces();
1104  forAll(surfaceGeometry, surfi)
1105  {
1106  label geomi = surfaceGeometry[surfi];
1107  const wordList& regNames = allGeometry.regionNames()[geomi];
1108 
1109  patchTypes[geomi].setSize(regNames.size());
1110  forAll(regNames, regioni)
1111  {
1112  label globalRegioni = surfaces.globalRegion(surfi, regioni);
1113 
1114  if (patchInfo.set(globalRegioni))
1115  {
1116  patchTypes[geomi][regioni] =
1117  meshRefinement::get<word>
1118  (
1119  patchInfo[globalRegioni],
1120  "type",
1121  dryRun,
1123  word::null
1124  );
1125  }
1126  else
1127  {
1128  patchTypes[geomi][regioni] = wallPolyPatch::typeName;
1129  }
1130  }
1131  }
1132 
1133  // Write some stats
1134  allGeometry.writeStats(patchTypes, Info);
1135  // Check topology
1136  allGeometry.checkTopology(true);
1137  // Check geometry
1138  allGeometry.checkGeometry
1139  (
1140  maxSizeRatio, // max size ratio
1141  1e-9, // intersection tolerance
1142  setFormatter,
1143  0.01, // min triangle quality
1144  true
1145  );
1146 
1147  if (!dryRun)
1148  {
1149  return 0;
1150  }
1151  }
1152 
1153 
1154  if (dryRun)
1155  {
1156  // Check geometry to mesh bounding box
1157  Info<< "Checking for geometry size relative to mesh." << endl;
1158  const boundBox& meshBb = mesh.bounds();
1159  forAll(allGeometry, geomi)
1160  {
1161  const searchableSurface& s = allGeometry[geomi];
1162  const boundBox& bb = s.bounds();
1163 
1164  scalar ratio = bb.mag() / meshBb.mag();
1165  if (ratio > maxSizeRatio || ratio < 1.0/maxSizeRatio)
1166  {
1167  Warning
1168  << " " << allGeometry.names()[geomi]
1169  << " bounds differ from mesh"
1170  << " by more than a factor " << maxSizeRatio << ":" << nl
1171  << " bounding box : " << bb << nl
1172  << " mesh bounding box : " << meshBb
1173  << endl;
1174  }
1175  if (!meshBb.contains(bb))
1176  {
1177  Warning
1178  << " " << allGeometry.names()[geomi]
1179  << " bounds not fully contained in mesh" << nl
1180  << " bounding box : " << bb << nl
1181  << " mesh bounding box : " << meshBb
1182  << endl;
1183  }
1184  }
1185  Info<< endl;
1186  }
1187 
1188 
1189 
1190 
1191  // Read refinement shells
1192  // ~~~~~~~~~~~~~~~~~~~~~~
1193 
1194  Info<< "Reading refinement shells." << endl;
1195  shellSurfaces shells
1196  (
1197  allGeometry,
1198  meshRefinement::subDict(refineDict, "refinementRegions", dryRun),
1199  dryRun
1200  );
1201  Info<< "Read refinement shells in = "
1202  << mesh.time().cpuTimeIncrement() << " s" << nl << endl;
1203 
1204 
1205  Info<< "Setting refinement level of surface to be consistent"
1206  << " with shells." << endl;
1207  surfaces.setMinLevelFields(shells);
1208  Info<< "Checked shell refinement in = "
1209  << mesh.time().cpuTimeIncrement() << " s" << nl << endl;
1210 
1211 
1212  // Optionally read limit shells
1213  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1214 
1215  const dictionary limitDict(refineDict.subOrEmptyDict("limitRegions"));
1216 
1217  if (!limitDict.empty())
1218  {
1219  Info<< "Reading limit shells." << endl;
1220  }
1221 
1222  shellSurfaces limitShells(allGeometry, limitDict, dryRun);
1223 
1224  if (!limitDict.empty())
1225  {
1226  Info<< "Read limit shells in = "
1227  << mesh.time().cpuTimeIncrement() << " s" << nl << endl;
1228  }
1229 
1230  if (dryRun)
1231  {
1232  // Check for use of all geometry
1233  const wordList& allGeomNames = allGeometry.names();
1234 
1235  labelHashSet unusedGeometries(identity(allGeomNames.size()));
1236  unusedGeometries.erase(surfaces.surfaces());
1237  unusedGeometries.erase(shells.shells());
1238  unusedGeometries.erase(limitShells.shells());
1239 
1240  if (unusedGeometries.size())
1241  {
1242  IOWarningInFunction(geometryDict)
1243  << "The following geometry entries are not used:" << nl;
1244  for (const label geomi : unusedGeometries)
1245  {
1246  Info<< " " << allGeomNames[geomi] << nl;
1247  }
1248  Info<< endl;
1249  }
1250  }
1251 
1252 
1253 
1254 
1255  // Read feature meshes
1256  // ~~~~~~~~~~~~~~~~~~~
1257 
1258  Info<< "Reading features." << endl;
1259  refinementFeatures features
1260  (
1261  mesh,
1263  (
1264  meshRefinement::lookup(refineDict, "features", dryRun)
1265  ),
1266  dryRun
1267  );
1268  Info<< "Read features in = "
1269  << mesh.time().cpuTimeIncrement() << " s" << nl << endl;
1270 
1271 
1272  if (dryRun)
1273  {
1274  // Check geometry to mesh bounding box
1275  Info<< "Checking for line geometry size relative to surface geometry."
1276  << endl;
1277 
1278  OStringStream os;
1279  bool hasErrors = features.checkSizes
1280  (
1281  maxSizeRatio, //const scalar maxRatio,
1282  mesh.bounds(),
1283  true, //const bool report,
1284  os //FatalIOError
1285  );
1286  if (hasErrors)
1287  {
1288  Warning<< os.str() << endl;
1289  }
1290  }
1291 
1292 
1293  // Refinement engine
1294  // ~~~~~~~~~~~~~~~~~
1295 
1296  Info<< nl
1297  << "Determining initial surface intersections" << nl
1298  << "-----------------------------------------" << nl
1299  << endl;
1300 
1301  // Main refinement engine
1302  meshRefinement meshRefiner
1303  (
1304  mesh,
1305  mergeDist, // tolerance used in sorting coordinates
1306  overwrite, // overwrite mesh files?
1307  surfaces, // for surface intersection refinement
1308  features, // for feature edges/point based refinement
1309  shells, // for volume (inside/outside) refinement
1310  limitShells, // limit of volume refinement
1311  labelList(), // initial faces to test
1312  dryRun
1313  );
1314 
1315  if (!dryRun)
1316  {
1317  meshRefiner.updateIntersections(identity(mesh.nFaces()));
1318  Info<< "Calculated surface intersections in = "
1319  << mesh.time().cpuTimeIncrement() << " s" << nl << endl;
1320  }
1321 
1322  // Some stats
1323  meshRefiner.printMeshInfo(debugLevel, "Initial mesh");
1324 
1325  meshRefiner.write
1326  (
1329  mesh.time().path()/meshRefiner.timeName()
1330  );
1331 
1332 
1333  // Refinement parameters
1334  const refinementParameters refineParams(refineDict, dryRun);
1335 
1336  // Snap parameters
1337  const snapParameters snapParams(snapDict, dryRun);
1338 
1339 
1340 
1341  // Add all the cellZones and faceZones
1342  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1343 
1344  // 1. cellZones relating to surface (faceZones added later)
1345 
1346  const labelList namedSurfaces
1347  (
1349  );
1350 
1352  (
1353  surfaces.surfZones(),
1354  namedSurfaces,
1355  mesh
1356  );
1357 
1358 
1359  // 2. cellZones relating to locations
1360 
1361  refineParams.addCellZonesToMesh(mesh);
1362 
1363 
1364 
1365  // Add all the surface regions as patches
1366  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1367 
1368  //- Global surface region to patch (non faceZone surface) or patches
1369  // (faceZone surfaces)
1370  labelList globalToMasterPatch;
1371  labelList globalToSlavePatch;
1372 
1373 
1374  {
1375  Info<< nl
1376  << "Adding patches for surface regions" << nl
1377  << "----------------------------------" << nl
1378  << endl;
1379 
1380  // From global region number to mesh patch.
1381  globalToMasterPatch.setSize(surfaces.nRegions(), -1);
1382  globalToSlavePatch.setSize(surfaces.nRegions(), -1);
1383 
1384  if (!dryRun)
1385  {
1386  Info<< setf(ios_base::left)
1387  << setw(6) << "Patch"
1388  << setw(20) << "Type"
1389  << setw(30) << "Region" << nl
1390  << setw(6) << "-----"
1391  << setw(20) << "----"
1392  << setw(30) << "------" << endl;
1393  }
1394 
1395  const labelList& surfaceGeometry = surfaces.surfaces();
1396  const PtrList<dictionary>& surfacePatchInfo = surfaces.patchInfo();
1397  const polyBoundaryMesh& pbm = mesh.boundaryMesh();
1398 
1399  forAll(surfaceGeometry, surfi)
1400  {
1401  label geomi = surfaceGeometry[surfi];
1402 
1403  const wordList& regNames = allGeometry.regionNames()[geomi];
1404 
1405  if (!dryRun)
1406  {
1407  Info<< surfaces.names()[surfi] << ':' << nl << nl;
1408  }
1409 
1410  const wordList& fzNames =
1411  surfaces.surfZones()[surfi].faceZoneNames();
1412 
1413  if (fzNames.empty())
1414  {
1415  // 'Normal' surface
1416  forAll(regNames, i)
1417  {
1418  label globalRegioni = surfaces.globalRegion(surfi, i);
1419 
1420  label patchi;
1421 
1422  if (surfacePatchInfo.set(globalRegioni))
1423  {
1424  patchi = meshRefiner.addMeshedPatch
1425  (
1426  regNames[i],
1427  surfacePatchInfo[globalRegioni]
1428  );
1429  }
1430  else
1431  {
1432  dictionary patchInfo;
1433  patchInfo.set("type", wallPolyPatch::typeName);
1434 
1435  patchi = meshRefiner.addMeshedPatch
1436  (
1437  regNames[i],
1438  patchInfo
1439  );
1440  }
1441 
1442  if (!dryRun)
1443  {
1444  Info<< setf(ios_base::left)
1445  << setw(6) << patchi
1446  << setw(20) << pbm[patchi].type()
1447  << setw(30) << regNames[i] << nl;
1448  }
1449 
1450  globalToMasterPatch[globalRegioni] = patchi;
1451  globalToSlavePatch[globalRegioni] = patchi;
1452  }
1453  }
1454  else
1455  {
1456  // Zoned surface
1457  forAll(regNames, i)
1458  {
1459  label globalRegioni = surfaces.globalRegion(surfi, i);
1460 
1461  // Add master side patch
1462  {
1463  label patchi;
1464 
1465  if (surfacePatchInfo.set(globalRegioni))
1466  {
1467  patchi = meshRefiner.addMeshedPatch
1468  (
1469  regNames[i],
1470  surfacePatchInfo[globalRegioni]
1471  );
1472  }
1473  else
1474  {
1475  dictionary patchInfo;
1476  patchInfo.set("type", wallPolyPatch::typeName);
1477 
1478  patchi = meshRefiner.addMeshedPatch
1479  (
1480  regNames[i],
1481  patchInfo
1482  );
1483  }
1484 
1485  if (!dryRun)
1486  {
1487  Info<< setf(ios_base::left)
1488  << setw(6) << patchi
1489  << setw(20) << pbm[patchi].type()
1490  << setw(30) << regNames[i] << nl;
1491  }
1492 
1493  globalToMasterPatch[globalRegioni] = patchi;
1494  }
1495  // Add slave side patch
1496  {
1497  const word slaveName = regNames[i] + "_slave";
1498  label patchi;
1499 
1500  if (surfacePatchInfo.set(globalRegioni))
1501  {
1502  patchi = meshRefiner.addMeshedPatch
1503  (
1504  slaveName,
1505  surfacePatchInfo[globalRegioni]
1506  );
1507  }
1508  else
1509  {
1510  dictionary patchInfo;
1511  patchInfo.set("type", wallPolyPatch::typeName);
1512 
1513  patchi = meshRefiner.addMeshedPatch
1514  (
1515  slaveName,
1516  patchInfo
1517  );
1518  }
1519 
1520  if (!dryRun)
1521  {
1522  Info<< setf(ios_base::left)
1523  << setw(6) << patchi
1524  << setw(20) << pbm[patchi].type()
1525  << setw(30) << slaveName << nl;
1526  }
1527 
1528  globalToSlavePatch[globalRegioni] = patchi;
1529  }
1530  }
1531 
1532  // For now: have single faceZone per surface. Use first
1533  // region in surface for patch for zoning
1534  if (regNames.size())
1535  {
1536  forAll(fzNames, fzi)
1537  {
1538  const word& fzName = fzNames[fzi];
1539  label globalRegioni = surfaces.globalRegion(surfi, fzi);
1540 
1541  meshRefiner.addFaceZone
1542  (
1543  fzName,
1544  pbm[globalToMasterPatch[globalRegioni]].name(),
1545  pbm[globalToSlavePatch[globalRegioni]].name(),
1546  surfaces.surfZones()[surfi].faceType()
1547  );
1548  }
1549  }
1550  }
1551 
1552  if (!dryRun)
1553  {
1554  Info<< nl;
1555  }
1556  }
1557  Info<< "Added patches in = "
1558  << mesh.time().cpuTimeIncrement() << " s" << nl << endl;
1559  }
1560 
1561 
1562 
1563  // Add all information for all the remaining faceZones
1564  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1565 
1566  HashTable<Pair<word>> faceZoneToPatches;
1567  forAll(mesh.faceZones(), zonei)
1568  {
1569  const word& fzName = mesh.faceZones()[zonei].name();
1570 
1571  label mpI, spI;
1573  bool hasInfo = meshRefiner.getFaceZoneInfo(fzName, mpI, spI, fzType);
1574 
1575  if (!hasInfo)
1576  {
1577  // faceZone does not originate from a surface but presumably
1578  // from a cellZone pair instead
1579  string::size_type i = fzName.find("_to_");
1580  if (i != string::npos)
1581  {
1582  word cz0 = fzName.substr(0, i);
1583  word cz1 = fzName.substr(i+4, fzName.size()-i+4);
1584  word slaveName(cz1 + "_to_" + cz0);
1585  faceZoneToPatches.insert(fzName, Pair<word>(fzName, slaveName));
1586  }
1587  else
1588  {
1589  // Add as fzName + fzName_slave
1590  const word slaveName = fzName + "_slave";
1591  faceZoneToPatches.insert(fzName, Pair<word>(fzName, slaveName));
1592  }
1593  }
1594  }
1595 
1596  if (faceZoneToPatches.size())
1597  {
1599  (
1600  meshRefiner,
1601  refineParams,
1602  faceZoneToPatches
1603  );
1604  }
1605 
1606 
1607 
1608  // Re-do intersections on meshed boundaries since they use an extrapolated
1609  // other side
1610  {
1611  const labelList adaptPatchIDs(meshRefiner.meshedPatches());
1612 
1613  const polyBoundaryMesh& pbm = mesh.boundaryMesh();
1614 
1615  label nFaces = 0;
1616  forAll(adaptPatchIDs, i)
1617  {
1618  nFaces += pbm[adaptPatchIDs[i]].size();
1619  }
1620 
1621  labelList faceLabels(nFaces);
1622  nFaces = 0;
1623  forAll(adaptPatchIDs, i)
1624  {
1625  const polyPatch& pp = pbm[adaptPatchIDs[i]];
1626  forAll(pp, i)
1627  {
1628  faceLabels[nFaces++] = pp.start()+i;
1629  }
1630  }
1631  meshRefiner.updateIntersections(faceLabels);
1632  }
1633 
1634 
1635 
1636  // Parallel
1637  // ~~~~~~~~
1638 
1639  // Construct decomposition engine. Note: cannot use decompositionModel
1640  // MeshObject since we're clearing out the mesh inside the mesh generation.
1641  autoPtr<decompositionMethod> decomposerPtr
1642  (
1644  (
1645  decomposeDict
1646  )
1647  );
1648  decompositionMethod& decomposer = *decomposerPtr;
1649 
1650  if (Pstream::parRun() && !decomposer.parallelAware())
1651  {
1653  << "You have selected decomposition method "
1654  << decomposer.typeName
1655  << " which is not parallel aware." << endl
1656  << "Please select one that is (hierarchical, ptscotch)"
1657  << exit(FatalError);
1658  }
1659 
1660  // Mesh distribution engine (uses tolerance to reconstruct meshes)
1661  fvMeshDistribute distributor(mesh, mergeDist);
1662 
1663 
1664 
1665 
1666 
1667  // Now do the real work -refinement -snapping -layers
1668  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1669 
1670  const bool wantRefine
1671  (
1672  meshRefinement::get<bool>(meshDict, "castellatedMesh", dryRun)
1673  );
1674  const bool wantSnap
1675  (
1676  meshRefinement::get<bool>(meshDict, "snap", dryRun)
1677  );
1678  const bool wantLayers
1679  (
1680  meshRefinement::get<bool>(meshDict, "addLayers", dryRun)
1681  );
1682 
1683  if (dryRun)
1684  {
1685  string errorMsg(FatalError.message());
1686  string IOerrorMsg(FatalIOError.message());
1687 
1688  if (errorMsg.size() || IOerrorMsg.size())
1689  {
1690  //errorMsg = "[dryRun] " + errorMsg;
1691  //errorMsg.replaceAll("\n", "\n[dryRun] ");
1692  //IOerrorMsg = "[dryRun] " + IOerrorMsg;
1693  //IOerrorMsg.replaceAll("\n", "\n[dryRun] ");
1694 
1695  Warning
1696  << nl
1697  << "Missing/incorrect required dictionary entries:" << nl
1698  << nl
1699  << IOerrorMsg.c_str() << nl
1700  << errorMsg.c_str() << nl << nl
1701  << "Exiting dry-run" << nl << endl;
1702 
1703  FatalError.clear();
1704  FatalIOError.clear();
1705 
1706  return 0;
1707  }
1708  }
1709 
1710 
1711  // How to treat co-planar faces
1712  meshRefinement::FaceMergeType mergeType =
1713  meshRefinement::FaceMergeType::GEOMETRIC;
1714  {
1715  const bool mergePatchFaces
1716  (
1717  meshDict.getOrDefault("mergePatchFaces", true)
1718  );
1719 
1720  if (!mergePatchFaces)
1721  {
1722  Info<< "Not merging patch-faces of cell to preserve"
1723  << " (split)hex cell shape."
1724  << nl << endl;
1725  mergeType = meshRefinement::FaceMergeType::NONE;
1726  }
1727  else
1728  {
1729  const bool mergeAcrossPatches
1730  (
1731  meshDict.getOrDefault("mergeAcrossPatches", false)
1732  );
1733 
1734  if (mergeAcrossPatches)
1735  {
1736  Info<< "Merging co-planar patch-faces of cells"
1737  << ", regardless of patch assignment"
1738  << nl << endl;
1739  mergeType = meshRefinement::FaceMergeType::IGNOREPATCH;
1740  }
1741  }
1742  }
1743 
1744 
1745 
1746  if (wantRefine)
1747  {
1748  cpuTime timer;
1749 
1750  snappyRefineDriver refineDriver
1751  (
1752  meshRefiner,
1753  decomposer,
1754  distributor,
1755  globalToMasterPatch,
1756  globalToSlavePatch,
1757  setFormatter,
1758  dryRun
1759  );
1760 
1761 
1762  if (!overwrite && !debugLevel)
1763  {
1764  const_cast<Time&>(mesh.time())++;
1765  }
1766 
1767 
1768  refineDriver.doRefine
1769  (
1770  refineDict,
1771  refineParams,
1772  snapParams,
1773  refineParams.handleSnapProblems(),
1774  mergeType,
1775  motionDict
1776  );
1777 
1778  // Remove zero sized patches originating from faceZones
1779  if (!keepPatches && !wantSnap && !wantLayers)
1780  {
1782  }
1783 
1784  if (!dryRun)
1785  {
1786  writeMesh
1787  (
1788  "Refined mesh",
1789  meshRefiner,
1790  debugLevel,
1792  );
1793  }
1794 
1795  Info<< "Mesh refined in = "
1796  << timer.cpuTimeIncrement() << " s." << endl;
1797 
1799  }
1800 
1801  if (wantSnap)
1802  {
1803  cpuTime timer;
1804 
1805  snappySnapDriver snapDriver
1806  (
1807  meshRefiner,
1808  globalToMasterPatch,
1809  globalToSlavePatch,
1810  dryRun
1811  );
1812 
1813  if (!overwrite && !debugLevel)
1814  {
1815  const_cast<Time&>(mesh.time())++;
1816  }
1817 
1818  // Use the resolveFeatureAngle from the refinement parameters
1819  scalar curvature = refineParams.curvature();
1820  scalar planarAngle = refineParams.planarAngle();
1821 
1822  snapDriver.doSnap
1823  (
1824  snapDict,
1825  motionDict,
1826  mergeType,
1827  curvature,
1828  planarAngle,
1829  snapParams
1830  );
1831 
1832  // Remove zero sized patches originating from faceZones
1833  if (!keepPatches && !wantLayers)
1834  {
1836  }
1837 
1838  if (!dryRun)
1839  {
1840  writeMesh
1841  (
1842  "Snapped mesh",
1843  meshRefiner,
1844  debugLevel,
1846  );
1847  }
1848 
1849  Info<< "Mesh snapped in = "
1850  << timer.cpuTimeIncrement() << " s." << endl;
1851 
1853  }
1854 
1855  if (wantLayers)
1856  {
1857  cpuTime timer;
1858 
1859  // Layer addition parameters
1860  const layerParameters layerParams
1861  (
1862  layerDict,
1863  mesh.boundaryMesh(),
1864  dryRun
1865  );
1866 
1867  snappyLayerDriver layerDriver
1868  (
1869  meshRefiner,
1870  globalToMasterPatch,
1871  globalToSlavePatch,
1872  dryRun
1873  );
1874 
1875  // Use the maxLocalCells from the refinement parameters
1876  bool preBalance = returnReduce
1877  (
1878  (mesh.nCells() >= refineParams.maxLocalCells()),
1879  orOp<bool>()
1880  );
1881 
1882 
1883  if (!overwrite && !debugLevel)
1884  {
1885  const_cast<Time&>(mesh.time())++;
1886  }
1887 
1888  layerDriver.doLayers
1889  (
1890  layerDict,
1891  motionDict,
1892  layerParams,
1893  mergeType,
1894  preBalance,
1895  decomposer,
1896  distributor
1897  );
1898 
1899  // Remove zero sized patches originating from faceZones
1900  if (!keepPatches)
1901  {
1903  }
1904 
1905  if (!dryRun)
1906  {
1907  writeMesh
1908  (
1909  "Layer mesh",
1910  meshRefiner,
1911  debugLevel,
1913  );
1914  }
1915 
1916  Info<< "Layers added in = "
1917  << timer.cpuTimeIncrement() << " s." << endl;
1918 
1920  }
1921 
1922 
1923  {
1924  addProfiling(checkMesh, "snappyHexMesh::checkMesh");
1925 
1926  // Check final mesh
1927  Info<< "Checking final mesh ..." << endl;
1928  faceSet wrongFaces(mesh, "wrongFaces", mesh.nFaces()/100);
1929  motionSmoother::checkMesh(false, mesh, motionDict, wrongFaces, dryRun);
1930  const label nErrors = returnReduce
1931  (
1932  wrongFaces.size(),
1933  sumOp<label>()
1934  );
1935 
1936  if (nErrors > 0)
1937  {
1938  Info<< "Finished meshing with " << nErrors << " illegal faces"
1939  << " (concave, zero area or negative cell pyramid volume)"
1940  << endl;
1941  wrongFaces.write();
1942  }
1943  else
1944  {
1945  Info<< "Finished meshing without any errors" << endl;
1946  }
1947 
1949  }
1950 
1951 
1952  if (surfaceSimplify)
1953  {
1954  addProfiling(surfaceSimplify, "snappyHexMesh::surfaceSimplify");
1955 
1957 
1958  labelHashSet includePatches(bMesh.size());
1959 
1960  if (args.found("patches"))
1961  {
1962  includePatches = bMesh.patchSet
1963  (
1964  args.getList<wordRe>("patches")
1965  );
1966  }
1967  else
1968  {
1969  forAll(bMesh, patchi)
1970  {
1971  const polyPatch& patch = bMesh[patchi];
1972 
1973  if (!isA<processorPolyPatch>(patch))
1974  {
1975  includePatches.insert(patchi);
1976  }
1977  }
1978  }
1979 
1980  fileName outFileName
1981  (
1983  (
1984  "outFile",
1985  "constant/triSurface/simplifiedSurface.stl"
1986  )
1987  );
1988 
1989  extractSurface
1990  (
1991  mesh,
1992  runTime,
1993  includePatches,
1994  outFileName
1995  );
1996 
1997  pointIOField cellCentres
1998  (
1999  IOobject
2000  (
2001  "internalCellCentres",
2002  runTime.timeName(),
2003  mesh,
2006  ),
2007  mesh.cellCentres()
2008  );
2009 
2010  cellCentres.write();
2011  }
2012 
2014 
2015  Info<< "Finished meshing in = "
2016  << runTime.elapsedCpuTime() << " s." << endl;
2017 
2018 
2019  if (dryRun)
2020  {
2021  string errorMsg(FatalError.message());
2022  string IOerrorMsg(FatalIOError.message());
2023 
2024  if (errorMsg.size() || IOerrorMsg.size())
2025  {
2026  //errorMsg = "[dryRun] " + errorMsg;
2027  //errorMsg.replaceAll("\n", "\n[dryRun] ");
2028  //IOerrorMsg = "[dryRun] " + IOerrorMsg;
2029  //IOerrorMsg.replaceAll("\n", "\n[dryRun] ");
2030 
2031  Perr<< nl
2032  << "Missing/incorrect required dictionary entries:" << nl
2033  << nl
2034  << IOerrorMsg.c_str() << nl
2035  << errorMsg.c_str() << nl << nl
2036  << "Exiting dry-run" << nl << endl;
2037 
2038  FatalError.clear();
2039  FatalIOError.clear();
2040 
2041  return 0;
2042  }
2043  }
2044 
2045 
2046  Info<< "End\n" << endl;
2047 
2048  return 0;
2049 }
2050 
2051 
2052 // ************************************************************************* //
Foam::expressions::patchExpr::debug
int debug
Static debugging option.
Foam::Pstream::mapCombineGather
static void mapCombineGather(const List< commsStruct > &comms, Container &Values, const CombineOp &cop, const int tag, const label comm)
Definition: combineGatherScatter.C:551
shellSurfaces.H
Foam::entry
A keyword and a list of tokens is an 'entry'.
Definition: entry.H:67
Foam::IOobject::NO_WRITE
Definition: IOobject.H:130
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:71
Foam::setf
Smanip< ios_base::fmtflags > setf(const ios_base::fmtflags flags)
Definition: IOmanip.H:169
profiling.H
Foam::pointField
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:44
Foam::IOdictionary
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:54
Foam::HashTable::size
label size() const noexcept
The number of elements in table.
Definition: HashTableI.H:52
runTime
engineTime & runTime
Definition: createEngineTime.H:13
Foam::autoPtr::reset
void reset(T *p=nullptr) noexcept
Delete managed object and set to new given pointer.
Definition: autoPtrI.H:109
Foam::polyMesh::points
virtual const pointField & points() const
Return raw points.
Definition: polyMesh.C:1038
Foam::scalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Definition: primitiveFieldsFwd.H:52
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:104
Foam::IOobject::AUTO_WRITE
Definition: IOobject.H:129
Foam::boundBox::mag
scalar mag() const
The magnitude of the bounding box span.
Definition: boundBoxI.H:133
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::refinementSurfaces::maxLevel
const labelList & maxLevel() const
From global region number to refinement level.
Definition: refinementSurfaces.H:212
Foam::meshRefinement::WRITEMESH
Definition: meshRefinement.H:114
Foam::surfaceZonesInfo::faceZoneType
faceZoneType
What to do with faceZone faces.
Definition: surfaceZonesInfo.H:86
Foam::accessOp
Definition: UList.H:614
Foam::IOobject::name
const word & name() const
Return name.
Definition: IOobjectI.H:70
snappySnapDriver.H
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
Foam::IOField
A primitive field of type <T> with automated input and output.
Definition: foamVtkLagrangianWriter.H:61
Foam::returnReduce
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
Definition: PstreamReduceOps.H:94
s
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Definition: gmvOutputSpray.H:25
uindirectPrimitivePatch.H
Foam::polyBoundaryMesh
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
Definition: polyBoundaryMesh.H:62
Foam::entry::keyword
const keyType & keyword() const
Return keyword.
Definition: entry.H:187
Foam::argList::getOrDefault
T getOrDefault(const word &optName, const T &deflt) const
Get a value from the named option if present, or return default.
Definition: argListI.H:286
Foam::meshRefinement::lookup
static ITstream & lookup(const dictionary &dict, const word &keyword, const bool noExit, enum keyType::option matchOpt=keyType::REGEX)
Wrapper around dictionary::lookup which does not exit.
Definition: meshRefinement.C:3496
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::DynamicList< label >
Foam::dictionary::found
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Search for an entry (const access) with the given keyword.
Definition: dictionary.C:364
Foam::refinementSurfaces::surfaces
const labelList & surfaces() const
Definition: refinementSurfaces.H:183
setFormat
const word setFormat(propsDict.getOrDefault< word >("setFormat", "vtk"))
Foam::Time::writeFormat
IOstream::streamFormat writeFormat() const
The write stream format.
Definition: Time.H:387
addOverwriteOption.H
Foam::primitiveMesh::nFaces
label nFaces() const
Number of mesh faces.
Definition: primitiveMeshI.H:90
globalIndex.H
Foam::UPstream::nProcs
static label nProcs(const label communicator=0)
Number of processes in parallel run.
Definition: UPstream.H:427
Foam::Warning
messageStream Warning
Foam::meshRefinement::writeLevel
static writeType writeLevel()
Get/set write level.
Definition: meshRefinement.C:3440
Foam::fvMeshTools::removeEmptyPatches
static labelList removeEmptyPatches(fvMesh &, const bool validBoundary)
Remove zero sized patches. All but processor patches are.
Definition: fvMeshTools.C:361
Foam::meshRefinement::printMeshInfo
void printMeshInfo(const bool, const string &) const
Print some mesh stats.
Definition: meshRefinement.C:3189
Foam::meshRefinement::addFaceZone
label addFaceZone(const word &fzName, const word &masterPatch, const word &slavePatch, const surfaceZonesInfo::faceZoneType &fzType)
Add/lookup faceZone and update information. Return index of.
Definition: meshRefinement.C:2396
Foam::searchableSurfaces::checkTopology
label checkTopology(const bool report) const
All topological checks. Return number of failed checks.
Definition: searchableSurfaces.C:820
polyTopoChange.H
motionSmoother.H
Foam::UPstream::parRun
static bool & parRun()
Is this a parallel run?
Definition: UPstream.H:415
Foam::Time::timeName
static word timeName(const scalar t, const int precision=precision_)
Definition: Time.C:785
Foam::edge
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:63
wallPolyPatch.H
Foam::meshRefinement::subDict
static const dictionary & subDict(const dictionary &dict, const word &keyword, const bool noExit, enum keyType::option matchOpt=keyType::REGEX)
Wrapper around dictionary::subDict which does not exit.
Definition: meshRefinement.C:3465
Foam::argList::addNote
static void addNote(const string &note)
Add extra notes for the usage information.
Definition: argList.C:413
dictName
const word dictName("blockMeshDict")
Foam::HashTable::insert
bool insert(const Key &key, const T &obj)
Copy insert a new entry, not overwriting existing entries.
Definition: HashTableI.H:168
Foam::Map
A HashTable to objects of type <T> with a label key.
Definition: lumpedPointController.H:69
Foam::faceSet
A list of face labels.
Definition: faceSet.H:51
Foam::surfaceZonesInfo::getNamedSurfaces
static labelList getNamedSurfaces(const PtrList< surfaceZonesInfo > &surfList)
Get indices of named surfaces (surfaces with faceZoneName)
Definition: surfaceZonesInfo.C:263
Foam::vtkSetWriter
Definition: vtkSetWriter.H:53
Foam::FatalIOError
IOerror FatalIOError
Foam::polyMesh::boundaryMesh
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:435
Foam::motionSmootherAlgo::checkMesh
static bool checkMesh(const bool report, const polyMesh &mesh, const dictionary &dict, labelHashSet &wrongFaces, const bool dryRun=false)
Check mesh with mesh settings in dict. Collects incorrect faces.
Definition: motionSmootherAlgoCheck.C:462
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:350
Foam::searchableSurfaces::writeStats
void writeStats(const List< wordList > &, Ostream &) const
Write some stats.
Definition: searchableSurfaces.C:870
Foam::snappySnapDriver
All to do with snapping to surface.
Definition: snappySnapDriver.H:58
decompositionMethod.H
Foam::dictionary::get
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:81
Foam::dictionary::set
entry * set(entry *entryPtr)
Assign a new entry, overwriting any existing entry.
Definition: dictionary.C:847
meshBb
List< treeBoundBox > meshBb(1, treeBoundBox(boundBox(coarseMesh.points(), false)).extend(rndGen, 1e-3))
refinementFeatures.H
Foam::Pout
prefixOSstream Pout
An Ostream wrapper for parallel output to std::cout.
Foam::HashSet< word >
Foam::meshRefinement::mesh
const fvMesh & mesh() const
Reference to mesh.
Definition: meshRefinement.H:953
processorMeshes.H
Foam::incrIndent
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Definition: Ostream.H:327
Foam::wordRe
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings.
Definition: wordRe.H:72
Foam::refinementSurfaces::gapLevel
const labelList & gapLevel() const
From global region number to small gap refinement level.
Definition: refinementSurfaces.H:218
setSystemMeshDictionaryIO.H
Foam::inplaceRenumber
void inplaceRenumber(const labelUList &oldToNew, IntListType &input)
Inplace renumber the values (not the indices) of a list.
Definition: ListOpsTemplates.C:61
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::regIOobject::store
bool store()
Definition: regIOobjectI.H:37
Foam::sumOp
Definition: ops.H:213
Foam::surfZoneIdentifier
Identifies a surface patch/zone by name, patch index and geometricType.
Definition: surfZoneIdentifier.H:59
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
patchTypes
wordList patchTypes(nPatches)
Foam::polyMesh::faceZones
const faceZoneMesh & faceZones() const
Return face zone mesh.
Definition: polyMesh.H:477
Foam::meshRefinement::FaceMergeType
FaceMergeType
Enumeration for what to do with co-planar patch faces on a single.
Definition: meshRefinement.H:133
Foam::globalMeshData::mergePoints
autoPtr< globalIndex > mergePoints(labelList &pointToGlobal, labelList &uniquePoints) const
Helper for merging (collocated!) mesh point data.
Definition: globalMeshData.C:2394
Foam::decompositionModel::canonicalName
static const word canonicalName
Definition: decompositionModel.H:80
UnsortedMeshedSurface.H
searchableSurfaces.H
Foam::snapParameters
Simple container to keep together snap specific information.
Definition: snapParameters.H:52
Foam::decompositionMethod::parallelAware
virtual bool parallelAware() const =0
Is method parallel aware?
Foam::refinementSurfaces::surfZones
const PtrList< surfaceZonesInfo > & surfZones() const
Definition: refinementSurfaces.H:194
Foam::polyBoundaryMesh::checkParallelSync
bool checkParallelSync(const bool report=false) const
Check whether all procs have all patches and in same order. Return.
Definition: polyBoundaryMesh.C:950
Foam::reduce
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
Definition: PstreamReduceOps.H:51
Foam::argList::noFunctionObjects
static void noFunctionObjects(bool addWithOption=false)
Remove '-noFunctionObjects' option and ignore any occurrences.
Definition: argList.C:454
Foam::meshRefinement::OBJINTERSECTIONS
Definition: meshRefinement.H:95
Foam::shellSurfaces
Encapsulates queries for volume refinement ('refine all cells within shell').
Definition: shellSurfaces.H:57
snappyVoxelMeshDriver.H
Foam::primitiveMesh::nCells
label nCells() const
Number of mesh cells.
Definition: primitiveMeshI.H:96
Foam::meshRefinement::timeName
word timeName() const
Definition: meshRefinement.C:3242
Foam::refinementSurfaces::names
const wordList & names() const
Names of surfaces.
Definition: refinementSurfaces.H:189
Foam::Field< vector >
Foam::meshRefinement::checkCoupledFaceZones
static void checkCoupledFaceZones(const polyMesh &)
Helper function: check that face zones are synced.
Definition: meshRefinement.C:1999
Foam::meshRefinement::readFlags
static int readFlags(const EnumContainer &namedEnum, const wordList &words)
Helper: convert wordList into bit pattern using provided Enum.
Definition: meshRefinementTemplates.C:253
Foam::UnsortedMeshedSurface
A surface geometry mesh, in which the surface zone information is conveyed by the 'zoneId' associated...
Definition: MeshedSurface.H:83
Foam::Info
messageStream Info
Information stream (uses stdout - output is on the master only)
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:67
refinementSurfaces.H
Foam::name
word name(const complex &c)
Return string representation of complex.
Definition: complex.C:76
addProfilingOption.H
argList.H
Foam::searchableSurface
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
Definition: searchableSurface.H:69
Foam::meshRefinement::meshedPatches
labelList meshedPatches() const
Get patchIDs for patches added in addMeshedPatch.
Definition: meshRefinement.C:2369
faceSet.H
Foam::dictionary::subDict
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
Definition: dictionary.C:528
Foam::refinementSurfaces::minLevel
const labelList & minLevel() const
From global region number to refinement level.
Definition: refinementSurfaces.H:206
addRegionOption.H
IOmanip.H
Istream and Ostream manipulators taking arguments.
Foam::refinementParameters
Simple container to keep together refinement specific information.
Definition: refinementParameters.H:58
Foam::IOobject::selectIO
static IOobject selectIO(const IOobject &io, const fileName &altFile, const word &ioName="")
Return the IOobject, but also consider an alternative file name.
Definition: IOobject.C:214
Foam::PtrList
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: List.H:62
size_type
graph_traits< Graph >::vertices_size_type size_type
Definition: SloanRenumber.C:76
Foam::fvMeshTools::reorderPatches
static void reorderPatches(fvMesh &, const labelList &oldToNew, const label nPatches, const bool validBoundary)
Reorder and remove trailing patches. If validBoundary call is parallel.
Definition: fvMeshTools.C:329
Foam::surfaceZonesInfo
Definition: surfaceZonesInfo.H:60
Foam::checkGeometry
label checkGeometry(const polyMesh &mesh, const bool allGeometry, autoPtr< surfaceWriter > &surfWriter, const autoPtr< writer< scalar >> &setWriter)
Foam::cpuTimeCxx::elapsedCpuTime
double elapsedCpuTime() const
Return CPU time (in seconds) from the start.
Definition: cpuTimeCxx.C:68
Foam::pow
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
Definition: dimensionedScalar.C:75
Foam::max
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
Foam::layerParameters
Simple container to keep together layer specific information.
Definition: layerParameters.H:57
Foam::meshRefinement::writeTypeNames
static const Enum< writeType > writeTypeNames
Definition: meshRefinement.H:121
Foam::cpuTimeCxx
Starts timing CPU usage and return elapsed time from start.
Definition: cpuTimeCxx.H:53
addProfiling
#define addProfiling(name, descr)
Define profiling trigger with specified name and description string.
Definition: profilingTrigger.H:114
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
createNamedMesh.H
Foam::refinementSurfaces::globalRegion
label globalRegion(const label surfI, const label regionI) const
From surface and region on surface to global region.
Definition: refinementSurfaces.H:270
Foam::log
dimensionedScalar log(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:262
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::decompositionMethod
Abstract base class for domain decomposition.
Definition: decompositionMethod.H:51
Foam::writer
Base class for graphics format writing. Entry points are.
Definition: writer.H:80
dictIO
IOobject dictIO
Definition: setConstantMeshDictionaryIO.H:1
snappyRefineDriver.H
Foam::Ostream::write
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
Foam::error::message
string message() const
The accumulated error message.
Definition: error.C:214
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:84
fvMesh.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::decrIndent
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Definition: Ostream.H:334
Foam::PtrList::set
const T * set(const label i) const
Return const pointer to element (if set) or nullptr.
Definition: PtrListI.H:143
Foam::refinementHistory::removeFiles
static void removeFiles(const polyMesh &)
Helper: remove all sets files from mesh instance.
Definition: refinementHistory.C:1727
Foam::setw
Omanip< int > setw(const int i)
Definition: IOmanip.H:199
Foam::entry::dict
virtual const dictionary & dict() const =0
Return dictionary, if entry is a dictionary.
Foam::indent
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:320
Foam::polyPatch::start
label start() const
Return start label of this patch in the polyMesh face list.
Definition: polyPatch.H:312
Foam::searchableSurfaces::regionNames
const List< wordList > & regionNames() const
Region names per surface.
Definition: searchableSurfaces.H:168
Foam::dictionary::subOrEmptyDict
dictionary subOrEmptyDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX, const bool mandatory=false) const
Definition: dictionary.C:608
Foam::refinementSurfaces::patchInfo
const PtrList< dictionary > & patchInfo() const
From global region number to patch type.
Definition: refinementSurfaces.H:261
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::UPstream::myProcNo
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
Definition: UPstream.H:445
Foam::snappyLayerDriver
All to do with adding layers.
Definition: snappyLayerDriver.H:59
Foam::UPstream::master
static bool master(const label communicator=0)
Am I the master process.
Definition: UPstream.H:439
Foam::HashTable< label >
Foam::polyMesh::bounds
const boundBox & bounds() const
Return mesh bounding box.
Definition: polyMesh.H:441
Foam::Perr
prefixOSstream Perr
An Ostream wrapper for parallel output to std::cerr.
Foam::Detail::StringStreamAllocator::str
Foam::string str() const
Get the string - as Foam::string rather than std::string.
Definition: StringStream.H:91
Foam::argList::addBoolOption
static void addBoolOption(const word &optName, const string &usage="", bool advanced=false)
Add a bool option to validOptions with usage information.
Definition: argList.C:325
Time.H
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
setRootCase.H
Foam::primitiveMesh::cellCentres
const vectorField & cellCentres() const
Definition: primitiveMeshCellCentresAndVols.C:175
vtkSetWriter.H
Foam::searchableSurfaces::checkGeometry
label checkGeometry(const scalar maxRatio, const scalar tolerance, const autoPtr< writer< scalar >> &setWriter, const scalar minQuality, const bool report) const
All geometric checks. Return number of failed checks.
Definition: searchableSurfaces.C:840
Foam::TimePaths::system
const word & system() const
Return system name.
Definition: TimePathsI.H:94
Foam::IOstreamOption::ASCII
"ascii" (normal default)
Definition: IOstreamOption.H:72
Foam::polyMesh::faces
virtual const faceList & faces() const
Return raw faces.
Definition: polyMesh.C:1063
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:372
Foam::Pstream::gatherList
static void gatherList(const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
Gather data but keep individual values separate.
Definition: gatherScatterList.C:52
fvMeshDistribute.H
Foam::nl
constexpr char nl
Definition: Ostream.H:385
Foam::Pair< word >
Foam::Time::path
fileName path() const
Return path.
Definition: Time.H:358
forAllConstIters
forAllConstIters(mixture.phases(), phase)
Definition: pEqn.H:28
Foam::Pstream::mapCombineScatter
static void mapCombineScatter(const List< commsStruct > &comms, Container &Values, const int tag, const label comm)
Scatter data. Reverse of combineGather.
Definition: combineGatherScatter.C:666
Foam::IOstream::defaultPrecision
static unsigned int defaultPrecision()
Return the default precision.
Definition: IOstream.H:333
fvMeshTools.H
Foam::ILList::erase
bool erase(T *item)
Remove the specified element from the list and delete it.
Definition: ILList.C:97
Foam::refinementFeatures
Encapsulates queries for features.
Definition: refinementFeatures.H:53
f
labelList f(nPoints)
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
layerParameters.H
refinementParameters.H
Foam::Vector< scalar >
Foam::regIOobject::rename
virtual void rename(const word &newName)
Rename.
Definition: regIOobject.C:432
Foam::meshRefinement::writeType
writeType
Enumeration for what to write. Used as a bit-pattern.
Definition: meshRefinement.H:112
Foam::List< label >
Foam::OStringStream
Output to string buffer, using a OSstream.
Definition: StringStream.H:196
Foam::searchableSurfaces
Container for searchableSurfaces. The collection is specified as a dictionary. For example,...
Definition: searchableSurfaces.H:92
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::refinementSurfaces::nRegions
label nRegions() const
Definition: refinementSurfaces.H:290
Foam::timer
Implements a timeout mechanism via sigalarm.
Definition: timer.H:83
Foam::meshRefinement
Helper class which maintains intersections of (changing) mesh with (static) surfaces.
Definition: meshRefinement.H:85
Foam::processorMeshes::removeFiles
static void removeFiles(const polyMesh &mesh)
Helper: remove all procAddressing files from mesh instance.
Definition: processorMeshes.C:274
Foam::dictionary::findEntry
entry * findEntry(const word &keyword, enum keyType::option matchOpt=keyType::REGEX)
Find for an entry (non-const access) with the given keyword.
Definition: dictionary.C:374
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::constant::electromagnetic::e
const dimensionedScalar e
Elementary charge.
Definition: createFields.H:11
Foam::dictionary::clone
autoPtr< dictionary > clone() const
Construct and return clone.
Definition: dictionary.C:178
Foam::meshRefinement::write
bool write() const
Write mesh and all data.
Definition: meshRefinement.C:3082
Foam::keyType::REGEX
Regular expression.
Definition: keyType.H:74
Foam::identity
labelList identity(const label len, label start=0)
Create identity map of the given length with (map[i] == i)
Definition: labelList.C:38
Foam::direction
uint8_t direction
Definition: direction.H:47
Foam::word::null
static const word null
An empty word.
Definition: word.H:77
Foam::error::clear
void clear() const
Clear any messages.
Definition: error.C:220
createTime.H
Foam::meshRefinement::addMeshedPatch
label addMeshedPatch(const word &name, const dictionary &)
Add patch originating from meshing. Update meshedPatches_.
Definition: meshRefinement.C:2319
Foam::IOobject::MUST_READ_IF_MODIFIED
Definition: IOobject.H:121
snapParameters.H
Foam::line
A line primitive.
Definition: line.H:59
Foam::argList::getList
List< T > getList(const label index) const
Get a List of values from the argument at index.
Foam::snappyRefineDriver::addFaceZones
static void addFaceZones(meshRefinement &meshRefiner, const refinementParameters &refineParams, const HashTable< Pair< word >> &faceZoneToPatches)
Helper: add faceZones and patches.
Definition: snappyRefineDriver.C:2736
Foam::dictionary::optionalSubDict
const dictionary & optionalSubDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary, otherwise return this dictionary.
Definition: dictionary.C:645
Foam::refinementSurfaces::setMinLevelFields
void setMinLevelFields(const shellSurfaces &shells)
Calculate minLevelFields.
Definition: refinementSurfaces.C:707
Foam::List::set
std::enable_if< std::is_same< bool, TypeT >::value, bool >::type set(const label i, bool val=true)
A bitSet::set() method for a list of bool.
Definition: List.H:325
Foam::boundBox
A bounding box defined in terms of min/max extrema points.
Definition: boundBox.H:63
Foam::TimePaths::globalPath
fileName globalPath() const
Return global path for the case.
Definition: TimePathsI.H:72
Foam::fileName::clean
static bool clean(std::string &str)
Cleanup filename.
Definition: fileName.C:298
Foam::cpuTimeCxx::cpuTimeIncrement
double cpuTimeIncrement() const
Return CPU time (in seconds) since last call to cpuTimeIncrement()
Definition: cpuTimeCxx.C:75
Foam::fvMesh::time
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:248
Foam::UIndirectList
A List with indirect addressing.
Definition: fvMatrix.H:109
Foam::dictionary::add
entry * add(entry *entryPtr, bool mergeEntry=false)
Add a new entry.
Definition: dictionary.C:708
Foam::face
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:72
decompositionModel.H
Foam::DelaunayMeshTools::allPoints
tmp< pointField > allPoints(const Triangulation &t)
Extract all points in vertex-index order.
Foam::meshRefinement::updateIntersections
void updateIntersections(const labelList &changedFaces)
Find any intersection of surface. Store in surfaceIndex_.
Definition: meshRefinement.C:304
Foam::plusEqOp
Definition: ops.H:72
Foam::dictionary::toc
wordList toc() const
Return the table of contents.
Definition: dictionary.C:670
Foam::searchableSurfaces::names
const wordList & names() const
Surface names, not region names.
Definition: searchableSurfaces.H:156
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
IOWarningInFunction
#define IOWarningInFunction(ios)
Report an IO warning using Foam::Warning.
Definition: messageStream.H:310
Foam::polyMesh::globalData
const globalMeshData & globalData() const
Return parallel info.
Definition: polyMesh.C:1234
Foam::TimePaths::processorCase
bool processorCase() const
Return true if this is a processor case.
Definition: TimePathsI.H:36
Foam::meshRefinement::debugTypeNames
static const Enum< debugType > debugTypeNames
Definition: meshRefinement.H:101
Foam::List::setSize
void setSize(const label newSize)
Alias for resize(const label)
Definition: ListI.H:146
Foam::TimePaths::constant
const word & constant() const
Return constant name.
Definition: TimePathsI.H:88
Foam::dictionary::getOrDefault
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:122
Foam::MeshedSurface< face >
Foam::IOobject::NO_READ
Definition: IOobject.H:123
Foam::argList::addOption
static void addOption(const word &optName, const string &param="", const string &usage="", bool advanced=false)
Add an option to validOptions with usage information.
Definition: argList.C:336
args
Foam::argList args(argc, argv)
Foam::meshRefinement::WRITELAYERSETS
Definition: meshRefinement.H:117
Foam::orOp
Definition: ops.H:234
Foam::refinementSurfaces
Container for data on surfaces used for surface-driven refinement. Contains all the data about the le...
Definition: refinementSurfaces.H:63
Foam::topoSet::removeFiles
static void removeFiles(const polyMesh &)
Helper: remove all sets files from mesh instance.
Definition: topoSet.C:638
Foam::snappyRefineDriver
Definition: snappyRefineDriver.H:65
Foam::patchIdentifier::name
const word & name() const
The patch name.
Definition: patchIdentifier.H:134
meshDict
const IOdictionary & meshDict
Definition: findBlockMeshDict.H:72
Foam::fvMeshDistribute
Sends/receives parts of mesh+fvfields to neighbouring processors. Used in load balancing.
Definition: fvMeshDistribute.H:73
Foam::patchIdentifier::index
label index() const
The index of this patch in the boundaryMesh.
Definition: patchIdentifier.H:158
Foam::decompositionMethod::New
static autoPtr< decompositionMethod > New(const dictionary &decompDict)
Return a reference to the selected decomposition method.
Definition: decompositionMethod.C:359
Foam::dictionary::readIfPresent
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:417
Foam::meshRefinement::getFaceZoneInfo
bool getFaceZoneInfo(const word &fzName, label &masterPatchID, label &slavePatchID, surfaceZonesInfo::faceZoneType &fzType) const
Lookup faceZone information. Return false if no information.
Definition: meshRefinement.C:2420
Foam::argList::found
bool found(const word &optName) const
Return true if the named option is found.
Definition: argListI.H:157
MeshedSurface.H
snappyLayerDriver.H
Foam::PrimitivePatch
A list of faces which address into the list of points.
Definition: PrimitivePatch.H:85
Foam::fvMesh::V
const DimensionedField< scalar, volMesh > & V() const
Return cell volumes.
Definition: fvMeshGeometry.C:179
Foam::surfaceZonesInfo::addCellZonesToMesh
static labelList addCellZonesToMesh(const PtrList< surfaceZonesInfo > &surfList, const labelList &namedSurfaces, polyMesh &mesh)
Definition: surfaceZonesInfo.C:458
Foam::IOobject::MUST_READ
Definition: IOobject.H:120
Foam::meshRefinement::debugType
debugType
Enumeration for what to debug. Used as a bit-pattern.
Definition: meshRefinement.H:92
surfZoneIdentifierList.H
Foam::profiling::writeNow
static bool writeNow()
Write profiling information now.
Definition: profiling.C:135