41 void Foam::conformalVoronoiMesh::calcDualMesh
53 bitSet& boundaryFacesToRemove
58 setVertexSizeAndAlignment();
60 timeCheck(
"After setVertexSizeAndAlignment");
62 indexDualVertices(
points, boundaryPts);
65 Info<<
nl <<
"Merging identical points" <<
endl;
68 mergeIdenticalDualVertices(
points, boundaryPts);
73 timeCheck(
"Before createFacesOwnerNeighbourAndPatches");
75 createFacesOwnerNeighbourAndPatches
83 patchToDelaunayVertex,
84 boundaryFacesToRemove,
92 cellToDelaunayVertex = removeUnusedCells(owner, neighbour);
94 cellCentres =
pointField(cellCentres, cellToDelaunayVertex);
96 removeUnusedPoints(faces,
points, boundaryPts);
102 void Foam::conformalVoronoiMesh::calcTetMesh
113 labelList vertexMap(number_of_vertices());
117 points.setSize(number_of_vertices());
118 pointToDelaunayVertex.setSize(number_of_vertices());
122 Delaunay::Finite_vertices_iterator vit = finite_vertices_begin();
123 vit != finite_vertices_end();
127 if (vit->internalPoint() || vit->boundaryPoint())
129 vertexMap[vit->index()] = vertI;
131 pointToDelaunayVertex[vertI] = vit->index();
137 pointToDelaunayVertex.setSize(vertI);
143 Delaunay::Finite_cells_iterator cit = finite_cells_begin();
144 cit != finite_cells_end();
148 if (cit->internalOrBoundaryDualVertex())
150 cit->cellIndex() = celli++;
154 cit->cellIndex() = Cb::ctFar;
158 patchNames = geometryToConformTo_.patchNames();
166 List<DynamicList<face>> patchFaces(
nPatches, DynamicList<face>(0));
168 List<DynamicList<label>> patchOwners(
nPatches, DynamicList<label>(0));
170 faces.setSize(number_of_finite_facets());
172 owner.setSize(number_of_finite_facets());
174 neighbour.setSize(number_of_finite_facets());
178 labelList verticesOnTriFace(3, label(-1));
180 face newFace(verticesOnTriFace);
184 Delaunay::Finite_facets_iterator fit = finite_facets_begin();
185 fit != finite_facets_end();
189 const Cell_handle
c1(fit->first);
190 const label oppositeVertex = fit->second;
191 const Cell_handle
c2(
c1->neighbor(oppositeVertex));
193 if (
c1->hasFarPoint() &&
c2->hasFarPoint())
199 label c1I =
c1->cellIndex();
200 label c2I =
c2->cellIndex();
202 label ownerCell = -1;
203 label neighbourCell = -1;
205 for (label i = 0; i < 3; i++)
207 verticesOnTriFace[i] = vertexMap
209 c1->vertex(vertex_triple_index(oppositeVertex, i))->index()
213 newFace = face(verticesOnTriFace);
215 if (
c1->hasFarPoint() ||
c2->hasFarPoint())
218 if (
c1->hasFarPoint())
231 label patchIndex = geometryToConformTo_.findPatch
236 if (patchIndex == -1)
242 <<
"did not find a surface patch. Adding to "
247 patchFaces[patchIndex].append(newFace);
248 patchOwners[patchIndex].append(ownerCell);
268 faces[facei] = newFace;
269 owner[facei] = ownerCell;
270 neighbour[facei] = neighbourCell;
275 label nInternalFaces = facei;
277 faces.setSize(nInternalFaces);
278 owner.setSize(nInternalFaces);
279 neighbour.setSize(nInternalFaces);
281 sortFaces(faces, owner, neighbour);
300 void Foam::conformalVoronoiMesh::mergeIdenticalDualVertices
308 label nPtsMerged = 0;
309 label nPtsMergedSum = 0;
313 Map<label> dualPtIndexMap;
315 nPtsMerged = mergeIdenticalDualVertices
321 reindexDualVertices(dualPtIndexMap, boundaryPts);
323 reduce(nPtsMerged, sumOp<label>());
325 nPtsMergedSum += nPtsMerged;
327 }
while (nPtsMerged > 0);
329 if (nPtsMergedSum > 0)
331 Info<<
" Merged " << nPtsMergedSum <<
" points " <<
endl;
336 Foam::label Foam::conformalVoronoiMesh::mergeIdenticalDualVertices
339 Map<label>& dualPtIndexMap
342 label nPtsMerged = 0;
346 Delaunay::Finite_facets_iterator fit = finite_facets_begin();
347 fit != finite_facets_end();
351 const Cell_handle
c1(fit->first);
352 const label oppositeVertex = fit->second;
353 const Cell_handle
c2(
c1->neighbor(oppositeVertex));
355 if (is_infinite(
c1) || is_infinite(
c2))
360 label& c1I =
c1->cellIndex();
361 label& c2I =
c2->cellIndex();
363 if ((c1I != c2I) && !
c1->hasFarPoint() && !
c2->hasFarPoint())
385 dualPtIndexMap.insert(c1I, c1I);
386 dualPtIndexMap.insert(c2I, c1I);
390 dualPtIndexMap.insert(c1I, c2I);
391 dualPtIndexMap.insert(c2I, c2I);
401 Info<<
"mergeIdenticalDualVertices:" <<
endl
402 <<
" zero-length edges : "
675 void Foam::conformalVoronoiMesh::deferredCollapseFaceSet
682 DynamicList<label> faceLabels;
686 if (deferredCollapseFaces.found(Pair<label>(owner[nI], neighbour[nI])))
688 faceLabels.append(nI);
692 Pout<<
"facesToCollapse" <<
nl << faceLabels <<
endl;
697 Foam::conformalVoronoiMesh::createPolyMeshFromPoints
709 bitSet boundaryFacesToRemove;
711 timeCheck(
"Start of checkPolyMeshQuality");
713 Info<<
nl <<
"Creating polyMesh to assess quality" <<
endl;
715 createFacesOwnerNeighbourAndPatches
723 patchToDelaunayVertex,
724 boundaryFacesToRemove,
730 labelList cellToDelaunayVertex(removeUnusedCells(owner, neighbour));
731 cellCentres =
pointField(cellCentres, cellToDelaunayVertex);
737 "foamyHexMesh_temporary",
753 label nValidPatches = 0;
757 label totalPatchSize =
patchDicts[
p].get<label>(
"nFaces");
762 &&
patchDicts[
p].get<word>(
"type") == processorPolyPatch::typeName
766 if (totalPatchSize > 0)
768 patchDicts[
p].set(
"transform",
"coincidentFullMatch");
770 patches[nValidPatches] =
new processorPolyPatch
775 pMesh.boundaryMesh(),
776 processorPolyPatch::typeName
785 reduce(totalPatchSize, sumOp<label>());
787 if (totalPatchSize > 0)
810 void Foam::conformalVoronoiMesh::checkCellSizing()
812 Info<<
"Checking cell sizes..."<<
endl;
814 timeCheck(
"Start of Cell Sizing");
816 labelList boundaryPts(number_of_finite_cells(),
internal);
819 indexDualVertices(ptsField, boundaryPts);
822 mergeIdenticalDualVertices(ptsField, boundaryPts);
824 autoPtr<polyMesh>
meshPtr = createPolyMeshFromPoints(ptsField);
825 const polyMesh& pMesh =
meshPtr();
830 DynamicList<label> checkFaces(
identity(pMesh.nFaces()));
833 Info<<
"Running checkMesh on mesh with " << pMesh.nCells()
836 const dictionary&
dict
837 = foamyHexMeshControls().foamyHexMeshDict();
839 const dictionary& meshQualityDict
842 const scalar maxNonOrtho =
845 label nWrongFaces = 0;
847 if (maxNonOrtho < 180.0 - SMALL)
861 label nNonOrthogonal =
returnReduce(wrongFaces.size(), sumOp<label>());
863 Info<<
" non-orthogonality > " << maxNonOrtho
864 <<
" degrees : " << nNonOrthogonal <<
endl;
866 nWrongFaces += nNonOrthogonal;
869 labelHashSet protrudingCells = findOffsetPatchFaces(pMesh, 0.25);
871 label nProtrudingCells = protrudingCells.size();
873 Info<<
" protruding/intruding cells : " << nProtrudingCells <<
endl;
875 nWrongFaces += nProtrudingCells;
886 Info<<
" Found total of " << nWrongFaces <<
" bad faces" <<
endl;
892 for (
const label facei : wrongFaces)
894 const label faceOwner = pMesh.faceOwner()[facei];
895 const label faceNeighbour = pMesh.faceNeighbour()[facei];
897 if (!cellsToResizeMap.found(faceOwner))
899 cellsToResizeMap.
insert(faceOwner);
902 if (!cellsToResizeMap.found(faceNeighbour))
904 cellsToResizeMap.insert(faceNeighbour);
908 cellsToResizeMap += protrudingCells;
910 pointField cellsToResize(cellsToResizeMap.size());
913 for (label celli = 0; celli < pMesh.nCells(); ++celli)
915 if (cellsToResizeMap.found(celli))
917 cellsToResize[
count++] = pMesh.cellCentres()[celli];
921 Info<<
" DISABLED: Automatically re-sizing " << cellsToResize.size()
922 <<
" cells that are attached to the bad faces: " <<
endl;
927 timeCheck(
"End of Cell Sizing");
929 Info<<
"Finished checking cell sizes"<<
endl;
935 const polyMesh&
mesh,
936 const scalar allowedOffset
939 timeCheck(
"Start findRemainingProtrusionSet");
943 cellSet offsetBoundaryCells
946 "foamyHexMesh_protrudingCells",
961 const face&
f = localFaces[pLFI];
965 const scalar targetSize = targetCellSize(faceCentre);
970 geometryToConformTo_.findSurfaceNearest
981 && (
mag(pHit.hitPoint() - faceCentre) > allowedOffset*targetSize)
984 offsetBoundaryCells.insert(fCell[pLFI]);
989 if (foamyHexMeshControls().objOutput())
991 offsetBoundaryCells.write();
994 return std::move(offsetBoundaryCells);
1003 autoPtr<polyMesh>
meshPtr = createPolyMeshFromPoints(pts);
1006 timeCheck(
"polyMesh created, checking quality");
1010 DynamicList<label> checkFaces(pMesh.nFaces());
1014 scalar faceAreaLimit = SMALL;
1018 if (
mag(fAreas[fI]) > faceAreaLimit)
1020 checkFaces.append(fI);
1024 Info<<
nl <<
"Excluding "
1025 <<
returnReduce(fAreas.size() - checkFaces.size(), sumOp<label>())
1026 <<
" faces from check, < " << faceAreaLimit <<
" area" <<
endl;
1028 const dictionary&
dict
1029 = foamyHexMeshControls().foamyHexMeshDict();
1031 const dictionary& meshQualityDict
1045 label nInvalidPolyhedra = 0;
1051 if (
cells[cI].size() < 4 &&
cells[cI].size() > 0)
1057 nInvalidPolyhedra++;
1059 wrongFaces.insert(
cells[cI]);
1063 Info<<
" cells with more than 1 but fewer than 4 faces : "
1071 for (label fI = 0; fI < pMesh.nInternalFaces(); fI++)
1073 nInternalFaces[pMesh.faceOwner()[fI]]++;
1074 nInternalFaces[pMesh.faceNeighbour()[fI]]++;
1077 const polyBoundaryMesh&
patches = pMesh.boundaryMesh();
1081 if (
patches[patchi].coupled())
1087 nInternalFaces[owners[i]]++;
1092 label oneInternalFaceCells = 0;
1094 forAll(nInternalFaces, cI)
1096 if (nInternalFaces[cI] <= 1)
1098 oneInternalFaceCells++;
1099 wrongFaces.insert(
cells[cI]);
1103 Info<<
" cells with with zero or one non-boundary face : "
1109 bitSet ptToBeLimited(pts.size(),
false);
1111 for (
const label facei : wrongFaces)
1113 const face
f = pMesh.faces()[facei];
1115 ptToBeLimited.
set(
f);
1149 label maxFilterCount = 0;
1153 Delaunay::Finite_cells_iterator cit = finite_cells_begin();
1154 cit != finite_cells_end();
1158 label cI = cit->cellIndex();
1162 if (ptToBeLimited.test(cI))
1164 cit->filterCount()++;
1167 if (cit->filterCount() > maxFilterCount)
1169 maxFilterCount = cit->filterCount();
1174 Info<<
nl <<
"Maximum number of filter limits applied: "
1181 Foam::label Foam::conformalVoronoiMesh::classifyBoundaryPoint
1186 if (cit->boundaryDualVertex())
1188 if (cit->featurePointDualVertex())
1190 return featurePoint;
1192 else if (cit->featureEdgeDualVertex())
1201 else if (cit->baffleSurfaceDualVertex())
1205 else if (cit->baffleEdgeDualVertex())
1216 void Foam::conformalVoronoiMesh::indexDualVertices
1224 this->resetCellCount();
1226 label nConstrainedVertices = 0;
1227 if (foamyHexMeshControls().guardFeaturePoints())
1231 Delaunay::Finite_vertices_iterator vit = finite_vertices_begin();
1232 vit != finite_vertices_end();
1236 if (vit->constrained())
1238 vit->index() = number_of_finite_cells() + nConstrainedVertices;
1239 nConstrainedVertices++;
1244 pts.setSize(number_of_finite_cells() + nConstrainedVertices);
1247 number_of_finite_cells() + nConstrainedVertices,
1251 if (foamyHexMeshControls().guardFeaturePoints())
1253 nConstrainedVertices = 0;
1256 Delaunay::Finite_vertices_iterator vit = finite_vertices_begin();
1257 vit != finite_vertices_end();
1261 if (vit->constrained())
1263 pts[number_of_finite_cells() + nConstrainedVertices] =
1266 boundaryPts[number_of_finite_cells() + nConstrainedVertices] =
1269 nConstrainedVertices++;
1280 Delaunay::Finite_cells_iterator cit = finite_cells_begin();
1281 cit != finite_cells_end();
1292 if (!cit->hasFarPoint())
1294 cit->cellIndex() = getNewCellIndex();
1302 typedef CGAL::Exact_predicates_exact_constructions_kernel Exact;
1303 typedef CGAL::Point_3<Exact> ExactPoint;
1305 List<labelPair> cellVerticesPair(4);
1306 List<ExactPoint> cellVertices(4);
1308 for (label vI = 0; vI < 4; ++vI)
1312 cit->vertex(vI)->procIndex(),
1313 cit->vertex(vI)->index()
1316 cellVertices[vI] = ExactPoint
1318 cit->vertex(vI)->point().x(),
1319 cit->vertex(vI)->point().y(),
1320 cit->vertex(vI)->point().z()
1327 oldToNew =
invert(oldToNew.size(), oldToNew);
1330 ExactPoint synchronisedDual = CGAL::circumcenter
1340 CGAL::to_double(synchronisedDual.x()),
1341 CGAL::to_double(synchronisedDual.y()),
1342 CGAL::to_double(synchronisedDual.z())
1347 pts[cit->cellIndex()] = cit->dual();
1351 if (foamyHexMeshControls().snapFeaturePoints())
1353 if (cit->featurePointDualVertex())
1361 geometryToConformTo_.findFeaturePointNearest
1364 sqr(targetCellSize(dual)),
1373 Info<<
"Dual = " << dual <<
nl
1374 <<
" Nearest = " << fpHit.hitPoint() <<
endl;
1377 pts[cit->cellIndex()] = fpHit.hitPoint();
1464 boundaryPts[cit->cellIndex()] = classifyBoundaryPoint(cit);
1468 cit->cellIndex() = Cb::ctFar;
1478 void Foam::conformalVoronoiMesh::reindexDualVertices
1480 const Map<label>& dualPtIndexMap,
1486 Delaunay::Finite_cells_iterator cit = finite_cells_begin();
1487 cit != finite_cells_end();
1491 if (dualPtIndexMap.found(cit->cellIndex()))
1493 cit->cellIndex() = dualPtIndexMap[cit->cellIndex()];
1494 boundaryPts[cit->cellIndex()] =
1497 boundaryPts[cit->cellIndex()],
1498 boundaryPts[dualPtIndexMap[cit->cellIndex()]]
1505 Foam::label Foam::conformalVoronoiMesh::createPatchInfo
1511 patchNames = geometryToConformTo_.patchNames();
1515 const PtrList<dictionary>& patchInfo = geometryToConformTo_.patchInfo();
1519 if (patchInfo.set(patchi))
1521 patchDicts.set(patchi,
new dictionary(patchInfo[patchi]));
1529 wallPolyPatch::typeName
1535 label defaultPatchIndex =
patchNames.size() - 1;
1536 patchNames[defaultPatchIndex] =
"foamyHexMesh_defaultPatch";
1537 patchDicts.set(defaultPatchIndex,
new dictionary());
1541 wallPolyPatch::typeName
1548 List<boolList> procUsedList
1559 Delaunay::Finite_vertices_iterator vit = finite_vertices_begin();
1560 vit != finite_vertices_end();
1567 if (vit->referred())
1569 procUsed[vit->procIndex()] =
true;
1577 forAll(procUsedList, proci)
1583 procUsed[proci] =
true;
1601 for (label pI = nNonProcPatches; pI < nTotalPatches; ++pI)
1618 processorPolyPatch::typeName
1627 patchDicts[nNonProcPatches + procAddI].set(
"neighbProcNo", pUI);
1634 return defaultPatchIndex;
1638 Foam::vector Foam::conformalVoronoiMesh::calcSharedPatchNormal
1647 for (label cI = 0; cI < 4; ++cI)
1649 if (
c1->neighbor(cI) !=
c2 && !
c1->vertex(cI)->constrained())
1651 if (
c1->vertex(cI)->internalBoundaryPoint())
1653 patchEdge[0] =
topoint(
c1->vertex(cI)->point());
1657 patchEdge[1] =
topoint(
c1->vertex(cI)->point());
1664 return vector(patchEdge[1] - patchEdge[0]);
1668 bool Foam::conformalVoronoiMesh::boundaryDualFace
1674 label nInternal = 0;
1675 label nExternal = 0;
1677 for (label cI = 0; cI < 4; ++cI)
1679 if (
c1->neighbor(cI) !=
c2 && !
c1->vertex(cI)->constrained())
1681 if (
c1->vertex(cI)->internalBoundaryPoint())
1685 else if (
c1->vertex(cI)->externalBoundaryPoint())
1692 Info<<
"in = " << nInternal <<
" out = " << nExternal <<
endl;
1694 return (nInternal == 1 && nExternal == 1);
1698 void Foam::conformalVoronoiMesh::createFacesOwnerNeighbourAndPatches
1707 bitSet& boundaryFacesToRemove,
1708 bool includeEmptyPatches
1716 forAll(procNeighbours, patchi)
1718 procNeighbours[patchi] =
1719 patchDicts[patchi].getOrDefault<label>(
"neighbProcNo", -1);
1722 List<DynamicList<face>> patchFaces(
nPatches, DynamicList<face>(0));
1723 List<DynamicList<label>> patchOwners(
nPatches, DynamicList<label>(0));
1725 List<DynamicList<label>> patchPPSlaves(
nPatches, DynamicList<label>(0));
1727 List<DynamicList<bool>> indirectPatchFace(
nPatches, DynamicList<bool>(0));
1730 faces.setSize(number_of_finite_edges());
1731 owner.setSize(number_of_finite_edges());
1732 neighbour.setSize(number_of_finite_edges());
1733 boundaryFacesToRemove.setSize(number_of_finite_edges(),
false);
1735 labelPairPairDynListList procPatchSortingIndex(
nPatches);
1737 label dualFacei = 0;
1739 if (foamyHexMeshControls().guardFeaturePoints())
1741 OBJstream startCellStr(
"startingCell.obj");
1742 OBJstream featurePointFacesStr(
"ftPtFaces.obj");
1743 OBJstream featurePointDualsStr(
"ftPtDuals.obj");
1744 OFstream cellStr(
"vertexCells.obj");
1750 Delaunay::Finite_vertices_iterator vit = finite_vertices_begin();
1751 vit != finite_vertices_end();
1755 if (vit->constrained())
1758 std::list<Cell_handle> vertexCells;
1759 finite_incident_cells(vit, std::back_inserter(vertexCells));
1761 Cell_handle startCell;
1765 std::list<Cell_handle>::iterator vcit = vertexCells.begin();
1766 vcit != vertexCells.end();
1770 if ((*vcit)->featurePointExternalCell())
1775 if ((*vcit)->real())
1777 featurePointDualsStr.write
1785 if (startCell ==
nullptr)
1787 Pout<<
"Start cell is null!" <<
endl;
1791 Cell_handle vc1 = startCell;
1794 Info<<
"c1 index = " << vc1->cellIndex() <<
" "
1795 << vc1->dual() <<
endl;
1797 for (label cI = 0; cI < 4; ++cI)
1799 Info<<
"c1 = " << cI <<
" "
1800 << vc1->neighbor(cI)->cellIndex() <<
" v = "
1801 << vc1->neighbor(cI)->dual() <<
endl;
1803 Info<< vc1->vertex(cI)->info();
1806 Cell_handle nextCell;
1808 for (label cI = 0; cI < 4; ++cI)
1810 if (vc1->vertex(cI)->externalBoundaryPoint())
1812 vc2 = vc1->neighbor(cI);
1814 Info<<
" c2 is neighbor "
1816 <<
" of c1" <<
endl;
1818 for (label cI = 0; cI < 4; ++cI)
1820 Info<<
" c2 = " << cI <<
" "
1821 << vc2->neighbor(cI)->cellIndex() <<
" v = "
1822 << vc2->vertex(cI)->index() <<
endl;
1826 f[0] = vit->index();
1827 f[1] = vc1->cellIndex();
1828 f[2] = vc2->cellIndex();
1836 vector correctNormal = calcSharedPatchNormal(vc1, vc2);
1837 correctNormal.normalise();
1839 Info<<
" cN " << correctNormal <<
endl;
1841 vector fN =
f.areaNormal(pts);
1843 if (
mag(fN) < SMALL)
1852 if ((fN & correctNormal) > 0)
1862 label own = vit->index();
1866 Info<<
"Start walk from " << vc1->cellIndex()
1867 <<
" to " << vc2->cellIndex() <<
endl;
1874 Info<<
" Walk from " << vc1->cellIndex()
1875 <<
" " << vc1->dual()
1876 <<
" to " << vc2->cellIndex()
1877 <<
" " << vc2->dual()
1885 geometryToConformTo_.findPatch
1890 f[1] = vc1->cellIndex();
1891 f[2] = vc2->cellIndex();
1893 patchFaces[patchIndex].
append(
f);
1894 patchOwners[patchIndex].append(own);
1895 patchPPSlaves[patchIndex].append(own);
1898 Cell_handle nextCell;
1900 Info<<
" c1 vertices " << vc2->dual() <<
endl;
1901 for (label cI = 0; cI < 4; ++cI)
1903 Info<<
" " << vc2->vertex(cI)->info();
1905 Info<<
" c1 neighbour vertices " <<
endl;
1906 for (label cI = 0; cI < 4; ++cI)
1910 !vc2->vertex(cI)->constrained()
1911 && vc2->neighbor(cI) != vc1
1912 && !is_infinite(vc2->neighbor(cI))
1915 vc2->neighbor(cI)->featurePointExternalCell()
1916 || vc2->neighbor(cI)->featurePointInternalCell()
1918 && vc2->neighbor(cI)->hasConstrainedPoint()
1928 Info<<
" neighbour " << cI <<
" "
1929 << vc2->neighbor(cI)->dual() <<
endl;
1930 for (label
I = 0;
I < 4; ++
I)
1933 << vc2->neighbor(cI)->vertex(
I)->info();
1938 for (label cI = 0; cI < 4; ++cI)
1942 !vc2->vertex(cI)->constrained()
1943 && vc2->neighbor(cI) != vc1
1944 && !is_infinite(vc2->neighbor(cI))
1947 vc2->neighbor(cI)->featurePointExternalCell()
1948 || vc2->neighbor(cI)->featurePointInternalCell()
1950 && vc2->neighbor(cI)->hasConstrainedPoint()
1954 if (boundaryDualFace(vc2, vc2->neighbor(cI)))
1956 nextCell = vc2->neighbor(cI);
1966 }
while (vc1 != startCell && iter < 100);
1973 Delaunay::Finite_edges_iterator eit = finite_edges_begin();
1974 eit != finite_edges_end();
1978 Cell_handle
c = eit->first;
1979 Vertex_handle vA =
c->vertex(eit->second);
1980 Vertex_handle vB =
c->vertex(eit->third);
1982 if (vA->constrained() && vB->constrained())
1989 (vA->constrained() && vB->internalOrBoundaryPoint())
1990 || (vB->constrained() && vA->internalOrBoundaryPoint())
1993 face newDualFace = buildDualFace(eit);
1998 if (ownerAndNeighbour(vA, vB, own, nei))
2004 faces[dualFacei] = newDualFace;
2005 owner[dualFacei] = own;
2006 neighbour[dualFacei] = nei;
2012 (vA->internalOrBoundaryPoint() && !vA->referred())
2013 || (vB->internalOrBoundaryPoint() && !vB->referred())
2018 (vA->internalPoint() && vB->externalBoundaryPoint())
2019 || (vB->internalPoint() && vA->externalBoundaryPoint())
2022 Cell_circulator ccStart = incident_cells(*eit);
2023 Cell_circulator cc1 = ccStart;
2024 Cell_circulator cc2 = cc1;
2028 bool skipEdge =
false;
2034 cc1->hasFarPoint() || cc2->hasFarPoint()
2035 || is_infinite(cc1) || is_infinite(cc2)
2038 Pout<<
"Ignoring edge between internal and external: "
2049 }
while (cc1 != ccStart);
2064 face newDualFace = buildDualFace(eit);
2066 if (newDualFace.size() >= 3)
2071 if (ownerAndNeighbour(vA, vB, own, nei))
2076 label patchIndex = -1;
2085 if (isProcBoundaryEdge(eit))
2090 label procIndex =
max(vA->procIndex(), vB->procIndex());
2094 procNeighbours.find(vA->procIndex()),
2095 procNeighbours.find(vB->procIndex())
2106 DynamicList<labelPairPair>& sortingIndex =
2107 procPatchSortingIndex[patchIndex];
2109 if (vB->internalOrBoundaryPoint() && vB->referred())
2115 labelPair(vA->index(), vA->procIndex()),
2126 labelPair(vB->index(), vB->procIndex()),
2137 DynamicList<labelPairPair>& sortingIndex =
2138 procPatchSortingIndex[patchIndex];
2140 if (vA->internalOrBoundaryPoint() && vA->referred())
2146 labelPair(vA->index(), vA->procIndex()),
2157 labelPair(vB->index(), vB->procIndex()),
2176 patchIndex = geometryToConformTo_.findPatch(ptA, ptB);
2179 if (patchIndex == -1)
2188 patchIndex = geometryToConformTo_.findPatch
2194 patchFaces[patchIndex].append(newDualFace);
2195 patchOwners[patchIndex].append(own);
2201 vA->boundaryPoint() && vB->boundaryPoint()
2202 && !ptPairs_.isPointPair(vA, vB)
2203 && !ftPtConformer_.featurePointPairs().isPointPair(vA, vB)
2206 indirectPatchFace[patchIndex].append(
true);
2210 indirectPatchFace[patchIndex].append(
false);
2214 if (vA->internalOrBoundaryPoint())
2216 patchPPSlaves[patchIndex].append(vB->index());
2220 patchPPSlaves[patchIndex].append(vA->index());
2227 !vA->boundaryPoint()
2228 || !vB->boundaryPoint()
2229 || ptPairs_.isPointPair(vA, vB)
2230 || ftPtConformer_.featurePointPairs().isPointPair(vA, vB)
2233 patchIndex = geometryToConformTo_.findPatch(ptA, ptB);
2239 && geometryToConformTo_.patchInfo().set(patchIndex)
2244 patchFaces[patchIndex].append(newDualFace);
2245 patchOwners[patchIndex].append(own);
2246 indirectPatchFace[patchIndex].append(
false);
2250 patchFaces[patchIndex].append(newDualFace);
2251 patchOwners[patchIndex].append(nei);
2252 indirectPatchFace[patchIndex].append(
false);
2257 <
labelPair(vA->index(), vA->procIndex())
2260 patchPPSlaves[patchIndex].append(vB->index());
2261 patchPPSlaves[patchIndex].append(vB->index());
2265 patchPPSlaves[patchIndex].append(vA->index());
2266 patchPPSlaves[patchIndex].append(vA->index());
2273 faces[dualFacei] = newDualFace;
2274 owner[dualFacei] = own;
2275 neighbour[dualFacei] = nei;
2284 if (!patchFaces[defaultPatchIndex].empty())
2286 Pout<<
nl << patchFaces[defaultPatchIndex].size()
2287 <<
" faces were not able to have their patch determined from "
2289 <<
nl <<
"Adding to patch " <<
patchNames[defaultPatchIndex]
2293 label nInternalFaces = dualFacei;
2295 faces.setSize(nInternalFaces);
2296 owner.setSize(nInternalFaces);
2297 neighbour.setSize(nInternalFaces);
2299 timeCheck(
"polyMesh quality checked");
2301 sortFaces(faces, owner, neighbour);
2308 procPatchSortingIndex
2311 timeCheck(
"faces, owner, neighbour sorted");
2319 boundaryFacesToRemove,
2326 patchPointPairSlaves.setSize(
nPatches);
2327 forAll(patchPPSlaves, patchi)
2329 patchPointPairSlaves[patchi].transfer(patchPPSlaves[patchi]);
2332 if (foamyHexMeshControls().objOutput())
2334 Info<<
"Writing processor interfaces" <<
endl;
2338 if (patchFaces[nbI].size() > 0)
2340 const label neighbour =
2341 patchDicts[nbI].getOrDefault<label>(
"neighbProcNo", -1);
2343 faceList procPatchFaces = patchFaces[nbI];
2349 forAll(procPatchFaces, fI)
2351 procPatchFaces[fI] = procPatchFaces[fI].reverseFace();
2355 if (neighbour != -1)
2366 time().
path()/fName,
2377 void Foam::conformalVoronoiMesh::sortFaces
2398 List<labelPair> ownerNeighbourPair(owner.size());
2400 forAll(ownerNeighbourPair, oNI)
2402 ownerNeighbourPair[oNI] =
labelPair(owner[oNI], neighbour[oNI]);
2406 <<
"Sorting faces, owner and neighbour into upper triangular order"
2410 oldToNew =
invert(oldToNew.size(), oldToNew);
2418 void Foam::conformalVoronoiMesh::sortProcPatches
2420 List<DynamicList<face>>& patchFaces,
2421 List<DynamicList<label>>& patchOwners,
2422 List<DynamicList<label>>& patchPointPairSlaves,
2423 labelPairPairDynListList& patchSortingIndices
2431 forAll(patchSortingIndices, patchi)
2433 faceList& faces = patchFaces[patchi];
2435 DynamicList<label>& slaves = patchPointPairSlaves[patchi];
2436 DynamicList<labelPairPair>& sortingIndices
2437 = patchSortingIndices[patchi];
2439 if (!sortingIndices.empty())
2443 faces.size() != sortingIndices.size()
2444 || owner.size() != sortingIndices.size()
2445 || slaves.size() != sortingIndices.size()
2449 <<
"patch size and size of sorting indices is inconsistent "
2450 <<
" for patch " << patchi <<
nl
2451 <<
" faces.size() " << faces.size() <<
nl
2452 <<
" owner.size() " << owner.size() <<
nl
2453 <<
" slaves.size() " << slaves.size() <<
nl
2454 <<
" sortingIndices.size() "
2455 << sortingIndices.size()
2460 oldToNew =
invert(oldToNew.size(), oldToNew);
2471 void Foam::conformalVoronoiMesh::addPatches
2473 const label nInternalFaces,
2477 bitSet& boundaryFacesToRemove,
2478 const List<DynamicList<face>>& patchFaces,
2479 const List<DynamicList<label>>& patchOwners,
2480 const List<DynamicList<bool>>& indirectPatchFace
2483 label nBoundaryFaces = 0;
2488 patchDicts[
p].set(
"startFace", nInternalFaces + nBoundaryFaces);
2490 nBoundaryFaces += patchFaces[
p].size();
2493 faces.setSize(nInternalFaces + nBoundaryFaces);
2494 owner.setSize(nInternalFaces + nBoundaryFaces);
2495 boundaryFacesToRemove.setSize(nInternalFaces + nBoundaryFaces);
2497 label facei = nInternalFaces;
2503 faces[facei] = patchFaces[
p][
f];
2504 owner[facei] = patchOwners[
p][
f];
2505 boundaryFacesToRemove[facei] = indirectPatchFace[
p][
f];
2513 void Foam::conformalVoronoiMesh::removeUnusedPoints
2520 Info<<
nl <<
"Removing unused points" <<
endl;
2522 bitSet ptUsed(pts.size(),
false);
2528 const face&
f = faces[fI];
2535 labelList oldToNew(pts.size(), label(-1));
2542 if (ptUsed.test(ptUI))
2544 oldToNew[ptUI] = pointi++;
2556 pts.setSize(pointi);
2557 boundaryPts.setSize(pointi);
2574 Info<<
nl <<
"Removing unused cells" <<
endl;
2576 bitSet cellUsed(vertexCount(),
false);
2580 cellUsed.set(owner);
2581 cellUsed.set(neighbour);
2585 labelList oldToNew(cellUsed.size(), label(-1));
2592 if (cellUsed.test(cellUI))
2594 oldToNew[cellUI] = celli++;
2604 DynamicList<label> unusedCells;
2608 if (!cellUsed.test(cUI))
2610 unusedCells.append(cUI);
2614 if (unusedCells.size() > 0)
2618 <<
" unused cell labels" <<
endl;
2622 label& o = owner[oI];
2629 label&
n = neighbour[nI];