84 { MeshType::CASTELLATED,
"castellated" },
85 { MeshType::CASTELLATEDBUFFERLAYER,
"castellatedBufferLayer" },
86 { MeshType::CASTELLATEDBUFFERLAYER2,
"castellatedBufferLayer2" }
96 { debugType::MESH,
"mesh" },
97 { debugType::OBJINTERSECTIONS,
"intersections" },
98 { debugType::FEATURESEEDS,
"featureSeeds" },
99 { debugType::ATTRACTION,
"attraction" },
100 { debugType::LAYERINFO,
"layerInfo" },
120 { writeType::WRITEMESH,
"mesh" },
121 { writeType::NOWRITEREFINEMENT,
"noRefinement" },
122 { writeType::WRITELEVELS,
"scalarLevels" },
123 { writeType::WRITELAYERSETS,
"layerSets" },
124 { writeType::WRITELAYERFIELDS,
"layerFields" },
145 Foam::label Foam::meshRefinement::globalFaceCount(
const labelList& elems)
const 148 const bitSet isElem(mesh_.nFaces(), elems);
149 if (label(isElem.count()) != elems.size())
152 <<
" isElem:" << isElem.count()
153 <<
" elems:" << elems.size()
159 bitSet isElem2(isElem);
164 label facei = mesh_.nInternalFaces();
165 facei < mesh_.nFaces();
169 if (isElem2[facei] != isElem[facei])
172 <<
"at face:" << facei
173 <<
" at:" << mesh_.faceCentres()[facei]
174 <<
" patch:" << mesh_.boundaryMesh().whichPatch(facei)
175 <<
" isElem:" << isElem[facei]
176 <<
" isElem2:" << isElem2[facei]
185 for (
const label i : isElem)
196 void Foam::meshRefinement::calcNeighbourData
202 const labelList& cellLevel = meshCutter_.cellLevel();
203 const pointField& cellCentres = mesh_.cellCentres();
205 const label nBoundaryFaces = mesh_.nBoundaryFaces();
207 if (neiLevel.size() != nBoundaryFaces || neiCc.size() != nBoundaryFaces)
210 << nBoundaryFaces <<
" neiLevel:" << neiLevel.size()
214 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
226 label bFacei =
pp.start()-mesh_.nInternalFaces();
232 neiLevel[bFacei] = cellLevel[faceCells[i]];
233 neiCc[bFacei] = cellCentres[faceCells[i]];
237 else if (addedPatchIDSet.found(patchi))
249 label own = faceCells[i];
250 label ownLevel = cellLevel[own];
251 label faceLevel = meshCutter_.faceLevel(
pp.start()+i);
256 faceLevel = ownLevel;
260 scalar d = ((faceCentres[i] - cellCentres[own]) & fn);
261 if (faceLevel > ownLevel)
266 neiLevel[bFacei] = faceLevel;
268 neiCc[bFacei] = faceCentres[i] + d*fn;
276 neiLevel[bFacei] = cellLevel[faceCells[i]];
277 neiCc[bFacei] = faceCentres[i];
289 void Foam::meshRefinement::calcCellCellRays
299 const labelList& cellLevel = meshCutter_.cellLevel();
300 const pointField& cellCentres = mesh_.cellCentres();
305 bitSet isMaster(mesh_.nBoundaryFaces(),
true);
307 for (
const polyPatch&
pp : mesh_.boundaryMesh())
309 if (
pp.coupled() && !refCast<const coupledPolyPatch>(
pp).owner())
311 isMaster.
unset(labelRange(
pp.offset(),
pp.size()));
317 start.setSize(testFaces.size());
318 end.setSize(testFaces.size());
319 minLevel.setSize(testFaces.size());
323 const label facei = testFaces[i];
324 const label own = mesh_.faceOwner()[facei];
326 if (mesh_.isInternalFace(facei))
328 const label nei = mesh_.faceNeighbour()[facei];
330 start[i] = cellCentres[own];
331 end[i] = cellCentres[nei];
332 minLevel[i] =
min(cellLevel[own], cellLevel[nei]);
336 const label bFacei = facei - mesh_.nInternalFaces();
338 if (isMaster[bFacei])
340 start[i] = cellCentres[own];
341 end[i] = neiCc[bFacei];
346 start[i] = neiCc[bFacei];
347 end[i] = cellCentres[own];
349 minLevel[i] =
min(cellLevel[own], neiLevel[bFacei]);
368 const label nMasterFaces =
371 label nChangedFaces = 0;
374 if (isMasterFace.
test(changedFaces[i]))
383 Info<<
"Edge intersection testing:" <<
nl 384 <<
" Number of edges : " << nMasterFaces <<
nl 385 <<
" Number of edges to retest : " << nChangedFaces
392 labelList neiLevel(mesh_.nBoundaryFaces());
394 calcNeighbourData(neiLevel, neiCc);
417 surfaces_.findHigherIntersection
431 surfaceIndex_[changedFaces[i]] = surfaceHit[i];
442 Info<<
" Number of intersected edges : " << nTotHits <<
endl;
446 setInstance(mesh_.facesInstance());
450 void Foam::meshRefinement::nearestFace
490 List<topoDistanceData<label>> startData(startFaces.
size());
493 const label facei = startFaces[i];
497 <<
" at:" << mesh_.faceCentres()[facei]
500 startData[i] = topoDistanceData<label>(0, globalStart.toGlobal(i));
505 FaceCellWave<topoDistanceData<label>> deltaCalc
514 deltaCalc.iterate(nIter);
518 faceToStart.
setSize(mesh_.nFaces());
520 bool haveWarned =
false;
523 if (!faceData[facei].valid(deltaCalc.data()))
528 <<
"Did not visit some faces, e.g. face " << facei
529 <<
" at " << mesh_.faceCentres()[facei]
536 faceToStart[facei] = faceData[facei].
data();
541 List<Map<label>> compactMap;
542 mapPtr.
reset(
new mapDistribute(globalStart, faceToStart, compactMap));
546 void Foam::meshRefinement::nearestPatch
556 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
558 nearestZone.
setSize(mesh_.nFaces(), -1);
560 if (adaptPatchIDs.size())
562 nearestPatch.setSize(mesh_.nFaces(), adaptPatchIDs[0]);
566 labelList faceToZone(mesh_.nFaces(), -1);
568 for (
const faceZone& fz : mesh_.faceZones())
570 UIndirectList<label>(faceToZone, fz) = fz.index();
579 const polyPatch&
pp =
patches[adaptPatchIDs[i]];
584 List<topoDistanceData<labelPair>> cellData(mesh_.nCells());
585 List<topoDistanceData<labelPair>> faceData(mesh_.nFaces());
589 List<topoDistanceData<labelPair>> patchData(nFaces);
593 label patchi = adaptPatchIDs[i];
598 patchFaces[nFaces] =
pp.start()+i;
599 patchData[nFaces] = topoDistanceData<labelPair>
605 faceToZone[
pp.start()+i]
613 FaceCellWave<topoDistanceData<labelPair>> deltaCalc
620 mesh_.globalData().nTotalCells()+1
625 bool haveWarned =
false;
628 if (!faceData[facei].valid(deltaCalc.data()))
633 <<
"Did not visit some faces, e.g. face " << facei
634 <<
" at " << mesh_.faceCentres()[facei] <<
endl 635 <<
"Assigning these faces to patch " 644 nearestPatch[facei] = data.first();
645 nearestZone[facei] = data.second();
652 nearestPatch.setSize(mesh_.nFaces(), 0);
664 nearestPatch(adaptPatchIDs, nearestAdaptPatch, nearestAdaptZone);
665 return nearestAdaptPatch;
669 void Foam::meshRefinement::nearestIntersection
683 labelList neiLevel(mesh_.nBoundaryFaces());
685 calcNeighbourData(neiLevel, neiCc);
706 surfaces_.findNearestIntersection
725 const label defaultRegion
734 const labelList testFaces(intersectedFaces());
757 labelList nearestRegion(mesh_.nFaces(), defaultRegion);
768 label facei = testFaces[i];
769 if (surface1[i] != -1)
771 patchFaces.append(facei);
772 label regioni = surfaces_.globalRegion(surface1[i], region1[i]);
775 else if (surface2[i] != -1)
777 patchFaces.append(facei);
778 label regioni = surfaces_.globalRegion(surface2[i], region2[i]);
779 patchData.append(topoDistanceData<label>(0, regioni));
784 FaceCellWave<topoDistanceData<label>> deltaCalc
791 mesh_.globalData().nTotalCells()+1
796 bool haveWarned =
false;
799 if (!faceData[facei].valid(deltaCalc.data()))
804 <<
"Did not visit some faces, e.g. face " << facei
805 <<
" at " << mesh_.faceCentres()[facei] <<
endl 806 <<
"Assigning these faces to global region " 807 << defaultRegion <<
endl;
813 nearestRegion[facei] = faceData[facei].data();
817 return nearestRegion;
836 Pout<<
"Checking field " << msg <<
endl;
855 const scalar& minVal = minFld[pointi];
856 const scalar& maxVal = maxFld[pointi];
857 if (
mag(minVal-maxVal) > SMALL)
860 <<
" minFld:" << minVal <<
nl 861 <<
" maxFld:" << maxVal <<
nl 883 Pout<<
"Checking field " << msg <<
endl;
890 point(GREAT, GREAT, GREAT)
902 const point& minVal = minFld[pointi];
903 const point& maxVal = maxFld[pointi];
904 if (
mag(minVal-maxVal) > SMALL)
907 <<
" minFld:" << minVal <<
nl 908 <<
" maxFld:" << maxVal <<
nl 917 Pout<<
"meshRefinement::checkData() : Checking refinement structure." 919 meshCutter_.checkMesh();
921 Pout<<
"meshRefinement::checkData() : Checking refinement levels." 923 meshCutter_.checkRefinementLevels(1,
labelList(0));
926 const label nBnd = mesh_.nBoundaryFaces();
928 Pout<<
"meshRefinement::checkData() : Checking synchronization." 938 mesh_.nInternalFaces()
951 testSyncBoundaryFaceList
954 "testing faceCentres : ",
961 const labelList& surfIndex = surfaceIndex();
968 calcNeighbourData(neiLevel, neiCc);
976 start[facei] = mesh_.cellCentres()[mesh_.faceOwner()[facei]];
978 if (mesh_.isInternalFace(facei))
980 end[facei] = mesh_.cellCentres()[mesh_.faceNeighbour()[facei]];
984 end[facei] = neiCc[facei-mesh_.nInternalFaces()];
1000 surfaces_.findHigherIntersection
1017 mesh_.nInternalFaces()
1023 forAll(surfaceHit, facei)
1025 if (surfIndex[facei] != surfaceHit[facei])
1027 if (mesh_.isInternalFace(facei))
1030 <<
"Internal face:" << facei
1031 <<
" fc:" << mesh_.faceCentres()[facei]
1032 <<
" cached surfaceIndex_:" << surfIndex[facei]
1033 <<
" current:" << surfaceHit[facei]
1035 << mesh_.cellCentres()[mesh_.faceOwner()[facei]]
1037 << mesh_.cellCentres()[mesh_.faceNeighbour()[facei]]
1043 != neiHit[facei-mesh_.nInternalFaces()]
1047 <<
"Boundary face:" << facei
1048 <<
" fc:" << mesh_.faceCentres()[facei]
1049 <<
" cached surfaceIndex_:" << surfIndex[facei]
1050 <<
" current:" << surfaceHit[facei]
1052 << mesh_.cellCentres()[mesh_.faceOwner()[facei]]
1054 << neiCc[facei-mesh_.nInternalFaces()]
1055 <<
" end:" <<
end[facei]
1057 << meshCutter_.cellLevel()[mesh_.faceOwner()[facei]]
1059 << meshCutter_.faceLevel(facei)
1069 mesh_.nBoundaryFaces(),
1070 mesh_.nInternalFaces()
1073 labelList neiBoundarySurface(boundarySurface);
1081 testSyncBoundaryFaceList
1084 "testing surfaceIndex() : ",
1092 Pout<<
"meshRefinement::checkData() : Counting duplicate faces." 1100 identity(mesh_.nBoundaryFaces(), mesh_.nInternalFaces())
1110 if (duplicateFace[i] != -1)
1116 Pout<<
"meshRefinement::checkData() : Found " << nDup
1117 <<
" duplicate pairs of faces." <<
endl;
1124 meshCutter_.setInstance(inst);
1125 surfaceIndex_.instance() = inst;
1150 mesh_.moving(
false);
1157 mesh_.updateMesh(map);
1172 setInstance(mesh_.facesInstance());
1187 updateMesh(map, newExposedFaces);
1202 if (
split.find(-1) != -1)
1219 label fp =
split[0];
1249 const label facei = splitFaces[i];
1250 const auto&
split = splits[i];
1251 const auto& twoPatches = splitPatches[i];
1253 const face&
f = mesh_.faces()[facei];
1256 splitFace(
f,
split, f0, f1);
1259 label own = mesh_.faceOwner()[facei];
1263 if (facei >= mesh_.nInternalFaces())
1269 : mesh_.boundaryMesh().whichPatch(facei)
1275 : mesh_.boundaryMesh().whichPatch(facei)
1280 nei = mesh_.faceNeighbour()[facei];
1283 label zonei = mesh_.faceZones().whichZone(facei);
1284 bool zoneFlip =
false;
1287 const faceZone& fz = mesh_.faceZones()[zonei];
1294 Pout<<
"face:" << facei <<
" verts:" <<
f 1295 <<
" split into f0:" << f0
1296 <<
" f1:" << f1 <<
endl;
1359 <<
"Splitting " << nSplit
1360 <<
" faces across diagonals" <<
"." <<
nl <<
endl;
1372 meshMod.
faces().size()+splitFaces.
size(),
1377 doSplitFaces(splitFaces, splits, splitPatches, meshMod);
1381 mesh_.moving(
false);
1388 mesh_.updateMesh(map);
1402 setInstance(mesh_.facesInstance());
1418 label oldFacei = map.
faceMap()[facei];
1420 const auto oldFaceFnd = splitFaceToIndex.
cfind(oldFacei);
1422 if (oldFaceFnd.good())
1424 labelPair& twoFaces = facePairs[oldFaceFnd.val()];
1425 if (twoFaces[0] == -1)
1427 twoFaces[0] = facei;
1429 else if (twoFaces[1] == -1)
1431 twoFaces[1] = facei;
1436 <<
"problem: twoFaces:" << twoFaces
1447 if (duplicateFace.
size())
1461 baffle.
first() = oldToNewFaces[baffle.
first()];
1464 if (baffle.
first() == -1 || baffle.
second() == -1)
1467 <<
"Removed baffle : faces:" << baffle
1480 changedFaces.
append(facePairs[i].first());
1481 changedFaces.
append(facePairs[i].second());
1485 updateMesh(map, growFaceCellFace(changedFaces));
1498 for (label iteration = 0; iteration < 100; iteration++)
1501 <<
"Undo iteration " << iteration <<
nl 1502 <<
"----------------" <<
endl;
1508 faceSet errorFaces(mesh_,
"errorFaces", mesh_.nBoundaryFaces());
1524 const labelList grownFaces(growFaceCellFace(errorFaces));
1526 errorFaces.insert(grownFaces);
1540 const labelPair& twoFaces = facePairs[index];
1544 errorFaces.found(twoFaces.
first())
1545 || errorFaces.found(twoFaces.
second())
1548 const face& originalFace = originalFaces[index];
1552 label own = mesh_.faceOwner()[twoFaces[0]];
1555 if (twoFaces[0] >= mesh_.nInternalFaces())
1557 patchi = mesh_.boundaryMesh().whichPatch(twoFaces[0]);
1561 nei = mesh_.faceNeighbour()[twoFaces[0]];
1564 label zonei = mesh_.faceZones().whichZone(twoFaces[0]);
1565 bool zoneFlip =
false;
1568 const faceZone& fz = mesh_.faceZones()[zonei];
1585 meshMod.
removeFace(twoFaces[1], twoFaces[0]);
1587 mergedIndices.insert(index);
1593 Info<<
"Detected " <<
n 1594 <<
" split faces that will be restored to their original faces." 1608 mesh_.moving(
false);
1615 mesh_.updateMesh(map);
1629 setInstance(mesh_.facesInstance());
1645 const labelPair& oldSplit = facePairs[index];
1646 label new0 = oldToNewFaces[oldSplit[0]];
1647 label new1 = oldToNewFaces[oldSplit[1]];
1649 if (!mergedIndices.found(index))
1652 if (new0 < 0 || new1 < 0)
1655 <<
"Problem: oldFaces:" << oldSplit
1656 <<
" newFaces:" <<
labelPair(new0, new1)
1660 facePairs[newIndex] =
labelPair(new0, new1);
1664 originalFaces[index]
1671 if (new0 < 0 || new1 == -1)
1674 <<
"Problem: oldFaces:" << oldSplit
1678 changedFaces.
append(new0);
1682 facePairs.setSize(newIndex);
1683 originalFaces.
setSize(newIndex);
1687 updateMesh(map, growFaceCellFace(changedFaces));
1693 if (duplicateFace.
size())
1707 baffle.
first() = reverseFaceMap[baffle.
first()];
1710 if (baffle.
first() == -1 || baffle.
second() == -1)
1713 <<
"Removed baffle : faces:" << baffle
1727 Foam::meshRefinement::meshRefinement
1730 const scalar mergeDistance,
1731 const bool overwrite,
1742 mergeDistance_(mergeDistance),
1743 overwrite_(overwrite),
1744 oldInstance_(
mesh.pointsInstance()),
1745 surfaces_(surfaces),
1746 features_(features),
1748 limitShells_(limitShells),
1749 meshType_(meshType),
1761 mesh_.facesInstance(),
1781 if (surfaceIndex_.size() != mesh_.nFaces())
1788 return surfaceIndex_;
1794 if (surfaceIndex_.size() != mesh_.nFaces())
1796 updateIntersections(
identity(mesh_.nFaces()));
1798 return surfaceIndex_;
1809 const labelList& surfIndex = surfaceIndex();
1813 if (surfIndex[facei] >= 0 && isMasterFace.
test(facei))
1824 const bool keepZoneFaces,
1825 const bool keepBaffles,
1843 label nUnblocked = 0;
1857 specifiedProcessorFaces,
1863 if (keepZoneFaces || keepBaffles)
1883 const faceZone& fZone = fZones[zonei];
1887 label facei = fZone[i];
1888 if (blockedFace[facei])
1892 mesh_.isInternalFace(facei)
1896 blockedFace[facei] =
false;
1918 Info<<
"Found " << nUnblocked
1919 <<
" zoned faces to keep together." <<
endl;
1925 boolList separatedCoupledFace(mesh_.nFaces(),
false);
1926 selectSeparatedCoupledFaces(separatedCoupledFace);
1928 label nSeparated = 0;
1929 forAll(separatedCoupledFace, facei)
1931 if (separatedCoupledFace[facei])
1933 if (blockedFace[facei])
1935 blockedFace[facei] =
false;
1941 Info<<
"Found " << nSeparated
1942 <<
" separated coupled faces to keep together." <<
endl;
1944 nUnblocked += nSeparated;
1950 const label nBnd = mesh_.nBoundaryFaces();
1952 labelList coupledFace(mesh_.nFaces(), -1);
1970 const labelPair& baffle = allCouples[i];
1978 forAll(coupledFace, facei)
1980 if (coupledFace[facei] != -1 && facei < coupledFace[facei])
1982 couples[nCpl++] =
labelPair(facei, coupledFace[facei]);
1991 Info<<
"Found " << nCouples <<
" baffles to keep together." 2001 blockedFace[baffle.
first()] =
false;
2002 blockedFace[baffle.
second()] =
false;
2012 label nPointFaces = 0;
2013 for (
const label pointi : singleProcPoints)
2015 for (
const label facei : mesh_.pointFaces()[pointi])
2017 if (blockedFace[facei])
2021 mesh_.isInternalFace(facei)
2025 blockedFace[facei] =
false;
2032 Info<<
"Found " << nPointFaces
2033 <<
" additional point-coupled faces to keep together." <<
endl;
2035 nUnblocked += nPointFaces;
2044 specifiedProcessorFaces,
2052 Pout<<
"Wanted distribution:" << nProcCells <<
endl;
2056 Pout<<
"Wanted resulting decomposition:" <<
endl;
2057 forAll(nProcCells, proci)
2059 Pout<<
" " << proci <<
'\t' << nProcCells[proci] <<
endl;
2072 setInstance(mesh_.facesInstance());
2075 if (
debug && keepZoneFaces)
2083 const faceZone& fZone = fZones[zonei];
2087 label facei = fZone[i];
2093 <<
"Face at " << mesh_.faceCentres()[facei]
2094 <<
" on zone " << fZone.
name()
2095 <<
" is on coupled patch " <<
pbm[patchi].
name()
2109 label nBoundaryFaces = 0;
2111 const labelList& surfIndex = surfaceIndex();
2115 if (surfIndex[facei] != -1)
2126 if (surfIndex[facei] != -1)
2128 surfaceFaces[nBoundaryFaces++] = facei;
2131 return surfaceFaces;
2137 const faceList& faces = mesh_.faces();
2140 bitSet isBoundaryPoint(mesh_.nPoints());
2142 const labelList& surfIndex = surfaceIndex();
2146 if (surfIndex[facei] != -1)
2148 isBoundaryPoint.set(faces[facei]);
2171 return isBoundaryPoint.sortedToc();
2191 nFaces +=
pp.size();
2202 label meshFacei =
pp.start();
2206 addressing[nFaces++] = meshFacei++;
2231 pointPatches.
size(),
2232 slipPointPatchVectorField::typeName
2237 patchFieldTypes[adaptPatchIDs[i]] =
2238 fixedValuePointPatchVectorField::typeName;
2241 forAll(pointPatches, patchi)
2243 if (isA<processorPointPatch>(pointPatches[patchi]))
2245 patchFieldTypes[patchi] = calculatedPointPatchVectorField::typeName;
2247 else if (isA<cyclicPointPatch>(pointPatches[patchi]))
2249 patchFieldTypes[patchi] = cyclicSlipPointPatchVectorField::typeName;
2259 "pointDisplacement",
2293 <<
"faceZones are not synchronised on processors." <<
nl 2294 <<
"Processor " << proci <<
" has faceZones " 2295 << zoneNames[proci] <<
nl 2297 <<
" has faceZones " 2310 const faceZone& fZone = fZones[zonei];
2318 if (faceToZone[bFacei] == -1)
2320 faceToZone[bFacei] = zonei;
2322 else if (faceToZone[bFacei] == zonei)
2325 <<
"Face " << fZone[i] <<
" in zone " 2327 <<
" is twice in zone!" 2333 <<
"Face " << fZone[i] <<
" in zone " 2335 <<
" is also in zone " 2336 << fZones[faceToZone[bFacei]].
name()
2348 if (faceToZone[i] != neiFaceToZone[i])
2352 <<
" is in zone " << faceToZone[i]
2353 <<
", its coupled face is in zone " << neiFaceToZone[i]
2363 const bitSet& isMasterEdge,
2378 const edge&
e = edges[edgei];
2384 pts[meshPoints[
e[1]]]
2385 -
pts[meshPoints[
e[0]]]
2388 edgeWeights[edgei] = 1.0/eMag;
2404 forAll(invSumWeight, pointi)
2406 scalar w = invSumWeight[pointi];
2410 invSumWeight[pointi] = 1.0/w;
2419 const label insertPatchi,
2420 const word& patchName,
2432 const label patchi = polyPatches.
size();
2450 polyPatches[patchi],
2455 addPatchFields<volScalarField>
2460 addPatchFields<volVectorField>
2465 addPatchFields<volSphericalTensorField>
2470 addPatchFields<volSymmTensorField>
2475 addPatchFields<volTensorField>
2483 addPatchFields<surfaceScalarField>
2488 addPatchFields<surfaceVectorField>
2493 addPatchFields<surfaceSphericalTensorField>
2498 addPatchFields<surfaceSymmTensorField>
2503 addPatchFields<surfaceTensorField>
2515 const word& patchName,
2523 const label patchi = polyPatches.
findPatchID(patchName);
2531 label insertPatchi = polyPatches.
size();
2534 forAll(polyPatches, patchi)
2538 if (isA<processorPolyPatch>(
pp))
2540 insertPatchi = patchi;
2541 startFacei =
pp.start();
2547 patchDict.
set(
"nFaces", 0);
2548 patchDict.
set(
"startFace", startFacei);
2553 label addedPatchi = appendPatch(
mesh, insertPatchi, patchName, patchDict);
2559 for (label i = 0; i < insertPatchi; i++)
2564 for (label i = insertPatchi; i < addedPatchi; i++)
2569 oldToNew[addedPatchi] = insertPatchi;
2572 polyPatches.
reorder(oldToNew,
true);
2575 reorderPatchFields<volScalarField>(
mesh, oldToNew);
2576 reorderPatchFields<volVectorField>(
mesh, oldToNew);
2577 reorderPatchFields<volSphericalTensorField>(
mesh, oldToNew);
2578 reorderPatchFields<volSymmTensorField>(
mesh, oldToNew);
2579 reorderPatchFields<volTensorField>(
mesh, oldToNew);
2580 reorderPatchFields<surfaceScalarField>(
mesh, oldToNew);
2581 reorderPatchFields<surfaceVectorField>(
mesh, oldToNew);
2582 reorderPatchFields<surfaceSphericalTensorField>(
mesh, oldToNew);
2583 reorderPatchFields<surfaceSymmTensorField>(
mesh, oldToNew);
2584 reorderPatchFields<surfaceTensorField>(
mesh, oldToNew);
2586 return insertPatchi;
2596 label meshedi = meshedPatches_.find(
name);
2601 return mesh_.boundaryMesh().findPatchID(
name);
2606 label patchi = addPatch(mesh_,
name, patchInfo);
2631 meshedPatches_.append(
name);
2634 faceToCoupledPatch_.clear();
2646 forAll(meshedPatches_, i)
2653 <<
"Problem : did not find patch " << meshedPatches_[i]
2670 const word& masterPatch,
2671 const word& slavePatch,
2683 faceZoneToMasterPatch_.insert(fzName, masterPatch);
2684 faceZoneToSlavePatch_.insert(fzName, slavePatch);
2685 faceZoneToType_.insert(fzName, fzType);
2694 label& masterPatchID,
2695 label& slavePatchID,
2701 if (!faceZoneToMasterPatch_.found(fzName))
2707 const word& masterName = faceZoneToMasterPatch_[fzName];
2710 const word& slaveName = faceZoneToSlavePatch_[fzName];
2713 fzType = faceZoneToType_[fzName];
2728 zoneI = pointZones.
size();
2747 const auto* cpp = isA<coupledPolyPatch>(
pp);
2749 if (cpp && (cpp->separated() || !cpp->parallel()))
2768 nEdgeFaces[edgei] = edgeFaces[edgei].
size();
2817 const vector& perturbVec,
2839 const vector& perturbVec,
2851 regioni = cellToRegion[celli];
2861 regioni = cellToRegion[celli];
2901 locationsOutsideMesh,
2910 label nSegments = 0;
2911 if (leakPath.segments().size())
2913 nSegments =
max(leakPath.segments())+1;
2915 reduce(nSegments, maxOp<label>());
2918 for (label segmenti : leakPath.segments())
2920 nElemsPerSegment[segmenti]++;
2922 segmentPoints.setSize(nElemsPerSegment.size());
2923 segmentDist.
setSize(nElemsPerSegment.size());
2924 forAll(nElemsPerSegment, i)
2926 segmentPoints[i].setSize(nElemsPerSegment[i]);
2927 segmentDist[i].
setSize(nElemsPerSegment[i]);
2929 nElemsPerSegment = 0;
2933 label segmenti = leakPath.segments()[elemi];
2936 label&
n = nElemsPerSegment[segmenti];
2939 dist[
n] = leakPath.distance()[elemi];
2944 PtrList<coordSet> allLeakPaths(segmentPoints.size());
2945 forAll(allLeakPaths, segmenti)
2959 ListListOps::combine<pointList>
2961 gatheredPts, accessOp<pointList>()
2966 ListListOps::combine<scalarList>
2968 gatheredDist, accessOp<scalarList>()
2992 List<scalarField> allLeakData(allLeakPaths.size());
2993 forAll(allLeakPaths, segmenti)
2995 allLeakData[segmenti] = allLeakPaths[segmenti].distance();
3003 (outputDir / allLeakPaths[0].
name())
3025 const vector& perturbVec,
3028 const label nRegions,
3032 const bool exitIfLeakPath,
3043 label regioni = findRegion
3051 insideRegions[i] = regioni;
3054 forAll(cellRegion, celli)
3056 if (cellRegion[celli] == regioni)
3058 insideCell.set(celli);
3067 forAll(locationsOutsideMesh, i)
3073 label regioni = findRegion
3078 locationsOutsideMesh[i]
3081 if (regioni == -1 && (indexi = insideRegions.find(regioni)) != -1)
3083 if (leakPathFormatter)
3091 locationsOutsideMesh,
3096 Info<<
"Dumped leak path to " << fName <<
endl;
3106 err <<
"Location in mesh " << locationsInMesh[indexi]
3107 <<
" is inside same mesh region " << regioni
3108 <<
" as one of the locations outside mesh " 3109 << locationsOutsideMesh <<
endl;
3122 forAll(insideCell, celli)
3124 if (!insideCell.test(celli))
3126 cellRegion[celli] = -1;
3129 else if (cellRegion[celli] == -1)
3145 const bool exitIfLeakPath,
3150 (void)mesh_.tetBasePtIs();
3155 boolList blockedFace(mesh_.nFaces(),
false);
3156 selectSeparatedCoupledFaces(blockedFace);
3160 label nRemove = findRegions
3163 vector::uniform(mergeDistance_),
3165 locationsOutsideMesh,
3179 forAll(cellRegion, celli)
3181 if (cellRegion[celli] == -1)
3183 cellsToRemove.append(celli);
3186 cellsToRemove.shrink();
3190 cellsToRemove.size(),
3196 if (nTotCellsToRemove > 0)
3198 label nCellsToKeep =
3199 mesh_.globalData().nTotalCells()
3200 - nTotCellsToRemove;
3202 Info<<
"Keeping all cells containing points " << locationsInMesh <<
endl 3203 <<
"Selected for keeping : " 3205 <<
" cells." <<
endl;
3223 label defaultPatch = 0;
3224 if (globalToMasterPatch.
size())
3226 defaultPatch = globalToMasterPatch[0];
3230 <<
"Removing non-reachable cells exposes " 3231 << nExposedFaces <<
" internal or coupled faces." <<
endl 3232 <<
" These get put into patch " << defaultPatch <<
endl;
3233 exposedPatch.setSize(exposedFaces.
size(), defaultPatch);
3236 mapPtr = doRemoveCells
3255 meshCutter_.distribute(map);
3262 faceToCoupledPatch_.clear();
3289 geometry[i].distribute
3300 geometry[i].instance() = geometry[i].time().timeName();
3318 updateMesh(map, changedFaces, dummyMap, dummyMap, dummyMap);
3330 meshCutter_.storeData
3351 meshCutter_.updateMesh
3360 updateList(map.
faceMap(), label(-1), surfaceIndex_);
3364 Map<label> newFaceToPatch(faceToCoupledPatch_.size());
3371 newFaceToPatch.insert(newFacei, iter.val());
3374 faceToCoupledPatch_.
transfer(newFaceToPatch);
3379 updateIntersections(changedFaces);
3384 labelList& data = userFaceData_[i].second();
3386 if (userFaceData_[i].first() == KEEPALL)
3389 updateList(map.
faceMap(), label(-1), data);
3391 else if (userFaceData_[i].first() == MASTERONLY)
3396 forAll(newFaceData, facei)
3398 label oldFacei = map.
faceMap()[facei];
3402 newFaceData[facei] = data[oldFacei];
3418 label oldFacei = map.
faceMap()[facei];
3422 if (reverseFaceMap[oldFacei] != facei)
3425 reverseFaceMap[oldFacei] = -1;
3432 forAll(newFaceData, facei)
3434 label oldFacei = map.
faceMap()[facei];
3438 if (reverseFaceMap[oldFacei] == facei)
3440 newFaceData[facei] = data[oldFacei];
3452 bool writeOk = mesh_.write();
3469 s.instance() !=
s.time().system()
3470 &&
s.instance() !=
s.time().caseSystem()
3471 &&
s.instance() !=
s.time().constant()
3472 &&
s.instance() !=
s.time().caseConstant()
3476 s.instance() =
s.time().timeName();
3477 writeOk = writeOk &&
s.write();
3509 bitSet isPatchMasterPoint(meshPoints.
size());
3510 forAll(meshPoints, pointi)
3512 if (myPoints[pointi] ==
globalPoints.toGlobal(myProci, pointi))
3514 isPatchMasterPoint.set(pointi);
3518 return isPatchMasterPoint;
3549 if (myEdges[edgei] == globalEdges.toGlobal(myProci, edgei))
3551 isMasterEdge.
set(edgei);
3555 return isMasterEdge;
3563 const bool printCellLevel
3572 <<
" : cells(local):" << mesh_.nCells()
3573 <<
" faces(local):" << mesh_.nFaces()
3574 <<
" points(local):" << mesh_.nPoints()
3580 label nMasterFaces = isMasterFace.
count();
3583 label nMasterPoints = isMeshMasterPoint.
count();
3592 const scalar nIdealCells =
3596 mag(1.0-mesh_.nCells()/nIdealCells),
3599 Info<<
" unbalance:" << unbalance;
3606 const labelList& cellLevel = meshCutter_.cellLevel();
3612 nCells[cellLevel[celli]]++;
3620 Info<<
"Cells per refinement level:" <<
endl;
3623 Info<<
" " << leveli <<
'\t' << nCells[leveli]
3633 if (overwrite_ && mesh_.time().timeIndex() == 0)
3635 return oldInstance_;
3638 return mesh_.time().timeName();
3652 mesh_.time().timeName(),
3663 const labelList& cellLevel = meshCutter_.cellLevel();
3665 forAll(volRefLevel, celli)
3667 volRefLevel[celli] = cellLevel[celli];
3670 volRefLevel.write();
3682 mesh_.time().timeName(),
3692 const labelList& pointLevel = meshCutter_.pointLevel();
3694 forAll(pointRefLevel, pointi)
3696 pointRefLevel[pointi] = pointLevel[pointi];
3699 pointRefLevel.write();
3707 OFstream str(prefix +
"_edges.obj");
3709 Pout<<
"meshRefinement::dumpIntersections :" 3710 <<
" Writing cellcentre-cellcentre intersections to file " 3718 labelList neiLevel(mesh_.nBoundaryFaces());
3720 calcNeighbourData(neiLevel, neiCc);
3722 labelList intersectionFaces(intersectedFaces());
3744 surfaces_.findAnyIntersection
3752 forAll(intersectionFaces, i)
3754 if (surfaceHit[i] != -1)
3762 str <<
"l " << verti-2 <<
' ' << verti-1 <<
nl 3763 <<
"l " << verti-1 <<
' ' << verti <<
nl;
3779 if (writeFlags & WRITEMESH)
3784 if (writeFlags && !(writeFlags & NOWRITEREFINEMENT))
3786 meshCutter_.write();
3789 (void)surfaceIndex();
3790 surfaceIndex_.write();
3793 if (writeFlags & WRITELEVELS)
3795 dumpRefinementLevel();
3798 if ((debugFlags & OBJINTERSECTIONS) && prefix.size())
3800 dumpIntersections(prefix);
3819 if (
exists(setsDir/
"surfaceIndex"))
3821 rm(setsDir/
"surfaceIndex");
3837 writeLevel_ = flags;
3856 const word& keyword,
3866 <<
"Entry '" << keyword
3867 <<
"' not found (or not a dictionary) in dictionary " 3888 const word& keyword,
3898 <<
"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)
MeshType
Enumeration for how to operate.
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.
T * data() noexcept
Return pointer to the underlying array serving as data storage.
label splitFacesUndo(const labelList &splitFaces, const labelPairList &splits, const labelPairList &splitPatches, const dictionary &motionDict, labelList &duplicateFace, List< labelPair > &baffles)
Split faces along diagonal. Maintain mesh quality. Return.
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.
static const Enum< MeshType > MeshTypeNames
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.
void resize_nocopy(const label len)
Adjust allocated size of list without necessarily.
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 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.
void doSplitFaces(const labelList &splitFaces, const labelPairList &splits, const labelPairList &splitPatches, polyTopoChange &meshMod) const
Split faces into two.
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.
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.
autoPtr< mapDistributePolyMesh > balance(const bool keepZoneFaces, const bool keepBaffles, const labelList &singleProcPoints, const scalarField &cellWeights, decompositionMethod &decomposer, fvMeshDistribute &distributor)
Redecompose according to cell count.
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)
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.
static void splitFace(const face &f, const labelPair &split, face &f0, face &f1)
Helper: split face into:
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)
bool returnReduceOr(const bool value, const label comm=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
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)