snappyHexMesh.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-2026 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 Application
25  snappyHexMesh
26 
27 Description
28  Automatic split hex mesher
29 
30  Refines, snaps to surface and adds surface layers.
31 
32 \*---------------------------------------------------------------------------*/
33 
34 #include "argList.H"
35 #include "fvMesh.H"
36 #include "snappyRefineDriver.H"
37 #include "snappySnapDriver.H"
38 #include "snappyLayerDriver.H"
39 #include "searchableSurfaceList.H"
40 #include "refinementSurfaces.H"
41 #include "refinementFeatures.H"
42 #include "refinementRegions.H"
43 #include "decompositionMethod.H"
44 #include "fvMeshDistribute.H"
45 #include "wallPolyPatch.H"
46 #include "snapParameters.H"
47 #include "layerParameters.H"
48 #include "faceSet.H"
49 #include "meshCheck.H"
51 #include "MeshedSurface.H"
52 #include "IOmanip.H"
53 #include "fvMeshTools.H"
54 #include "systemDict.H"
55 
56 using namespace Foam;
57 
58 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
59 
60 // Convert size (as fraction of defaultCellSize) to refinement level
61 label sizeCoeffToRefinement
62 (
63  const scalar level0Coeff, // ratio of hex cell size v.s. defaultCellSize
64  const scalar sizeCoeff
65 )
66 {
67  return round(::log(level0Coeff/sizeCoeff)/::log(2));
68 }
69 
70 
71 autoPtr<refinementSurfaces> createRefinementSurfaces
72 (
73  const searchableSurfaceList& allGeometry,
74  const dictionary& surfacesDict,
75  const dictionary& shapeControlDict,
76  const label gapLevelIncrement,
77  const scalar level0Coeff
78 )
79 {
80  autoPtr<refinementSurfaces> surfacePtr;
81 
82  // Count number of surfaces.
83  label surfI = 0;
84  forAll(allGeometry.names(), geomI)
85  {
86  const word& geomName = allGeometry.names()[geomI];
87 
88  if (surfacesDict.found(geomName))
89  {
90  surfI++;
91  }
92  }
93 
94  labelList surfaces(surfI);
95  wordList names(surfI);
96  PtrList<surfaceZonesInfo> surfZones(surfI);
97 
98  labelList regionOffset(surfI);
99 
100  labelList globalMinLevel(surfI, 0);
101  labelList globalMaxLevel(surfI, 0);
102  labelList globalLevelIncr(surfI, 0);
103  PtrList<dictionary> globalPatchInfo(surfI);
104  List<Map<label>> regionMinLevel(surfI);
105  List<Map<label>> regionMaxLevel(surfI);
106  List<Map<label>> regionLevelIncr(surfI);
107  List<Map<scalar>> regionAngle(surfI);
108  List<Map<autoPtr<dictionary>>> regionPatchInfo(surfI);
109 
110  HashSet<word> unmatchedKeys(surfacesDict.toc());
111 
112  surfI = 0;
113  forAll(allGeometry.names(), geomI)
114  {
115  const word& geomName = allGeometry.names()[geomI];
116 
117  const entry* ePtr = surfacesDict.lookupEntryPtr(geomName, false, true);
118 
119  if (ePtr)
120  {
121  const dictionary& shapeDict = ePtr->dict();
122  unmatchedKeys.erase(ePtr->keyword());
123 
124  names[surfI] = geomName;
125  surfaces[surfI] = geomI;
126 
127  const searchableSurface& surface = allGeometry[geomI];
128 
129  // Find the index in shapeControlDict
130  // Invert surfaceCellSize to get the refinementLevel
131 
132  const word scsFuncName =
133  shapeDict.lookup("surfaceCellSizeFunction");
134  const dictionary& scsDict =
135  shapeDict.optionalTypeDict(scsFuncName);
136 
137  const scalar surfaceCellSize =
138  scsDict.lookup<scalar>("surfaceCellSizeCoeff");
139 
140  const label refLevel = sizeCoeffToRefinement
141  (
142  level0Coeff,
143  surfaceCellSize
144  );
145 
146  globalMinLevel[surfI] = refLevel;
147  globalMaxLevel[surfI] = refLevel;
148  globalLevelIncr[surfI] = gapLevelIncrement;
149 
150  // Surface zones
151  surfZones.set(surfI, new surfaceZonesInfo(surface, shapeDict));
152 
153 
154  // Global perpendicular angle
155  if (shapeDict.found("patchInfo"))
156  {
157  globalPatchInfo.set
158  (
159  surfI,
160  shapeDict.subDict("patchInfo").clone()
161  );
162  }
163 
164 
165  // Per region override of patchInfo
166 
167  if (shapeDict.found("regions"))
168  {
169  const dictionary& regionsDict = shapeDict.subDict("regions");
170  const wordList& regionNames =
171  allGeometry[surfaces[surfI]].regions();
172 
173  forAll(regionNames, regionI)
174  {
175  if (regionsDict.found(regionNames[regionI]))
176  {
177  // Get the dictionary for region
178  const dictionary& regionDict = regionsDict.subDict
179  (
180  regionNames[regionI]
181  );
182 
183  if (regionDict.found("patchInfo"))
184  {
185  regionPatchInfo[surfI].insert
186  (
187  regionI,
188  regionDict.subDict("patchInfo").clone()
189  );
190  }
191  }
192  }
193  }
194 
195  // Per region override of cellSize
196  if (shapeDict.found("regions"))
197  {
198  const dictionary& shapeControlRegionsDict =
199  shapeDict.subDict("regions");
200  const wordList& regionNames =
201  allGeometry[surfaces[surfI]].regions();
202 
203  forAll(regionNames, regionI)
204  {
205  if (shapeControlRegionsDict.found(regionNames[regionI]))
206  {
207  const dictionary& shapeControlRegionDict =
208  shapeControlRegionsDict.subDict
209  (
210  regionNames[regionI]
211  );
212 
213  const word scsFuncName =
214  shapeControlRegionDict.lookup
215  (
216  "surfaceCellSizeFunction"
217  );
218  const dictionary& scsDict =
219  shapeControlRegionDict.typeDict(scsFuncName);
220 
221  const scalar surfaceCellSize =
222  scsDict.lookup<scalar>("surfaceCellSizeCoeff");
223 
224  const label refLevel = sizeCoeffToRefinement
225  (
226  level0Coeff,
227  surfaceCellSize
228  );
229 
230  regionMinLevel[surfI].insert(regionI, refLevel);
231  regionMaxLevel[surfI].insert(regionI, refLevel);
232  regionLevelIncr[surfI].insert(regionI, 0);
233  }
234  }
235  }
236 
237  surfI++;
238  }
239  }
240 
241  // Calculate local to global region offset
242  label nRegions = 0;
243 
244  forAll(surfaces, surfI)
245  {
246  regionOffset[surfI] = nRegions;
247  nRegions += allGeometry[surfaces[surfI]].regions().size();
248  }
249 
250  // Rework surface specific information into information per global region
251  labelList minLevel(nRegions, 0);
252  labelList maxLevel(nRegions, 0);
253  labelList gapLevel(nRegions, -1);
254  PtrList<dictionary> patchInfo(nRegions);
255 
256  forAll(globalMinLevel, surfI)
257  {
258  label nRegions = allGeometry[surfaces[surfI]].regions().size();
259 
260  // Initialise to global (i.e. per surface)
261  for (label i = 0; i < nRegions; i++)
262  {
263  label globalRegionI = regionOffset[surfI] + i;
264  minLevel[globalRegionI] = globalMinLevel[surfI];
265  maxLevel[globalRegionI] = globalMaxLevel[surfI];
266  gapLevel[globalRegionI] =
267  maxLevel[globalRegionI]
268  + globalLevelIncr[surfI];
269 
270  if (globalPatchInfo.set(surfI))
271  {
272  patchInfo.set
273  (
274  globalRegionI,
275  globalPatchInfo[surfI].clone()
276  );
277  }
278  }
279 
280  // Overwrite with region specific information
281  forAllConstIter(Map<label>, regionMinLevel[surfI], iter)
282  {
283  label globalRegionI = regionOffset[surfI] + iter.key();
284 
285  minLevel[globalRegionI] = iter();
286  maxLevel[globalRegionI] = regionMaxLevel[surfI][iter.key()];
287  gapLevel[globalRegionI] =
288  maxLevel[globalRegionI]
289  + regionLevelIncr[surfI][iter.key()];
290  }
291 
292  const Map<autoPtr<dictionary>>& localInfo = regionPatchInfo[surfI];
293  forAllConstIter(Map<autoPtr<dictionary>>, localInfo, iter)
294  {
295  label globalRegionI = regionOffset[surfI] + iter.key();
296  patchInfo.set(globalRegionI, iter()().clone());
297  }
298  }
299 
300  surfacePtr.set
301  (
303  (
304  allGeometry,
305  surfaces,
306  names,
307  surfZones,
308  regionOffset,
309  minLevel,
310  maxLevel,
311  gapLevel,
312  scalarField(nRegions, -great), // perpendicularAngle,
313  patchInfo
314  )
315  );
316 
317 
318  const refinementSurfaces& rf = surfacePtr();
319 
320  // Determine maximum region name length
321  label maxLen = 0;
322  forAll(rf.surfaces(), surfI)
323  {
324  label geomI = rf.surfaces()[surfI];
325  const wordList& regionNames = allGeometry.regionNames()[geomI];
326  forAll(regionNames, regionI)
327  {
328  maxLen = Foam::max(maxLen, label(regionNames[regionI].size()));
329  }
330  }
331 
332 
333  Info<< setw(maxLen) << "Region"
334  << setw(10) << "Min Level"
335  << setw(10) << "Max Level"
336  << setw(10) << "Gap Level" << nl
337  << setw(maxLen) << "------"
338  << setw(10) << "---------"
339  << setw(10) << "---------"
340  << setw(10) << "---------" << endl;
341 
342  forAll(rf.surfaces(), surfI)
343  {
344  label geomI = rf.surfaces()[surfI];
345 
346  Info<< rf.names()[surfI] << ':' << nl;
347 
348  const wordList& regionNames = allGeometry.regionNames()[geomI];
349 
350  forAll(regionNames, regionI)
351  {
352  label globalI = rf.globalRegion(surfI, regionI);
353 
354  Info<< setw(maxLen) << regionNames[regionI]
355  << setw(10) << rf.minLevel()[globalI]
356  << setw(10) << rf.maxLevel()[globalI]
357  << setw(10) << rf.gapLevel()[globalI] << endl;
358  }
359  }
360 
361 
362  return surfacePtr;
363 }
364 
365 
366 void extractSurface
367 (
368  const polyMesh& mesh,
369  const Time& runTime,
371  const fileName& outFileName
372 )
373 {
374  const polyBoundaryMesh& bMesh = mesh.boundary();
375 
376  // Collect sizes. Hash on names to handle local-only patches (e.g.
377  // processor patches)
378  HashTable<label> patchSize(1000);
379  label nFaces = 0;
381  {
382  const polyPatch& pp = bMesh[iter.key()];
383  patchSize.insert(pp.name(), pp.size());
384  nFaces += pp.size();
385  }
387 
388 
389  // Allocate zone/patch for all patches
390  HashTable<label> compactZoneID(1000);
391  forAllConstIter(HashTable<label>, patchSize, iter)
392  {
393  label sz = compactZoneID.size();
394  compactZoneID.insert(iter.key(), sz);
395  }
396  Pstream::mapCombineScatter(compactZoneID);
397 
398 
399  // Rework HashTable into labelList just for speed of conversion
400  labelList patchToCompactZone(bMesh.size(), -1);
401  forAllConstIter(HashTable<label>, compactZoneID, iter)
402  {
403  label patchi = bMesh.findIndex(iter.key());
404  if (patchi != -1)
405  {
406  patchToCompactZone[patchi] = iter();
407  }
408  }
409 
410  // Collect faces on zones
411  DynamicList<label> faceLabels(nFaces);
412  DynamicList<label> compactZones(nFaces);
414  {
415  const polyPatch& pp = bMesh[iter.key()];
416  forAll(pp, i)
417  {
418  faceLabels.append(pp.start()+i);
419  compactZones.append(patchToCompactZone[pp.index()]);
420  }
421  }
422 
423  // Addressing engine for all faces
424  uindirectPrimitivePatch allBoundary
425  (
426  UIndirectList<face>(mesh.faces(), faceLabels),
427  mesh.points()
428  );
429 
430 
431  // Find correspondence to master points
432  labelList pointToGlobal;
433  labelList uniqueMeshPoints;
435  (
436  allBoundary.meshPoints(),
437  allBoundary.meshPointMap(),
438  pointToGlobal,
439  uniqueMeshPoints
440  );
441 
442  // Gather all unique points on master
443  List<pointField> gatheredPoints(Pstream::nProcs());
444  gatheredPoints[Pstream::myProcNo()] = pointField
445  (
446  mesh.points(),
447  uniqueMeshPoints
448  );
449  Pstream::gatherList(gatheredPoints);
450 
451  // Gather all faces
452  List<faceList> gatheredFaces(Pstream::nProcs());
453  gatheredFaces[Pstream::myProcNo()] = allBoundary.localFaces();
454  forAll(gatheredFaces[Pstream::myProcNo()], i)
455  {
456  inplaceRenumber(pointToGlobal, gatheredFaces[Pstream::myProcNo()][i]);
457  }
458  Pstream::gatherList(gatheredFaces);
459 
460  // Gather all ZoneIDs
461  List<labelList> gatheredZones(Pstream::nProcs());
462  gatheredZones[Pstream::myProcNo()] = move(compactZones);
463  Pstream::gatherList(gatheredZones);
464 
465  // On master combine all points, faces, zones
466  if (Pstream::master())
467  {
468  pointField allPoints = ListListOps::combine<pointField>
469  (
470  gatheredPoints,
472  );
473  gatheredPoints.clear();
474 
475  faceList allFaces = ListListOps::combine<faceList>
476  (
477  gatheredFaces,
479  );
480  gatheredFaces.clear();
481 
482  labelList allZones = ListListOps::combine<labelList>
483  (
484  gatheredZones,
486  );
487  gatheredZones.clear();
488 
489 
490  // Zones
491  surfZoneIdentifierList surfZones(compactZoneID.size());
492  forAllConstIter(HashTable<label>, compactZoneID, iter)
493  {
494  surfZones[iter()] = surfZoneIdentifier(iter.key(), iter());
495  Info<< "surfZone " << iter() << " : " << surfZones[iter()].name()
496  << endl;
497  }
498 
499  UnsortedMeshedSurface<face> unsortedFace
500  (
501  move(allPoints),
502  move(allFaces),
503  move(allZones),
504  move(surfZones)
505  );
506 
507 
508  MeshedSurface<face> sortedFace(unsortedFace);
509 
510  Info<< "Writing merged surface to "
511  << runTime.globalPath()/outFileName << endl;
512 
513  sortedFace.write(runTime.globalPath()/outFileName);
514  }
515 }
516 
517 
518 // Check writing tolerance before doing any serious work
519 scalar getMergeDistance(const polyMesh& mesh, const scalar mergeTol)
520 {
521  const boundBox& meshBb = mesh.bounds();
522  scalar mergeDist = mergeTol * meshBb.mag();
523 
524  Info<< nl
525  << "Overall mesh bounding box : " << meshBb << nl
526  << "Relative tolerance : " << mergeTol << nl
527  << "Absolute matching distance : " << mergeDist << nl
528  << endl;
529 
530  // check writing tolerance
532  {
533  const scalar writeTol = std::pow
534  (
535  scalar(10.0),
536  -scalar(IOstream::defaultPrecision())
537  );
538 
539  if (mergeTol < writeTol)
540  {
542  << "Your current settings specify ASCII writing with "
543  << IOstream::defaultPrecision() << " digits precision." << nl
544  << "Your merging tolerance (" << mergeTol
545  << ") is finer than this." << nl
546  << "Change to binary writeFormat, "
547  << "or increase the writePrecision" << endl
548  << "or adjust the merge tolerance (mergeTol)."
549  << exit(FatalError);
550  }
551  }
552 
553  return mergeDist;
554 }
555 
556 
557 void removeZeroSizedPatches(fvMesh& mesh)
558 {
559  // Remove non-constraint zero-sized patches
560 
561  const polyBoundaryMesh& pbm = mesh.poly().boundary();
562 
563  labelList oldToNew(pbm.size(), -1);
564  label newPatchi = 0;
565  forAll(pbm, patchi)
566  {
567  const polyPatch& pp = pbm[patchi];
568 
569  if
570  (
571  pp.constraint()
572  || returnReduce(pp.size(), sumOp<label>())
573  )
574  {
575  oldToNew[patchi] = newPatchi++;
576  }
577  }
578 
579  const label nKeepPatches = newPatchi;
580 
581  // Shuffle unused ones to end
582  if (nKeepPatches != pbm.size())
583  {
584  Info<< endl
585  << "Removing zero-sized patches:" << endl << incrIndent;
586 
587  forAll(oldToNew, patchi)
588  {
589  if (oldToNew[patchi] == -1)
590  {
591  Info<< indent << pbm[patchi].name()
592  << " type " << pbm[patchi].type()
593  << " at position " << patchi << endl;
594  oldToNew[patchi] = newPatchi++;
595  }
596  }
597  Info<< decrIndent;
598 
599  fvMeshTools::reorderPatches(mesh, oldToNew, nKeepPatches, true);
600  Info<< endl;
601  }
602 }
603 
604 
605 // Write mesh and additional information
606 void writeMesh
607 (
608  const string& msg,
609  const meshRefinement& meshRefiner,
610  const meshRefinement::debugType debugLevel,
611  const meshRefinement::writeType writeLevel
612 )
613 {
614  const fvMesh& mesh = meshRefiner.mesh();
615 
616  meshRefiner.printMeshInfo(debugLevel, msg);
617  Info<< "Writing mesh to time " << meshRefiner.name() << endl;
618 
619  meshRefiner.write
620  (
621  debugLevel,
623  mesh.time().path()/meshRefiner.name()
624  );
625  Info<< "Wrote mesh in = "
626  << mesh.time().cpuTimeIncrement() << " s." << endl;
627 }
628 
629 
630 int main(int argc, char *argv[])
631 {
632  #include "addNoOverwriteOption.H"
634  (
635  "checkGeometry",
636  "check all surface geometry for quality"
637  );
639  (
640  "surfaceSimplify",
641  "boundBox",
642  "simplify the surface using snappyHexMesh starting from a boundBox"
643  );
645  (
646  "patches",
647  "(patch0 .. patchN)",
648  "only triangulate selected patches (wildcards supported)"
649  );
651  (
652  "outFile",
653  "file",
654  "name of the file to save the simplified surface to"
655  );
656  #include "addDictOption.H"
657  #include "addMeshOption.H"
658  #include "addRegionOption.H"
659 
663 
664  Info<< "Read mesh in = "
665  << runTime.cpuTimeIncrement() << " s" << endl;
666 
667  #include "setNoOverwrite.H"
668  const bool checkGeometry = args.optionFound("checkGeometry");
669  const bool surfaceSimplify = args.optionFound("surfaceSimplify");
670 
671  // Check that the read mesh is fully 3D
672  // as required for mesh relaxation after snapping
673  if (mesh.nSolutionD() != 3)
674  {
676  << "Mesh provided is not fully 3D"
677  " as required for mesh relaxation after snapping" << nl
678  << "Convert all empty patches to appropriate types for a 3D mesh,"
679  " current patch types are" << nl
680  << mesh.poly().boundary().types()
681  << exit(FatalError);
682  }
683 
684  // Check patches and faceZones are synchronised
687 
688 
689  // Read meshing dictionary
690  const IOdictionary meshDict(systemDict("snappyHexMeshDict", args, mesh));
691 
692 
693  // all surface geometry
694  const dictionary& geometryDict = meshDict.subDict("geometry");
695 
696  // refinement parameters
697  const dictionary& refineDict = meshDict.subDict("castellatedMeshControls");
698 
699  // mesh motion and mesh quality parameters
700  const dictionary& motionDict = meshDict.subDict("meshQualityControls");
701 
702  // snap-to-surface parameters
703  const dictionary& snapDict = meshDict.subDict("snapControls");
704 
705  // absolute merge distance
706  const scalar mergeDist = getMergeDistance
707  (
708  mesh,
709  meshDict.lookup<scalar>("mergeTolerance")
710  );
711 
712  const Switch keepPatches(meshDict.lookupOrDefault("keepPatches", false));
713 
714 
715  // Read decomposePar dictionary
716  dictionary decomposeDict;
717  {
718  if (Pstream::parRun())
719  {
720  decomposeDict = decompositionMethod::decomposeParDict(runTime);
721  }
722  else
723  {
724  decomposeDict.add("method", "none");
725  decomposeDict.add("numberOfSubdomains", 1);
726  }
727  }
728 
729 
730  // Debug
731  // ~~~~~
732 
733  // Set debug level
735  (
736  meshDict.lookupOrDefault<label>
737  (
738  "debug",
739  0
740  )
741  );
742  {
743  wordList flags;
744  if (meshDict.readIfPresent("debugFlags", flags))
745  {
746  debugLevel = meshRefinement::debugType
747  (
749  (
751  flags
752  )
753  );
754  }
755  }
756  if (debugLevel > 0)
757  {
758  meshRefinement::debug = debugLevel;
759  snappyRefineDriver::debug = debugLevel;
760  snappySnapDriver::debug = debugLevel;
761  snappyLayerDriver::debug = debugLevel;
762  }
763 
764  // Set file writing level
765  {
766  wordList flags;
767  if (meshDict.readIfPresent("writeFlags", flags))
768  {
770  (
772  (
774  (
776  flags
777  )
778  )
779  );
780  }
781  }
782 
783  // Set output level
784  {
785  wordList flags;
786  if (meshDict.readIfPresent("outputFlags", flags))
787  {
789  (
791  (
793  (
795  flags
796  )
797  )
798  );
799  }
800  }
801 
802 
803  // Read geometry
804  // ~~~~~~~~~~~~~
805 
806  searchableSurfaceList allGeometry
807  (
808  IOobject
809  (
810  "abc",
811  mesh.time().constant(),
813  mesh.time(),
816  ),
817  geometryDict,
818  meshDict.lookupOrDefault("singleRegionName", true)
819  );
820 
821 
822  // Read refinement surfaces
823  // ~~~~~~~~~~~~~~~~~~~~~~~~
824 
825  Info<< "Reading refinement surfaces..." << endl;
826 
827  refinementSurfaces surfaces
828  (
829  allGeometry,
830  refineDict.found("refinementSurfaces")
831  ? refineDict.subDict("refinementSurfaces")
833  refineDict.lookupOrDefault("gapLevelIncrement", 0)
834  );
835 
836  Info<< "Read refinement surfaces in = "
837  << mesh.time().cpuTimeIncrement() << " s" << nl << endl;
838 
839 
840  // Checking only?
841 
842  if (checkGeometry)
843  {
844  // Extract patchInfo
845  List<wordList> patchTypes(allGeometry.size());
846 
847  const PtrList<dictionary>& patchInfo = surfaces.patchInfo();
848  const labelList& surfaceGeometry = surfaces.surfaces();
849  forAll(surfaceGeometry, surfI)
850  {
851  label geomI = surfaceGeometry[surfI];
852  const wordList& regNames = allGeometry.regionNames()[geomI];
853 
854  patchTypes[geomI].setSize(regNames.size());
855  forAll(regNames, regionI)
856  {
857  label globalRegionI = surfaces.globalRegion(surfI, regionI);
858 
859  if (patchInfo.set(globalRegionI))
860  {
861  patchTypes[geomI][regionI] =
862  word(patchInfo[globalRegionI].lookup("type"));
863  }
864  else
865  {
866  patchTypes[geomI][regionI] = wallPolyPatch::typeName;
867  }
868  }
869  }
870 
871  // Write some stats
872  allGeometry.writeStats(patchTypes, Info);
873  // Check topology
874  allGeometry.checkTopology(true);
875  // Check geometry
876  allGeometry.checkGeometry
877  (
878  100.0, // max size ratio
879  1e-9, // intersection tolerance
880  0.01, // min triangle quality
881  true
882  );
883 
884  return 0;
885  }
886 
887 
888 
889  // Read refinement shells
890  // ~~~~~~~~~~~~~~~~~~~~~~
891 
892  Info<< "Reading refinement regions..." << endl;
893  refinementRegions shells
894  (
895  allGeometry,
896  refineDict.found("refinementRegions")
897  ? refineDict.subDict("refinementRegions")
899  );
900  Info<< "Read refinement regions in = "
901  << mesh.time().cpuTimeIncrement() << " s" << nl << endl;
902 
903 
904 
905  // Read feature meshes
906  // ~~~~~~~~~~~~~~~~~~~
907 
908  Info<< "Reading features..." << endl;
909  refinementFeatures features
910  (
911  mesh,
912  refineDict.found("features")
913  ? refineDict.lookup("features")
915  );
916  Info<< "Read features in = "
917  << mesh.time().cpuTimeIncrement() << " s" << nl << endl;
918 
919 
920 
921  // Refinement engine
922  // ~~~~~~~~~~~~~~~~~
923 
924  Info<< nl
925  << "Determining initial surface intersections" << nl
926  << "-----------------------------------------" << nl
927  << endl;
928 
929  // Main refinement engine
930  meshRefinement meshRefiner
931  (
932  mesh,
933  refineDict,
934  mergeDist, // tolerance used in sorting coordinates
935  overwrite, // overwrite mesh files?
936  surfaces, // for surface intersection refinement
937  features, // for feature edges/point based refinement
938  shells // for volume (inside/outside) refinement
939  );
940  Info<< "Calculated surface intersections in = "
941  << mesh.time().cpuTimeIncrement() << " s" << nl << endl;
942 
943  // Some stats
944  meshRefiner.printMeshInfo(debugLevel, "Initial mesh");
945 
946  meshRefiner.write
947  (
950  mesh.time().path()/meshRefiner.name()
951  );
952 
953 
954  // Add all the surface regions as patches
955  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
956 
957  //- Global surface region to patch (non faceZone surface) or patches
958  // (faceZone surfaces)
959  labelList globalToMasterPatch;
960  labelList globalToSlavePatch;
961  {
962  Info<< nl
963  << "Adding patches for surface regions" << nl
964  << "----------------------------------" << nl
965  << endl;
966 
967  // From global region number to mesh patch.
968  globalToMasterPatch.setSize(surfaces.nRegions(), -1);
969  globalToSlavePatch.setSize(surfaces.nRegions(), -1);
970 
971  Info<< setf(ios_base::left)
972  << setw(6) << "Patch"
973  << setw(20) << "Type"
974  << setw(30) << "Region" << nl
975  << setw(6) << "-----"
976  << setw(20) << "----"
977  << setw(30) << "------" << endl;
978 
979  const labelList& surfaceGeometry = surfaces.surfaces();
980  const PtrList<dictionary>& surfacePatchInfo = surfaces.patchInfo();
981 
982  forAll(surfaceGeometry, surfI)
983  {
984  label geomI = surfaceGeometry[surfI];
985 
986  const wordList& regNames = allGeometry.regionNames()[geomI];
987 
988  Info<< surfaces.names()[surfI] << ':' << nl << nl;
989 
990  if (surfaces.surfZones()[surfI].faceZoneName().empty())
991  {
992  // 'Normal' surface
993  forAll(regNames, i)
994  {
995  label globalRegionI = surfaces.globalRegion(surfI, i);
996 
997  label patchi;
998 
999  if (surfacePatchInfo.set(globalRegionI))
1000  {
1001  patchi = meshRefiner.addMeshedPatch
1002  (
1003  regNames[i],
1004  surfacePatchInfo[globalRegionI]
1005  );
1006  }
1007  else
1008  {
1009  dictionary patchInfo;
1010  patchInfo.set("type", wallPolyPatch::typeName);
1011 
1012  patchi = meshRefiner.addMeshedPatch
1013  (
1014  regNames[i],
1015  patchInfo
1016  );
1017  }
1018 
1019  Info<< setf(ios_base::left)
1020  << setw(6) << patchi
1021  << setw(20) << mesh.poly().boundary()[patchi].type()
1022  << setw(30) << regNames[i] << nl;
1023 
1024  globalToMasterPatch[globalRegionI] = patchi;
1025  globalToSlavePatch[globalRegionI] = patchi;
1026  }
1027  }
1028  else
1029  {
1030  // Zoned surface
1031  forAll(regNames, i)
1032  {
1033  label globalRegionI = surfaces.globalRegion(surfI, i);
1034 
1035  // Add master side patch
1036  {
1037  label patchi;
1038 
1039  if (surfacePatchInfo.set(globalRegionI))
1040  {
1041  patchi = meshRefiner.addMeshedPatch
1042  (
1043  regNames[i],
1044  surfacePatchInfo[globalRegionI]
1045  );
1046  }
1047  else
1048  {
1049  dictionary patchInfo;
1050  patchInfo.set("type", wallPolyPatch::typeName);
1051 
1052  patchi = meshRefiner.addMeshedPatch
1053  (
1054  regNames[i],
1055  patchInfo
1056  );
1057  }
1058 
1059  Info<< setf(ios_base::left)
1060  << setw(6) << patchi
1061  << setw(20) << mesh.poly().boundary()[patchi].type()
1062  << setw(30) << regNames[i] << nl;
1063 
1064  globalToMasterPatch[globalRegionI] = patchi;
1065  }
1066  // Add slave side patch
1067  {
1068  const word slaveName = regNames[i] + "_slave";
1069  label patchi;
1070 
1071  if (surfacePatchInfo.set(globalRegionI))
1072  {
1073  patchi = meshRefiner.addMeshedPatch
1074  (
1075  slaveName,
1076  surfacePatchInfo[globalRegionI]
1077  );
1078  }
1079  else
1080  {
1081  dictionary patchInfo;
1082  patchInfo.set("type", wallPolyPatch::typeName);
1083 
1084  patchi = meshRefiner.addMeshedPatch
1085  (
1086  slaveName,
1087  patchInfo
1088  );
1089  }
1090 
1091  Info<< setf(ios_base::left)
1092  << setw(6) << patchi
1093  << setw(20) << mesh.poly().boundary()[patchi].type()
1094  << setw(30) << slaveName << nl;
1095 
1096  globalToSlavePatch[globalRegionI] = patchi;
1097  }
1098  }
1099  }
1100 
1101  Info<< nl;
1102  }
1103 
1104  meshRefiner.addedMeshedPatches();
1105 
1106  Info<< "Added patches in = "
1107  << mesh.time().cpuTimeIncrement() << " s" << nl << endl;
1108  }
1109 
1110 
1111  // Parallel
1112  // ~~~~~~~~
1113 
1114  // Decomposition
1115  autoPtr<decompositionMethod> decomposerPtr
1116  (
1118  );
1119  decompositionMethod& decomposer = decomposerPtr();
1120 
1121  // Mesh distribution engine (uses tolerance to reconstruct meshes)
1122  fvMeshDistribute distributor(mesh);
1123 
1124 
1125  // Now do the real work -refinement -snapping -layers
1126  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1127 
1128  const Switch wantRefine(meshDict.lookup("castellatedMesh"));
1129  const Switch wantSnap(meshDict.lookup("snap"));
1130  const Switch wantLayers(meshDict.lookup("addLayers"));
1131 
1132  // Refinement parameters
1133  const refinementParameters refineParams(refineDict);
1134 
1135  // Snap parameters
1136  const snapParameters snapParams(snapDict);
1137 
1138  if (wantRefine)
1139  {
1140  cpuTime timer;
1141 
1142  snappyRefineDriver refineDriver
1143  (
1144  meshRefiner,
1145  decomposer,
1146  distributor,
1147  globalToMasterPatch,
1148  globalToSlavePatch
1149  );
1150 
1151  if (!overwrite && !debugLevel)
1152  {
1153  const_cast<Time&>(mesh.time())++;
1154  }
1155 
1156  refineDriver.doRefine
1157  (
1158  refineDict,
1159  refineParams,
1160  snapParams,
1161  refineParams.handleSnapProblems(),
1162  motionDict
1163  );
1164 
1165  if (!keepPatches && !wantSnap && !wantLayers)
1166  {
1167  removeZeroSizedPatches(mesh);
1168  }
1169 
1170  writeMesh
1171  (
1172  "Refined mesh",
1173  meshRefiner,
1174  debugLevel,
1176  );
1177 
1178  Info<< "Mesh refined in = "
1179  << timer.cpuTimeIncrement() << " s." << endl;
1180  }
1181 
1182  if (wantSnap)
1183  {
1184  cpuTime timer;
1185 
1186  snappySnapDriver snapDriver
1187  (
1188  meshRefiner,
1189  globalToMasterPatch,
1190  globalToSlavePatch
1191  );
1192 
1193  if (!overwrite && !debugLevel)
1194  {
1195  const_cast<Time&>(mesh.time())++;
1196  }
1197 
1198  // Use the resolveFeatureAngle from the refinement parameters
1199  scalar curvature = refineParams.curvature();
1200  scalar planarAngle = refineParams.planarAngle();
1201 
1202  snapDriver.doSnap
1203  (
1204  snapDict,
1205  motionDict,
1206  curvature,
1207  planarAngle,
1208  snapParams
1209  );
1210 
1211  if (!keepPatches && !wantLayers)
1212  {
1213  removeZeroSizedPatches(mesh);
1214  }
1215 
1216  writeMesh
1217  (
1218  "Snapped mesh",
1219  meshRefiner,
1220  debugLevel,
1222  );
1223 
1224  Info<< "Mesh snapped in = "
1225  << timer.cpuTimeIncrement() << " s." << endl;
1226  }
1227 
1228  if (wantLayers)
1229  {
1230  cpuTime timer;
1231 
1232  // Layer addition parameters dictionary
1233  const dictionary& layersDict = meshDict.subDict("addLayersControls");
1234 
1235  // Layer addition parameters
1236  const layerParameters layerParams(layersDict, mesh.poly().boundary());
1237 
1238  snappyLayerDriver layerDriver
1239  (
1240  meshRefiner,
1241  globalToMasterPatch,
1242  globalToSlavePatch
1243  );
1244 
1245  // Use the maxLocalCells from the refinement parameters
1246  bool preBalance = returnReduce
1247  (
1248  (mesh.nCells() >= refineParams.maxLocalCells()),
1249  orOp<bool>()
1250  );
1251 
1252 
1253  if (!overwrite && !debugLevel)
1254  {
1255  const_cast<Time&>(mesh.time())++;
1256  }
1257 
1258  layerDriver.doLayers
1259  (
1260  layersDict,
1261  motionDict,
1262  layerParams,
1263  preBalance,
1264  decomposer,
1265  distributor
1266  );
1267 
1268  if (!keepPatches)
1269  {
1270  removeZeroSizedPatches(mesh);
1271  }
1272 
1273  writeMesh
1274  (
1275  "Layer mesh",
1276  meshRefiner,
1277  debugLevel,
1279  );
1280 
1281  Info<< "Layers added in = "
1282  << timer.cpuTimeIncrement() << " s." << endl;
1283  }
1284 
1285 
1286  {
1287  // Check final mesh
1288  Info<< "Checking final mesh ..." << endl;
1289  faceSet wrongFaces(mesh, "wrongFaces", mesh.nFaces()/100);
1290  meshCheck::checkMesh(false, mesh, motionDict, wrongFaces);
1291  const label nErrors = returnReduce
1292  (
1293  wrongFaces.size(),
1294  sumOp<label>()
1295  );
1296 
1297  if (nErrors > 0)
1298  {
1299  Info<< "Finished meshing with " << nErrors << " illegal faces"
1300  << " (concave, zero area or negative cell pyramid volume)"
1301  << endl;
1302  wrongFaces.write();
1303  }
1304  else
1305  {
1306  Info<< "Finished meshing without any errors" << endl;
1307  }
1308  }
1309 
1310 
1311  if (surfaceSimplify)
1312  {
1313  const polyBoundaryMesh& bMesh = mesh.poly().boundary();
1314 
1316 
1317  if (args.optionFound("patches"))
1318  {
1320  (
1321  wordReList(args.optionLookup("patches")())
1322  );
1323  }
1324  else
1325  {
1326  forAll(bMesh, patchi)
1327  {
1328  const polyPatch& patch = bMesh[patchi];
1329 
1330  if (!isA<processorPolyPatch>(patch))
1331  {
1333  }
1334  }
1335  }
1336 
1337  fileName outFileName
1338  (
1340  (
1341  "outFile",
1342  "constant/triSurface/simplifiedSurface.stl"
1343  )
1344  );
1345 
1346  extractSurface
1347  (
1348  mesh,
1349  runTime,
1351  outFileName
1352  );
1353 
1354  pointIOField cellCentres
1355  (
1356  IOobject
1357  (
1358  "internalCellCentres",
1359  runTime.name(),
1360  mesh,
1363  ),
1364  mesh.cellCentres()
1365  );
1366 
1367  cellCentres.write();
1368  }
1369 
1370 
1371  Info<< "Finished meshing in = "
1372  << runTime.elapsedCpuTime() << " s." << endl;
1373 
1374  Info<< "End\n" << endl;
1375 
1376  return 0;
1377 }
1378 
1379 
1380 // ************************************************************************* //
Istream and Ostream manipulators taking arguments.
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:449
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
Definition: UList.H:492
A HashTable with keys but without contents.
Definition: HashSet.H:62
bool insert(const Key &key)
Insert a new entry.
Definition: HashSet.H:109
bool erase(T *p)
Remove the specified element from the list and delete it.
Definition: ILList.C:105
A primitive field of type <Type> with automated input and output.
Definition: IOField.H:53
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:57
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
const word & name() const
Return name.
Definition: IOobject.H:307
static unsigned int defaultPrecision()
Return the default precision.
Definition: IOstream.H:473
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
virtual Ostream & write(const token &)
Write token.
Definition: Ostream.C:51
A list of faces which address into the list of points.
static void mapCombineScatter(const List< commsStruct > &comms, Container &Values, const int tag, const label comm)
Scatter data. Reverse of combineGather.
static void mapCombineGather(const List< commsStruct > &comms, Container &Values, const CombineOp &cop, const int tag, const label comm)
static void gatherList(const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
Gather data but keep individual values separate.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: PtrList.H:75
bool set(const label) const
Is element set.
Definition: PtrListI.H:62
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:61
static const word & constant()
Return constant name.
Definition: TimePaths.H:122
fileName globalPath() const
Return the global path.
Definition: TimePaths.H:132
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
fileName path() const
Explicitly inherit path from TimePaths to disambiguate from.
Definition: TimePaths.H:138
IOstream::streamFormat writeFormat() const
Default write format.
Definition: Time.H:292
A List with indirect addressing.
Definition: UIndirectList.H:61
label size() const
Return the number of elements in the UList.
Definition: UListI.H:311
static bool master(const label communicator=0)
Am I the master process.
Definition: UPstream.H:423
static label nProcs(const label communicator=0)
Number of processes in parallel run.
Definition: UPstream.H:411
static bool & parRun()
Is this a parallel run?
Definition: UPstream.H:399
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
Definition: UPstream.H:429
label size() const
Return the number of elements in the UPtrList.
Definition: UPtrListI.H:29
A surface geometry mesh, in which the surface zone information is conveyed by the 'zoneId' associated...
static void addOption(const word &opt, const string &param="", const string &usage="")
Add to an option to validOptions with usage information.
Definition: argList.C:121
static void addBoolOption(const word &opt, const string &usage="")
Add to a bool option to validOptions with usage information.
Definition: argList.C:111
bool optionFound(const word &opt) const
Return true if the named option is found.
Definition: argListI.H:114
const word & executable() const
Name of executable without the path.
Definition: argListI.H:36
IStringStream optionLookup(const word &opt) const
Return an IStringStream from the named option.
Definition: argListI.H:120
T optionLookupOrDefault(const word &opt, const T &deflt) const
Read a value from the named option if present.
Definition: argListI.H:294
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
void set(T *)
Set pointer to that given.
Definition: autoPtrI.H:99
A bounding box defined in terms of the points at its extremities.
Definition: boundBox.H:60
Starts timing CPU usage and return elapsed time from start.
Definition: cpuTime.H:55
double cpuTimeIncrement() const
Return CPU time (in seconds) since last call to cpuTimeIncrement()
Definition: cpuTime.C:60
double elapsedCpuTime() const
Return CPU time (in seconds) from the start.
Definition: cpuTime.C:53
Abstract base class for decomposition.
static IOdictionary decomposeParDict(const Time &time)
Read and return the decomposeParDict.
static autoPtr< decompositionMethod > NewDistributor(const dictionary &decompositionDict)
Return a reference to the selected decomposition method.
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
T lookupOrDefault(const word &, const T &) const
Find and return a T, if not found return the given default.
autoPtr< dictionary > clone() const
Construct and return clone.
Definition: dictionary.C:327
const entry * lookupEntryPtr(const word &, bool recursive, bool patternMatch) const
Find and return an entry data stream pointer if present.
Definition: dictionary.C:507
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:669
const dictionary & typeDict(const word &typeName) const
Find and return a type sub-dictionary.
Definition: dictionary.C:874
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Definition: dictionary.C:778
bool add(entry *, bool mergeEntry=false)
Add a new entry.
Definition: dictionary.C:1019
wordList toc() const
Return the table of contents.
Definition: dictionary.C:981
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:468
static const dictionary null
Null dictionary.
Definition: dictionary.H:261
const dictionary & optionalTypeDict(const word &typeName) const
Find and return an optional type sub-dictionary.
Definition: dictionary.C:921
const word & name() const
Return const reference to name.
A keyword and a list of tokens is an 'entry'.
Definition: entry.H:68
const keyType & keyword() const
Return keyword.
Definition: entry.H:136
virtual const dictionary & dict() const =0
Return dictionary if this entry is a dictionary.
A list of face labels.
Definition: faceSet.H:51
A class for handling file names.
Definition: fileName.H:82
Sends/receives parts of mesh+fvfields to neighbouring processors. Used in load balancing.
static void reorderPatches(fvMesh &, const labelList &oldToNew, const label nPatches, const bool validBoundary)
Reorder and remove trailing patches. If validBoundary call is.
Definition: fvMeshTools.C:104
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:98
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:433
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
Definition: fvMesh.C:932
const polyMesh & poly() const
Return reference to polyMesh.
Definition: fvMesh.H:456
autoPtr< globalIndex > mergePoints(labelList &pointToGlobal, labelList &uniquePoints) const
Helper for merging (collocated!) mesh point data.
Simple container to keep together layer specific information.
Helper class which maintains intersections of (changing) mesh with (static) surfaces.
static int readFlags(const Enum &namedEnum, const wordList &)
Helper: convert wordList into bit pattern using provided.
word name() const
Replacement for Time::name() : return oldInstance (if.
const fvMesh & mesh() const
Reference to mesh.
static const NamedEnum< IOwriteType, 5 > IOwriteTypeNames
void printMeshInfo(const bool, const string &) const
Print some mesh stats.
static const NamedEnum< IOdebugType, 5 > IOdebugTypeNames
static void checkCoupledFaceZones(const polyMesh &)
Helper function: check that face zones are synced.
label addMeshedPatch(const word &name, const dictionary &)
Add patch originating from meshing. Update meshedPatches_.
static const NamedEnum< IOoutputType, 1 > IOoutputTypeNames
bool write() const
Write mesh and all data.
static writeType writeLevel()
Get/set write level.
static outputType outputLevel()
Get/set output level.
void addedMeshedPatches()
Complete adding patches originating from meshing.
label index() const
Return the index of this patch in the boundaryMesh.
const word & name() const
Return name.
Foam::polyBoundaryMesh.
label findIndex(const word &patchName) const
Find patch index given a name.
wordList types() const
Return a list of patch types.
labelHashSet patchSet(const UList< wordRe > &patchNames, const bool warnNotFound=true, const bool usePatchGroups=true) const
Return the patch set corresponding to the given names.
bool checkParallelSync(const bool report=false) const
Check whether all procs have all patches and in same order. Return.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:78
const polyBoundaryMesh & boundary() const
Return boundary mesh.
Definition: polyMesh.H:393
virtual const faceList & faces() const
Return raw faces.
Definition: polyMesh.C:1308
const globalMeshData & globalData() const
Return parallel info.
Definition: polyMesh.C:1471
label nSolutionD() const
Return the number of valid solved-for dimensions in the mesh.
Definition: polyMesh.C:1058
virtual const pointField & points() const
Return raw points.
Definition: polyMesh.C:1295
const boundBox & bounds() const
Return mesh bounding box.
Definition: polyMesh.H:399
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:71
label start() const
Return start label of this patch in the polyMesh face list.
Definition: polyPatch.H:277
virtual bool constraint() const
Return false as this patch is not a constraint type.
Definition: polyPatch.H:289
const vectorField & cellCentres() const
label nCells() const
label nFaces() const
Encapsulates queries for features.
Simple container to keep together refinement specific information.
Encapsulates queries for volume refinement ('refine all cells within shell').
Container for data on surfaces used for surface-driven refinement. Contains all the data about the le...
const wordList & names() const
Names of surfaces.
const labelList & minLevel() const
From global region number to refinement level.
const labelList & maxLevel() const
From global region number to refinement level.
const labelList & surfaces() const
label globalRegion(const label surfi, const label regioni) const
From surface and region on surface to global region.
const labelList & gapLevel() const
From global region number to small gap refinement level.
Container for searchableSurfaces.
label checkGeometry(const scalar maxRatio, const scalar tolerance, const scalar minQuality, const bool report) const
All geometric checks. Return number of failed checks.
const wordList & names() const
const List< wordList > & regionNames() const
label checkTopology(const bool report) const
All topological checks. Return number of failed checks.
void writeStats(const List< wordList > &, Ostream &) const
Write some stats.
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
static const word & geometryDir()
Return the geometry directory name.
Simple container to keep together snap specific information.
All to do with adding layers.
All to do with snapping to surface.
An identifier for a surface zone on a meshed surface.
Implements a timeout mechanism via sigalarm.
Definition: timer.H:82
A class for handling words, derived from string.
Definition: word.H:63
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:329
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
int main(int argc, char *argv[])
Definition: financialFoam.C:44
const polyBoundaryMesh & bMesh
label patchi
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
label checkGeometry(const polyMesh &mesh, const bool allGeometry, const scalar nonOrthThreshold, const scalar skewThreshold, const autoPtr< surfaceWriter > &, const autoPtr< setWriter > &)
Check the geometry.
const unitSet & lookup(const word &unitName)
Lookup and return the named unit from the table.
Definition: units.C:346
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
Smanip< ios_base::fmtflags > setf(const ios_base::fmtflags flags)
Definition: IOmanip.H:164
const doubleScalar e
Definition: doubleScalar.H:106
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Definition: Ostream.H:272
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:288
Omanip< int > setw(const int i)
Definition: IOmanip.H:199
String typeName(const std::type_info &info)
Return the un-mangled name given the standard type info.
messageStream Info
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:42
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Definition: Ostream.H:265
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
dimensionedScalar log(const dimensionedScalar &ds)
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
void inplaceRenumber(const labelUList &oldToNew, ListType &)
Inplace renumber the values of a list.
T clone(const T &t)
Definition: List.H:55
List< wordRe > wordReList
A List of wordRe (word or regular expression)
Definition: wordReList.H:50
tmp< DimensionedField< typename powProduct< Type, r >::type, GeoMesh, Field > > pow(const DimensionedField< Type, GeoMesh, PrimitiveField > &df, typename powProduct< Type, r >::type)
error FatalError
IOdictionary systemDict(const word &dictName, const argList &args, const objectRegistry &ob, const word &regionName=polyMesh::defaultRegion, const fileName &path=fileName::null)
Definition: systemDict.C:93
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:243
static const char nl
Definition: Ostream.H:297
dimensioned< Type > max(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
wordList patchTypes(nPatches)
labelHashSet includePatches
List< treeBoundBox > meshBb(1, treeBoundBox(boundBox(coarseMesh.points(), false)).extend(1e-3))
const bool overwrite
Definition: setNoOverwrite.H:1
const Foam::wordList regionNames(args.optionFound("allRegions") ? runTime.regionNames() :wordList(1, args.optionFound("region") ? args.optionRead< word >("region") :polyMesh::defaultRegion))
Foam::argList args(argc, argv)