foamyHexMeshBackgroundMesh.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) 2012-2016 OpenFOAM Foundation
9  Copyright (C) 2016-2021 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  foamyHexMeshBackGroundMesh
29 
30 Description
31  Writes out background mesh as constructed by foamyHexMesh and constructs
32  distanceSurface.
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #include "PatchTools.H"
37 #include "argList.H"
38 #include "Time.H"
39 #include "triSurface.H"
40 #include "searchableSurfaces.H"
41 #include "conformationSurfaces.H"
42 #include "cellShapeControl.H"
44 #include "cellShape.H"
45 #include "DynamicField.H"
46 #include "isoSurfaceCell.H"
47 #include "foamVtkSurfaceWriter.H"
48 #include "syncTools.H"
49 #include "decompositionModel.H"
50 
51 using namespace Foam;
52 
53 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54 
55 // Tolerance (as fraction of the bounding box). Needs to be fairly lax since
56 // usually meshes get written with limited precision (6 digits)
57 static const scalar defaultMergeTol = 1e-6;
58 
59 // Get merging distance when matching face centres
60 scalar getMergeDistance
61 (
62  const argList& args,
63  const Time& runTime,
64  const boundBox& bb
65 )
66 {
67  const scalar mergeTol =
68  args.getOrDefault<scalar>("mergeTol", defaultMergeTol);
69 
70  scalar writeTol =
71  Foam::pow(scalar(10), -scalar(IOstream::defaultPrecision()));
72 
73  Info<< "Merge tolerance : " << mergeTol << nl
74  << "Write tolerance : " << writeTol << endl;
75 
76  if (runTime.writeFormat() == IOstream::ASCII && mergeTol < writeTol)
77  {
79  << "Your current settings specify ASCII writing with "
80  << IOstream::defaultPrecision() << " digits precision." << endl
81  << "Your merging tolerance (" << mergeTol << ") is finer than this."
82  << endl
83  << "Please change your writeFormat to binary"
84  << " or increase the writePrecision" << endl
85  << "or adjust the merge tolerance (-mergeTol)."
86  << exit(FatalError);
87  }
88 
89  scalar mergeDist = mergeTol * bb.mag();
90 
91  Info<< "Overall meshes bounding box : " << bb << nl
92  << "Relative tolerance : " << mergeTol << nl
93  << "Absolute matching distance : " << mergeDist << nl
94  << endl;
95 
96  return mergeDist;
97 }
98 
99 
100 void printMeshData(const polyMesh& mesh)
101 {
102  // Collect all data on master
103 
104  globalIndex globalCells(mesh.nCells());
105  labelListList patchNeiProcNo(Pstream::nProcs());
106  labelListList patchSize(Pstream::nProcs());
107  const labelList& pPatches = mesh.globalData().processorPatches();
108  patchNeiProcNo[Pstream::myProcNo()].setSize(pPatches.size());
109  patchSize[Pstream::myProcNo()].setSize(pPatches.size());
110  forAll(pPatches, i)
111  {
112  const processorPolyPatch& ppp = refCast<const processorPolyPatch>
113  (
114  mesh.boundaryMesh()[pPatches[i]]
115  );
116  patchNeiProcNo[Pstream::myProcNo()][i] = ppp.neighbProcNo();
117  patchSize[Pstream::myProcNo()][i] = ppp.size();
118  }
119  Pstream::gatherList(patchNeiProcNo);
120  Pstream::gatherList(patchSize);
121 
122 
123  // Print stats
124 
125  globalIndex globalBoundaryFaces(mesh.nBoundaryFaces());
126 
127  label maxProcCells = 0;
128  label totProcFaces = 0;
129  label maxProcPatches = 0;
130  label totProcPatches = 0;
131  label maxProcFaces = 0;
132 
133  for (const int proci : Pstream::allProcs())
134  {
135  Info<< endl
136  << "Processor " << proci << nl
137  << " Number of cells = " << globalCells.localSize(proci)
138  << endl;
139 
140  label nProcFaces = 0;
141 
142  const labelList& nei = patchNeiProcNo[proci];
143 
144  forAll(patchNeiProcNo[proci], i)
145  {
146  Info<< " Number of faces shared with processor "
147  << patchNeiProcNo[proci][i] << " = " << patchSize[proci][i]
148  << endl;
149 
150  nProcFaces += patchSize[proci][i];
151  }
152 
153  Info<< " Number of processor patches = " << nei.size() << nl
154  << " Number of processor faces = " << nProcFaces << nl
155  << " Number of boundary faces = "
156  << globalBoundaryFaces.localSize(proci) << endl;
157 
158  maxProcCells = max(maxProcCells, globalCells.localSize(proci));
159  totProcFaces += nProcFaces;
160  totProcPatches += nei.size();
161  maxProcPatches = max(maxProcPatches, nei.size());
162  maxProcFaces = max(maxProcFaces, nProcFaces);
163  }
164 
165  // Stats
166 
167  scalar avgProcCells = scalar(globalCells.size())/Pstream::nProcs();
168  scalar avgProcPatches = scalar(totProcPatches)/Pstream::nProcs();
169  scalar avgProcFaces = scalar(totProcFaces)/Pstream::nProcs();
170 
171  // In case of all faces on one processor. Just to avoid division by 0.
172  if (totProcPatches == 0)
173  {
174  avgProcPatches = 1;
175  }
176  if (totProcFaces == 0)
177  {
178  avgProcFaces = 1;
179  }
180 
181  Info<< nl
182  << "Number of processor faces = " << totProcFaces/2 << nl
183  << "Max number of cells = " << maxProcCells
184  << " (" << 100.0*(maxProcCells-avgProcCells)/avgProcCells
185  << "% above average " << avgProcCells << ")" << nl
186  << "Max number of processor patches = " << maxProcPatches
187  << " (" << 100.0*(maxProcPatches-avgProcPatches)/avgProcPatches
188  << "% above average " << avgProcPatches << ")" << nl
189  << "Max number of faces between processors = " << maxProcFaces
190  << " (" << 100.0*(maxProcFaces-avgProcFaces)/avgProcFaces
191  << "% above average " << avgProcFaces << ")" << nl
192  << endl;
193 }
194 
195 
196 // Return cellID
197 label cellLabel
198 (
199  const Vector<label>& nCells,
200  const label i,
201  const label j,
202  const label k
203 )
204 {
205  return i*nCells[1]*nCells[2]+j*nCells[2]+k;
206 }
207 
208 label vtxLabel
209 (
210  const Vector<label>& nCells,
211  const label i,
212  const label j,
213  const label k
214 )
215 {
217  (
218  nCells[0]+1,
219  nCells[1]+1,
220  nCells[2]+1
221  );
222  return i*nPoints[1]*nPoints[2]+j*nPoints[2]+k;
223 }
224 
225 
226 autoPtr<polyMesh> generateHexMesh
227 (
228  const IOobject& io,
229  const point& origin,
230  const vector& cellSize,
231  const Vector<label>& nCells
232 )
233 {
235  if (nCells[0]+nCells[1]+nCells[2] > 0)
236  {
237  points.setSize((nCells[0]+1)*(nCells[1]+1)*(nCells[2]+1));
238 
239  // Generate points
240  for (label i = 0; i <= nCells[0]; i++)
241  {
242  for (label j = 0; j <= nCells[1]; j++)
243  {
244  for (label k = 0; k <= nCells[2]; k++)
245  {
246  point pt = origin;
247  pt.x() += i*cellSize[0];
248  pt.y() += j*cellSize[1];
249  pt.z() += k*cellSize[2];
250  points[vtxLabel(nCells, i, j, k)] = pt;
251  }
252  }
253  }
254  }
255 
256 
258  cellShapeList cellShapes(nCells[0]*nCells[1]*nCells[2]);
259 
260  labelList hexPoints(8);
261  label celli = 0;
262  for (label i = 0; i < nCells[0]; i++)
263  {
264  for (label j = 0; j < nCells[1]; j++)
265  {
266  for (label k = 0; k < nCells[2]; k++)
267  {
268  hexPoints[0] = vtxLabel(nCells, i, j, k);
269  hexPoints[1] = vtxLabel(nCells, i+1, j, k);
270  hexPoints[2] = vtxLabel(nCells, i+1, j+1, k);
271  hexPoints[3] = vtxLabel(nCells, i, j+1, k);
272  hexPoints[4] = vtxLabel(nCells, i, j, k+1);
273  hexPoints[5] = vtxLabel(nCells, i+1, j, k+1);
274  hexPoints[6] = vtxLabel(nCells, i+1, j+1, k+1);
275  hexPoints[7] = vtxLabel(nCells, i, j+1, k+1);
276  cellShapes[celli++].reset(hex, hexPoints);
277  }
278  }
279  }
280 
282  wordList patchNames(0);
283  wordList patchTypes(0);
284  word defaultFacesName = "defaultFaces";
285  word defaultFacesType = polyPatch::typeName;
286  wordList patchPhysicalTypes(0);
287 
289  (
290  io,
291  std::move(points),
292  cellShapes,
293  boundary,
294  patchNames,
295  patchTypes,
298  patchPhysicalTypes
299  );
300 }
301 
302 
303 // Determine for every point a signed distance to the nearest surface
304 // (outside is positive)
305 tmp<scalarField> signedDistance
306 (
307  const scalarField& distSqr,
308  const pointField& points,
309  const searchableSurfaces& geometry,
310  const labelList& surfaces
311 )
312 {
313  tmp<scalarField> tfld(new scalarField(points.size(), Foam::sqr(GREAT)));
314  scalarField& fld = tfld.ref();
315 
316  // Find nearest
317  List<pointIndexHit> nearest;
318  labelList nearestSurfaces;
320  (
321  geometry,
322  surfaces,
323  points,
324  scalarField(points.size(), Foam::sqr(GREAT)),//distSqr
325  nearestSurfaces,
326  nearest
327  );
328 
329  // Determine sign of nearest. Sort by surface to do this.
330  DynamicField<point> surfPoints(points.size());
331  DynamicList<label> surfIndices(points.size());
332 
333  forAll(surfaces, surfI)
334  {
335  // Extract points on this surface
336  surfPoints.clear();
337  surfIndices.clear();
338  forAll(nearestSurfaces, i)
339  {
340  if (nearestSurfaces[i] == surfI)
341  {
342  surfPoints.append(points[i]);
343  surfIndices.append(i);
344  }
345  }
346 
347  // Calculate sideness of these surface points
348  label geomI = surfaces[surfI];
349  List<volumeType> volType;
350  geometry[geomI].getVolumeType(surfPoints, volType);
351 
352  // Push back to original
353  forAll(volType, i)
354  {
355  label pointi = surfIndices[i];
356  scalar dist = mag(points[pointi] - nearest[pointi].hitPoint());
357 
358  volumeType vT = volType[i];
359 
360  if (vT == volumeType::OUTSIDE)
361  {
362  fld[pointi] = dist;
363  }
364  else if (vT == volumeType::INSIDE)
365  {
366  fld[i] = -dist;
367  }
368  else
369  {
371  << "getVolumeType failure, neither INSIDE or OUTSIDE"
372  << exit(FatalError);
373  }
374  }
375  }
376 
377  return tfld;
378 }
379 
380 
381 
382 // Main program:
383 
384 int main(int argc, char *argv[])
385 {
387  (
388  "Generate foamyHexMesh-consistent representation of surfaces"
389  );
391  (
392  "writeMesh",
393  "Write the resulting mesh and distance fields"
394  );
396  (
397  "mergeTol",
398  "scalar",
399  "The merge distance relative to the bounding box size (default 1e-6)"
400  );
401 
402  argList::noFunctionObjects(); // Never use function objects
403 
404  #include "setRootCase.H"
405  #include "createTime.H"
406 
407  const bool writeMesh = args.found("writeMesh");
408 
409  if (writeMesh)
410  {
411  Info<< "Writing resulting mesh and cellDistance, pointDistance fields."
412  << nl << endl;
413  }
414 
415 
416  IOdictionary foamyHexMeshDict
417  (
418  IOobject
419  (
420  "foamyHexMeshDict",
421  runTime.system(),
422  runTime,
425  )
426  );
427 
428  // Define/load all geometry
429  searchableSurfaces allGeometry
430  (
431  IOobject
432  (
433  "cvSearchableSurfaces",
434  runTime.constant(),
435  "triSurface",
436  runTime,
439  ),
440  foamyHexMeshDict.subDict("geometry"),
441  foamyHexMeshDict.getOrDefault("singleRegionName", true)
442  );
443 
445 
446  conformationSurfaces geometryToConformTo
447  (
448  runTime,
449  rndGen,
450  allGeometry,
451  foamyHexMeshDict.subDict("surfaceConformation")
452  );
453 
454  cellShapeControl cellShapeControls
455  (
456  runTime,
457  foamyHexMeshDict.subDict("motionControl"),
458  allGeometry,
459  geometryToConformTo
460  );
461 
462 
463  // Generate starting block mesh
464  vector cellSize;
465  {
466  const treeBoundBox& bb = geometryToConformTo.globalBounds();
467 
468  // Determine the number of cells in each direction.
469  const vector span = bb.span();
470  vector nScalarCells = span/cellShapeControls.defaultCellSize();
471 
472  // Calculate initial cell size to be a little bit smaller than the
473  // defaultCellSize to avoid initial refinement triggering.
475  (
476  label(nScalarCells.x())+2,
477  label(nScalarCells.y())+2,
478  label(nScalarCells.z())+2
479  );
480  cellSize = vector
481  (
482  span[0]/nCells[0],
483  span[1]/nCells[1],
484  span[2]/nCells[2]
485  );
486 
487  Info<< "Generating initial hex mesh with" << nl
488  << " bounding box : " << bb << nl
489  << " nCells : " << nCells << nl
490  << " cellSize : " << cellSize << nl
491  << endl;
492 
494  (
495  generateHexMesh
496  (
497  IOobject
498  (
500  runTime.constant(),
501  runTime
502  ),
503  bb.min(),
504  cellSize,
505  (
507  ? nCells
508  : Vector<label>(0, 0, 0)
509  )
510  )
511  );
512  Info<< "Writing initial hex mesh to " << meshPtr().instance() << nl
513  << endl;
514  meshPtr().write();
515  }
516 
517  // Distribute the initial mesh
518  if (Pstream::parRun())
519  {
520  #include "createNamedMesh.H"
521  Info<< "Loaded mesh:" << endl;
522  printMeshData(mesh);
523 
524  // Allow override of decomposeParDict location
525  const fileName decompDictFile =
526  args.getOrDefault<fileName>("decomposeParDict", "");
527 
529  (
530  mesh,
531  decompDictFile
533 
534  // Global matching tolerance
535  //const scalar tolDim = getMergeDistance
536  //(
537  // args,
538  // runTime,
539  // mesh.bounds()
540  //);
541 
542  // Mesh distribution engine
543  fvMeshDistribute distributor(mesh);
544 
545  Info<< "Wanted distribution:"
546  << distributor.countCells(decomp) << nl << endl;
547 
548  // Do actual sending/receiving of mesh
549  autoPtr<mapDistributePolyMesh> map = distributor.distribute(decomp);
550 
551  // Print some statistics
552  //Info<< "After distribution:" << endl;
553  //printMeshData(mesh);
554 
556  Info<< "Writing redistributed mesh" << nl << endl;
557  mesh.write();
558  }
559 
560 
561  Info<< "Refining background mesh according to cell size specification" << nl
562  << endl;
563 
564  const dictionary& backgroundMeshDict =
565  foamyHexMeshDict.subDict("backgroundMeshDecomposition");
566 
567  backgroundMeshDecomposition backgroundMesh
568  (
569  runTime,
570  rndGen,
571  geometryToConformTo,
572  backgroundMeshDict
573  );
574 
575  if (writeMesh)
576  {
577  ++runTime;
578  Info<< "Writing mesh to " << runTime.timeName() << endl;
579  backgroundMesh.mesh().write();
580  }
581 
582  const scalar tolDim = getMergeDistance
583  (
584  args,
585  runTime,
586  backgroundMesh.mesh().bounds()
587  );
588 
589 
590  faceList isoFaces;
591  pointField isoPoints;
592 
593  {
594  // Apply a distanceSurface to it.
595  const fvMesh& fvm = backgroundMesh.mesh();
596 
597  volScalarField cellDistance
598  (
599  IOobject
600  (
601  "cellDistance",
602  fvm.time().timeName(),
603  fvm.time(),
606  false
607  ),
608  fvm,
610  );
611 
612  const searchableSurfaces& geometry = geometryToConformTo.geometry();
613  const labelList& surfaces = geometryToConformTo.surfaces();
614 
615 
616  // Get maximum search size per cell
617  scalarField distSqr(cellDistance.size());
618 
619  const labelList& cellLevel = backgroundMesh.cellLevel();
620  forAll(cellLevel, celli)
621  {
622  // The largest edge of the cell will always be less than the
623  // span of the bounding box of the cell.
624  distSqr[celli] = magSqr(cellSize)/pow(2, cellLevel[celli]);
625  }
626 
627  {
628  // Internal field
629  cellDistance.primitiveFieldRef() = signedDistance
630  (
631  distSqr,
632  fvm.C(),
633  geometry,
634  surfaces
635  );
636 
637  // Patch fields
638  volScalarField::Boundary& cellDistanceBf =
639  cellDistance.boundaryFieldRef();
640  forAll(fvm.C().boundaryField(), patchi)
641  {
642  const pointField& cc = fvm.C().boundaryField()[patchi];
643  fvPatchScalarField& fld = cellDistanceBf[patchi];
644  scalarField patchDistSqr
645  (
646  fld.patch().patchInternalField(distSqr)
647  );
648  fld = signedDistance(patchDistSqr, cc, geometry, surfaces);
649  }
650 
651  // On processor patches the fvm.C() will already be the cell centre
652  // on the opposite side so no need to swap cellDistance.
653 
654  if (writeMesh)
655  {
656  cellDistance.write();
657  }
658  }
659 
660 
661  // Distance to points
662  pointScalarField pointDistance
663  (
664  IOobject
665  (
666  "pointDistance",
667  fvm.time().timeName(),
668  fvm.time(),
671  false
672  ),
673  pointMesh::New(fvm),
675  );
676  {
677  scalarField pointDistSqr(fvm.nPoints(), -sqr(GREAT));
678  for (label facei = 0; facei < fvm.nInternalFaces(); facei++)
679  {
680  label own = fvm.faceOwner()[facei];
681  label ownDistSqr = distSqr[own];
682 
683  const face& f = fvm.faces()[facei];
684  forAll(f, fp)
685  {
686  pointDistSqr[f[fp]] = max(pointDistSqr[f[fp]], ownDistSqr);
687  }
688  }
690  (
691  fvm,
692  pointDistSqr,
693  maxEqOp<scalar>(),
694  -sqr(GREAT) // null value
695  );
696 
697  pointDistance.primitiveFieldRef() = signedDistance
698  (
699  pointDistSqr,
700  fvm.points(),
701  geometry,
702  surfaces
703  );
704 
705  if (writeMesh)
706  {
707  pointDistance.write();
708  }
709  }
710 
711  isoSurfaceCell iso
712  (
713  fvm,
714  cellDistance,
715  pointDistance,
716  scalar(0) // distance
717  );
718 
719  isoFaces.setSize(iso.size());
720  forAll(isoFaces, i)
721  {
722  isoFaces[i] = iso[i];
723  }
724  isoPoints = iso.points();
725  }
726 
727 
728  pointField mergedPoints;
729  faceList mergedFaces;
730  labelList pointMergeMap;
732  (
733  tolDim,
735  (
736  SubList<face>(isoFaces, isoFaces.size()),
737  isoPoints
738  ),
739  mergedPoints,
740  mergedFaces,
741  pointMergeMap
742  );
743 
744  if (Pstream::master())
745  {
747  (
748  mergedPoints,
749  mergedFaces,
750  (runTime.path() / "iso"),
751  false // serial only
752  );
753 
754  writer.writeGeometry();
755  }
756 
757  Info<< "End\n" << endl;
758 
759  return 0;
760 }
761 
762 
763 // ************************************************************************* //
Foam::fvPatchField< scalar >
Foam::IOobject::NO_WRITE
Definition: IOobject.H:195
Foam::autoPtr::New
static autoPtr< T > New(Args &&... args)
Construct autoPtr of T with forwarding arguments.
Foam::IOdictionary
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:54
runTime
engineTime & runTime
Definition: createEngineTime.H:13
Foam::Random
Random number generator.
Definition: Random.H:59
Foam::polyMesh::points
virtual const pointField & points() const
Return raw points.
Definition: polyMesh.C:1069
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:169
Foam::Vector::x
const Cmpt & x() const
Access to the vector x component.
Definition: VectorI.H:73
meshPtr
Foam::autoPtr< Foam::fvMesh > meshPtr(nullptr)
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
cellShapeControl.H
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::fileName
A class for handling file names.
Definition: fileName.H:73
Foam::fvMesh::write
virtual bool write(const bool valid=true) const
Write mesh using IO settings from time.
Definition: fvMesh.C:1041
Foam::dimLength
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:52
Foam::polyMesh::defaultRegion
static word defaultRegion
Return the default region name.
Definition: polyMesh.H:318
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:307
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
PatchTools.H
Foam::DynamicList< label >
isoSurfaceCell.H
Foam::Time::writeFormat
IOstream::streamFormat writeFormat() const
The write stream format.
Definition: Time.H:387
Foam::cellModel::HEX
hex
Definition: cellModel.H:81
Foam::PatchTools::gatherAndMerge
static void gatherAndMerge(const scalar mergeDist, const PrimitivePatch< FaceList, PointField > &p, Field< typename PrimitivePatch< FaceList, PointField >::point_type > &mergedPoints, List< typename PrimitivePatch< FaceList, PointField >::face_type > &mergedFaces, labelList &pointMergeMap)
Gather points and faces onto master and merge into single patch.
Definition: PatchToolsGatherAndMerge.C:38
Foam::SubList
A List obtained as a section of another List.
Definition: SubList.H:54
Foam::treeBoundBox
Standard boundBox with extra functionality for use in octree.
Definition: treeBoundBox.H:86
Foam::MeshObject< polyMesh, UpdateableMeshObject, pointMesh >::New
static const pointMesh & New(const polyMesh &mesh, Args &&... args)
Get existing or create a new MeshObject.
Definition: MeshObject.C:48
Foam::Time::timeName
static word timeName(const scalar t, const int precision=precision_)
Definition: Time.C:780
Foam::argList::addNote
static void addNote(const string &note)
Add extra notes for the usage information.
Definition: argList.C:412
Foam::UPstream::master
static bool master(const label communicator=worldComm)
Am I the master process.
Definition: UPstream.H:457
Foam::processorPolyPatch::neighbProcNo
int neighbProcNo() const
Return neighbour processor number.
Definition: processorPolyPatch.H:274
Foam::argList
Extract command arguments and options from the supplied argc and argv parameters.
Definition: argList.H:123
Foam::polyMesh::boundaryMesh
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:444
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::decompositionModel::decomposer
decompositionMethod & decomposer() const
Return demand-driven decomposition method.
Definition: decompositionModel.C:101
foamVtkSurfaceWriter.H
triSurface.H
defaultFacesType
word defaultFacesType
Definition: readKivaGrid.H:456
syncTools.H
Foam::conformationSurfaces
Definition: conformationSurfaces.H:55
Foam::Vector::z
const Cmpt & z() const
Access to the vector z component.
Definition: VectorI.H:85
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::syncTools::syncPointList
static void syncPointList(const polyMesh &mesh, List< T > &pointValues, const CombineOp &cop, const T &nullValue, const TransformOp &top)
Synchronize values on all mesh points.
Definition: syncToolsTemplates.C:721
Foam::boundBox::min
const point & min() const
Minimum describing the bounding box.
Definition: boundBoxI.H:91
Foam::globalMeshData::processorPatches
const labelList & processorPatches() const noexcept
Return list of processor patch labels.
Definition: globalMeshData.H:381
Foam::primitiveMesh::nPoints
label nPoints() const noexcept
Number of mesh points.
Definition: primitiveMeshI.H:37
Foam::isoSurfaceCell
A surface formed by the iso value. After "Polygonising A Scalar Field Using Tetrahedrons",...
Definition: isoSurfaceCell.H:66
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
patchTypes
wordList patchTypes(nPatches)
Foam::decompositionModel::New
static const decompositionModel & New(const polyMesh &mesh, const fileName &decompDictFile="", const dictionary *fallback=nullptr)
Definition: decompositionModel.C:83
Foam::magSqr
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
Foam::DynamicField
Dynamically sized Field.
Definition: DynamicField.H:49
nPoints
label nPoints
Definition: gmvOutputHeader.H:2
Foam::boundBox::span
vector span() const
The bounding box span (from minimum to maximum)
Definition: boundBoxI.H:127
searchableSurfaces.H
Foam::argList::noFunctionObjects
static void noFunctionObjects(bool addWithOption=false)
Remove '-noFunctionObjects' option and ignore any occurrences.
Definition: argList.C:473
Foam::primitiveMesh::nCells
label nCells() const noexcept
Number of mesh cells.
Definition: primitiveMeshI.H:96
backgroundMeshDecomposition.H
Foam::volumeType
An enumeration wrapper for classification of a location as being inside/outside of a volume.
Definition: volumeType.H:60
Foam::Field< vector >
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
Foam::List::setSize
void setSize(const label n)
Alias for resize()
Definition: List.H:222
argList.H
Foam::polyMesh::faceOwner
virtual const labelList & faceOwner() const
Return face owner.
Definition: polyMesh.C:1107
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:460
conformationSurfaces.H
Foam::primitiveMesh::nBoundaryFaces
label nBoundaryFaces() const noexcept
Number of boundary faces (== nFaces - nInternalFaces)
Definition: primitiveMeshI.H:84
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:42
Foam::processorPolyPatch
Neighbour processor patch.
Definition: processorPolyPatch.H:58
patchNames
wordList patchNames(nPatches)
Foam::cellModel::ref
static const cellModel & ref(const modelType model)
Look up reference to cellModel by enumeration. Fatal on failure.
Definition: cellModels.C:157
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
fld
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;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Definition: gmvOutputLagrangian.H:23
Foam::fvMesh::C
const volVectorField & C() const
Return cell centres as volVectorField.
Definition: fvMeshGeometry.C:341
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:123
Foam::cellShapeControl
Definition: cellShapeControl.H:64
createNamedMesh.H
Required Variables.
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::writer
Base class for graphics format writing. Entry points are.
Definition: writer.H:81
Foam::Ostream::write
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::globalIndex
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
Definition: globalIndex.H:68
Foam::vector
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:51
Foam::maxEqOp
Definition: ops.H:80
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::hex
IOstream & hex(IOstream &io)
Definition: IOstream.H:446
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:324
Foam::IOstream::defaultPrecision
static unsigned int defaultPrecision() noexcept
Return the default precision.
Definition: IOstream.H:342
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::Vector::y
const Cmpt & y() const
Access to the vector y component.
Definition: VectorI.H:79
Foam::primitiveMesh::cellCentres
const vectorField & cellCentres() const
Definition: primitiveMeshCellCentresAndVols.C:84
Foam::TimePaths::system
const word & system() const
Return system name.
Definition: TimePathsI.H:102
Foam::IOstreamOption::ASCII
"ascii" (normal default)
Definition: IOstreamOption.H:72
Foam::polyMesh::faces
virtual const faceList & faces() const
Return raw faces.
Definition: polyMesh.C:1094
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
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
Foam::decompositionMethod::decompose
virtual labelList decompose(const pointField &points, const scalarField &pointWeights) const
Return the wanted processor number for every coordinate.
Definition: decompositionMethod.C:1325
DynamicField.H
Foam::UPstream::allProcs
static rangeType allProcs(const label communicator=worldComm)
Range of process indices for all processes.
Definition: UPstream.H:508
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:51
Foam::UPstream::myProcNo
static int myProcNo(const label communicator=worldComm)
Number of this process (starting from masterNo() = 0)
Definition: UPstream.H:463
Foam::nl
constexpr char nl
Definition: Ostream.H:404
Foam::Time::path
fileName path() const
Return path.
Definition: Time.H:358
defaultFacesName
word defaultFacesName
Definition: readKivaGrid.H:455
f
labelList f(nPoints)
Foam::vtk::surfaceWriter
Write faces/points (optionally with fields) as a vtp file or a legacy vtk file.
Definition: foamVtkSurfaceWriter.H:65
Foam::Vector< label >
Foam::primitiveMesh::nInternalFaces
label nInternalFaces() const noexcept
Number of internal faces.
Definition: primitiveMeshI.H:78
Foam::UPstream::parRun
static bool & parRun() noexcept
Test if this a parallel run.
Definition: UPstream.H:433
Foam::List< labelList >
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::backgroundMeshDecomposition
Store a background polyMesh to use for the decomposition of space and queries for parallel conformalV...
Definition: backgroundMeshDecomposition.H:94
points
const pointField & points
Definition: gmvOutputHeader.H:1
k
label k
Boltzmann constant.
Definition: LISASMDCalcMethod2.H:41
Foam::constant::electromagnetic::e
const dimensionedScalar e
Elementary charge.
Definition: createFields.H:11
createTime.H
Foam::IOobject::MUST_READ_IF_MODIFIED
Definition: IOobject.H:186
Foam::volumeType::INSIDE
A location inside the volume.
Definition: volumeType.H:68
Foam::boundBox
A bounding box defined in terms of min/max extrema points.
Definition: boundBox.H:63
cellShape.H
rndGen
Random rndGen
Definition: createFields.H:23
Foam::fvMesh::time
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:280
Foam::face
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:72
decompositionModel.H
cellShapes
cellShapeList cellShapes
Definition: createBlockMesh.H:3
Foam::cellModel
Maps a geometry to a set of cell primitives.
Definition: cellModel.H:72
Foam::polyMesh::globalData
const globalMeshData & globalData() const
Return parallel info.
Definition: polyMesh.C:1295
Foam::TimePaths::constant
const word & constant() const
Return constant name.
Definition: TimePathsI.H:96
Foam::GeometricField< scalar, fvPatchField, volMesh >
Foam::IOobject::NO_READ
Definition: IOobject.H:188
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:335
args
Foam::argList args(argc, argv)
writer
vtk::internalMeshWriter writer(topoMesh, topoCells, vtk::formatType::INLINE_ASCII, runTime.path()/"blockTopology")
Foam::fvMeshDistribute
Sends/receives parts of mesh+fvfields to neighbouring processors. Used in load balancing.
Definition: fvMeshDistribute.H:70
Foam::searchableSurfacesQueries::findNearest
static void findNearest(const PtrList< searchableSurface > &, const labelList &surfacesToTest, const pointField &, const scalarField &nearestDistSqr, labelList &surfaces, List< pointIndexHit > &)
Find nearest. Return -1 (and a miss()) or surface and nearest.
Definition: searchableSurfacesQueries.C:349
boundary
faceListList boundary
Definition: createBlockMesh.H:4
Foam::polyMesh::setInstance
void setInstance(const fileName &instance, const IOobject::writeOption wOpt=IOobject::AUTO_WRITE)
Set the instance for mesh files.
Definition: polyMeshIO.C:36
Foam::UPstream::nProcs
static label nProcs(const label communicator=worldComm)
Number of processes in parallel run, and 1 for serial run.
Definition: UPstream.H:445
Foam::volumeType::OUTSIDE
A location outside the volume.
Definition: volumeType.H:69
Foam::GeometricField::boundaryField
const Boundary & boundaryField() const
Return const-reference to the boundary field.
Definition: GeometricFieldI.H:62
Foam::argList::found
bool found(const word &optName) const
Return true if the named option is found.
Definition: argListI.H:178
Foam::PrimitivePatch
A list of faces which address into the list of points.
Definition: PrimitivePatch.H:79
Foam::IOobject::MUST_READ
Definition: IOobject.H:185