33 #include "indirectPrimitivePatch.H"
56 isBoundaryFace[faceI] =
true;
58 const labelList& fEdges = mesh_.faceEdges(faceI);
62 isBoundaryEdge[fEdges[fp]] =
true;
65 const face&
f = mesh_.faces()[faceI];
69 isBoundaryPoint[
f[fp]] =
true;
86 fc[i] = mesh_.faceCentres()[meshFaces[i]];
101 nearestNormal.setSize(nearestInfo.
size());
104 forAll(allSurfaces, surfI)
110 if (nearestSurface[i] == surfI)
112 localHits.
append(nearestInfo[i]);
116 label geomI = surfaces_.surfaces()[surfI];
119 surfaces_.geometry()[geomI].getNormal(localHits, localNormals);
122 surfaces_.geometry()[geomI].getRegion(localHits, localRegion);
127 if (nearestSurface[i] == surfI)
129 nearestNormal[i] = localNormals[localI];
130 nearestRegion[i] = localRegion[localI];
147 meshRefinement::makePatch
163 const labelList& cellLevel = meshCutter_.cellLevel();
167 const labelList& eFaces = edgeFaces[edgeI];
169 if (eFaces.
size() == 2)
171 label face0 = pp.addressing()[eFaces[0]];
172 label face1 = pp.addressing()[eFaces[1]];
174 label cell0 = mesh_.faceOwner()[face0];
175 label cell1 = mesh_.faceOwner()[face1];
177 if (cellLevel[cell0] > cellLevel[cell1])
183 if (
mag(n0 & n1) < 0.1)
185 candidateFaces.
append(face0);
188 else if (cellLevel[cell1] > cellLevel[cell0])
194 if (
mag(n0 & n1) < 0.1)
196 candidateFaces.
append(face1);
204 <<
" faces on edge-connected cells of differing level."
209 faceSet fSet(mesh_,
"edgeConnectedFaces", candidateFaces);
212 <<
" with problematic topology to faceSet "
238 Map<label> candidateCells(candidateFaces.size());
240 faceSet perpFaces(mesh_,
"perpendicularFaces", pp.size()/100);
244 label faceI = candidateFaces[i];
246 vector n = mesh_.faceAreas()[faceI];
249 label region = surfaces_.globalRegion
255 scalar angle =
degToRad(perpendicularAngle[region]);
262 candidateCells.insert
264 mesh_.faceOwner()[faceI],
265 globalToPatch[region]
274 Pout<<
"Writing " << perpFaces.
size()
275 <<
" faces that are perpendicular to the surface to set "
279 return candidateCells;
290 const scalar minFaceArea,
291 const scalar maxNonOrtho,
296 const scalar severeNonorthogonalityThreshold =
300 scalar magS =
mag(
s);
303 if (magS < minFaceArea)
309 const point& ownCc = mesh_.cellCentres()[mesh_.faceOwner()[faceI]];
311 if (mesh_.isInternalFace(faceI))
313 label nei = mesh_.faceNeighbour()[faceI];
314 vector d = mesh_.cellCentres()[nei] - ownCc;
316 scalar dDotS = (d &
s)/(
mag(d)*magS + VSMALL);
318 if (dDotS < severeNonorthogonalityThreshold)
329 label patchI = mesh_.boundaryMesh().whichPatch(faceI);
331 if (mesh_.boundaryMesh()[patchI].coupled())
333 vector d = neiCc[faceI-mesh_.nInternalFaces()] - ownCc;
335 scalar dDotS = (d &
s)/(
mag(d)*magS + VSMALL);
337 if (dDotS < severeNonorthogonalityThreshold)
360 const scalar volFraction,
364 scalar vol = mesh_.cells()[cellI].mag(
points, mesh_.faces());
366 if (vol/mesh_.cellVolumes()[cellI] < volFraction)
386 if (adaptPatchIDs.
size())
388 nearestAdaptPatch.
setSize(mesh_.nFaces(), adaptPatchIDs[0]);
409 label patchI = adaptPatchIDs[i];
428 mesh_.globalData().nTotalCells()+1
433 bool haveWarned =
false;
436 if (!faceData[faceI].valid(deltaCalc.
data()))
441 <<
"Did not visit some faces, e.g. face " << faceI
442 <<
" at " << mesh_.faceCentres()[faceI] <<
endl
443 <<
"Assigning these cells to patch "
451 nearestAdaptPatch[faceI] = faceData[faceI].data();
458 nearestAdaptPatch.
setSize(mesh_.nFaces(), 0);
461 return nearestAdaptPatch;
474 const bool removeEdgeConnectedCells,
479 const labelList& cellLevel = meshCutter_.cellLevel();
480 const labelList& pointLevel = meshCutter_.pointLevel();
486 boolList isBoundaryPoint(mesh_.nPoints(),
false);
487 boolList isBoundaryEdge(mesh_.nEdges(),
false);
488 boolList isBoundaryFace(mesh_.nFaces(),
false);
492 labelList adaptPatchIDs(meshedPatches());
524 labelList neiLevel(mesh_.nFaces()-mesh_.nInternalFaces());
525 pointField neiCc(mesh_.nFaces()-mesh_.nInternalFaces());
526 calcNeighbourData(neiLevel, neiCc);
530 label nBaffleFaces = 0;
534 label nPrevented = 0;
536 if (removeEdgeConnectedCells &&
max(perpendicularAngle) >= 0)
538 Info<<
"markFacesOnProblemCells :"
539 <<
" Checking for edge-connected cells of highly differing sizes."
546 findEdgeConnectedProblemCells
556 const cell& cFaces = mesh_.cells()[iter.key()];
560 label faceI = cFaces[i];
562 if (facePatch[faceI] == -1 && mesh_.isInternalFace(faceI))
564 facePatch[faceI] = nearestAdaptPatch[faceI];
578 Info<<
"markFacesOnProblemCells : Marked "
580 <<
" additional internal faces to be converted into baffles"
583 <<
" cells edge-connected to lower level cells." <<
endl;
587 cellSet problemCellSet(mesh_,
"problemCells", problemCells.toc());
589 Pout<<
"Writing " << problemCellSet.
size()
590 <<
" cells that are edge connected to coarser cell to set "
592 problemCellSet.
write();
596 syncTools::syncPointList
604 syncTools::syncEdgeList
612 syncTools::syncFaceList
624 const scalar volFraction =
627 const bool checkCollapse = (volFraction > 0);
629 scalar maxNonOrtho = -1;
640 Info<<
"markFacesOnProblemCells :"
641 <<
" Deleting all-anchor surface cells only if"
642 <<
" snapping them violates mesh quality constraints:" <<
nl
643 <<
" snapped/original cell volume < " << volFraction <<
nl
644 <<
" face area < " << minArea <<
nl
645 <<
" non-orthogonality > " << maxNonOrtho <<
nl
651 meshRefinement::makePatch
663 surfaces_.findNearest
665 surfaceZonesInfo::getUnnamedSurfaces(surfaces_.surfZones()),
673 newPoints = mesh_.points();
677 if (hitInfo[i].hit())
679 newPoints[meshPoints[i]] = hitInfo[i].hitPoint();
685 const_cast<Time&
>(mesh_.time())++;
687 mesh_.movePoints(newPoints);
694 mesh_.time().path()/
"newPoints"
696 mesh_.movePoints(oldPoints);
724 const labelList& cPoints = mesh_.cellPoints(cellI, dynCPoints);
728 label nBoundaryAnchors = 0;
729 label nNonAnchorBoundary = 0;
730 label nonBoundaryAnchor = -1;
734 label pointI = cPoints[i];
736 if (pointLevel[pointI] <= cellLevel[cellI])
739 if (isBoundaryPoint[pointI])
746 nonBoundaryAnchor = pointI;
749 else if (isBoundaryPoint[pointI])
751 nNonAnchorBoundary++;
755 if (nBoundaryAnchors == 8)
757 const cell& cFaces = mesh_.cells()[cellI];
764 if (isBoundaryFace[cFaces[cFaceI]])
780 && !isCollapsedCell(newPoints, volFraction, cellI)
797 label faceI = cFaces[cf];
801 facePatch[faceI] == -1
802 && mesh_.isInternalFace(faceI)
805 facePatch[faceI] = nearestAdaptPatch[faceI];
821 else if (nBoundaryAnchors == 7)
824 hasSevenBoundaryAnchorPoints.
set(cellI, 1u);
825 nonBoundaryAnchors.
insert(nonBoundaryAnchor);
838 label pointI = iter.key();
840 const labelList& pCells = mesh_.pointCells(pointI, dynPCells);
847 if (hasSevenBoundaryAnchorPoints.
get(pCells[i]) == 1u)
858 label cellI = pCells[i];
860 if (hasSevenBoundaryAnchorPoints.
get(cellI) == 1u)
865 && !isCollapsedCell(newPoints, volFraction, cellI)
880 const cell& cFaces = mesh_.cells()[cellI];
884 label faceI = cFaces[cf];
888 facePatch[faceI] == -1
889 && mesh_.isInternalFace(faceI)
892 facePatch[faceI] = nearestAdaptPatch[faceI];
915 syncTools::syncPointList
923 syncTools::syncEdgeList
931 syncTools::syncFaceList
940 for (
label faceI = 0; faceI < mesh_.nInternalFaces(); faceI++)
942 if (facePatch[faceI] == -1)
944 const labelList& fEdges = mesh_.faceEdges(faceI, dynFEdges);
945 label nFaceBoundaryEdges = 0;
949 if (isBoundaryEdge[fEdges[fe]])
951 nFaceBoundaryEdges++;
955 if (nFaceBoundaryEdges == fEdges.
size())
979 facePatch[faceI] = nearestAdaptPatch[faceI];
999 if (facePatch[faceI] == -1)
1001 const labelList& fEdges = mesh_.faceEdges(faceI, dynFEdges);
1002 label nFaceBoundaryEdges = 0;
1006 if (isBoundaryEdge[fEdges[fe]])
1008 nFaceBoundaryEdges++;
1012 if (nFaceBoundaryEdges == fEdges.
size())
1036 facePatch[faceI] = nearestAdaptPatch[faceI];
1037 if (isMasterFace[faceI])
1058 syncTools::syncFaceList
1066 Info<<
"markFacesOnProblemCells : marked "
1068 <<
" additional internal faces to be converted into baffles."
1073 Info<<
"markFacesOnProblemCells : prevented "
1075 <<
" internal faces from getting converted into baffles."
1097 labelList adaptPatchIDs(meshedPatches());
1102 meshRefinement::makePatch
1113 autoSnapDriver::calcSnapDistance(mesh_, snapParams, pp)
1118 Info<<
"Constructing mesh displacer ..." <<
endl;
1119 Info<<
"Using mesh parameters " << motionDict <<
nl <<
endl;
1128 meshRefinement::makeDisplacementField(pMesh, adaptPatchIDs)(),
1134 Info<<
"Checking initial mesh ..." <<
endl;
1143 Info<<
"Detected " << nInitErrors <<
" illegal faces"
1144 <<
" (concave, zero area or negative cell pyramid volume)"
1148 Info<<
"Checked initial mesh in = "
1149 << mesh_.time().cpuTimeIncrement() <<
" s\n" <<
nl <<
endl;
1152 autoSnapDriver::preSmoothPatch
1165 autoSnapDriver::calcNearestSurface
1169 globalToMasterPatch,
1183 newPoints[meshPoints[i]] += disp[i];
1186 syncTools::syncPointList
1191 vector(GREAT, GREAT, GREAT)
1194 mesh_.movePoints(newPoints);
1203 labelList facePatch(mesh_.nFaces(), -1);
1205 label nBaffleFaces = 0;
1208 faceSet wrongFaces(mesh_,
"wrongFaces", 100);
1216 label nWrongFaces = 0;
1248 if (minArea > -SMALL)
1250 polyMeshGeometry::checkFaceArea
1266 Info<<
" faces with area < "
1267 <<
setw(5) << minArea
1269 << nNewWrongFaces-nWrongFaces <<
endl;
1271 nWrongFaces = nNewWrongFaces;
1277 polyMeshGeometry::checkCellDeterminant
1284 polyMeshGeometry::affectedCells(mesh_, allFaces),
1294 Info<<
" faces on cells with determinant < "
1295 <<
setw(5) << minDet <<
" : "
1296 << nNewWrongFaces-nWrongFaces <<
endl;
1298 nWrongFaces = nNewWrongFaces;
1305 label patchI = mesh_.boundaryMesh().whichPatch(iter.key());
1307 if (patchI == -1 || mesh_.boundaryMesh()[patchI].coupled())
1309 facePatch[iter.key()] = nearestAdaptPatch[iter.key()];
1322 mesh_.movePoints(oldPoints);
1325 Info<<
"markFacesOnProblemCellsGeometric : marked "
1327 <<
" additional internal and coupled faces"
1328 <<
" to be converted into baffles." <<
endl;
1330 syncTools::syncFaceList