84 { debugType::MESH,
"mesh" },
85 { debugType::OBJINTERSECTIONS,
"intersections" },
86 { debugType::FEATURESEEDS,
"featureSeeds" },
87 { debugType::ATTRACTION,
"attraction" },
88 { debugType::LAYERINFO,
"layerInfo" },
108 { writeType::WRITEMESH,
"mesh" },
109 { writeType::NOWRITEREFINEMENT,
"noRefinement" },
110 { writeType::WRITELEVELS,
"scalarLevels" },
111 { writeType::WRITELAYERSETS,
"layerSets" },
112 { writeType::WRITELAYERFIELDS,
"layerFields" },
133 Foam::label Foam::meshRefinement::globalFaceCount(
const labelList& elems)
const 136 const bitSet isElem(mesh_.nFaces(), elems);
137 if (label(isElem.count()) != elems.size())
140 <<
" isElem:" << isElem.count()
141 <<
" elems:" << elems.size()
147 bitSet isElem2(isElem);
152 label facei = mesh_.nInternalFaces();
153 facei < mesh_.nFaces();
157 if (isElem2[facei] != isElem[facei])
160 <<
"at face:" << facei
161 <<
" at:" << mesh_.faceCentres()[facei]
162 <<
" patch:" << mesh_.boundaryMesh().whichPatch(facei)
163 <<
" isElem:" << isElem[facei]
164 <<
" isElem2:" << isElem2[facei]
173 for (
const label i : isElem)
184 void Foam::meshRefinement::calcNeighbourData
190 const labelList& cellLevel = meshCutter_.cellLevel();
191 const pointField& cellCentres = mesh_.cellCentres();
193 const label nBoundaryFaces = mesh_.nBoundaryFaces();
195 if (neiLevel.size() != nBoundaryFaces || neiCc.size() != nBoundaryFaces)
198 << nBoundaryFaces <<
" neiLevel:" << neiLevel.size()
202 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
214 label bFacei =
pp.start()-mesh_.nInternalFaces();
220 neiLevel[bFacei] = cellLevel[faceCells[i]];
221 neiCc[bFacei] = cellCentres[faceCells[i]];
225 else if (addedPatchIDSet.found(patchi))
237 label own = faceCells[i];
238 label ownLevel = cellLevel[own];
239 label faceLevel = meshCutter_.faceLevel(
pp.start()+i);
244 faceLevel = ownLevel;
248 scalar d = ((faceCentres[i] - cellCentres[own]) & fn);
249 if (faceLevel > ownLevel)
254 neiLevel[bFacei] = faceLevel;
256 neiCc[bFacei] = faceCentres[i] + d*fn;
264 neiLevel[bFacei] = cellLevel[faceCells[i]];
265 neiCc[bFacei] = faceCentres[i];
277 void Foam::meshRefinement::calcCellCellRays
287 const labelList& cellLevel = meshCutter_.cellLevel();
288 const pointField& cellCentres = mesh_.cellCentres();
293 bitSet isMaster(mesh_.nBoundaryFaces(),
true);
295 for (
const polyPatch&
pp : mesh_.boundaryMesh())
297 if (
pp.coupled() && !refCast<const coupledPolyPatch>(
pp).owner())
299 isMaster.
unset(labelRange(
pp.offset(),
pp.size()));
305 start.setSize(testFaces.size());
306 end.setSize(testFaces.size());
307 minLevel.setSize(testFaces.size());
311 const label facei = testFaces[i];
312 const label own = mesh_.faceOwner()[facei];
314 if (mesh_.isInternalFace(facei))
316 const label nei = mesh_.faceNeighbour()[facei];
318 start[i] = cellCentres[own];
319 end[i] = cellCentres[nei];
320 minLevel[i] =
min(cellLevel[own], cellLevel[nei]);
324 const label bFacei = facei - mesh_.nInternalFaces();
326 if (isMaster[bFacei])
328 start[i] = cellCentres[own];
329 end[i] = neiCc[bFacei];
334 start[i] = neiCc[bFacei];
335 end[i] = cellCentres[own];
337 minLevel[i] =
min(cellLevel[own], neiLevel[bFacei]);
356 const label nMasterFaces =
359 label nChangedFaces = 0;
362 if (isMasterFace.
test(changedFaces[i]))
371 Info<<
"Edge intersection testing:" <<
nl 372 <<
" Number of edges : " << nMasterFaces <<
nl 373 <<
" Number of edges to retest : " << nChangedFaces
380 labelList neiLevel(mesh_.nBoundaryFaces());
382 calcNeighbourData(neiLevel, neiCc);
405 surfaces_.findHigherIntersection
419 surfaceIndex_[changedFaces[i]] = surfaceHit[i];
430 Info<<
" Number of intersected edges : " << nTotHits <<
endl;
434 setInstance(mesh_.facesInstance());
438 void Foam::meshRefinement::nearestFace
441 const bitSet& isBlockedFace,
473 for (
const label facei : isBlockedFace)
478 List<topoDistanceData<label>> startData(startFaces.
size());
481 const label facei = startFaces[i];
482 if (isBlockedFace[facei])
485 <<
" at:" << mesh_.faceCentres()[facei]
488 startData[i] = topoDistanceData<label>(0, globalStart.toGlobal(i));
493 FaceCellWave<topoDistanceData<label>> deltaCalc
502 deltaCalc.iterate(nIter);
506 faceToStart.
setSize(mesh_.nFaces());
508 bool haveWarned =
false;
511 if (!faceData[facei].valid(deltaCalc.data()))
516 <<
"Did not visit some faces, e.g. face " << facei
517 <<
" at " << mesh_.faceCentres()[facei]
524 faceToStart[facei] = faceData[facei].
data();
529 List<Map<label>> compactMap;
530 mapPtr.
reset(
new mapDistribute(globalStart, faceToStart, compactMap));
534 void Foam::meshRefinement::nearestPatch
544 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
546 nearestZone.
setSize(mesh_.nFaces(), -1);
548 if (adaptPatchIDs.size())
550 nearestPatch.setSize(mesh_.nFaces(), adaptPatchIDs[0]);
554 labelList faceToZone(mesh_.nFaces(), -1);
556 for (
const faceZone& fz : mesh_.faceZones())
558 UIndirectList<label>(faceToZone, fz) = fz.index();
567 const polyPatch&
pp =
patches[adaptPatchIDs[i]];
572 List<topoDistanceData<labelPair>> cellData(mesh_.nCells());
573 List<topoDistanceData<labelPair>> faceData(mesh_.nFaces());
577 List<topoDistanceData<labelPair>> patchData(nFaces);
581 label patchi = adaptPatchIDs[i];
586 patchFaces[nFaces] =
pp.start()+i;
587 patchData[nFaces] = topoDistanceData<labelPair>
593 faceToZone[
pp.start()+i]
601 FaceCellWave<topoDistanceData<labelPair>> deltaCalc
608 mesh_.globalData().nTotalCells()+1
613 bool haveWarned =
false;
616 if (!faceData[facei].valid(deltaCalc.data()))
621 <<
"Did not visit some faces, e.g. face " << facei
622 <<
" at " << mesh_.faceCentres()[facei] <<
endl 623 <<
"Assigning these faces to patch " 632 nearestPatch[facei] = data.first();
633 nearestZone[facei] = data.second();
640 nearestPatch.setSize(mesh_.nFaces(), 0);
652 nearestPatch(adaptPatchIDs, nearestAdaptPatch, nearestAdaptZone);
653 return nearestAdaptPatch;
657 void Foam::meshRefinement::nearestIntersection
671 labelList neiLevel(mesh_.nBoundaryFaces());
673 calcNeighbourData(neiLevel, neiCc);
694 surfaces_.findNearestIntersection
713 const label defaultRegion
722 const labelList testFaces(intersectedFaces());
745 labelList nearestRegion(mesh_.nFaces(), defaultRegion);
756 label facei = testFaces[i];
757 if (surface1[i] != -1)
759 patchFaces.append(facei);
760 label regioni = surfaces_.globalRegion(surface1[i], region1[i]);
763 else if (surface2[i] != -1)
765 patchFaces.append(facei);
766 label regioni = surfaces_.globalRegion(surface2[i], region2[i]);
767 patchData.append(topoDistanceData<label>(0, regioni));
772 FaceCellWave<topoDistanceData<label>> deltaCalc
779 mesh_.globalData().nTotalCells()+1
784 bool haveWarned =
false;
787 if (!faceData[facei].valid(deltaCalc.data()))
792 <<
"Did not visit some faces, e.g. face " << facei
793 <<
" at " << mesh_.faceCentres()[facei] <<
endl 794 <<
"Assigning these faces to global region " 795 << defaultRegion <<
endl;
801 nearestRegion[facei] = faceData[facei].data();
805 return nearestRegion;
824 Pout<<
"Checking field " << msg <<
endl;
843 const scalar& minVal = minFld[pointi];
844 const scalar& maxVal = maxFld[pointi];
845 if (
mag(minVal-maxVal) > SMALL)
848 <<
" minFld:" << minVal <<
nl 849 <<
" maxFld:" << maxVal <<
nl 871 Pout<<
"Checking field " << msg <<
endl;
878 point(GREAT, GREAT, GREAT)
890 const point& minVal = minFld[pointi];
891 const point& maxVal = maxFld[pointi];
892 if (
mag(minVal-maxVal) > SMALL)
895 <<
" minFld:" << minVal <<
nl 896 <<
" maxFld:" << maxVal <<
nl 905 Pout<<
"meshRefinement::checkData() : Checking refinement structure." 907 meshCutter_.checkMesh();
909 Pout<<
"meshRefinement::checkData() : Checking refinement levels." 911 meshCutter_.checkRefinementLevels(1,
labelList(0));
914 const label nBnd = mesh_.nBoundaryFaces();
916 Pout<<
"meshRefinement::checkData() : Checking synchronization." 926 mesh_.nInternalFaces()
939 testSyncBoundaryFaceList
942 "testing faceCentres : ",
949 const labelList& surfIndex = surfaceIndex();
956 calcNeighbourData(neiLevel, neiCc);
964 start[facei] = mesh_.cellCentres()[mesh_.faceOwner()[facei]];
966 if (mesh_.isInternalFace(facei))
968 end[facei] = mesh_.cellCentres()[mesh_.faceNeighbour()[facei]];
972 end[facei] = neiCc[facei-mesh_.nInternalFaces()];
988 surfaces_.findHigherIntersection
1005 mesh_.nInternalFaces()
1011 forAll(surfaceHit, facei)
1013 if (surfIndex[facei] != surfaceHit[facei])
1015 if (mesh_.isInternalFace(facei))
1018 <<
"Internal face:" << facei
1019 <<
" fc:" << mesh_.faceCentres()[facei]
1020 <<
" cached surfaceIndex_:" << surfIndex[facei]
1021 <<
" current:" << surfaceHit[facei]
1023 << mesh_.cellCentres()[mesh_.faceOwner()[facei]]
1025 << mesh_.cellCentres()[mesh_.faceNeighbour()[facei]]
1031 != neiHit[facei-mesh_.nInternalFaces()]
1035 <<
"Boundary face:" << facei
1036 <<
" fc:" << mesh_.faceCentres()[facei]
1037 <<
" cached surfaceIndex_:" << surfIndex[facei]
1038 <<
" current:" << surfaceHit[facei]
1040 << mesh_.cellCentres()[mesh_.faceOwner()[facei]]
1042 << neiCc[facei-mesh_.nInternalFaces()]
1043 <<
" end:" <<
end[facei]
1045 << meshCutter_.cellLevel()[mesh_.faceOwner()[facei]]
1047 << meshCutter_.faceLevel(facei)
1057 mesh_.nBoundaryFaces(),
1058 mesh_.nInternalFaces()
1061 labelList neiBoundarySurface(boundarySurface);
1069 testSyncBoundaryFaceList
1072 "testing surfaceIndex() : ",
1080 Pout<<
"meshRefinement::checkData() : Counting duplicate faces." 1088 identity(mesh_.nBoundaryFaces(), mesh_.nInternalFaces())
1098 if (duplicateFace[i] != -1)
1104 Pout<<
"meshRefinement::checkData() : Found " << nDup
1105 <<
" duplicate pairs of faces." <<
endl;
1112 meshCutter_.setInstance(inst);
1113 surfaceIndex_.instance() = inst;
1138 mesh_.moving(
false);
1145 mesh_.updateMesh(map);
1160 setInstance(mesh_.facesInstance());
1175 updateMesh(map, newExposedFaces);
1191 label facei = splitFaces[i];
1192 const face&
f = mesh_.faces()[facei];
1208 label fp =
split[0];
1225 label own = mesh_.faceOwner()[facei];
1228 if (facei >= mesh_.nInternalFaces())
1230 patchi = mesh_.boundaryMesh().whichPatch(facei);
1234 nei = mesh_.faceNeighbour()[facei];
1237 label zonei = mesh_.faceZones().whichZone(facei);
1238 bool zoneFlip =
false;
1241 const faceZone& fz = mesh_.faceZones()[zonei];
1248 Pout<<
"face:" << facei <<
" verts:" <<
f 1249 <<
" split into f0:" << f0
1250 <<
" f1:" << f1 <<
endl;
1312 <<
"Splitting " << nSplit
1313 <<
" faces across diagonals" <<
"." <<
nl <<
endl;
1325 meshMod.
faces().size()+splitFaces.
size(),
1330 doSplitFaces(splitFaces, splits, meshMod);
1334 mesh_.moving(
false);
1341 mesh_.updateMesh(map);
1355 setInstance(mesh_.facesInstance());
1370 splitFaceToIndex.insert(splitFaces[i], i);
1375 label oldFacei = map.
faceMap()[facei];
1377 const auto oldFaceFnd = splitFaceToIndex.cfind(oldFacei);
1379 if (oldFaceFnd.good())
1381 labelPair& twoFaces = facePairs[oldFaceFnd.val()];
1382 if (twoFaces[0] == -1)
1384 twoFaces[0] = facei;
1386 else if (twoFaces[1] == -1)
1388 twoFaces[1] = facei;
1393 <<
"problem: twoFaces:" << twoFaces
1404 if (duplicateFace.
size())
1418 baffle.
first() = oldToNewFaces[baffle.
first()];
1421 if (baffle.
first() == -1 || baffle.
second() == -1)
1424 <<
"Removed baffle : faces:" << baffle
1437 changedFaces.
append(facePairs[i].first());
1438 changedFaces.
append(facePairs[i].second());
1442 updateMesh(map, growFaceCellFace(changedFaces));
1455 for (label iteration = 0; iteration < 100; iteration++)
1458 <<
"Undo iteration " << iteration <<
nl 1459 <<
"----------------" <<
endl;
1465 faceSet errorFaces(mesh_,
"errorFaces", mesh_.nBoundaryFaces());
1481 const labelList grownFaces(growFaceCellFace(errorFaces));
1483 errorFaces.insert(grownFaces);
1497 const labelPair& twoFaces = facePairs[index];
1501 errorFaces.found(twoFaces.
first())
1502 || errorFaces.found(twoFaces.
second())
1505 const face& originalFace = originalFaces[index];
1509 label own = mesh_.faceOwner()[twoFaces[0]];
1512 if (twoFaces[0] >= mesh_.nInternalFaces())
1514 patchi = mesh_.boundaryMesh().whichPatch(twoFaces[0]);
1518 nei = mesh_.faceNeighbour()[twoFaces[0]];
1521 label zonei = mesh_.faceZones().whichZone(twoFaces[0]);
1522 bool zoneFlip =
false;
1525 const faceZone& fz = mesh_.faceZones()[zonei];
1542 meshMod.
removeFace(twoFaces[1], twoFaces[0]);
1544 mergedIndices.insert(index);
1550 Info<<
"Detected " <<
n 1551 <<
" split faces that will be restored to their original faces." 1565 mesh_.moving(
false);
1572 mesh_.updateMesh(map);
1586 setInstance(mesh_.facesInstance());
1602 const labelPair& oldSplit = facePairs[index];
1603 label new0 = oldToNewFaces[oldSplit[0]];
1604 label new1 = oldToNewFaces[oldSplit[1]];
1606 if (!mergedIndices.found(index))
1609 if (new0 < 0 || new1 < 0)
1612 <<
"Problem: oldFaces:" << oldSplit
1613 <<
" newFaces:" <<
labelPair(new0, new1)
1617 facePairs[newIndex] =
labelPair(new0, new1);
1621 originalFaces[index]
1628 if (new0 < 0 || new1 == -1)
1631 <<
"Problem: oldFaces:" << oldSplit
1635 changedFaces.
append(new0);
1639 facePairs.setSize(newIndex);
1640 originalFaces.
setSize(newIndex);
1644 updateMesh(map, growFaceCellFace(changedFaces));
1650 if (duplicateFace.
size())
1664 baffle.
first() = reverseFaceMap[baffle.
first()];
1667 if (baffle.
first() == -1 || baffle.
second() == -1)
1670 <<
"Removed baffle : faces:" << baffle
1684 Foam::meshRefinement::meshRefinement
1687 const scalar mergeDistance,
1688 const bool overwrite,
1698 mergeDistance_(mergeDistance),
1699 overwrite_(overwrite),
1700 oldInstance_(
mesh.pointsInstance()),
1701 surfaces_(surfaces),
1702 features_(features),
1704 limitShells_(limitShells),
1716 mesh_.facesInstance(),
1736 if (surfaceIndex_.size() != mesh_.nFaces())
1743 return surfaceIndex_;
1749 if (surfaceIndex_.size() != mesh_.nFaces())
1751 updateIntersections(
identity(mesh_.nFaces()));
1753 return surfaceIndex_;
1764 const labelList& surfIndex = surfaceIndex();
1768 if (surfIndex[facei] >= 0 && isMasterFace.
test(facei))
1779 const bool keepZoneFaces,
1780 const bool keepBaffles,
1797 label nUnblocked = 0;
1811 specifiedProcessorFaces,
1817 if (keepZoneFaces || keepBaffles)
1837 const faceZone& fZone = fZones[zonei];
1841 label facei = fZone[i];
1842 if (blockedFace[facei])
1846 mesh_.isInternalFace(facei)
1850 blockedFace[facei] =
false;
1872 Info<<
"Found " << nUnblocked
1873 <<
" zoned faces to keep together." <<
endl;
1879 boolList separatedCoupledFace(mesh_.nFaces(),
false);
1880 selectSeparatedCoupledFaces(separatedCoupledFace);
1882 label nSeparated = 0;
1883 forAll(separatedCoupledFace, facei)
1885 if (separatedCoupledFace[facei])
1887 if (blockedFace[facei])
1889 blockedFace[facei] =
false;
1895 Info<<
"Found " << nSeparated
1896 <<
" separated coupled faces to keep together." <<
endl;
1898 nUnblocked += nSeparated;
1904 const label nBnd = mesh_.nBoundaryFaces();
1906 labelList coupledFace(mesh_.nFaces(), -1);
1924 const labelPair& baffle = allCouples[i];
1932 forAll(coupledFace, facei)
1934 if (coupledFace[facei] != -1 && facei < coupledFace[facei])
1936 couples[nCpl++] =
labelPair(facei, coupledFace[facei]);
1945 Info<<
"Found " << nCouples <<
" baffles to keep together." 1955 blockedFace[baffle.
first()] =
false;
1956 blockedFace[baffle.
second()] =
false;
1964 specifiedProcessorFaces,
1972 Pout<<
"Wanted distribution:" << nProcCells <<
endl;
1976 Pout<<
"Wanted resulting decomposition:" <<
endl;
1977 forAll(nProcCells, proci)
1979 Pout<<
" " << proci <<
'\t' << nProcCells[proci] <<
endl;
1992 setInstance(mesh_.facesInstance());
1995 if (
debug && keepZoneFaces)
2003 const faceZone& fZone = fZones[zonei];
2007 label facei = fZone[i];
2013 <<
"Face at " << mesh_.faceCentres()[facei]
2014 <<
" on zone " << fZone.
name()
2015 <<
" is on coupled patch " <<
pbm[patchi].
name()
2029 label nBoundaryFaces = 0;
2031 const labelList& surfIndex = surfaceIndex();
2035 if (surfIndex[facei] != -1)
2046 if (surfIndex[facei] != -1)
2048 surfaceFaces[nBoundaryFaces++] = facei;
2051 return surfaceFaces;
2057 const faceList& faces = mesh_.faces();
2060 bitSet isBoundaryPoint(mesh_.nPoints());
2061 label nBoundaryPoints = 0;
2063 const labelList& surfIndex = surfaceIndex();
2067 if (surfIndex[facei] != -1)
2069 const face&
f = faces[facei];
2073 if (isBoundaryPoint.set(
f[fp]))
2110 labelList boundaryPoints(nBoundaryPoints);
2111 nBoundaryPoints = 0;
2112 forAll(isBoundaryPoint, pointi)
2114 if (isBoundaryPoint.test(pointi))
2116 boundaryPoints[nBoundaryPoints++] = pointi;
2120 return boundaryPoints;
2140 nFaces +=
pp.size();
2151 label meshFacei =
pp.start();
2155 addressing[nFaces++] = meshFacei++;
2180 pointPatches.
size(),
2181 slipPointPatchVectorField::typeName
2186 patchFieldTypes[adaptPatchIDs[i]] =
2187 fixedValuePointPatchVectorField::typeName;
2190 forAll(pointPatches, patchi)
2192 if (isA<processorPointPatch>(pointPatches[patchi]))
2194 patchFieldTypes[patchi] = calculatedPointPatchVectorField::typeName;
2196 else if (isA<cyclicPointPatch>(pointPatches[patchi]))
2198 patchFieldTypes[patchi] = cyclicSlipPointPatchVectorField::typeName;
2208 "pointDisplacement",
2242 <<
"faceZones are not synchronised on processors." <<
nl 2243 <<
"Processor " << proci <<
" has faceZones " 2244 << zoneNames[proci] <<
nl 2246 <<
" has faceZones " 2259 const faceZone& fZone = fZones[zonei];
2267 if (faceToZone[bFacei] == -1)
2269 faceToZone[bFacei] = zonei;
2271 else if (faceToZone[bFacei] == zonei)
2274 <<
"Face " << fZone[i] <<
" in zone " 2276 <<
" is twice in zone!" 2282 <<
"Face " << fZone[i] <<
" in zone " 2284 <<
" is also in zone " 2285 << fZones[faceToZone[bFacei]].
name()
2297 if (faceToZone[i] != neiFaceToZone[i])
2301 <<
" is in zone " << faceToZone[i]
2302 <<
", its coupled face is in zone " << neiFaceToZone[i]
2312 const bitSet& isMasterEdge,
2327 const edge&
e = edges[edgei];
2333 pts[meshPoints[
e[1]]]
2334 -
pts[meshPoints[
e[0]]]
2337 edgeWeights[edgei] = 1.0/eMag;
2353 forAll(invSumWeight, pointi)
2355 scalar w = invSumWeight[pointi];
2359 invSumWeight[pointi] = 1.0/w;
2368 const label insertPatchi,
2369 const word& patchName,
2381 const label patchi = polyPatches.
size();
2399 polyPatches[patchi],
2404 addPatchFields<volScalarField>
2409 addPatchFields<volVectorField>
2414 addPatchFields<volSphericalTensorField>
2419 addPatchFields<volSymmTensorField>
2424 addPatchFields<volTensorField>
2432 addPatchFields<surfaceScalarField>
2437 addPatchFields<surfaceVectorField>
2442 addPatchFields<surfaceSphericalTensorField>
2447 addPatchFields<surfaceSymmTensorField>
2452 addPatchFields<surfaceTensorField>
2464 const word& patchName,
2472 const label patchi = polyPatches.
findPatchID(patchName);
2480 label insertPatchi = polyPatches.
size();
2483 forAll(polyPatches, patchi)
2487 if (isA<processorPolyPatch>(
pp))
2489 insertPatchi = patchi;
2490 startFacei =
pp.start();
2496 patchDict.
set(
"nFaces", 0);
2497 patchDict.
set(
"startFace", startFacei);
2502 label addedPatchi = appendPatch(
mesh, insertPatchi, patchName, patchDict);
2508 for (label i = 0; i < insertPatchi; i++)
2513 for (label i = insertPatchi; i < addedPatchi; i++)
2518 oldToNew[addedPatchi] = insertPatchi;
2521 polyPatches.
reorder(oldToNew,
true);
2524 reorderPatchFields<volScalarField>(
mesh, oldToNew);
2525 reorderPatchFields<volVectorField>(
mesh, oldToNew);
2526 reorderPatchFields<volSphericalTensorField>(
mesh, oldToNew);
2527 reorderPatchFields<volSymmTensorField>(
mesh, oldToNew);
2528 reorderPatchFields<volTensorField>(
mesh, oldToNew);
2529 reorderPatchFields<surfaceScalarField>(
mesh, oldToNew);
2530 reorderPatchFields<surfaceVectorField>(
mesh, oldToNew);
2531 reorderPatchFields<surfaceSphericalTensorField>(
mesh, oldToNew);
2532 reorderPatchFields<surfaceSymmTensorField>(
mesh, oldToNew);
2533 reorderPatchFields<surfaceTensorField>(
mesh, oldToNew);
2535 return insertPatchi;
2545 label meshedi = meshedPatches_.find(
name);
2550 return mesh_.boundaryMesh().findPatchID(
name);
2555 label patchi = addPatch(mesh_,
name, patchInfo);
2580 meshedPatches_.append(
name);
2583 faceToCoupledPatch_.clear();
2595 forAll(meshedPatches_, i)
2602 <<
"Problem : did not find patch " << meshedPatches_[i]
2619 const word& masterPatch,
2620 const word& slavePatch,
2632 faceZoneToMasterPatch_.insert(fzName, masterPatch);
2633 faceZoneToSlavePatch_.insert(fzName, slavePatch);
2634 faceZoneToType_.insert(fzName, fzType);
2643 label& masterPatchID,
2644 label& slavePatchID,
2650 if (!faceZoneToMasterPatch_.found(fzName))
2656 const word& masterName = faceZoneToMasterPatch_[fzName];
2659 const word& slaveName = faceZoneToSlavePatch_[fzName];
2662 fzType = faceZoneToType_[fzName];
2677 zoneI = pointZones.
size();
2696 const auto* cpp = isA<coupledPolyPatch>(
pp);
2698 if (cpp && (cpp->separated() || !cpp->parallel()))
2717 nEdgeFaces[edgei] = edgeFaces[edgei].
size();
2766 const vector& perturbVec,
2788 const vector& perturbVec,
2800 regioni = cellToRegion[celli];
2810 regioni = cellToRegion[celli];
2850 locationsOutsideMesh,
2859 label nSegments = 0;
2860 if (leakPath.segments().size())
2862 nSegments =
max(leakPath.segments())+1;
2864 reduce(nSegments, maxOp<label>());
2867 for (label segmenti : leakPath.segments())
2869 nElemsPerSegment[segmenti]++;
2871 segmentPoints.setSize(nElemsPerSegment.size());
2872 segmentDist.
setSize(nElemsPerSegment.size());
2873 forAll(nElemsPerSegment, i)
2875 segmentPoints[i].setSize(nElemsPerSegment[i]);
2876 segmentDist[i].
setSize(nElemsPerSegment[i]);
2878 nElemsPerSegment = 0;
2882 label segmenti = leakPath.segments()[elemi];
2885 label&
n = nElemsPerSegment[segmenti];
2888 dist[
n] = leakPath.distance()[elemi];
2893 PtrList<coordSet> allLeakPaths(segmentPoints.size());
2894 forAll(allLeakPaths, segmenti)
2908 ListListOps::combine<pointList>
2910 gatheredPts, accessOp<pointList>()
2915 ListListOps::combine<scalarList>
2917 gatheredDist, accessOp<scalarList>()
2941 List<scalarField> allLeakData(allLeakPaths.size());
2942 forAll(allLeakPaths, segmenti)
2944 allLeakData[segmenti] = allLeakPaths[segmenti].distance();
2952 (outputDir / allLeakPaths[0].
name())
2974 const vector& perturbVec,
2977 const label nRegions,
2981 const bool exitIfLeakPath,
2992 label regioni = findRegion
3000 insideRegions[i] = regioni;
3003 forAll(cellRegion, celli)
3005 if (cellRegion[celli] == regioni)
3007 insideCell.set(celli);
3016 forAll(locationsOutsideMesh, i)
3022 label regioni = findRegion
3027 locationsOutsideMesh[i]
3030 if (regioni == -1 && (indexi = insideRegions.find(regioni)) != -1)
3032 if (leakPathFormatter)
3040 locationsOutsideMesh,
3045 Info<<
"Dumped leak path to " << fName <<
endl;
3055 err <<
"Location in mesh " << locationsInMesh[indexi]
3056 <<
" is inside same mesh region " << regioni
3057 <<
" as one of the locations outside mesh " 3058 << locationsOutsideMesh <<
endl;
3071 forAll(insideCell, celli)
3073 if (!insideCell.test(celli))
3075 cellRegion[celli] = -1;
3078 else if (cellRegion[celli] == -1)
3094 const bool exitIfLeakPath,
3099 (void)mesh_.tetBasePtIs();
3104 boolList blockedFace(mesh_.nFaces(),
false);
3105 selectSeparatedCoupledFaces(blockedFace);
3109 label nRemove = findRegions
3112 vector::uniform(mergeDistance_),
3114 locationsOutsideMesh,
3128 forAll(cellRegion, celli)
3130 if (cellRegion[celli] == -1)
3132 cellsToRemove.append(celli);
3135 cellsToRemove.shrink();
3139 cellsToRemove.size(),
3145 if (nTotCellsToRemove > 0)
3147 label nCellsToKeep =
3148 mesh_.globalData().nTotalCells()
3149 - nTotCellsToRemove;
3151 Info<<
"Keeping all cells containing points " << locationsInMesh <<
endl 3152 <<
"Selected for keeping : " 3154 <<
" cells." <<
endl;
3172 label defaultPatch = 0;
3173 if (globalToMasterPatch.
size())
3175 defaultPatch = globalToMasterPatch[0];
3179 <<
"Removing non-reachable cells exposes " 3180 << nExposedFaces <<
" internal or coupled faces." <<
endl 3181 <<
" These get put into patch " << defaultPatch <<
endl;
3182 exposedPatch.setSize(exposedFaces.
size(), defaultPatch);
3185 mapPtr = doRemoveCells
3204 meshCutter_.distribute(map);
3211 faceToCoupledPatch_.clear();
3238 geometry[i].distribute
3249 geometry[i].instance() = geometry[i].time().timeName();
3267 updateMesh(map, changedFaces, dummyMap, dummyMap, dummyMap);
3279 meshCutter_.storeData
3300 meshCutter_.updateMesh
3309 updateList(map.
faceMap(), label(-1), surfaceIndex_);
3313 Map<label> newFaceToPatch(faceToCoupledPatch_.size());
3320 newFaceToPatch.insert(newFacei, iter.val());
3323 faceToCoupledPatch_.
transfer(newFaceToPatch);
3328 updateIntersections(changedFaces);
3333 labelList& data = userFaceData_[i].second();
3335 if (userFaceData_[i].first() == KEEPALL)
3338 updateList(map.
faceMap(), label(-1), data);
3340 else if (userFaceData_[i].first() == MASTERONLY)
3345 forAll(newFaceData, facei)
3347 label oldFacei = map.
faceMap()[facei];
3351 newFaceData[facei] = data[oldFacei];
3367 label oldFacei = map.
faceMap()[facei];
3371 if (reverseFaceMap[oldFacei] != facei)
3374 reverseFaceMap[oldFacei] = -1;
3381 forAll(newFaceData, facei)
3383 label oldFacei = map.
faceMap()[facei];
3387 if (reverseFaceMap[oldFacei] == facei)
3389 newFaceData[facei] = data[oldFacei];
3401 bool writeOk = mesh_.write();
3418 s.instance() !=
s.time().system()
3419 &&
s.instance() !=
s.time().caseSystem()
3420 &&
s.instance() !=
s.time().constant()
3421 &&
s.instance() !=
s.time().caseConstant()
3425 s.instance() =
s.time().timeName();
3426 writeOk = writeOk &&
s.write();
3457 bitSet isPatchMasterPoint(meshPoints.
size());
3458 forAll(meshPoints, pointi)
3462 isPatchMasterPoint.set(pointi);
3466 return isPatchMasterPoint;
3480 identity(globalEdges.localSize(), globalEdges.localStart())
3496 if (myEdges[edgei] == globalEdges.toGlobal(edgei))
3498 isMasterEdge.
set(edgei);
3502 return isMasterEdge;
3510 const bool printCellLevel
3519 <<
" : cells(local):" << mesh_.nCells()
3520 <<
" faces(local):" << mesh_.nFaces()
3521 <<
" points(local):" << mesh_.nPoints()
3527 label nMasterFaces = isMasterFace.
count();
3530 label nMasterPoints = isMeshMasterPoint.
count();
3539 const scalar nIdealCells =
3543 mag(1.0-mesh_.nCells()/nIdealCells),
3546 Info<<
" unbalance:" << unbalance;
3553 const labelList& cellLevel = meshCutter_.cellLevel();
3559 nCells[cellLevel[celli]]++;
3567 Info<<
"Cells per refinement level:" <<
endl;
3570 Info<<
" " << leveli <<
'\t' << nCells[leveli]
3580 if (overwrite_ && mesh_.time().timeIndex() == 0)
3582 return oldInstance_;
3585 return mesh_.time().timeName();
3599 mesh_.time().timeName(),
3610 const labelList& cellLevel = meshCutter_.cellLevel();
3612 forAll(volRefLevel, celli)
3614 volRefLevel[celli] = cellLevel[celli];
3617 volRefLevel.write();
3629 mesh_.time().timeName(),
3639 const labelList& pointLevel = meshCutter_.pointLevel();
3641 forAll(pointRefLevel, pointi)
3643 pointRefLevel[pointi] = pointLevel[pointi];
3646 pointRefLevel.write();
3654 OFstream str(prefix +
"_edges.obj");
3656 Pout<<
"meshRefinement::dumpIntersections :" 3657 <<
" Writing cellcentre-cellcentre intersections to file " 3665 labelList neiLevel(mesh_.nBoundaryFaces());
3667 calcNeighbourData(neiLevel, neiCc);
3669 labelList intersectionFaces(intersectedFaces());
3691 surfaces_.findAnyIntersection
3699 forAll(intersectionFaces, i)
3701 if (surfaceHit[i] != -1)
3709 str <<
"l " << verti-2 <<
' ' << verti-1 <<
nl 3710 <<
"l " << verti-1 <<
' ' << verti <<
nl;
3726 if (writeFlags & WRITEMESH)
3731 if (writeFlags && !(writeFlags & NOWRITEREFINEMENT))
3733 meshCutter_.write();
3736 (void)surfaceIndex();
3737 surfaceIndex_.write();
3740 if (writeFlags & WRITELEVELS)
3742 dumpRefinementLevel();
3745 if ((debugFlags & OBJINTERSECTIONS) && prefix.size())
3747 dumpIntersections(prefix);
3766 if (
exists(setsDir/
"surfaceIndex"))
3768 rm(setsDir/
"surfaceIndex");
3784 writeLevel_ = flags;
3803 const word& keyword,
3808 const auto finder(
dict.
csearch(keyword, matchOpt));
3814 err <<
"Entry '" << keyword <<
"' not found in dictionary " 3827 return finder.dict();
3834 const word& keyword,
3845 err <<
"Entry '" << keyword <<
"' not found in dictionary " static const word & zeroGradientType() noexcept
The type name for zeroGradient patch fields.
label findPatchID(const word &patchName, const bool allowNotFound=true) const
Find patch index given a name, return -1 if not found.
List< scalar > scalarList
List of scalar.
This class separates the mesh into distinct unconnected regions, each of which is then given a label ...
static bool checkMesh(const bool report, const polyMesh &mesh, const dictionary &dict, labelHashSet &wrongFaces, const bool dryRun=false)
Check mesh with mesh settings in dict. Collects incorrect faces.
const labelList patchIDs(pbm.indices(polyPatchNames, true))
const Field< point_type > & faceAreas() const
Return face area vectors for patch.
Various (local, not parallel) searches on polyMesh; uses (demand driven) octree to search...
const polyBoundaryMesh & pbm
void clearOut()
Clear all geometry and addressing.
const T & first() const noexcept
Access the first element.
label addFaceZone(const word &fzName, const word &masterPatch, const word &slavePatch, const surfaceZonesInfo::faceZoneType &fzType)
Add/lookup faceZone and update information. Return index of.
void size(const label n)
Older name for setAddressableSize.
labelList getExposedFaces(const bitSet &removedCell) const
Get labels of faces exposed after cells removal.
std::enable_if< std::is_same< bool, TypeT >::value, bool >::type unset(const label i)
Unset the bool entry at specified position, always false for out-of-range access. ...
unsigned int count(const bool on=true) const
Count number of bits set.
static const dictionary & subDict(const dictionary &dict, const word &keyword, const bool noExit, enum keyType::option matchOpt=keyType::REGEX)
Wrapper around dictionary::subDict which does not exit.
void clearAddressing()
Clear addressing.
const labelList & reversePointMap() const
Reverse point map.
void set(const bitSet &bitset)
Set specified bits from another bitset.
A class for handling file names.
const DynamicList< face > & faces() const
label addPointZone(const word &name)
Add pointZone if does not exist. Return index of zone.
errorManipArg< error, int > exit(error &err, const int errNo=1)
const fileName & facesInstance() const
Return the current instance directory for faces.
A face is a list of labels corresponding to mesh vertices.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
vtk::lineWriter writer(edgeCentres, edgeList::null(), fileName(aMesh.time().globalPath()/"finiteArea-edgesCentres"))
label countHits() const
Count number of intersections (local)
void transfer(List< T > &list)
Transfer the contents of the argument List into this list and annul the argument list.
label nPoints() const noexcept
Number of mesh points.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
static void removeFiles(const polyMesh &)
Helper: remove all relevant files from mesh instance.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
void append(const T &val)
Append an element at the end of the list.
labelList sortedOrder(const UList< T > &input)
Return the (stable) sort order for the list.
const labelIOList & tetBasePtIs() const
Return the tetBasePtIs.
bool getFaceZoneInfo(const word &fzName, label &masterPatchID, label &slavePatchID, surfaceZonesInfo::faceZoneType &fzType) const
Lookup faceZone information. Return false if no information.
virtual const fileName & name() const override
Read/write access to the name of the stream.
static label findRegions(const polyMesh &, const vector &perturbVec, const pointField &locationsInMesh, const pointField &locationsOutsideMesh, const label nRegions, labelList &cellRegion, const boolList &blockedFace, const bool exitIfLeakPath, const refPtr< coordSetWriter > &leakPathFormatter)
Find regions points are in.
const word & name() const noexcept
Return the object name.
static void removeFiles(const polyMesh &)
Helper: remove all relevant files from mesh instance.
const mapDistribute & globalEdgeSlavesMap() const
static const pointMesh & New(const polyMesh &mesh, Args &&... args)
Get existing or create a new MeshObject. Registered with typeName.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
static label findRegion(const polyMesh &, const labelList &cellRegion, const vector &perturbVec, const point &p)
Find region point is in. Uses optional perturbation to re-test.
Various mesh related information for a parallel run. Upon construction, constructs all info using par...
IntListType renumber(const labelUList &oldToNew, const IntListType &input)
Renumber the values (not the indices) of a list.
Output to file stream, using an OSstream.
void printMeshInfo(const bool debug, const string &msg, const bool printCellLevel) const
Print some mesh stats.
constexpr char nl
The newline '\n' character (0x0a)
autoPtr< mapPolyMesh > doRemoveCells(const labelList &cellsToRemove, const labelList &exposedFaces, const labelList &exposedPatchIDs, removeCells &cellRemover)
Remove cells. Put exposedFaces into exposedPatchIDs.
static ITstream & lookup(const dictionary &dict, const word &keyword, const bool noExit, enum keyType::option matchOpt=keyType::REGEX)
Wrapper around dictionary::lookup which does not exit.
label splitFacesUndo(const labelList &splitFaces, const labelPairList &splits, const dictionary &motionDict, labelList &duplicateFace, List< labelPair > &baffles)
Split faces along diagonal. Maintain mesh quality. Return.
T * data() noexcept
Return pointer to the underlying array serving as data storage.
Given list of cells to remove, insert all the topology changes.
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
void reorder(const labelUList &oldToNew, const bool validBoundary)
Reorders patches. Ordering does not have to be done in.
dimensioned< vector > dimensionedVector
Dimensioned vector obtained from generic dimensioned type.
Ostream & endl(Ostream &os)
Add newline and flush stream.
void setConstraints(const polyMesh &mesh, boolList &blockedFace, PtrList< labelList > &specifiedProcessorFaces, labelList &specifiedProcessor, List< labelPair > &explicitConnections) const
Helper: extract constraints:
static bool & parRun() noexcept
Test if this a parallel run.
void reorder(const labelUList &oldToNew, const bool check=false)
Reorder elements. Reordering must be unique (ie, shuffle).
void clear() noexcept
Same as reset(nullptr)
label constructSize() const noexcept
Constructed data size.
labelList intersectedFaces() const
Get faces with intersection.
static writeType writeLevel()
Get/set write level.
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
static const word & calculatedType() noexcept
The type name for calculated patch fields.
label whichFace(const label globalCellID) const
Helper function to re-direct to zone::localID(...)
static bitSet getMasterEdges(const polyMesh &mesh, const labelList &meshEdges)
Determine master edge for subset of edges. If coupled.
Base class of (analytical or triangulated) surface. Encapsulates all the search routines. WIP.
Ignore writing from objectRegistry::writeObject()
const labelListList & globalEdgeSlaves() const
quaternion normalised(const quaternion &q)
Return the normalised (unit) quaternion of the given quaternion.
const dimensionSet dimless
Dimensionless.
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Can be negative if the process i...
static void calculateEdgeWeights(const polyMesh &mesh, const bitSet &isMasterEdge, const labelList &meshPoints, const edgeList &edges, scalarField &edgeWeights, scalarField &invSumWeight)
Helper: calculate edge weights (1/length)
const Time & time() const
Return the top-level database.
label nFaces() const noexcept
Number of mesh faces.
labelList intersectedPoints() const
Get points on surfaces with intersection and boundary faces.
autoPtr< mapPolyMesh > changeMesh(polyMesh &mesh, const labelUList &patchMap, const bool inflate, const bool syncParallel=true, const bool orderCells=false, const bool orderPoints=false)
Inplace changes mesh without change of patches.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
cellDecomposition
Enumeration defining the decomposition of the cell for.
Finds shortest path (in terms of cell centres) to walk on mesh from any point in insidePoints to any ...
void write(const word &fieldName, const UList< Type > &field)
Write primitive field of CellData (Poly or Line) or PointData values.
A class for managing references or pointers (no reference counting)
bool hasMotionPoints() const
Has valid preMotionPoints?
T & emplace_back(Args &&... args)
Construct and append an element to the end of the list, return reference to the new list element...
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
UList< label > labelUList
A UList of labels.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
static void broadcast(Type &value, const label comm=UPstream::worldComm)
Broadcast content (contiguous or non-contiguous) to all communicator ranks. Does nothing in non-paral...
static labelPairList findDuplicateFacePairs(const polyMesh &)
Helper routine to find all baffles (two boundary faces.
fileName path() const
The complete path for the object (with instance, local,...).
Container for data on surfaces used for surface-driven refinement. Contains all the data about the le...
static label addPatch(fvMesh &, const word &name, const dictionary &)
Helper:add patch to mesh. Update all registered fields.
virtual const pointField & points() const
Return raw points.
Mesh representing a set of points created from polyMesh.
#define forAll(list, i)
Loop across all elements in list.
static void syncData(List< Type > &elems, const labelListList &slaves, const labelListList &transformedSlaves, const mapDistribute &slavesMap, const globalIndexAndTransform &, const CombineOp &cop, const TransformOp &top)
Helper: synchronise data with transforms.
label fcIndex(const label i) const noexcept
The forward circular index. The next index in the list which returns to the first at the end of the l...
T & constCast() const
Return non-const reference to the object or to the contents of a (non-null) managed pointer...
void reset(T *p=nullptr) noexcept
Delete managed object and set to new given pointer.
static const Enum< writeType > writeTypeNames
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
Encapsulates queries for features.
void distributeFaceData(List< T > &values) const
Distribute list of face data.
static label appendPatch(fvMesh &, const label insertPatchi, const word &, const dictionary &)
Helper:append patch to end of mesh.
static void allGatherList(List< T > &values, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Gather data, but keep individual values separate. Uses linear/tree communication. ...
void doSplitFaces(const labelList &splitFaces, const labelPairList &splits, polyTopoChange &meshMod) const
Split faces into two.
void distribute(const mapDistributePolyMesh &)
Update local numbering for mesh redistribution.
static void updateList(const labelList &newToOld, const T &nullValue, List< T > &elems)
Helper: reorder list according to map.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
A list of faces which address into the list of points.
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
A List obtained as a section of another List.
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run. ...
Sends/receives parts of mesh+fvfields to neighbouring processors. Used in load balancing.
bool returnReduceAnd(const bool value, const label comm=UPstream::worldComm)
Perform logical (and) MPI Allreduce on a copy. Uses UPstream::reduceAnd.
vectorField pointField
pointField is a vectorField.
static void gatherList(const List< commsStruct > &comms, List< T > &values, const int tag, const label comm)
Gather data, but keep individual values separate. Uses the specified communication schedule...
const dimensionedScalar e
Elementary charge.
const fileName & pointsInstance() const
Return the current instance directory for points.
void setSize(const label n)
Alias for resize()
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
label addFace(const face &f, const label own, const label nei, const label masterPointID, const label masterEdgeID, const label masterFaceID, const bool flipFaceFlux, const label patchID, const label zoneID, const bool zoneFlip)
Add face to cells. Return new face label.
label findZoneID(const word &zoneName) const
Find zone index by name, return -1 if not found.
An edge is a list of two vertex labels. This can correspond to a directed graph edge or an edge on a ...
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i), works like std::iota() but returning a...
fileName globalPath() const
Return global path for the case = rootPath/globalCaseName. Same as TimePaths::globalPath() ...
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
A class for handling words, derived from Foam::string.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
const DynamicList< point > & points() const
Points. Shrunk after constructing mesh (or calling of compact())
wordList names() const
Return a list of patch names.
label size() const noexcept
The number of entries in the list.
const Field< point_type > & faceCentres() const
Return face centres for patch.
Base class for writing coordSet(s) and tracks with fields.
static void checkCoupledFaceZones(const polyMesh &)
Helper function: check that face zones are synced.
static const dictionary null
An empty dictionary, which is also the parent for all dictionaries.
Container for searchableSurfaces. The collection is specified as a dictionary. For example...
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
bool exists(const fileName &name, const bool checkGzip=true, const bool followLink=true)
Does the name exist (as DIRECTORY or FILE) in the file system?
const labelList & surfaceIndex() const
Per start-end edge the index of the surface hit.
const labelListList & edgeFaces() const
Return edge-face addressing.
Abstract base class for domain decomposition.
label nInternalFaces() const noexcept
Number of internal faces.
Encapsulates queries for volume refinement ('refine all cells within shell').
autoPtr< mapDistributePolyMesh > balance(const bool keepZoneFaces, const bool keepBaffles, const scalarField &cellWeights, decompositionMethod &decomposer, fvMeshDistribute &distributor)
Redecompose according to cell count.
virtual const faceList & faces() const
Return raw faces.
label whichPatch(const label meshFacei) const
Return patch index for a given mesh face index. Uses binary search.
Accumulating histogram of values. Specified bin resolution automatic generation of bins...
const HashTable< labelList > & groupPatchIDs() const
The patch indices per patch group.
void updateMesh(const mapPolyMesh &)
Force recalculation of locally stored data on topological change.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
errorManip< error > abort(error &err)
bool test(const label pos) const
Test for True value at specified position, never auto-vivify entries.
void setRefinement(const bitSet &removedCell, const labelUList &facesToExpose, const labelUList &patchIDs, polyTopoChange &) const
Play commands into polyTopoChange to remove cells.
word timeName() const
Replacement for Time::timeName() that returns oldInstance (if overwrite_)
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO...
void setCapacity(const label nPoints, const label nFaces, const label nCells)
Explicitly pre-size the dynamic storage for expected mesh size for if construct-without-mesh.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
static word timeName(const scalar t, const int precision=precision_)
Return a time name for the given scalar time value formatted with the given precision.
void checkData()
Debugging: check that all faces still obey start()>end()
int debug
Static debugging option.
Pair< label > labelPair
A pair of labels.
Type gMax(const FieldField< Field, Type > &f)
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
const faceZoneMesh & faceZones() const noexcept
Return face zone mesh.
virtual bool open(const fileName &file, bool parallel=UPstream::parRun())
Open file for writing (creates parent directory).
defineTypeNameAndDebug(combustionModel, 0)
static bool clean(std::string &str)
Cleanup filename string, possibly applies other transformations such as changing the path separator e...
label addMeshedPatch(const word &name, const dictionary &)
Add patch originating from meshing. Update meshedPatches_.
labelList meshedPatches() const
Get patchIDs for patches added in addMeshedPatch.
autoPtr< mapDistributePolyMesh > distribute(const labelList &dist)
Send cells to neighbours according to distribution.
void setSize(const label newLen)
Same as resize()
label nTotalCells() const noexcept
Return total number of cells in decomposed mesh.
static autoPtr< indirectPrimitivePatch > makePatch(const polyMesh &, const labelList &)
Create patch from set of patches.
fileName relativeName(const bool caseTag=false) const
The dictionary name relative to the case.
const labelList & faceMap() const
Old face map.
void updateMesh(const mapPolyMesh &, const labelList &changedFaces)
Update for external change to mesh. changedFaces are in new mesh.
void updateIntersections(const labelList &changedFaces)
Find any intersection of surface. Store in surfaceIndex_.
static const Foam::polyMesh::cellDecomposition findCellMode(Foam::polyMesh::FACE_DIAG_TRIS)
autoPtr< mapPolyMesh > splitMeshRegions(const labelList &globalToMasterPatch, const labelList &globalToSlavePatch, const pointField &locationsInMesh, const pointField &locationsOutsideMesh, const bool exitIfLeakPath, const refPtr< coordSetWriter > &leakPathFormatter)
Split mesh. Keep part containing point. Return empty map if.
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))
Helper class which maintains intersections of (changing) mesh with (static) surfaces.
Use additional distance field for (scalar) axis.
static bool split(const std::string &line, std::string &key, std::string &val)
const indirectPrimitivePatch & coupledPatch() const
Return patch of all coupled faces.
void setInstance(const fileName &)
Set instance of all local IOobjects.
Calculates points shared by more than two processor patches or cyclic patches.
void modifyFace(const face &f, const label facei, const label own, const label nei, const bool flipFaceFlux, const label patchID, const label zoneID, const bool zoneFlip)
Modify vertices or cell of face.
void inplaceRenumber(const labelUList &oldToNew, IntListType &input)
Inplace renumber the values (not the indices) of a list.
Class containing processor-to-processor mapping information.
static bool constraintType(const word &patchType)
Return true if the given type is a constraint type.
void storeData(const labelList &pointsToStore, const labelList &facesToStore, const labelList &cellsToStore)
Signal points/face/cells for which to store data.
vector point
Point is a vector.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
#define WarningInFunction
Report a warning using Foam::Warning.
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
static void testSyncPointList(const string &msg, const polyMesh &mesh, const List< scalar > &fld)
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
label nCells() const noexcept
Number of mesh cells.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
static bitSet getMasterPoints(const polyMesh &mesh, const labelList &meshPoints)
Determine master point for subset of points. If coupled.
Mesh data needed to do the Finite Volume discretisation.
A List with indirect addressing. Like IndirectList but does not store addressing. ...
Direct mesh changes based on v1.3 polyTopoChange syntax.
void close()
End the file contents and close the file after writing.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
const polyBoundaryMesh & patches
const word & name() const noexcept
The zone name.
option
Enumeration for the data type and search/match modes (bitmask)
static const word & calculatedType() noexcept
The type name for calculated patch fields.
Automatically write from objectRegistry::writeObject()
static word outputPrefix
Directory prefix.
void push_back(T *ptr)
Append an element to the end of the list.
For use with FaceCellWave. Determines topological distance to starting faces. Templated on passive tr...
label nRegions() const
Return total number of regions.
const entry * findEntry(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry (const access) with the given keyword.
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
Reduce inplace (cf. MPI Allreduce) using specified communication schedule.
label findCell(const point &p, const cellDecomposition=CELL_TETS) const
Find cell enclosing this location and return index.
static const Enum< debugType > debugTypeNames
const boolList & flipMap() const noexcept
Return face flip map.
static labelList findDuplicateFaces(const primitiveMesh &, const labelList &)
Helper routine to find baffles (two boundary faces using the.
void selectSeparatedCoupledFaces(boolList &) const
Select coupled faces that are not collocated.
Standard boundBox with extra functionality for use in octree.
wordList names() const
A list of the zone names.
messageStream Info
Information stream (stdout output on master, null elsewhere)
const fvBoundaryMesh & boundary() const noexcept
Return reference to boundary mesh.
SubField< vector > subField
Declare type of subField.
writeType
Enumeration for what to write. Used as a bit-pattern.
Field< vector > vectorField
Specialisation of Field<T> for vector.
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.
faceZoneType
What to do with faceZone faces.
debugType
Enumeration for what to debug. Used as a bit-pattern.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
#define DebugVar(var)
Report a variable name and value.
T * data() noexcept
Return pointer to the underlying array serving as data storage.
Mesh consisting of general polyhedral cells.
entry * set(entry *entryPtr)
Assign a new entry, overwriting any existing entry.
static void listCombineGather(const List< commsStruct > &comms, List< T > &values, const CombineOp &cop, const int tag, const label comm)
static autoPtr< fvPatch > New(const polyPatch &, const fvBoundaryMesh &)
Return a pointer to a new patch created on freestore from polyPatch.
A subset of mesh faces organised as a primitive patch.
bool write() const
Write mesh and all data.
List< point > pointList
List of point.
List< label > labelList
A List of labels.
const_searcher csearch(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Search dictionary for given keyword.
static tmp< pointVectorField > makeDisplacementField(const pointMesh &pMesh, const labelList &adaptPatchIDs)
Helper function to make a pointVectorField with correct.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
A class for managing temporary objects.
T * first()
The first entry in the list.
static autoPtr< T > New(Args &&... args)
Construct autoPtr with forwarding arguments.
A patch is a list of labels that address the faces in the global face list.
const T & second() const noexcept
Access the second element.
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;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
const pointBoundaryMesh & boundary() const noexcept
Return reference to boundary mesh.
void dumpIntersections(const fileName &prefix) const
Debug: Write intersection information to OBJ format.
virtual ITstream & stream() const =0
Return token stream, if entry is a primitive entry.
label nBoundaryFaces() const noexcept
Number of boundary faces (== nFaces - nInternalFaces)
static labelList countCells(const labelList &)
Helper function: count cells per processor in wanted distribution.
void removeFace(const label facei, const label mergeFacei)
Remove/merge face.
Defines the attributes of an object for which implicit objectRegistry management is supported...
List< bool > boolList
A List of bools.
A List with indirect addressing.
void dumpRefinementLevel() const
Write refinement level as volScalarFields for postprocessing.
labelList countEdgeFaces(const uindirectPrimitivePatch &pp) const
Count number of faces per patch edge. Parallel consistent.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
label size() const noexcept
Number of entries.
Do not request registration (bool: false)
List< treeBoundBox > meshBb(1, treeBoundBox(coarseMesh.points()).extend(rndGen, 1e-3))
An input stream of tokens.
static label addFaceZone(const word &name, const labelList &addressing, const boolList &flipMap, polyMesh &mesh)
const labelList & reverseFaceMap() const
Reverse face map.
const pointField & preMotionPoints() const
Pre-motion point positions.
static label findCell(const polyMesh &, const vector &perturbVec, const point &p)
Find cell point is in. Uses optional perturbation to re-test.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
forAllConstIters(mixture.phases(), phase)
A keyword and a list of tokens is an 'entry'.
virtual labelList decompose(const pointField &points, const scalarField &pointWeights=scalarField::null()) const
Return the wanted processor number for every coordinate, using uniform or specified point weights...
static void listCombineReduce(List< T > &values, const CombineOp &cop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
After completion all processors have the same data.
static const Enum< coordFormat > coordFormatNames
String representation of coordFormat enum.
const labelListList & globalEdgeTransformedSlaves() const
bool rm(const fileName &file)
Remove a file (or its gz equivalent), returning true if successful.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
static constexpr const zero Zero
Global zero (0)