Go to the documentation of this file.
48 const string& description
58 const string& description,
64 Info<<
nl <<
"--- [ cpuTime "
70 Info<<
", " << description <<
" ";
83 PrintTable<word, label> memoryTable
89 memoryTable.add(
"mSize", m.size());
90 memoryTable.add(
"mPeak", m.peak());
91 memoryTable.add(
"mRss", m.rss());
121 bitSet boundaryFacesToRemove;
133 cellToDelaunayVertex,
134 patchToDelaunayVertex,
135 boundaryFacesToRemove
138 Info<<
nl <<
"Writing polyMesh to " << instance <<
endl;
152 boundaryFacesToRemove
157 forAll(dualPatchStarts, patchi)
159 dualPatchStarts[patchi] =
164 if (foamyHexMeshControls().writeCellShapeControlMesh())
166 cellShapeControls().shapeControlMesh().write();
169 if (foamyHexMeshControls().writeBackgroundMeshDecomposition())
171 Info<<
nl <<
"Writing " <<
"backgroundMeshDecomposition" <<
endl;
174 const_cast<fvMesh&
>(decomposition_().mesh()).setInstance
179 decomposition_().mesh().
write();
182 if (foamyHexMeshControls().writeTetDualMesh())
187 Finite_cells_iterator cit = finite_cells_begin();
188 cit != finite_cells_end();
198 cit->cellIndex() = celli++;
202 Info<<
nl <<
"Writing " <<
"tetDualMesh" <<
endl;
206 autoPtr<polyMesh> tetMesh =
207 createMesh(
"tetDualMesh", vertexMap, cellMap);
422 == processorPolyPatch::typeName
426 patches[patchi] =
new processorPolyPatch
433 patchDicts[patchi].get<label>(
"neighbProcNo"),
457 void Foam::conformalVoronoiMesh::checkProcessorPatchesMatch
476 == processorPolyPatch::typeName
480 const label procNeighb =
481 patchDicts[patchi].get<label>(
"neighbProcNo");
492 bool allMatch =
true;
494 forAll(procPatchSizes, proci)
496 const labelList& patchSizes = procPatchSizes[proci];
498 forAll(patchSizes, patchi)
500 if (patchSizes[patchi] != procPatchSizes[patchi][proci])
504 Info<<
indent <<
"Patches " << proci <<
" and " << patchi
505 <<
" have different sizes: " << patchSizes[patchi]
506 <<
" and " << procPatchSizes[patchi][proci] <<
endl;
513 Info<<
indent <<
"All processor patches have matching numbers of "
520 void Foam::conformalVoronoiMesh::reorderPoints
525 const label nInternalFaces
534 for (label fI = nInternalFaces; fI < faces.size(); ++fI)
536 const face&
f = faces[fI];
540 oldToNew[
f[fpI]] = 1;
544 const label nInternalPoints =
points.size() -
sum(oldToNew);
546 label countInternal = 0;
547 label countExternal = nInternalPoints;
551 if (oldToNew[pI] == 0)
553 oldToNew[pI] = countInternal++;
557 oldToNew[pI] = countExternal++;
562 <<
"Number of internal points: " << countInternal <<
nl
563 <<
indent <<
"Number of external points: " << countExternal
575 f[fpI] = oldToNew[
f[fpI]];
581 void Foam::conformalVoronoiMesh::reorderProcessorPatches
583 const word& meshName,
584 const fileName& instance,
597 autoPtr<fvMesh> sortMeshPtr
614 const fvMesh& sortMesh = sortMeshPtr();
623 forAll(sortMesh.boundaryMesh(), patchi)
625 const polyPatch& pp = sortMesh.boundaryMesh()[patchi];
627 if (isA<processorPolyPatch>(pp))
629 refCast<const processorPolyPatch>(pp).initOrder
646 pBufs.finishedSends();
651 bool anyChanged =
false;
653 forAll(sortMesh.boundaryMesh(), patchi)
655 const polyPatch& pp = sortMesh.boundaryMesh()[patchi];
657 if (isA<processorPolyPatch>(pp))
659 const label nPatchFaces =
662 const label patchStartFace =
665 labelList patchFaceMap(nPatchFaces, label(-1));
668 bool changed = refCast<const processorPolyPatch>(pp).order
688 forAll(patchFaceRotation, patchFacei)
690 rotation[patchFacei + patchStartFace]
691 = patchFaceRotation[patchFacei];
694 forAll(patchFaceMap, patchFacei)
696 if (patchFaceMap[patchFacei] != patchFacei)
698 faceMap[patchFacei + patchStartFace]
699 = patchFaceMap[patchFacei] + patchStartFace;
710 reduce(anyChanged, orOp<bool>());
714 label nReorderedFaces = 0;
724 if (nReorderedFaces > 0)
734 if (rotation[facei] != 0)
736 faces[facei] =
rotateList(faces[facei], rotation[facei]);
741 Info<< indent << returnReduce(nReorderedFaces, sumOp<label>())
742 <<
" faces have been reordered" <<
nl
744 <<
" faces have been rotated"
753 const word& meshName,
754 const fileName& instance,
763 bitSet& boundaryFacesToRemove
766 if (foamyHexMeshControls().objOutput())
770 time().
path()/word(meshName +
".obj"),
776 const label nInternalFaces =
patchDicts[0].get<label>(
"startFace");
778 reorderPoints(
points, boundaryPts, faces, nInternalFaces);
782 reorderProcessorPatches
796 timeCheck(
"Before fvMesh construction");
818 label nValidPatches = 0;
822 label totalPatchSize =
patchDicts[
p].get<label>(
"nFaces");
829 == processorPolyPatch::typeName
836 "coincidentFullMatch"
840 if (totalPatchSize > 0)
842 patches[nValidPatches] =
new processorPolyPatch
848 processorPolyPatch::typeName
857 reduce(totalPatchSize, sumOp<label>());
859 if (totalPatchSize > 0)
880 addZones(
mesh, cellCentres);
887 DynamicList<label> bPts(boundaryPts.size());
889 forAll(dualMeshPointTypeNames_, typeI)
892 dualMeshPointTypeNames_[dualMeshPointType(typeI)];
896 const label& bPtType = boundaryPts[ptI];
898 if (bPtType == typeI)
907 <<
"Adding " << bPts.size()
908 <<
" points of type " << znName
934 boundaryFacesToRemove,
935 orEqOp<unsigned int>()
938 labelList addr(boundaryFacesToRemove.toc());
940 faceSet indirectPatchFaces
943 "indirectPatchFaces",
948 indirectPatchFaces.sync(
mesh);
953 timeCheck(
"Before fvMesh filtering");
955 autoPtr<polyMeshFilter> meshFilter;
957 label nInitialBadFaces = 0;
959 if (foamyHexMeshControls().filterEdges())
961 Info<<
nl <<
"Filtering edges on polyMesh" <<
nl <<
endl;
963 meshFilter.reset(
new polyMeshFilter(
mesh, boundaryPts));
967 nInitialBadFaces = meshFilter().filterEdges(0);
969 const autoPtr<fvMesh>& newMesh = meshFilter().filteredMesh();
971 polyTopoChange meshMod(newMesh());
973 autoPtr<mapPolyMesh> map = meshMod.changeMesh(
mesh,
false);
975 polyMeshFilter::copySets(newMesh(),
mesh);
979 if (foamyHexMeshControls().filterFaces())
1000 Info<<
nl <<
"Filtering faces on polyMesh" <<
nl <<
endl;
1002 meshFilter.reset(
new polyMeshFilter(
mesh, boundaryPtsIO));
1004 meshFilter().filter(nInitialBadFaces);
1006 const autoPtr<fvMesh>& newMesh = meshFilter().filteredMesh();
1008 polyTopoChange meshMod(newMesh());
1010 autoPtr<mapPolyMesh> map = meshMod.changeMesh(
mesh,
false);
1012 polyMeshFilter::copySets(newMesh(),
mesh);
1016 timeCheck(
"After fvMesh filtering");
1023 <<
"Failed writing polyMesh."
1028 Info<<
nl <<
"Written filtered mesh to "
1029 <<
mesh.polyMesh::instance() <<
nl
1038 "boundaryPoints_collapsed",
1067 boundaryPtsScalarField.write();
1068 boundaryPtsIO.write();
1077 findRemainingProtrusionSet(
mesh);
1087 timeCheck(
"Start writeCellSizes");
1089 Info<<
nl <<
"Create targetCellSize volScalarField" <<
endl;
1096 mesh.polyMesh::instance(),
1103 zeroGradientFvPatchScalarField::typeName
1106 scalarField& cellSize = targetCellSize.primitiveFieldRef();
1112 cellSize[i] = cellShapeControls().cellSize(
C[i]);
1176 targetCellSize.correctBoundaryConditions();
1181 targetCellSize.write();
1290 Info<<
"Writing components of cellCentre positions to volScalarFields"
1291 <<
" ccx, ccy, ccz in " << runTime_.timeName() <<
endl;
1300 runTime_.timeName(),
1315 const polyMesh&
mesh
1318 timeCheck(
"Start findRemainingProtrusionSet");
1330 label meshPtI =
patch.meshPoints()[pLPI];
1336 geometryToConformTo_.wellOutside
1339 sqr(targetCellSize(pt))
1343 protrudingBoundaryPoints.insert(meshPtI);
1348 cellSet protrudingCells
1351 "foamyHexMesh_remainingProtrusions",
1355 for (
const label pointi : protrudingBoundaryPoints)
1358 protrudingCells.insert(pCells);
1361 const label protrudingCellsSize =
1364 if (foamyHexMeshControls().objOutput() && protrudingCellsSize)
1366 Info<<
nl <<
"Found " << protrudingCellsSize
1367 <<
" cells protruding from the surface, writing cellSet "
1368 << protrudingCells.name()
1371 protrudingCells.
write();
1374 return std::move(protrudingCells);
1378 void Foam::conformalVoronoiMesh::writePointPairs
1380 const fileName& fName
1383 OBJstream
os(fName);
1387 Delaunay::Finite_edges_iterator eit = finite_edges_begin();
1388 eit != finite_edges_end();
1392 Cell_handle
c = eit->first;
1393 Vertex_handle vA =
c->vertex(eit->second);
1394 Vertex_handle vB =
c->vertex(eit->third);
1396 if (ptPairs_.isPointPair(vA, vB))
static autoPtr< T > New(Args &&... args)
Construct autoPtr of T with forwarding arguments.
List< label > labelList
A List of labels.
vectorField pointField
pointField is a vectorField.
void clear()
Clear the zones.
virtual const pointField & points() const
Return raw points.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
tmp< GeometricField< cmptType, PatchField, GeoMesh > > component(const direction) const
Return a component of the field.
Foam::autoPtr< Foam::fvMesh > meshPtr(nullptr)
void set(List< bool > &bools, const labelRange &range)
Set the specified range 'on' in a boolList.
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
static const char *const componentNames[]
virtual bool write(const bool valid=true) const
Write mesh using IO settings from time.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
static word defaultRegion
Return the default region name.
static constexpr const zero Zero
Global zero (0)
static const pointMesh & New(const polyMesh &mesh, Args &&... args)
Get existing or create a new MeshObject.
virtual void print(Ostream &os) const
Print stream description to Ostream.
static bool master(const label communicator=worldComm)
Am I the master process.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Ostream & endl(Ostream &os)
Add newline and flush stream.
virtual Ostream & write(const char c)
Write character.
IOList< label > labelIOList
Label container classes.
Ostream & incrIndent(Ostream &os)
Increment the indent level.
pointFromPoint topoint(const Point &P)
label nPoints() const noexcept
Number of mesh points.
#define forAll(list, i)
Loop across all elements in list.
PtrList< dictionary > patchDicts
Field< vector > vectorField
Specialisation of Field<T> for vector.
List< word > wordList
A List of words.
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
label nCells() const noexcept
Number of mesh cells.
static void check(const int retVal, const char *what)
messageStream Info
Information stream (stdout output on master, null elsewhere)
void setSize(const label newLen)
Same as resize()
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
wordList patchNames(nPatches)
double elapsedCpuTime() const
Return CPU time (in seconds) from the start.
HashTable< label, labelPair, Foam::Hash< labelPair > > labelPairLookup
This is a Map of a labelPair to a label. Used for e.g. for face1, face2 to shared edge....
const volVectorField & C() const
Return cell centres as volVectorField.
label whichZone(const label objectIndex) const
Given a global object index, return the zone it is in.
void addFvPatches(PtrList< polyPatch > &plist, const bool validBoundary=true)
Add boundary patches. Constructor helper.
static autoPtr< polyPatch > New(const word &patchType, const word &name, const label size, const label start, const label index, const polyBoundaryMesh &bm)
Return pointer to a new patch created on freestore from components.
OBJstream os(runTime.globalPath()/outputName)
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
ListType rotateList(const ListType &list, const label n)
Rotate a list by n places.
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Ostream & indent(Ostream &os)
Indent stream.
errorManipArg< error, int > exit(error &err, const int errNo=1)
List< labelList > labelListList
A List of labelList.
const vectorField & cellCentres() const
line< point, const point & > linePointRef
A line using referred points.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
static void gatherList(const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
Gather data but keep individual values separate.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
static int myProcNo(const label communicator=worldComm)
Number of this process (starting from masterNo() = 0)
const std::string patch
OpenFOAM patch number as a std::string.
List< face > faceList
A List of faces.
Templated 3D Vector derived from VectorSpace adding construction from 3 components,...
static bool & parRun() noexcept
Test if this a parallel run.
const labelListList & pointCells() const
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
static const word null
An empty word.
const pointZoneMesh & pointZones() const noexcept
Return point zone mesh.
const polyBoundaryMesh & patches
const dimensionedScalar c
Speed of light in a vacuum.
double cpuTimeIncrement() const
Return CPU time (in seconds) since last call to cpuTimeIncrement()
PrimitivePatch< SubList< face >, const pointField & > primitivePatch
A PrimitivePatch with a SubList addressing for the faces, const reference for the point field.
void inplaceReorder(const labelUList &oldToNew, ListType &input, const bool prune=false)
Inplace reorder the elements of a list.
Various functions to operate on Lists.
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
void setInstance(const fileName &instance, const IOobject::writeOption wOpt=IOobject::AUTO_WRITE)
Set the instance for mesh files.
static label nProcs(const label communicator=worldComm)
Number of processes in parallel run, and 1 for serial run.
static constexpr direction nComponents
Number of components in this vector space.
const dimensionSet dimless
Dimensionless.
GeometricField< scalar, pointPatchField, pointMesh > pointScalarField