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
478 List<topoDistanceData<label>> startData(startFaces.
size());
481 const label facei = startFaces[i];
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());
1371 label oldFacei = map.
faceMap()[facei];
1373 const auto oldFaceFnd = splitFaceToIndex.
cfind(oldFacei);
1375 if (oldFaceFnd.good())
1377 labelPair& twoFaces = facePairs[oldFaceFnd.val()];
1378 if (twoFaces[0] == -1)
1380 twoFaces[0] = facei;
1382 else if (twoFaces[1] == -1)
1384 twoFaces[1] = facei;
1389 <<
"problem: twoFaces:" << twoFaces
1400 if (duplicateFace.
size())
1414 baffle.
first() = oldToNewFaces[baffle.
first()];
1417 if (baffle.
first() == -1 || baffle.
second() == -1)
1420 <<
"Removed baffle : faces:" << baffle
1433 changedFaces.
append(facePairs[i].first());
1434 changedFaces.
append(facePairs[i].second());
1438 updateMesh(map, growFaceCellFace(changedFaces));
1451 for (label iteration = 0; iteration < 100; iteration++)
1454 <<
"Undo iteration " << iteration <<
nl 1455 <<
"----------------" <<
endl;
1461 faceSet errorFaces(mesh_,
"errorFaces", mesh_.nBoundaryFaces());
1477 const labelList grownFaces(growFaceCellFace(errorFaces));
1479 errorFaces.insert(grownFaces);
1493 const labelPair& twoFaces = facePairs[index];
1497 errorFaces.found(twoFaces.
first())
1498 || errorFaces.found(twoFaces.
second())
1501 const face& originalFace = originalFaces[index];
1505 label own = mesh_.faceOwner()[twoFaces[0]];
1508 if (twoFaces[0] >= mesh_.nInternalFaces())
1510 patchi = mesh_.boundaryMesh().whichPatch(twoFaces[0]);
1514 nei = mesh_.faceNeighbour()[twoFaces[0]];
1517 label zonei = mesh_.faceZones().whichZone(twoFaces[0]);
1518 bool zoneFlip =
false;
1521 const faceZone& fz = mesh_.faceZones()[zonei];
1538 meshMod.
removeFace(twoFaces[1], twoFaces[0]);
1540 mergedIndices.insert(index);
1546 Info<<
"Detected " <<
n 1547 <<
" split faces that will be restored to their original faces." 1561 mesh_.moving(
false);
1568 mesh_.updateMesh(map);
1582 setInstance(mesh_.facesInstance());
1598 const labelPair& oldSplit = facePairs[index];
1599 label new0 = oldToNewFaces[oldSplit[0]];
1600 label new1 = oldToNewFaces[oldSplit[1]];
1602 if (!mergedIndices.found(index))
1605 if (new0 < 0 || new1 < 0)
1608 <<
"Problem: oldFaces:" << oldSplit
1609 <<
" newFaces:" <<
labelPair(new0, new1)
1613 facePairs[newIndex] =
labelPair(new0, new1);
1617 originalFaces[index]
1624 if (new0 < 0 || new1 == -1)
1627 <<
"Problem: oldFaces:" << oldSplit
1631 changedFaces.
append(new0);
1635 facePairs.setSize(newIndex);
1636 originalFaces.
setSize(newIndex);
1640 updateMesh(map, growFaceCellFace(changedFaces));
1646 if (duplicateFace.
size())
1660 baffle.
first() = reverseFaceMap[baffle.
first()];
1663 if (baffle.
first() == -1 || baffle.
second() == -1)
1666 <<
"Removed baffle : faces:" << baffle
1680 Foam::meshRefinement::meshRefinement
1683 const scalar mergeDistance,
1684 const bool overwrite,
1694 mergeDistance_(mergeDistance),
1695 overwrite_(overwrite),
1696 oldInstance_(
mesh.pointsInstance()),
1697 surfaces_(surfaces),
1698 features_(features),
1700 limitShells_(limitShells),
1712 mesh_.facesInstance(),
1732 if (surfaceIndex_.size() != mesh_.nFaces())
1739 return surfaceIndex_;
1745 if (surfaceIndex_.size() != mesh_.nFaces())
1747 updateIntersections(
identity(mesh_.nFaces()));
1749 return surfaceIndex_;
1760 const labelList& surfIndex = surfaceIndex();
1764 if (surfIndex[facei] >= 0 && isMasterFace.
test(facei))
1775 const bool keepZoneFaces,
1776 const bool keepBaffles,
1793 label nUnblocked = 0;
1807 specifiedProcessorFaces,
1813 if (keepZoneFaces || keepBaffles)
1833 const faceZone& fZone = fZones[zonei];
1837 label facei = fZone[i];
1838 if (blockedFace[facei])
1842 mesh_.isInternalFace(facei)
1846 blockedFace[facei] =
false;
1868 Info<<
"Found " << nUnblocked
1869 <<
" zoned faces to keep together." <<
endl;
1875 boolList separatedCoupledFace(mesh_.nFaces(),
false);
1876 selectSeparatedCoupledFaces(separatedCoupledFace);
1878 label nSeparated = 0;
1879 forAll(separatedCoupledFace, facei)
1881 if (separatedCoupledFace[facei])
1883 if (blockedFace[facei])
1885 blockedFace[facei] =
false;
1891 Info<<
"Found " << nSeparated
1892 <<
" separated coupled faces to keep together." <<
endl;
1894 nUnblocked += nSeparated;
1900 const label nBnd = mesh_.nBoundaryFaces();
1902 labelList coupledFace(mesh_.nFaces(), -1);
1920 const labelPair& baffle = allCouples[i];
1928 forAll(coupledFace, facei)
1930 if (coupledFace[facei] != -1 && facei < coupledFace[facei])
1932 couples[nCpl++] =
labelPair(facei, coupledFace[facei]);
1941 Info<<
"Found " << nCouples <<
" baffles to keep together." 1951 blockedFace[baffle.
first()] =
false;
1952 blockedFace[baffle.
second()] =
false;
1960 specifiedProcessorFaces,
1968 Pout<<
"Wanted distribution:" << nProcCells <<
endl;
1972 Pout<<
"Wanted resulting decomposition:" <<
endl;
1973 forAll(nProcCells, proci)
1975 Pout<<
" " << proci <<
'\t' << nProcCells[proci] <<
endl;
1988 setInstance(mesh_.facesInstance());
1991 if (
debug && keepZoneFaces)
1999 const faceZone& fZone = fZones[zonei];
2003 label facei = fZone[i];
2009 <<
"Face at " << mesh_.faceCentres()[facei]
2010 <<
" on zone " << fZone.
name()
2011 <<
" is on coupled patch " <<
pbm[patchi].
name()
2025 label nBoundaryFaces = 0;
2027 const labelList& surfIndex = surfaceIndex();
2031 if (surfIndex[facei] != -1)
2042 if (surfIndex[facei] != -1)
2044 surfaceFaces[nBoundaryFaces++] = facei;
2047 return surfaceFaces;
2053 const faceList& faces = mesh_.faces();
2056 bitSet isBoundaryPoint(mesh_.nPoints());
2057 label nBoundaryPoints = 0;
2059 const labelList& surfIndex = surfaceIndex();
2063 if (surfIndex[facei] != -1)
2065 const face&
f = faces[facei];
2069 if (isBoundaryPoint.set(
f[fp]))
2106 labelList boundaryPoints(nBoundaryPoints);
2107 nBoundaryPoints = 0;
2108 forAll(isBoundaryPoint, pointi)
2110 if (isBoundaryPoint.test(pointi))
2112 boundaryPoints[nBoundaryPoints++] = pointi;
2116 return boundaryPoints;
2136 nFaces +=
pp.size();
2147 label meshFacei =
pp.start();
2151 addressing[nFaces++] = meshFacei++;
2176 pointPatches.
size(),
2177 slipPointPatchVectorField::typeName
2182 patchFieldTypes[adaptPatchIDs[i]] =
2183 fixedValuePointPatchVectorField::typeName;
2186 forAll(pointPatches, patchi)
2188 if (isA<processorPointPatch>(pointPatches[patchi]))
2190 patchFieldTypes[patchi] = calculatedPointPatchVectorField::typeName;
2192 else if (isA<cyclicPointPatch>(pointPatches[patchi]))
2194 patchFieldTypes[patchi] = cyclicSlipPointPatchVectorField::typeName;
2204 "pointDisplacement",
2238 <<
"faceZones are not synchronised on processors." <<
nl 2239 <<
"Processor " << proci <<
" has faceZones " 2240 << zoneNames[proci] <<
nl 2242 <<
" has faceZones " 2255 const faceZone& fZone = fZones[zonei];
2263 if (faceToZone[bFacei] == -1)
2265 faceToZone[bFacei] = zonei;
2267 else if (faceToZone[bFacei] == zonei)
2270 <<
"Face " << fZone[i] <<
" in zone " 2272 <<
" is twice in zone!" 2278 <<
"Face " << fZone[i] <<
" in zone " 2280 <<
" is also in zone " 2281 << fZones[faceToZone[bFacei]].
name()
2293 if (faceToZone[i] != neiFaceToZone[i])
2297 <<
" is in zone " << faceToZone[i]
2298 <<
", its coupled face is in zone " << neiFaceToZone[i]
2308 const bitSet& isMasterEdge,
2323 const edge&
e = edges[edgei];
2329 pts[meshPoints[
e[1]]]
2330 -
pts[meshPoints[
e[0]]]
2333 edgeWeights[edgei] = 1.0/eMag;
2349 forAll(invSumWeight, pointi)
2351 scalar w = invSumWeight[pointi];
2355 invSumWeight[pointi] = 1.0/w;
2364 const label insertPatchi,
2365 const word& patchName,
2377 const label patchi = polyPatches.
size();
2395 polyPatches[patchi],
2400 addPatchFields<volScalarField>
2405 addPatchFields<volVectorField>
2410 addPatchFields<volSphericalTensorField>
2415 addPatchFields<volSymmTensorField>
2420 addPatchFields<volTensorField>
2428 addPatchFields<surfaceScalarField>
2433 addPatchFields<surfaceVectorField>
2438 addPatchFields<surfaceSphericalTensorField>
2443 addPatchFields<surfaceSymmTensorField>
2448 addPatchFields<surfaceTensorField>
2460 const word& patchName,
2468 const label patchi = polyPatches.
findPatchID(patchName);
2476 label insertPatchi = polyPatches.
size();
2479 forAll(polyPatches, patchi)
2483 if (isA<processorPolyPatch>(
pp))
2485 insertPatchi = patchi;
2486 startFacei =
pp.start();
2492 patchDict.
set(
"nFaces", 0);
2493 patchDict.
set(
"startFace", startFacei);
2498 label addedPatchi = appendPatch(
mesh, insertPatchi, patchName, patchDict);
2504 for (label i = 0; i < insertPatchi; i++)
2509 for (label i = insertPatchi; i < addedPatchi; i++)
2514 oldToNew[addedPatchi] = insertPatchi;
2517 polyPatches.
reorder(oldToNew,
true);
2520 reorderPatchFields<volScalarField>(
mesh, oldToNew);
2521 reorderPatchFields<volVectorField>(
mesh, oldToNew);
2522 reorderPatchFields<volSphericalTensorField>(
mesh, oldToNew);
2523 reorderPatchFields<volSymmTensorField>(
mesh, oldToNew);
2524 reorderPatchFields<volTensorField>(
mesh, oldToNew);
2525 reorderPatchFields<surfaceScalarField>(
mesh, oldToNew);
2526 reorderPatchFields<surfaceVectorField>(
mesh, oldToNew);
2527 reorderPatchFields<surfaceSphericalTensorField>(
mesh, oldToNew);
2528 reorderPatchFields<surfaceSymmTensorField>(
mesh, oldToNew);
2529 reorderPatchFields<surfaceTensorField>(
mesh, oldToNew);
2531 return insertPatchi;
2541 label meshedi = meshedPatches_.find(
name);
2546 return mesh_.boundaryMesh().findPatchID(
name);
2551 label patchi = addPatch(mesh_,
name, patchInfo);
2576 meshedPatches_.append(
name);
2579 faceToCoupledPatch_.clear();
2591 forAll(meshedPatches_, i)
2598 <<
"Problem : did not find patch " << meshedPatches_[i]
2615 const word& masterPatch,
2616 const word& slavePatch,
2628 faceZoneToMasterPatch_.insert(fzName, masterPatch);
2629 faceZoneToSlavePatch_.insert(fzName, slavePatch);
2630 faceZoneToType_.insert(fzName, fzType);
2639 label& masterPatchID,
2640 label& slavePatchID,
2646 if (!faceZoneToMasterPatch_.found(fzName))
2652 const word& masterName = faceZoneToMasterPatch_[fzName];
2655 const word& slaveName = faceZoneToSlavePatch_[fzName];
2658 fzType = faceZoneToType_[fzName];
2673 zoneI = pointZones.
size();
2692 const auto* cpp = isA<coupledPolyPatch>(
pp);
2694 if (cpp && (cpp->separated() || !cpp->parallel()))
2713 nEdgeFaces[edgei] = edgeFaces[edgei].
size();
2762 const vector& perturbVec,
2784 const vector& perturbVec,
2796 regioni = cellToRegion[celli];
2806 regioni = cellToRegion[celli];
2846 locationsOutsideMesh,
2855 label nSegments = 0;
2856 if (leakPath.segments().size())
2858 nSegments =
max(leakPath.segments())+1;
2860 reduce(nSegments, maxOp<label>());
2863 for (label segmenti : leakPath.segments())
2865 nElemsPerSegment[segmenti]++;
2867 segmentPoints.setSize(nElemsPerSegment.size());
2868 segmentDist.
setSize(nElemsPerSegment.size());
2869 forAll(nElemsPerSegment, i)
2871 segmentPoints[i].setSize(nElemsPerSegment[i]);
2872 segmentDist[i].
setSize(nElemsPerSegment[i]);
2874 nElemsPerSegment = 0;
2878 label segmenti = leakPath.segments()[elemi];
2881 label&
n = nElemsPerSegment[segmenti];
2884 dist[
n] = leakPath.distance()[elemi];
2889 PtrList<coordSet> allLeakPaths(segmentPoints.size());
2890 forAll(allLeakPaths, segmenti)
2904 ListListOps::combine<pointList>
2906 gatheredPts, accessOp<pointList>()
2911 ListListOps::combine<scalarList>
2913 gatheredDist, accessOp<scalarList>()
2937 List<scalarField> allLeakData(allLeakPaths.size());
2938 forAll(allLeakPaths, segmenti)
2940 allLeakData[segmenti] = allLeakPaths[segmenti].distance();
2948 (outputDir / allLeakPaths[0].
name())
2970 const vector& perturbVec,
2973 const label nRegions,
2977 const bool exitIfLeakPath,
2988 label regioni = findRegion
2996 insideRegions[i] = regioni;
2999 forAll(cellRegion, celli)
3001 if (cellRegion[celli] == regioni)
3003 insideCell.set(celli);
3012 forAll(locationsOutsideMesh, i)
3018 label regioni = findRegion
3023 locationsOutsideMesh[i]
3026 if (regioni == -1 && (indexi = insideRegions.find(regioni)) != -1)
3028 if (leakPathFormatter)
3036 locationsOutsideMesh,
3041 Info<<
"Dumped leak path to " << fName <<
endl;
3051 err <<
"Location in mesh " << locationsInMesh[indexi]
3052 <<
" is inside same mesh region " << regioni
3053 <<
" as one of the locations outside mesh " 3054 << locationsOutsideMesh <<
endl;
3067 forAll(insideCell, celli)
3069 if (!insideCell.test(celli))
3071 cellRegion[celli] = -1;
3074 else if (cellRegion[celli] == -1)
3090 const bool exitIfLeakPath,
3095 (void)mesh_.tetBasePtIs();
3100 boolList blockedFace(mesh_.nFaces(),
false);
3101 selectSeparatedCoupledFaces(blockedFace);
3105 label nRemove = findRegions
3108 vector::uniform(mergeDistance_),
3110 locationsOutsideMesh,
3124 forAll(cellRegion, celli)
3126 if (cellRegion[celli] == -1)
3128 cellsToRemove.append(celli);
3131 cellsToRemove.shrink();
3135 cellsToRemove.size(),
3141 if (nTotCellsToRemove > 0)
3143 label nCellsToKeep =
3144 mesh_.globalData().nTotalCells()
3145 - nTotCellsToRemove;
3147 Info<<
"Keeping all cells containing points " << locationsInMesh <<
endl 3148 <<
"Selected for keeping : " 3150 <<
" cells." <<
endl;
3168 label defaultPatch = 0;
3169 if (globalToMasterPatch.
size())
3171 defaultPatch = globalToMasterPatch[0];
3175 <<
"Removing non-reachable cells exposes " 3176 << nExposedFaces <<
" internal or coupled faces." <<
endl 3177 <<
" These get put into patch " << defaultPatch <<
endl;
3178 exposedPatch.setSize(exposedFaces.
size(), defaultPatch);
3181 mapPtr = doRemoveCells
3200 meshCutter_.distribute(map);
3207 faceToCoupledPatch_.clear();
3234 geometry[i].distribute
3245 geometry[i].instance() = geometry[i].time().timeName();
3263 updateMesh(map, changedFaces, dummyMap, dummyMap, dummyMap);
3275 meshCutter_.storeData
3296 meshCutter_.updateMesh
3305 updateList(map.
faceMap(), label(-1), surfaceIndex_);
3309 Map<label> newFaceToPatch(faceToCoupledPatch_.size());
3316 newFaceToPatch.insert(newFacei, iter.val());
3319 faceToCoupledPatch_.
transfer(newFaceToPatch);
3324 updateIntersections(changedFaces);
3329 labelList& data = userFaceData_[i].second();
3331 if (userFaceData_[i].first() == KEEPALL)
3334 updateList(map.
faceMap(), label(-1), data);
3336 else if (userFaceData_[i].first() == MASTERONLY)
3341 forAll(newFaceData, facei)
3343 label oldFacei = map.
faceMap()[facei];
3347 newFaceData[facei] = data[oldFacei];
3363 label oldFacei = map.
faceMap()[facei];
3367 if (reverseFaceMap[oldFacei] != facei)
3370 reverseFaceMap[oldFacei] = -1;
3377 forAll(newFaceData, facei)
3379 label oldFacei = map.
faceMap()[facei];
3383 if (reverseFaceMap[oldFacei] == facei)
3385 newFaceData[facei] = data[oldFacei];
3397 bool writeOk = mesh_.write();
3414 s.instance() !=
s.time().system()
3415 &&
s.instance() !=
s.time().caseSystem()
3416 &&
s.instance() !=
s.time().constant()
3417 &&
s.instance() !=
s.time().caseConstant()
3421 s.instance() =
s.time().timeName();
3422 writeOk = writeOk &&
s.write();
3454 bitSet isPatchMasterPoint(meshPoints.
size());
3455 forAll(meshPoints, pointi)
3457 if (myPoints[pointi] ==
globalPoints.toGlobal(myProci, pointi))
3459 isPatchMasterPoint.set(pointi);
3463 return isPatchMasterPoint;
3494 if (myEdges[edgei] == globalEdges.toGlobal(myProci, edgei))
3496 isMasterEdge.
set(edgei);
3500 return isMasterEdge;
3508 const bool printCellLevel
3517 <<
" : cells(local):" << mesh_.nCells()
3518 <<
" faces(local):" << mesh_.nFaces()
3519 <<
" points(local):" << mesh_.nPoints()
3525 label nMasterFaces = isMasterFace.
count();
3528 label nMasterPoints = isMeshMasterPoint.
count();
3537 const scalar nIdealCells =
3541 mag(1.0-mesh_.nCells()/nIdealCells),
3544 Info<<
" unbalance:" << unbalance;
3551 const labelList& cellLevel = meshCutter_.cellLevel();
3557 nCells[cellLevel[celli]]++;
3565 Info<<
"Cells per refinement level:" <<
endl;
3568 Info<<
" " << leveli <<
'\t' << nCells[leveli]
3578 if (overwrite_ && mesh_.time().timeIndex() == 0)
3580 return oldInstance_;
3583 return mesh_.time().timeName();
3597 mesh_.time().timeName(),
3608 const labelList& cellLevel = meshCutter_.cellLevel();
3610 forAll(volRefLevel, celli)
3612 volRefLevel[celli] = cellLevel[celli];
3615 volRefLevel.write();
3627 mesh_.time().timeName(),
3637 const labelList& pointLevel = meshCutter_.pointLevel();
3639 forAll(pointRefLevel, pointi)
3641 pointRefLevel[pointi] = pointLevel[pointi];
3644 pointRefLevel.write();
3652 OFstream str(prefix +
"_edges.obj");
3654 Pout<<
"meshRefinement::dumpIntersections :" 3655 <<
" Writing cellcentre-cellcentre intersections to file " 3663 labelList neiLevel(mesh_.nBoundaryFaces());
3665 calcNeighbourData(neiLevel, neiCc);
3667 labelList intersectionFaces(intersectedFaces());
3689 surfaces_.findAnyIntersection
3697 forAll(intersectionFaces, i)
3699 if (surfaceHit[i] != -1)
3707 str <<
"l " << verti-2 <<
' ' << verti-1 <<
nl 3708 <<
"l " << verti-1 <<
' ' << verti <<
nl;
3724 if (writeFlags & WRITEMESH)
3729 if (writeFlags && !(writeFlags & NOWRITEREFINEMENT))
3731 meshCutter_.write();
3734 (void)surfaceIndex();
3735 surfaceIndex_.write();
3738 if (writeFlags & WRITELEVELS)
3740 dumpRefinementLevel();
3743 if ((debugFlags & OBJINTERSECTIONS) && prefix.size())
3745 dumpIntersections(prefix);
3764 if (
exists(setsDir/
"surfaceIndex"))
3766 rm(setsDir/
"surfaceIndex");
3782 writeLevel_ = flags;
3801 const word& keyword,
3811 <<
"Entry '" << keyword
3812 <<
"' not found (or not a dictionary) in dictionary " 3833 const word& keyword,
3843 <<
"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.
static void listCombineGather(UList< T > &values, const CombineOp &cop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Combines List elements.
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
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.
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.
const bitSet isBlockedFace(intersectedFaces())
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 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 within a list.
Output to file stream as an OSstream, normally using std::ofstream for the actual output...
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.
static void gatherList(const UList< commsStruct > &comms, UList< T > &values, const int tag, const label comm)
Gather data, but keep individual values separate. Uses the specified communication schedule...
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.
void clearOut(const bool isMeshUpdate=false)
Clear all geometry and addressing.
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)
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.
const labelList & reverseFaceMap() const noexcept
Reverse face map.
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.
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.
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.
const_iterator cfind(const Key &key) const
Find and return an const_iterator set at the hashed entry.
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.
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, const bool multiZone=false)
Modify vertices or cell of face.
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').
const labelList & reversePointMap() const noexcept
Reverse point map.
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
Total global number of mesh cells.
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.
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)
bool hasMotionPoints() const noexcept
Has valid preMotionPoints?
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.
static void allGatherList(UList< T > &values, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Gather data, but keep individual values separate. Uses MPI_Allgather or manual linear/tree communicat...
void setInstance(const fileName &)
Set instance of all local IOobjects.
Calculates points shared by more than two processor patches or cyclic patches.
void inplaceRenumber(const labelUList &oldToNew, IntListType &input)
Inplace renumber the values within 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.
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)
static ITstream & empty_stream()
Return reference to an empty ITstream, for functions needing to return an ITstream reference but whic...
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 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.
const labelList & faceMap() const noexcept
Old face map.
bool write() const
Write mesh and all data.
List< point > pointList
List of point.
List< label > labelList
A List of labels.
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.
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...
Map< label > invertToMap(const labelUList &values)
Create inverse mapping, which is a lookup table into the given list.
List< bool > boolList
A List of bools.
A List with indirect addressing.
void dumpRefinementLevel() const
Write refinement level as volScalarFields for postprocessing.
const pointField & preMotionPoints() const noexcept
Pre-motion point positions.
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)
void reduce(T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce) using linear/tree communication schedule.
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)
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)
Combines List elements. 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.
const dictionary * findDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary pointer if present (and it is a dictionary) otherwise return nullptr...
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)