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 cellsToResizeMap.insert(faceOwner);
898 cellsToResizeMap.insert(faceNeighbour);
901 cellsToResizeMap += protrudingCells;
903 pointField cellsToResize(cellsToResizeMap.size());
906 for (label celli = 0; celli < pMesh.nCells(); ++celli)
908 if (cellsToResizeMap.found(celli))
910 cellsToResize[
count++] = pMesh.cellCentres()[celli];
914 Info<<
" DISABLED: Automatically re-sizing " << cellsToResize.size()
915 <<
" cells that are attached to the bad faces: " <<
endl;
920 timeCheck(
"End of Cell Sizing");
922 Info<<
"Finished checking cell sizes"<<
endl;
928 const polyMesh&
mesh,
929 const scalar allowedOffset
932 timeCheck(
"Start findRemainingProtrusionSet");
936 cellSet offsetBoundaryCells
939 "foamyHexMesh_protrudingCells",
954 const face&
f = localFaces[pLFI];
958 const scalar targetSize = targetCellSize(faceCentre);
963 geometryToConformTo_.findSurfaceNearest
974 && (
mag(pHit.hitPoint() - faceCentre) > allowedOffset*targetSize)
977 offsetBoundaryCells.insert(fCell[pLFI]);
982 if (foamyHexMeshControls().objOutput())
984 offsetBoundaryCells.write();
987 return std::move(offsetBoundaryCells);
996 autoPtr<polyMesh>
meshPtr = createPolyMeshFromPoints(pts);
999 timeCheck(
"polyMesh created, checking quality");
1003 DynamicList<label> checkFaces(pMesh.nFaces());
1007 scalar faceAreaLimit = SMALL;
1011 if (
mag(fAreas[fI]) > faceAreaLimit)
1013 checkFaces.append(fI);
1017 Info<<
nl <<
"Excluding "
1018 <<
returnReduce(fAreas.size() - checkFaces.size(), sumOp<label>())
1019 <<
" faces from check, < " << faceAreaLimit <<
" area" <<
endl;
1021 const dictionary&
dict
1022 = foamyHexMeshControls().foamyHexMeshDict();
1024 const dictionary& meshQualityDict
1038 label nInvalidPolyhedra = 0;
1044 if (
cells[cI].size() < 4 &&
cells[cI].size() > 0)
1050 nInvalidPolyhedra++;
1052 wrongFaces.insert(
cells[cI]);
1056 Info<<
" cells with more than 1 but fewer than 4 faces : "
1064 for (label fI = 0; fI < pMesh.nInternalFaces(); fI++)
1066 nInternalFaces[pMesh.faceOwner()[fI]]++;
1067 nInternalFaces[pMesh.faceNeighbour()[fI]]++;
1070 const polyBoundaryMesh&
patches = pMesh.boundaryMesh();
1080 nInternalFaces[owners[i]]++;
1085 label oneInternalFaceCells = 0;
1087 forAll(nInternalFaces, cI)
1089 if (nInternalFaces[cI] <= 1)
1091 oneInternalFaceCells++;
1092 wrongFaces.insert(
cells[cI]);
1096 Info<<
" cells with with zero or one non-boundary face : "
1102 bitSet ptToBeLimited(pts.size(),
false);
1104 for (
const label facei : wrongFaces)
1106 const face
f = pMesh.faces()[facei];
1108 ptToBeLimited.
set(
f);
1142 label maxFilterCount = 0;
1146 Delaunay::Finite_cells_iterator cit = finite_cells_begin();
1147 cit != finite_cells_end();
1151 label cI = cit->cellIndex();
1155 if (ptToBeLimited.test(cI))
1157 cit->filterCount()++;
1160 if (cit->filterCount() > maxFilterCount)
1162 maxFilterCount = cit->filterCount();
1167 Info<<
nl <<
"Maximum number of filter limits applied: "
1174 Foam::label Foam::conformalVoronoiMesh::classifyBoundaryPoint
1179 if (cit->boundaryDualVertex())
1181 if (cit->featurePointDualVertex())
1183 return featurePoint;
1185 else if (cit->featureEdgeDualVertex())
1194 else if (cit->baffleSurfaceDualVertex())
1198 else if (cit->baffleEdgeDualVertex())
1209 void Foam::conformalVoronoiMesh::indexDualVertices
1217 this->resetCellCount();
1219 label nConstrainedVertices = 0;
1220 if (foamyHexMeshControls().guardFeaturePoints())
1224 Delaunay::Finite_vertices_iterator vit = finite_vertices_begin();
1225 vit != finite_vertices_end();
1229 if (vit->constrained())
1231 vit->index() = number_of_finite_cells() + nConstrainedVertices;
1232 nConstrainedVertices++;
1237 pts.setSize(number_of_finite_cells() + nConstrainedVertices);
1240 number_of_finite_cells() + nConstrainedVertices,
1244 if (foamyHexMeshControls().guardFeaturePoints())
1246 nConstrainedVertices = 0;
1249 Delaunay::Finite_vertices_iterator vit = finite_vertices_begin();
1250 vit != finite_vertices_end();
1254 if (vit->constrained())
1256 pts[number_of_finite_cells() + nConstrainedVertices] =
1259 boundaryPts[number_of_finite_cells() + nConstrainedVertices] =
1262 nConstrainedVertices++;
1273 Delaunay::Finite_cells_iterator cit = finite_cells_begin();
1274 cit != finite_cells_end();
1285 if (!cit->hasFarPoint())
1287 cit->cellIndex() = getNewCellIndex();
1295 typedef CGAL::Exact_predicates_exact_constructions_kernel Exact;
1296 typedef CGAL::Point_3<Exact> ExactPoint;
1298 List<labelPair> cellVerticesPair(4);
1299 List<ExactPoint> cellVertices(4);
1301 for (label vI = 0; vI < 4; ++vI)
1305 cit->vertex(vI)->procIndex(),
1306 cit->vertex(vI)->index()
1309 cellVertices[vI] = ExactPoint
1311 cit->vertex(vI)->point().x(),
1312 cit->vertex(vI)->point().y(),
1313 cit->vertex(vI)->point().z()
1320 oldToNew =
invert(oldToNew.size(), oldToNew);
1323 ExactPoint synchronisedDual = CGAL::circumcenter
1333 CGAL::to_double(synchronisedDual.x()),
1334 CGAL::to_double(synchronisedDual.y()),
1335 CGAL::to_double(synchronisedDual.z())
1340 pts[cit->cellIndex()] = cit->dual();
1344 if (foamyHexMeshControls().snapFeaturePoints())
1346 if (cit->featurePointDualVertex())
1354 geometryToConformTo_.findFeaturePointNearest
1357 sqr(targetCellSize(dual)),
1366 Info<<
"Dual = " << dual <<
nl
1367 <<
" Nearest = " << fpHit.hitPoint() <<
endl;
1370 pts[cit->cellIndex()] = fpHit.hitPoint();
1457 boundaryPts[cit->cellIndex()] = classifyBoundaryPoint(cit);
1461 cit->cellIndex() = Cb::ctFar;
1471 void Foam::conformalVoronoiMesh::reindexDualVertices
1473 const Map<label>& dualPtIndexMap,
1479 Delaunay::Finite_cells_iterator cit = finite_cells_begin();
1480 cit != finite_cells_end();
1484 if (dualPtIndexMap.found(cit->cellIndex()))
1486 cit->cellIndex() = dualPtIndexMap[cit->cellIndex()];
1487 boundaryPts[cit->cellIndex()] =
1490 boundaryPts[cit->cellIndex()],
1491 boundaryPts[dualPtIndexMap[cit->cellIndex()]]
1498 Foam::label Foam::conformalVoronoiMesh::createPatchInfo
1504 patchNames = geometryToConformTo_.patchNames();
1508 const PtrList<dictionary>& patchInfo = geometryToConformTo_.patchInfo();
1512 if (patchInfo.set(patchi))
1514 patchDicts.set(patchi,
new dictionary(patchInfo[patchi]));
1522 wallPolyPatch::typeName
1528 label defaultPatchIndex =
patchNames.size() - 1;
1529 patchNames[defaultPatchIndex] =
"foamyHexMesh_defaultPatch";
1530 patchDicts.set(defaultPatchIndex,
new dictionary());
1534 wallPolyPatch::typeName
1541 List<boolList> procUsedList
1552 Delaunay::Finite_vertices_iterator vit = finite_vertices_begin();
1553 vit != finite_vertices_end();
1560 if (vit->referred())
1562 procUsed[vit->procIndex()] =
true;
1570 forAll(procUsedList, proci)
1576 procUsed[proci] =
true;
1594 for (label pI = nNonProcPatches; pI < nTotalPatches; ++pI)
1611 processorPolyPatch::typeName
1620 patchDicts[nNonProcPatches + procAddI].set(
"neighbProcNo", pUI);
1627 return defaultPatchIndex;
1631 Foam::vector Foam::conformalVoronoiMesh::calcSharedPatchNormal
1640 for (label cI = 0; cI < 4; ++cI)
1642 if (
c1->neighbor(cI) !=
c2 && !
c1->vertex(cI)->constrained())
1644 if (
c1->vertex(cI)->internalBoundaryPoint())
1646 patchEdge[0] =
topoint(
c1->vertex(cI)->point());
1650 patchEdge[1] =
topoint(
c1->vertex(cI)->point());
1657 return vector(patchEdge[1] - patchEdge[0]);
1661 bool Foam::conformalVoronoiMesh::boundaryDualFace
1667 label nInternal = 0;
1668 label nExternal = 0;
1670 for (label cI = 0; cI < 4; ++cI)
1672 if (
c1->neighbor(cI) !=
c2 && !
c1->vertex(cI)->constrained())
1674 if (
c1->vertex(cI)->internalBoundaryPoint())
1678 else if (
c1->vertex(cI)->externalBoundaryPoint())
1685 Info<<
"in = " << nInternal <<
" out = " << nExternal <<
endl;
1687 return (nInternal == 1 && nExternal == 1);
1691 void Foam::conformalVoronoiMesh::createFacesOwnerNeighbourAndPatches
1700 bitSet& boundaryFacesToRemove,
1701 bool includeEmptyPatches
1709 forAll(procNeighbours, patchi)
1711 procNeighbours[patchi] =
1712 patchDicts[patchi].getOrDefault<label>(
"neighbProcNo", -1);
1715 List<DynamicList<face>> patchFaces(
nPatches, DynamicList<face>(0));
1716 List<DynamicList<label>> patchOwners(
nPatches, DynamicList<label>(0));
1718 List<DynamicList<label>> patchPPSlaves(
nPatches, DynamicList<label>(0));
1720 List<DynamicList<bool>> indirectPatchFace(
nPatches, DynamicList<bool>(0));
1723 faces.setSize(number_of_finite_edges());
1724 owner.setSize(number_of_finite_edges());
1725 neighbour.setSize(number_of_finite_edges());
1726 boundaryFacesToRemove.setSize(number_of_finite_edges(),
false);
1728 labelPairPairDynListList procPatchSortingIndex(
nPatches);
1730 label dualFacei = 0;
1732 if (foamyHexMeshControls().guardFeaturePoints())
1734 OBJstream startCellStr(
"startingCell.obj");
1735 OBJstream featurePointFacesStr(
"ftPtFaces.obj");
1736 OBJstream featurePointDualsStr(
"ftPtDuals.obj");
1737 OFstream cellStr(
"vertexCells.obj");
1743 Delaunay::Finite_vertices_iterator vit = finite_vertices_begin();
1744 vit != finite_vertices_end();
1748 if (vit->constrained())
1751 std::list<Cell_handle> vertexCells;
1752 finite_incident_cells(vit, std::back_inserter(vertexCells));
1754 Cell_handle startCell;
1758 std::list<Cell_handle>::iterator vcit = vertexCells.begin();
1759 vcit != vertexCells.end();
1763 if ((*vcit)->featurePointExternalCell())
1768 if ((*vcit)->real())
1770 featurePointDualsStr.write
1778 if (startCell ==
nullptr)
1780 Pout<<
"Start cell is null!" <<
endl;
1784 Cell_handle vc1 = startCell;
1787 Info<<
"c1 index = " << vc1->cellIndex() <<
" "
1788 << vc1->dual() <<
endl;
1790 for (label cI = 0; cI < 4; ++cI)
1792 Info<<
"c1 = " << cI <<
" "
1793 << vc1->neighbor(cI)->cellIndex() <<
" v = "
1794 << vc1->neighbor(cI)->dual() <<
endl;
1796 Info<< vc1->vertex(cI)->info();
1799 Cell_handle nextCell;
1801 for (label cI = 0; cI < 4; ++cI)
1803 if (vc1->vertex(cI)->externalBoundaryPoint())
1805 vc2 = vc1->neighbor(cI);
1807 Info<<
" c2 is neighbor "
1809 <<
" of c1" <<
endl;
1811 for (label cI = 0; cI < 4; ++cI)
1813 Info<<
" c2 = " << cI <<
" "
1814 << vc2->neighbor(cI)->cellIndex() <<
" v = "
1815 << vc2->vertex(cI)->index() <<
endl;
1819 f[0] = vit->index();
1820 f[1] = vc1->cellIndex();
1821 f[2] = vc2->cellIndex();
1829 vector correctNormal = calcSharedPatchNormal(vc1, vc2);
1830 correctNormal.normalise();
1832 Info<<
" cN " << correctNormal <<
endl;
1834 vector fN =
f.areaNormal(pts);
1836 if (
mag(fN) < SMALL)
1845 if ((fN & correctNormal) > 0)
1855 label own = vit->index();
1859 Info<<
"Start walk from " << vc1->cellIndex()
1860 <<
" to " << vc2->cellIndex() <<
endl;
1867 Info<<
" Walk from " << vc1->cellIndex()
1868 <<
" " << vc1->dual()
1869 <<
" to " << vc2->cellIndex()
1870 <<
" " << vc2->dual()
1878 geometryToConformTo_.findPatch
1883 f[1] = vc1->cellIndex();
1884 f[2] = vc2->cellIndex();
1886 patchFaces[patchIndex].
append(
f);
1887 patchOwners[patchIndex].append(own);
1888 patchPPSlaves[patchIndex].append(own);
1891 Cell_handle nextCell;
1893 Info<<
" c1 vertices " << vc2->dual() <<
endl;
1894 for (label cI = 0; cI < 4; ++cI)
1896 Info<<
" " << vc2->vertex(cI)->info();
1898 Info<<
" c1 neighbour vertices " <<
endl;
1899 for (label cI = 0; cI < 4; ++cI)
1903 !vc2->vertex(cI)->constrained()
1904 && vc2->neighbor(cI) != vc1
1905 && !is_infinite(vc2->neighbor(cI))
1908 vc2->neighbor(cI)->featurePointExternalCell()
1909 || vc2->neighbor(cI)->featurePointInternalCell()
1911 && vc2->neighbor(cI)->hasConstrainedPoint()
1921 Info<<
" neighbour " << cI <<
" "
1922 << vc2->neighbor(cI)->dual() <<
endl;
1923 for (label
I = 0;
I < 4; ++
I)
1926 << vc2->neighbor(cI)->vertex(
I)->info();
1931 for (label cI = 0; cI < 4; ++cI)
1935 !vc2->vertex(cI)->constrained()
1936 && vc2->neighbor(cI) != vc1
1937 && !is_infinite(vc2->neighbor(cI))
1940 vc2->neighbor(cI)->featurePointExternalCell()
1941 || vc2->neighbor(cI)->featurePointInternalCell()
1943 && vc2->neighbor(cI)->hasConstrainedPoint()
1947 if (boundaryDualFace(vc2, vc2->neighbor(cI)))
1949 nextCell = vc2->neighbor(cI);
1959 }
while (vc1 != startCell && iter < 100);
1966 Delaunay::Finite_edges_iterator eit = finite_edges_begin();
1967 eit != finite_edges_end();
1971 Cell_handle
c = eit->first;
1972 Vertex_handle vA =
c->vertex(eit->second);
1973 Vertex_handle vB =
c->vertex(eit->third);
1975 if (vA->constrained() && vB->constrained())
1982 (vA->constrained() && vB->internalOrBoundaryPoint())
1983 || (vB->constrained() && vA->internalOrBoundaryPoint())
1986 face newDualFace = buildDualFace(eit);
1991 if (ownerAndNeighbour(vA, vB, own, nei))
1997 faces[dualFacei] = newDualFace;
1998 owner[dualFacei] = own;
1999 neighbour[dualFacei] = nei;
2005 (vA->internalOrBoundaryPoint() && !vA->referred())
2006 || (vB->internalOrBoundaryPoint() && !vB->referred())
2011 (vA->internalPoint() && vB->externalBoundaryPoint())
2012 || (vB->internalPoint() && vA->externalBoundaryPoint())
2015 Cell_circulator ccStart = incident_cells(*eit);
2016 Cell_circulator cc1 = ccStart;
2017 Cell_circulator cc2 = cc1;
2021 bool skipEdge =
false;
2027 cc1->hasFarPoint() || cc2->hasFarPoint()
2028 || is_infinite(cc1) || is_infinite(cc2)
2031 Pout<<
"Ignoring edge between internal and external: "
2042 }
while (cc1 != ccStart);
2057 face newDualFace = buildDualFace(eit);
2059 if (newDualFace.size() >= 3)
2064 if (ownerAndNeighbour(vA, vB, own, nei))
2069 label patchIndex = -1;
2078 if (isProcBoundaryEdge(eit))
2083 label procIndex =
max(vA->procIndex(), vB->procIndex());
2087 procNeighbours.find(vA->procIndex()),
2088 procNeighbours.find(vB->procIndex())
2099 DynamicList<labelPairPair>& sortingIndex =
2100 procPatchSortingIndex[patchIndex];
2102 if (vB->internalOrBoundaryPoint() && vB->referred())
2108 labelPair(vA->index(), vA->procIndex()),
2119 labelPair(vB->index(), vB->procIndex()),
2130 DynamicList<labelPairPair>& sortingIndex =
2131 procPatchSortingIndex[patchIndex];
2133 if (vA->internalOrBoundaryPoint() && vA->referred())
2139 labelPair(vA->index(), vA->procIndex()),
2150 labelPair(vB->index(), vB->procIndex()),
2169 patchIndex = geometryToConformTo_.findPatch(ptA, ptB);
2172 if (patchIndex == -1)
2181 patchIndex = geometryToConformTo_.findPatch
2187 patchFaces[patchIndex].append(newDualFace);
2188 patchOwners[patchIndex].append(own);
2194 vA->boundaryPoint() && vB->boundaryPoint()
2195 && !ptPairs_.isPointPair(vA, vB)
2196 && !ftPtConformer_.featurePointPairs().isPointPair(vA, vB)
2199 indirectPatchFace[patchIndex].append(
true);
2203 indirectPatchFace[patchIndex].append(
false);
2207 if (vA->internalOrBoundaryPoint())
2209 patchPPSlaves[patchIndex].append(vB->index());
2213 patchPPSlaves[patchIndex].append(vA->index());
2220 !vA->boundaryPoint()
2221 || !vB->boundaryPoint()
2222 || ptPairs_.isPointPair(vA, vB)
2223 || ftPtConformer_.featurePointPairs().isPointPair(vA, vB)
2226 patchIndex = geometryToConformTo_.findPatch(ptA, ptB);
2232 && geometryToConformTo_.patchInfo().set(patchIndex)
2237 patchFaces[patchIndex].append(newDualFace);
2238 patchOwners[patchIndex].append(own);
2239 indirectPatchFace[patchIndex].append(
false);
2243 patchFaces[patchIndex].append(newDualFace);
2244 patchOwners[patchIndex].append(nei);
2245 indirectPatchFace[patchIndex].append(
false);
2250 <
labelPair(vA->index(), vA->procIndex())
2253 patchPPSlaves[patchIndex].append(vB->index());
2254 patchPPSlaves[patchIndex].append(vB->index());
2258 patchPPSlaves[patchIndex].append(vA->index());
2259 patchPPSlaves[patchIndex].append(vA->index());
2266 faces[dualFacei] = newDualFace;
2267 owner[dualFacei] = own;
2268 neighbour[dualFacei] = nei;
2277 if (!patchFaces[defaultPatchIndex].empty())
2279 Pout<<
nl << patchFaces[defaultPatchIndex].size()
2280 <<
" faces were not able to have their patch determined from "
2282 <<
nl <<
"Adding to patch " <<
patchNames[defaultPatchIndex]
2286 label nInternalFaces = dualFacei;
2288 faces.setSize(nInternalFaces);
2289 owner.setSize(nInternalFaces);
2290 neighbour.setSize(nInternalFaces);
2292 timeCheck(
"polyMesh quality checked");
2294 sortFaces(faces, owner, neighbour);
2301 procPatchSortingIndex
2304 timeCheck(
"faces, owner, neighbour sorted");
2312 boundaryFacesToRemove,
2319 patchPointPairSlaves.setSize(
nPatches);
2320 forAll(patchPPSlaves, patchi)
2322 patchPointPairSlaves[patchi].transfer(patchPPSlaves[patchi]);
2325 if (foamyHexMeshControls().objOutput())
2327 Info<<
"Writing processor interfaces" <<
endl;
2331 if (patchFaces[nbI].size() > 0)
2333 const label neighbour =
2334 patchDicts[nbI].getOrDefault<label>(
"neighbProcNo", -1);
2336 faceList procPatchFaces = patchFaces[nbI];
2342 forAll(procPatchFaces, fI)
2344 procPatchFaces[fI].flip();
2348 if (neighbour != -1)
2359 time().
path()/fName,
2370 void Foam::conformalVoronoiMesh::sortFaces
2391 List<labelPair> ownerNeighbourPair(owner.size());
2393 forAll(ownerNeighbourPair, oNI)
2395 ownerNeighbourPair[oNI] =
labelPair(owner[oNI], neighbour[oNI]);
2399 <<
"Sorting faces, owner and neighbour into upper triangular order"
2403 oldToNew =
invert(oldToNew.size(), oldToNew);
2411 void Foam::conformalVoronoiMesh::sortProcPatches
2413 List<DynamicList<face>>& patchFaces,
2414 List<DynamicList<label>>& patchOwners,
2415 List<DynamicList<label>>& patchPointPairSlaves,
2416 labelPairPairDynListList& patchSortingIndices
2424 forAll(patchSortingIndices, patchi)
2426 faceList& faces = patchFaces[patchi];
2428 DynamicList<label>& slaves = patchPointPairSlaves[patchi];
2429 DynamicList<labelPairPair>& sortingIndices
2430 = patchSortingIndices[patchi];
2432 if (!sortingIndices.empty())
2436 faces.size() != sortingIndices.size()
2437 || owner.size() != sortingIndices.size()
2438 || slaves.size() != sortingIndices.size()
2442 <<
"patch size and size of sorting indices is inconsistent "
2443 <<
" for patch " << patchi <<
nl
2444 <<
" faces.size() " << faces.size() <<
nl
2445 <<
" owner.size() " << owner.size() <<
nl
2446 <<
" slaves.size() " << slaves.size() <<
nl
2447 <<
" sortingIndices.size() "
2448 << sortingIndices.size()
2453 oldToNew =
invert(oldToNew.size(), oldToNew);
2464 void Foam::conformalVoronoiMesh::addPatches
2466 const label nInternalFaces,
2470 bitSet& boundaryFacesToRemove,
2471 const List<DynamicList<face>>& patchFaces,
2472 const List<DynamicList<label>>& patchOwners,
2473 const List<DynamicList<bool>>& indirectPatchFace
2476 label nBoundaryFaces = 0;
2481 patchDicts[
p].set(
"startFace", nInternalFaces + nBoundaryFaces);
2483 nBoundaryFaces += patchFaces[
p].size();
2486 faces.setSize(nInternalFaces + nBoundaryFaces);
2487 owner.setSize(nInternalFaces + nBoundaryFaces);
2488 boundaryFacesToRemove.setSize(nInternalFaces + nBoundaryFaces);
2490 label facei = nInternalFaces;
2496 faces[facei] = patchFaces[
p][
f];
2497 owner[facei] = patchOwners[
p][
f];
2498 boundaryFacesToRemove[facei] = indirectPatchFace[
p][
f];
2506 void Foam::conformalVoronoiMesh::removeUnusedPoints
2513 Info<<
nl <<
"Removing unused points" <<
endl;
2515 bitSet ptUsed(pts.size(),
false);
2521 const face&
f = faces[fI];
2528 labelList oldToNew(pts.size(), label(-1));
2535 if (ptUsed.test(ptUI))
2537 oldToNew[ptUI] = pointi++;
2549 pts.setSize(pointi);
2550 boundaryPts.setSize(pointi);
2567 Info<<
nl <<
"Removing unused cells" <<
endl;
2569 bitSet cellUsed(vertexCount(),
false);
2573 cellUsed.set(owner);
2574 cellUsed.set(neighbour);
2578 labelList oldToNew(cellUsed.size(), label(-1));
2585 if (cellUsed.test(cellUI))
2587 oldToNew[cellUI] = celli++;
2597 DynamicList<label> unusedCells;
2601 if (!cellUsed.test(cUI))
2603 unusedCells.append(cUI);
2607 if (unusedCells.size() > 0)
2611 <<
" unused cell labels" <<
endl;
2615 label& o = owner[oI];
2622 label&
n = neighbour[nI];