Go to the documentation of this file.
37 #include "indirectPrimitivePatch.H"
130 const labelList& cellLevel = meshCutter_.cellLevel();
131 const pointField& cellCentres = mesh_.cellCentres();
133 label nBoundaryFaces = mesh_.nFaces() - mesh_.nInternalFaces();
135 if (neiLevel.
size() != nBoundaryFaces || neiCc.size() != nBoundaryFaces)
138 << nBoundaryFaces <<
" neiLevel:" << neiLevel.
size()
154 label bFaceI = pp.
start()-mesh_.nInternalFaces();
160 neiLevel[bFaceI] = cellLevel[faceCells[i]];
161 neiCc[bFaceI] = cellCentres[faceCells[i]];
165 else if (addedPatchIDSet.
found(patchI))
176 fn /=
mag(fn)+VSMALL;
178 label own = faceCells[i];
179 label ownLevel = cellLevel[own];
180 label faceLevel = meshCutter_.faceLevel(pp.
start()+i);
185 faceLevel = ownLevel;
189 scalar d = ((faceCentres[i] - cellCentres[own]) & fn);
190 if (faceLevel > ownLevel)
195 neiLevel[bFaceI] = faceLevel;
197 neiCc[bFaceI] = faceCentres[i] + d*fn;
205 neiLevel[bFaceI] = cellLevel[faceCells[i]];
206 neiCc[bFaceI] = faceCentres[i];
213 syncTools::swapBoundaryFacePositions(mesh_, neiCc);
214 syncTools::swapBoundaryFaceList(mesh_, neiLevel);
228 const labelList& cellLevel = meshCutter_.cellLevel();
229 const pointField& cellCentres = mesh_.cellCentres();
231 start.setSize(testFaces.
size());
232 end.setSize(testFaces.
size());
237 label faceI = testFaces[i];
238 label own = mesh_.faceOwner()[faceI];
240 if (mesh_.isInternalFace(faceI))
242 label nei = mesh_.faceNeighbour()[faceI];
244 start[i] = cellCentres[own];
245 end[i] = cellCentres[nei];
246 minLevel[i] =
min(cellLevel[own], cellLevel[nei]);
250 label bFaceI = faceI - mesh_.nInternalFaces();
252 start[i] = cellCentres[own];
253 end[i] = neiCc[bFaceI];
254 minLevel[i] =
min(cellLevel[own], neiLevel[bFaceI]);
277 label nMasterFaces = 0;
278 forAll(isMasterFace, faceI)
280 if (isMasterFace.
get(faceI) == 1)
287 label nChangedFaces = 0;
290 if (isMasterFace.
get(changedFaces[i]) == 1)
297 Info<<
"Edge intersection testing:" <<
nl
298 <<
" Number of edges : " << nMasterFaces <<
nl
299 <<
" Number of edges to retest : " << nChangedFaces
315 label faceI = changedFaces[i];
318 start[i] = cellCentres[own];
365 Info<<
" Number of intersected edges : " << nTotHits <<
endl;
387 Pout<<
"Checking field " << msg <<
endl;
406 const scalar& minVal = minFld[pointI];
407 const scalar& maxVal = maxFld[pointI];
408 if (
mag(minVal-maxVal) > SMALL)
411 <<
" minFld:" << minVal <<
nl
412 <<
" maxFld:" << maxVal <<
nl
434 Pout<<
"Checking field " << msg <<
endl;
441 point(GREAT, GREAT, GREAT)
453 const point& minVal = minFld[pointI];
454 const point& maxVal = maxFld[pointI];
455 if (
mag(minVal-maxVal) > SMALL)
458 <<
" minFld:" << minVal <<
nl
459 <<
" maxFld:" << maxVal <<
nl
468 Pout<<
"meshRefinement::checkData() : Checking refinement structure."
470 meshCutter_.checkMesh();
472 Pout<<
"meshRefinement::checkData() : Checking refinement levels."
474 meshCutter_.checkRefinementLevels(1,
labelList(0));
477 label nBnd = mesh_.nFaces()-mesh_.nInternalFaces();
479 Pout<<
"meshRefinement::checkData() : Checking synchronization."
485 pointField::subList boundaryFc
489 mesh_.nInternalFaces()
502 testSyncBoundaryFaceList
505 "testing faceCentres : ",
515 calcNeighbourData(neiLevel, neiCc);
523 start[faceI] = mesh_.cellCentres()[mesh_.faceOwner()[faceI]];
525 if (mesh_.isInternalFace(faceI))
527 end[faceI] = mesh_.cellCentres()[mesh_.faceNeighbour()[faceI]];
531 end[faceI] = neiCc[faceI-mesh_.nInternalFaces()];
547 surfaces_.findHigherIntersection
564 mesh_.nInternalFaces()
572 if (surfaceIndex_[faceI] != surfaceHit[faceI])
574 if (mesh_.isInternalFace(faceI))
577 <<
"Internal face:" << faceI
578 <<
" fc:" << mesh_.faceCentres()[faceI]
579 <<
" cached surfaceIndex_:" << surfaceIndex_[faceI]
580 <<
" current:" << surfaceHit[faceI]
582 << mesh_.cellCentres()[mesh_.faceOwner()[faceI]]
584 << mesh_.cellCentres()[mesh_.faceNeighbour()[faceI]]
590 != neiHit[faceI-mesh_.nInternalFaces()]
594 <<
"Boundary face:" << faceI
595 <<
" fc:" << mesh_.faceCentres()[faceI]
596 <<
" cached surfaceIndex_:" << surfaceIndex_[faceI]
597 <<
" current:" << surfaceHit[faceI]
599 << mesh_.cellCentres()[mesh_.faceOwner()[faceI]]
601 << neiCc[faceI-mesh_.nInternalFaces()]
602 <<
" end:" << end[faceI]
604 << meshCutter_.cellLevel()[mesh_.faceOwner()[faceI]]
606 << meshCutter_.faceLevel(faceI)
616 mesh_.nFaces()-mesh_.nInternalFaces(),
617 mesh_.nInternalFaces()
620 labelList neiBoundarySurface(boundarySurface);
628 testSyncBoundaryFaceList
631 "testing surfaceIndex() : ",
639 Pout<<
"meshRefinement::checkData() : Counting duplicate faces."
647 identity(mesh_.nFaces()-mesh_.nInternalFaces())
648 + mesh_.nInternalFaces()
658 if (duplicateFace[i] != -1)
664 Pout<<
"meshRefinement::checkData() : Found " << nDup
665 <<
" duplicate pairs of faces." <<
endl;
672 meshCutter_.setInstance(inst);
673 surfaceIndex_.instance() = inst;
702 mesh_.updateMesh(map);
705 if (map().hasMotionPoints())
707 mesh_.movePoints(map().preMotionPoints());
717 setInstance(mesh_.facesInstance());
725 map().reverseFaceMap(),
732 updateMesh(map, newExposedFaces);
749 label faceI = splitFaces[i];
750 const face&
f = mesh_.faces()[faceI];
755 label nVerts = split[1]-split[0];
783 label own = mesh_.faceOwner()[faceI];
786 if (faceI >= mesh_.nInternalFaces())
788 patchI = mesh_.boundaryMesh().whichPatch(faceI);
792 nei = mesh_.faceNeighbour()[faceI];
795 label zoneI = mesh_.faceZones().whichZone(faceI);
796 bool zoneFlip =
false;
799 const faceZone& fz = mesh_.faceZones()[zoneI];
866 <<
"Splitting " << nSplit
867 <<
" faces across diagonals" <<
"." <<
nl <<
endl;
879 meshMod.
faces().size()+splitFaces.
size(),
884 doSplitFaces(splitFaces, splits, meshMod);
890 mesh_.updateMesh(map);
893 if (map().hasMotionPoints())
895 mesh_.movePoints(map().preMotionPoints());
900 setInstance(mesh_.facesInstance());
915 splitFaceToIndex.insert(splitFaces[i], i);
920 label oldFaceI = map().faceMap()[faceI];
925 if (oldFaceFnd != splitFaceToIndex.end())
927 labelPair& twoFaces = facePairs[oldFaceFnd()];
928 if (twoFaces[0] == -1)
932 else if (twoFaces[1] == -1)
939 <<
"problem: twoFaces:" << twoFaces
950 if (duplicateFace.
size())
960 const labelList& oldToNewFaces = map().reverseFaceMap();
964 baffle.
first() = oldToNewFaces[baffle.
first()];
970 <<
"Removed baffle : faces:" << baffle
983 changedFaces.
append(facePairs[i].first());
984 changedFaces.
append(facePairs[i].second());
988 updateMesh(map, growFaceCellFace(changedFaces));
1001 for (
label iteration = 0; iteration < 100; iteration++)
1004 <<
"Undo iteration " << iteration <<
nl
1005 <<
"----------------" <<
endl;
1015 mesh_.nFaces()-mesh_.nInternalFaces()
1031 const labelList grownFaces(growFaceCellFace(errorFaces));
1033 errorFaces.
insert(grownFaces);
1047 const labelPair& twoFaces = facePairs[index];
1055 const face& originalFace = originalFaces[index];
1059 label own = mesh_.faceOwner()[twoFaces[0]];
1062 if (twoFaces[0] >= mesh_.nInternalFaces())
1064 patchI = mesh_.boundaryMesh().whichPatch(twoFaces[0]);
1068 nei = mesh_.faceNeighbour()[twoFaces[0]];
1071 label zoneI = mesh_.faceZones().whichZone(twoFaces[0]);
1072 bool zoneFlip =
false;
1075 const faceZone& fz = mesh_.faceZones()[zoneI];
1092 meshMod.
removeFace(twoFaces[1], twoFaces[0]);
1094 mergedIndices.
insert(index);
1100 Info<<
"Detected " <<
n
1101 <<
" split faces that will be restored to their original faces."
1117 mesh_.updateMesh(map);
1120 if (map().hasMotionPoints())
1122 mesh_.movePoints(map().preMotionPoints());
1127 setInstance(mesh_.facesInstance());
1134 const labelList& oldToNewFaces = map().reverseFaceMap();
1135 const labelList& oldToNewPoints = map().reversePointMap();
1143 const labelPair& oldSplit = facePairs[index];
1144 label new0 = oldToNewFaces[oldSplit[0]];
1145 label new1 = oldToNewFaces[oldSplit[1]];
1147 if (!mergedIndices.
found(index))
1150 if (new0 < 0 || new1 < 0)
1153 <<
"Problem: oldFaces:" << oldSplit
1154 <<
" newFaces:" <<
labelPair(new0, new1)
1158 facePairs[newIndex] =
labelPair(new0, new1);
1162 originalFaces[index]
1169 if (new0 < 0 || new1 == -1)
1172 <<
"Problem: oldFaces:" << oldSplit
1176 changedFaces.
append(new0);
1181 originalFaces.
setSize(newIndex);
1185 updateMesh(map, growFaceCellFace(changedFaces));
1191 if (duplicateFace.
size())
1201 const labelList& reverseFaceMap = map().reverseFaceMap();
1205 baffle.
first() = reverseFaceMap[baffle.
first()];
1208 if (baffle.
first() == -1 || baffle.
second() == -1)
1211 <<
"Removed baffle : faces:" << baffle
1229 const scalar mergeDistance,
1230 const bool overwrite,
1238 mergeDistance_(mergeDistance),
1239 overwrite_(overwrite),
1241 surfaces_(surfaces),
1242 features_(features),
1244 limitShells_(limitShells),
1255 mesh_.facesInstance(),
1267 updateIntersections(
identity(mesh_.nFaces()));
1280 forAll(surfaceIndex_, faceI)
1282 if (surfaceIndex_[faceI] >= 0 && isMasterFace.
get(faceI) == 1)
1293 const bool keepZoneFaces,
1294 const bool keepBaffles,
1316 label nUnblocked = 0;
1330 specifiedProcessorFaces,
1336 if (keepZoneFaces || keepBaffles)
1356 const faceZone& fZone = fZones[zoneI];
1360 label faceI = fZone[i];
1361 if (blockedFace[faceI])
1365 mesh_.isInternalFace(faceI)
1369 blockedFace[faceI] =
false;
1391 Info<<
"Found " << nUnblocked
1392 <<
" zoned faces to keep together." <<
endl;
1398 boolList separatedCoupledFace(mesh_.nFaces(),
false);
1399 selectSeparatedCoupledFaces(separatedCoupledFace);
1401 label nSeparated = 0;
1402 forAll(separatedCoupledFace, faceI)
1404 if (separatedCoupledFace[faceI])
1406 if (blockedFace[faceI])
1408 blockedFace[faceI] =
false;
1414 Info<<
"Found " << nSeparated
1415 <<
" separated coupled faces to keep together." <<
endl;
1417 nUnblocked += nSeparated;
1423 label nBnd = mesh_.nFaces()-mesh_.nInternalFaces();
1425 labelList coupledFace(mesh_.nFaces(), -1);
1443 const labelPair& baffle = allCouples[i];
1451 forAll(coupledFace, faceI)
1453 if (coupledFace[faceI] != -1 && faceI < coupledFace[faceI])
1455 couples[nCpl++] =
labelPair(faceI, coupledFace[faceI]);
1464 Info<<
"Found " << nCouples <<
" baffles to keep together."
1474 blockedFace[baffle.
first()] =
false;
1475 blockedFace[baffle.
second()] =
false;
1483 specifiedProcessorFaces,
1491 Pout<<
"Wanted distribution:" << nProcCells <<
endl;
1496 Pout<<
"Wanted resulting decomposition:" <<
endl;
1497 forAll(nProcCells, procI)
1499 Pout<<
" " << procI <<
'\t' << nProcCells[procI] <<
endl;
1512 const faceZone& fZone = fZones[zoneI];
1516 label faceI = fZone[i];
1519 if (patchI >= 0 && pbm[patchI].coupled())
1522 <<
"Face at " << mesh_.faceCentres()[faceI]
1523 <<
" on zone " << fZone.
name()
1524 <<
" is on coupled patch " << pbm[patchI].
name()
1540 setInstance(mesh_.facesInstance());
1550 label nBoundaryFaces = 0;
1552 forAll(surfaceIndex_, faceI)
1554 if (surfaceIndex_[faceI] != -1)
1563 forAll(surfaceIndex_, faceI)
1565 if (surfaceIndex_[faceI] != -1)
1567 surfaceFaces[nBoundaryFaces++] = faceI;
1570 return surfaceFaces;
1577 const faceList& faces = mesh_.faces();
1581 label nBoundaryPoints = 0;
1583 forAll(surfaceIndex_, faceI)
1585 if (surfaceIndex_[faceI] != -1)
1587 const face&
f = faces[faceI];
1591 if (isBoundaryPoint.
set(
f[fp], 1u))
1628 labelList boundaryPoints(nBoundaryPoints);
1629 nBoundaryPoints = 0;
1630 forAll(isBoundaryPoint, pointI)
1632 if (isBoundaryPoint.
get(pointI) == 1u)
1634 boundaryPoints[nBoundaryPoints++] = pointI;
1638 return boundaryPoints;
1658 nFaces += pp.size();
1673 addressing[nFaces++] = meshFaceI++;
1702 pointPatches.
size(),
1703 slipPointPatchVectorField::typeName
1708 patchFieldTypes[adaptPatchIDs[i]] =
1709 fixedValuePointPatchVectorField::typeName;
1712 forAll(pointPatches, patchI)
1714 if (isA<processorPointPatch>(pointPatches[patchI]))
1716 patchFieldTypes[patchI] = calculatedPointPatchVectorField::typeName;
1718 else if (isA<cyclicPointPatch>(pointPatches[patchI]))
1720 patchFieldTypes[patchI] = cyclicSlipPointPatchVectorField::typeName;
1732 "pointDisplacement",
1766 <<
"faceZones are not synchronised on processors." <<
nl
1767 <<
"Processor " << procI <<
" has faceZones "
1768 << zoneNames[procI] <<
nl
1770 <<
" has faceZones "
1784 const faceZone& fZone = fZones[zoneI];
1792 if (faceToZone[bFaceI] == -1)
1794 faceToZone[bFaceI] = zoneI;
1796 else if (faceToZone[bFaceI] == zoneI)
1799 <<
"Face " << fZone[i] <<
" in zone "
1801 <<
" is twice in zone!"
1807 <<
"Face " << fZone[i] <<
" in zone "
1809 <<
" is also in zone "
1810 << fZones[faceToZone[bFaceI]].name()
1822 if (faceToZone[i] != neiFaceToZone[i])
1826 <<
" is in zone " << faceToZone[i]
1827 <<
", its coupled face is in zone " << neiFaceToZone[i]
1847 edgeWeights.setSize(isMasterEdge.
size());
1848 invSumWeight.setSize(meshPoints.
size());
1852 const edge&
e = edges[edgeI];
1858 pts[meshPoints[
e[1]]]
1859 - pts[meshPoints[
e[0]]]
1862 edgeWeights[edgeI] = 1.0/eMag;
1878 forAll(invSumWeight, pointI)
1880 scalar
w = invSumWeight[pointI];
1884 invSumWeight[pointI] = 1.0/
w;
1893 const label insertPatchI,
1894 const word& patchName,
1908 polyPatches.
setSize(patchI+1);
1926 polyPatches[patchI],
1931 addPatchFields<volScalarField>
1936 addPatchFields<volVectorField>
1941 addPatchFields<volSphericalTensorField>
1946 addPatchFields<volSymmTensorField>
1951 addPatchFields<volTensorField>
1959 addPatchFields<surfaceScalarField>
1964 addPatchFields<surfaceVectorField>
1969 addPatchFields<surfaceSphericalTensorField>
1974 addPatchFields<surfaceSymmTensorField>
1979 addPatchFields<surfaceTensorField>
1992 const word& patchName,
2008 label insertPatchI = polyPatches.
size();
2011 forAll(polyPatches, patchI)
2013 const polyPatch& pp = polyPatches[patchI];
2015 if (isA<processorPolyPatch>(pp))
2017 insertPatchI = patchI;
2018 startFaceI = pp.
start();
2024 patchDict.
set(
"nFaces", 0);
2025 patchDict.
set(
"startFace", startFaceI);
2030 label addedPatchI = appendPatch(
mesh, insertPatchI, patchName, patchDict);
2036 for (
label i = 0; i < insertPatchI; i++)
2041 for (
label i = insertPatchI; i < addedPatchI; i++)
2046 oldToNew[addedPatchI] = insertPatchI;
2049 polyPatches.
reorder(oldToNew,
true);
2052 reorderPatchFields<volScalarField>(
mesh, oldToNew);
2053 reorderPatchFields<volVectorField>(
mesh, oldToNew);
2054 reorderPatchFields<volSphericalTensorField>(
mesh, oldToNew);
2055 reorderPatchFields<volSymmTensorField>(
mesh, oldToNew);
2056 reorderPatchFields<volTensorField>(
mesh, oldToNew);
2057 reorderPatchFields<surfaceScalarField>(
mesh, oldToNew);
2058 reorderPatchFields<surfaceVectorField>(
mesh, oldToNew);
2059 reorderPatchFields<surfaceSphericalTensorField>(
mesh, oldToNew);
2060 reorderPatchFields<surfaceSymmTensorField>(
mesh, oldToNew);
2061 reorderPatchFields<surfaceTensorField>(
mesh, oldToNew);
2063 return insertPatchI;
2078 return mesh_.boundaryMesh().findPatchID(
name);
2083 label patchI = addPatch(mesh_,
name, patchInfo);
2108 meshedPatches_.append(
name);
2111 faceToCoupledPatch_.clear();
2123 forAll(meshedPatches_, i)
2130 <<
"Problem : did not find patch " << meshedPatches_[i]
2131 <<
endl <<
"Valid patches are " <<
patches.names()
2147 const word& masterPatch,
2148 const word& slavePatch,
2160 faceZoneToMasterPatch_.insert(fzName, masterPatch);
2161 faceZoneToSlavePatch_.insert(fzName, slavePatch);
2162 faceZoneToType_.insert(fzName, fzType);
2171 label& masterPatchID,
2172 label& slavePatchID,
2178 if (!faceZoneToMasterPatch_.found(fzName))
2184 const word& masterName = faceZoneToMasterPatch_[fzName];
2187 const word& slaveName = faceZoneToSlavePatch_[fzName];
2190 fzType = faceZoneToType_[fzName];
2204 if (isA<coupledPolyPatch>(
patches[patchI]))
2215 selected[cpp.
start()+i] =
true;
2227 const vector& perturbVec,
2250 regionI = cellToRegion[cellI];
2260 regionI = cellToRegion[cellI];
2323 const vector& perturbVec,
2326 const label nRegions,
2334 labelList insideRegions(locationsInMesh.size());
2338 label regionI = findRegion
2346 insideRegions[i] = regionI;
2349 forAll(cellRegion, cellI)
2351 if (cellRegion[cellI] == regionI)
2353 insideCell[cellI] =
true;
2362 forAll(locationsOutsideMesh, i)
2365 label regionI = findRegion
2370 locationsOutsideMesh[i]
2381 <<
"Location in mesh " << locationsInMesh[index]
2382 <<
" is inside same mesh region " << regionI
2383 <<
" as location outside mesh "
2384 << locationsOutsideMesh[i]
2392 forAll(insideCell, cellI)
2394 if (!insideCell[cellI])
2396 cellRegion[cellI] = -1;
2411 (void)mesh_.tetBasePtIs();
2416 boolList blockedFace(mesh_.nFaces(),
false);
2417 selectSeparatedCoupledFaces(blockedFace);
2424 mergeDistance_*
vector(1,1,1),
2426 locationsOutsideMesh,
2436 forAll(cellRegion, cellI)
2438 if (cellRegion[cellI] == -1)
2440 cellsToRemove.
append(cellI);
2447 cellsToRemove.size(),
2453 if (nTotCellsToRemove > 0)
2455 label nCellsToKeep =
2456 mesh_.globalData().nTotalCells()
2457 - nTotCellsToRemove;
2459 Info<<
"Keeping all cells containing points " << locationsInMesh <<
endl
2460 <<
"Selected for keeping : "
2462 <<
" cells." <<
endl;
2480 label defaultPatch = 0;
2481 if (globalToMasterPatch.
size())
2483 defaultPatch = globalToMasterPatch[0];
2487 <<
"Removing non-reachable cells exposes "
2488 << nExposedFaces <<
" internal or coupled faces." <<
endl
2489 <<
" These get put into patch " << defaultPatch <<
endl;
2490 exposedPatch.
setSize(exposedFaces.
size(), defaultPatch);
2493 mapPtr = doRemoveCells
2512 meshCutter_.distribute(map);
2519 faceToCoupledPatch_.clear();
2545 geometry[i].distribute
2556 geometry[i].instance() = geometry[i].time().timeName();
2575 updateMesh(map, changedFaces, dummyMap, dummyMap, dummyMap);
2587 meshCutter_.storeData
2608 meshCutter_.updateMesh
2621 Map<label> newFaceToPatch(faceToCoupledPatch_.size());
2628 newFaceToPatch.insert(newFaceI, iter());
2631 faceToCoupledPatch_.transfer(newFaceToPatch);
2636 updateIntersections(changedFaces);
2643 if (userFaceData_[i].first() == KEEPALL)
2648 else if (userFaceData_[i].first() == MASTERONLY)
2653 forAll(newFaceData, faceI)
2659 newFaceData[faceI] =
data[oldFaceI];
2679 if (reverseFaceMap[oldFaceI] != faceI)
2682 reverseFaceMap[oldFaceI] = -1;
2689 forAll(newFaceData, faceI)
2695 if (reverseFaceMap[oldFaceI] == faceI)
2697 newFaceData[faceI] =
data[oldFaceI];
2711 && meshCutter_.write()
2712 && surfaceIndex_.write();
2730 s.instance() !=
s.time().system()
2731 &&
s.instance() !=
s.time().caseSystem()
2732 &&
s.instance() !=
s.time().constant()
2733 &&
s.instance() !=
s.time().caseConstant()
2737 s.instance() =
s.time().timeName();
2738 writeOk = writeOk &&
s.write();
2755 forAll(meshPoints, pointI)
2771 forAll(meshPoints, pointI)
2775 isPatchMasterPoint[pointI] =
true;
2779 return isPatchMasterPoint;
2794 myEdges[edgeI] = globalEdges.
toGlobal(edgeI);
2810 if (myEdges[edgeI] == globalEdges.
toGlobal(edgeI))
2812 isMasterEdge[edgeI] =
true;
2816 return isMasterEdge;
2828 <<
" : cells(local):" << mesh_.nCells()
2829 <<
" faces(local):" << mesh_.nFaces()
2830 <<
" points(local):" << mesh_.nPoints()
2836 label nMasterFaces = 0;
2839 if (isMasterFace[i])
2846 label nMasterPoints = 0;
2847 forAll(isMeshMasterPoint, i)
2849 if (isMeshMasterPoint[i])
2865 const labelList& cellLevel = meshCutter_.cellLevel();
2871 nCells[cellLevel[cellI]]++;
2877 Info<<
"Cells per refinement level:" <<
endl;
2880 Info<<
" " << levelI <<
'\t' << nCells[levelI]
2890 if (overwrite_ && mesh_.time().timeIndex() == 0)
2892 return oldInstance_;
2896 return mesh_.time().timeName();
2911 mesh_.time().timeName(),
2919 zeroGradientFvPatchScalarField::typeName
2922 const labelList& cellLevel = meshCutter_.cellLevel();
2924 forAll(volRefLevel, cellI)
2926 volRefLevel[cellI] = cellLevel[cellI];
2929 volRefLevel.write();
2941 mesh_.time().timeName(),
2951 const labelList& pointLevel = meshCutter_.pointLevel();
2953 forAll(pointRefLevel, pointI)
2955 pointRefLevel[pointI] = pointLevel[pointI];
2958 pointRefLevel.write();
2966 const pointField& cellCentres = mesh_.cellCentres();
2968 OFstream str(prefix +
"_edges.obj");
2970 Pout<<
"meshRefinement::dumpIntersections :"
2971 <<
" Writing cellcentre-cellcentre intersections to file "
2979 labelList neiLevel(mesh_.nFaces()-mesh_.nInternalFaces());
2980 pointField neiCc(mesh_.nFaces()-mesh_.nInternalFaces());
2981 calcNeighbourData(neiLevel, neiCc);
2983 labelList intersectionFaces(intersectedFaces());
2989 forAll(intersectionFaces, i)
2991 label faceI = intersectionFaces[i];
2992 start[i] = cellCentres[mesh_.faceOwner()[faceI]];
2994 if (mesh_.isInternalFace(faceI))
2996 end[i] = cellCentres[mesh_.faceNeighbour()[faceI]];
3000 end[i] = neiCc[faceI-mesh_.nInternalFaces()];
3006 const vectorField smallVec(ROOTSMALL*(end-start));
3015 surfaces_.findAnyIntersection
3023 forAll(intersectionFaces, i)
3025 if (surfaceHit[i] != -1)
3033 str <<
"l " << vertI-2 <<
' ' << vertI-1 <<
nl
3034 <<
"l " << vertI-1 <<
' ' << vertI <<
nl;
3050 if (writeFlags & WRITEMESH)
3054 if (writeFlags & WRITELEVELS)
3056 dumpRefinementLevel();
3058 if (debugFlags & OBJINTERSECTIONS && prefix.size())
3060 dumpIntersections(prefix);
3073 writeLevel_ = flags;
3079 return outputLevel_;
3085 outputLevel_ = flags;
static writeType writeLevel_
Control of writing level.
static labelList countCells(const labelList &)
Helper function: count cells per processor in wanted distribution.
Simple random number generator.
virtual const pointField & points() const
Return raw points.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Accumulating histogram of values. Specified bin resolution automatic generation of bins.
const pointBoundaryMesh & boundary() const
Return reference to boundary mesh.
const dimensionSet dimless(0, 0, 0, 0, 0, 0, 0)
Calculates points shared by more than two processor patches or cyclic patches.
volScalarField w(IOobject("w", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE), mesh, dimensionedScalar("w", dimensionSet(0, 0, 0, 0, 0, 0, 0), 0.0))
faceZoneType
What to do with faceZone faces.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
void dumpIntersections(const fileName &prefix) const
Debug: Write intersection information to OBJ format.
label findPatchID(const word &patchName) const
Find patch index given a name.
static void findRegions(const polyMesh &, const vector &perturbVec, const pointField &locationsInMesh, const pointField &locationsOutsideMesh, const label nRegions, labelList &cellRegion)
A class for handling words, derived from string.
A class for handling file names.
void calcCellCellRays(const pointField &neiCc, const labelList &neiLevel, const labelList &testFaces, pointField &start, pointField &end, labelList &minLevel) const
Calculate rays from cell-centre to cell-centre and corresponding.
List< label > labelList
A List of labels.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
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.
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
#define forAll(list, i)
Loop across all elements in list.
A class for managing temporary objects.
labelList intersectedPoints() const
Get points on surfaces with intersection and boundary faces.
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurence of given element and return index,.
IOoutputType
Enumeration for what to output.
Given list of cells to remove insert all the topology changes.
autoPtr< mapPolyMesh > changeMesh(polyMesh &mesh, const bool inflate, const bool syncParallel=true, const bool orderCells=false, const bool orderPoints=false)
Inplace changes mesh without change of patches.
const DynamicList< point > & points() const
Points. Shrunk after constructing mesh (or calling of compact())
const labelList & tetBasePtIs() const
Return the tetBasePtIs.
static void scatterList(const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
Scatter data. Reverse of gatherList.
A List obtained as a section of another List.
static const label labelMax
static label nProcs(const label communicator=0)
Number of processes in parallel run.
void set(const PackedList< 1 > &)
Set specified bits.
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.
Standard boundBox + extra functionality for use in octree.
static writeType writeLevel()
Get/set write level.
labelList intersectedFaces() const
Get faces with intersection.
virtual bool coupled() const
Return true if this patch is geometrically coupled (i.e. faces and.
void modifyFace(const face &f, const label faceI, const label own, const label nei, const bool flipFaceFlux, const label patchID, const label zoneID, const bool zoneFlip)
Modify vertices or cell of face.
void printMeshInfo(const bool, const string &) const
Print some mesh stats.
label addFaceZone(const word &fzName, const word &masterPatch, const word &slavePatch, const surfaceZonesInfo::faceZoneType &fzType)
Add/lookup faceZone and update information. Return index of.
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
static bool & parRun()
Is this a parallel run?
Direct mesh changes based on v1.3 polyTopoChange syntax.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
label countHits() const
Count number of intersections (local)
static autoPtr< fvPatch > New(const polyPatch &, const fvBoundaryMesh &)
Return a pointer to a new patch created on freestore from polyPatch.
label nTotalCells() const
Return total number of cells in decomposed mesh.
const Type & first() const
Return first.
void findHigherIntersection(const shellSurfaces &shells, const pointField &start, const pointField &end, const labelList ¤tLevel, labelList &surfaces, labelList &surfaceLevel) const
Find intersection of edge. Return -1 or first surface.
IOdebugType
Enumeration for what to debug.
const fileName & facesInstance() const
Return the current instance directory for faces.
void updateMesh(const mapPolyMesh &)
Force recalculation of locally stored data on topological change.
static const NamedEnum< IOoutputType, 1 > IOoutputTypeNames
static label appendPatch(fvMesh &, const label insertPatchI, const word &, const dictionary &)
Helper:append patch to end of mesh.
label splitFacesUndo(const labelList &splitFaces, const labelPairList &splits, const dictionary &motionDict, labelList &duplicateFace, List< labelPair > &baffles)
Split faces along diagonal. Maintain mesh quality. Return.
static const NamedEnum< IOwriteType, 4 > IOwriteTypeNames
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Ostream & endl(Ostream &os)
Add newline and flush stream.
The coupledPolyPatch is an abstract base class for patches that couple regions of the computational d...
void reorder(const labelUList &, const bool validBoundary)
Reorders patches. Ordering does not have to be done in.
static void calculateEdgeWeights(const polyMesh &mesh, const PackedBoolList &isMasterEdge, const labelList &meshPoints, const edgeList &edges, scalarField &edgeWeights, scalarField &invSumWeight)
Helper: calculate edge weights (1/length)
IOwriteType
Enumeration for what to write.
dimensioned< scalar > mag(const dimensioned< Type > &)
static label addPatch(fvMesh &, const word &name, const dictionary &)
Helper:add patch to mesh. Update all registered fields.
void doSplitFaces(const labelList &splitFaces, const labelPairList &splits, polyTopoChange &meshMod) const
Split faces into two.
List< treeBoundBox > meshBb(1, treeBoundBox(boundBox(coarseMesh.points(), false)).extend(rndGen, 1e-3))
Mesh consisting of general polyhedral cells.
static void updateList(const labelList &newToOld, const T &nullValue, List< T > &elems)
Helper: reorder list according to map.
static const pointMesh & New(const polyMesh &mesh)
static const NamedEnum< IOdebugType, 5 > IOdebugTypeNames
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
const faceZoneMesh & faceZones() const
Return face zone mesh.
void setCapacity(const label nPoints, const label nFaces, const label nCells)
Explicitly pre-size the dynamic storage for expected mesh.
const refinementSurfaces & surfaces_
All surface-intersection interaction.
autoPtr< mapPolyMesh > doRemoveCells(const labelList &cellsToRemove, const labelList &exposedFaces, const labelList &exposedPatchIDs, removeCells &cellRemover)
Remove cells. Put exposedFaces into exposedPatchIDs.
Pre-declare related SubField type.
ListType renumber(const labelUList &oldToNew, const ListType &)
Renumber the values (not the indices) of a list.
void inplaceRenumber(const labelUList &oldToNew, ListType &)
Inplace renumber the values of a list.
virtual bool parallel() const
Are the cyclic planes parallel.
const fileName & pointsInstance() const
Return the current instance directory for points.
virtual bool separated() const
Are the planes separated.
autoPtr< mapPolyMesh > splitMeshRegions(const labelList &globalToMasterPatch, const labelList &globalToSlavePatch, const pointField &locationsInMesh, const pointField &locationsOutsideMesh)
Split mesh. Keep part containing point. Return empty map if.
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
Encapsulates queries for volume refinement ('refine all cells within shell').
bool set(const label) const
Is element set.
labelIOList surfaceIndex_
Per cc-cc vector the index of the surface hit.
word timeName() const
Replacement for Time::timeName() : return oldInstance (if.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Pre-declare SubField and related Field type.
const DynamicList< face > & faces() const
static void checkCoupledFaceZones(const polyMesh &)
Helper function: check that face zones are synced.
A subset of mesh faces organised as a primitive patch.
treeBoundBox extend(Random &, const scalar s) const
Return slightly wider bounding box.
A patch is a list of labels that address the faces in the global face list.
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
labelList meshedPatches() const
Get patchIDs for patches added in addMeshedPatch.
virtual const labelList & faceOwner() const
Return face owner.
A List with indirect addressing.
const Type & second() const
Return second.
label whichPatch(const label faceIndex) const
Return patch index for a given face label.
const word & name() const
Return name.
This class separates the mesh into distinct unconnected regions, each of which is then given a label ...
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
label nRegions() const
Return total number of regions.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & shrink()
Shrink the allocated space to the number of elements used.
static bool constraintType(const word &pt)
Return true if the given type is a constraint type.
void distribute(const mapDistributePolyMesh &)
Update local numbering for mesh redistribution.
void setRefinement(const labelList &cellsToRemove, const labelList &facesToExpose, const labelList &patchIDs, polyTopoChange &) const
Play commands into polyTopoChange to remove cells.
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
void removeFace(const label, const label)
Remove/merge face.
void reorder(const labelUList &)
Reorders elements. Ordering does not have to be done in.
void setConstraints(const polyMesh &mesh, boolList &blockedFace, PtrList< labelList > &specifiedProcessorFaces, labelList &specifiedProcessor, List< labelPair > &explicitConnections)
Helper: extract constraints:
A list of keyword definitions, which are a keyword followed by any number of values (e....
label size() const
Return number of elements in table.
label nInternalFaces() const
Various mesh related information for a parallel run. Upon construction, constructs all info using par...
static autoPtr< polyPatch > New(const word &patchType, const word &name, const label size, const label start, const label index, const polyBoundaryMesh &bm)
Return a pointer to a new patch created on freestore from.
static autoPtr< indirectPrimitivePatch > makePatch(const polyMesh &, const labelList &)
Create patch from set of patches.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< ' ';}gmvFile<< nl;forAll(lagrangianScalarNames, i){ const word &name=lagrangianScalarNames[i];IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Generic dimensioned Type class.
Abstract base class for decomposition.
static labelList findDuplicateFaces(const primitiveMesh &, const labelList &)
Helper routine to find baffles (two boundary faces using the.
bool found(const Key &) const
Return true if hashedEntry is found in table.
void calcNeighbourData(labelList &neiLevel, pointField &neiCc) const
Calculate coupled boundary end vector and refinement level.
void distributeFaceData(List< T > &lst) const
Distribute list of face data.
Mesh data needed to do the Finite Volume discretisation.
This boundary condition is not designed to be evaluated; it is assmued that the value is assigned via...
Mesh representing a set of points created from polyMesh.
fvMesh & mesh_
Reference to mesh.
label whichFace(const label globalCellID) const
Helper function to re-direct to zone::localID(...)
errorManip< error > abort(error &err)
const labelUList & faceCells() const
Return face-cell addressing.
const word & name() const
Return name.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
unsigned int get(const label) const
Get value at index I.
const double e
Elementary charge.
void updateMesh(const mapPolyMesh &, const labelList &changedFaces)
Update for external change to mesh. changedFaces are in new mesh.
List< bool > boolList
Bool container classes.
Vector< scalar > vector
A scalar version of the templated Vector.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().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))
label start() const
Return start label of this patch in the polyMesh face list.
static PackedBoolList getMasterEdges(const polyMesh &mesh, const labelList &meshEdges)
Determine master edge for subset of edges. If coupled.
autoPtr< mapDistributePolyMesh > balance(const bool keepZoneFaces, const bool keepBaffles, const scalarField &cellWeights, decompositionMethod &decomposer, fvMeshDistribute &distributor)
Redecompose according to cell count.
meshRefinement(const meshRefinement &)
Disallow default bitwise copy construct.
wordList names() const
Return a list of zone names.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
errorManipArg< error, int > exit(error &err, const int errNo=1)
void setInstance(const fileName &)
Set instance of all local IOobjects.
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
const labelList & reverseFaceMap() const
Reverse face map.
void selectSeparatedCoupledFaces(boolList &) const
Select coupled faces that are not collocated.
static void listCombineGather(const List< commsStruct > &comms, List< T > &Value, const CombineOp &cop, const int tag, const label comm)
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
void setSize(const label)
Reset size of List.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
label findCell(const point &p, const cellDecomposition=CELL_TETS) const
Find cell enclosing this location and return index.
virtual labelList decompose(const pointField &points, const scalarField &pointWeights)
Return for every coordinate the wanted processor number.
const vectorField & cellCentres() const
static PackedBoolList getMasterPoints(const polyMesh &mesh, const labelList &meshPoints)
Determine master point for subset of points. If coupled.
virtual const faceList & faces() const
Return raw faces.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
static void gatherList(const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
Gather data but keep individual values separate.
An ordered pair of two objects of type <T> with first() and second() elements.
prefixOSstream Pout(cout, "Pout")
const vectorField::subField faceCentres() const
Return face centres.
void clear()
Clear all entries from table.
Encapsulates queries for features.
static bool checkMesh(const bool report, const polyMesh &mesh, const dictionary &dict, labelHashSet &wrongFaces)
Check mesh with mesh settings in dict. Collects incorrect faces.
static word timeName(const scalar, const int precision=precision_)
Return time name of given scalar time.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
bool isInternalFace(const label faceIndex) const
Return true if given face label is internal to the mesh.
const vectorField::subField faceAreas() const
Return face normals.
Container for searchableSurfaces.
void checkData()
Debugging: check that all faces still obey start()>end()
void transfer(dictionary &)
Transfer the contents of the argument and annul the argument.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
bool write() const
Write mesh and all data.
label size() const
Return the number of elements in the PtrList.
bool insert(const Key &key)
Insert a new entry.
void setSize(const label)
Reset size of PtrList. If extending the PtrList, new entries are.
label addMeshedPatch(const word &name, const dictionary &)
Add patch originating from meshing. Update meshedPatches_.
void storeData(const labelList &pointsToStore, const labelList &facesToStore, const labelList &cellsToStore)
Signal points/face/cells for which to store data.
autoPtr< mapDistributePolyMesh > distribute(const labelList &dist)
Send cells to neighbours according to distribution.
const labelList & faceMap() const
Old face map.
static void testSyncPointList(const string &msg, const polyMesh &mesh, const List< scalar > &fld)
static outputType outputLevel()
Get/set output level.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
void clear()
Delete object (if the pointer is valid) and set pointer to NULL.
const Time & time() const
Return the top-level database.
A List with indirect addressing.
A face is a list of labels corresponding to mesh vertices.
void updateIntersections(const labelList &changedFaces)
Find any intersection of surface. Store in surfaceIndex_.
const fileName & name() const
Return the name of the stream.
label size() const
Number of entries.
void size(const label)
Override size to be inconsistent with allocated storage.
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
static void listCombineScatter(const List< commsStruct > &comms, List< T > &Value, const int tag, const label comm)
Scatter data. Reverse of combineGather.
vector point
Point is a vector.
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
const shellSurfaces & shells_
All shell-refinement interaction.
Generic GeometricField class.
Container for data on surfaces used for surface-driven refinement. Contains all the data about the le...
static outputType outputLevel_
Control of output/log level.
const boolList & flipMap() const
Return face flip map.
defineTypeNameAndDebug(combustionModel, 0)
labelList getExposedFaces(const labelList &cellsToRemove) const
Get labels of exposed faces.
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
static tmp< pointVectorField > makeDisplacementField(const pointMesh &pMesh, const labelList &adaptPatchIDs)
Helper function to make a pointVectorField with correct.
#define WarningInFunction
Report a warning using Foam::Warning.
Sends/receives parts of mesh+fvfields to neighbouring processors. Used in load balancing.
Pair< label > labelPair
Label pair.
Database for solution data, solver performance and other reduced data.
cachedRandom rndGen(label(0), -1)
Type gMax(const FieldField< Field, Type > &f)
word name(const complex &)
Return a string representation of a complex.
virtual const labelList & faceNeighbour() const
Return face neighbour.
bool getFaceZoneInfo(const word &fzName, label &masterPatchID, label &slavePatchID, surfaceZonesInfo::faceZoneType &fzType) const
Lookup faceZone information. Return false if no information.
static labelPairList findDuplicateFacePairs(const polyMesh &)
Helper routine to find all baffles (two boundary faces.
Initialise the NamedEnum HashTable from the static list of names.
void clearOut()
Clear all geometry and addressing.
label toGlobal(const label i) const
From local to global.
A list of faces which address into the list of points.
void set(entry *)
Assign a new entry, overwrite any existing entry.
void dumpRefinementLevel() const
Write refinement level as volScalarFields for postprocessing.
static label addFaceZone(const word &name, const labelList &addressing, const boolList &flipMap, polyMesh &mesh)