44 const scalar planarCos,
46 const label nAllowRefine,
54 const labelList& cellLevel = meshCutter_.cellLevel();
55 const pointField& cellCentres = mesh_.cellCentres();
58 const labelList maxLevel(shells_.maxGapLevel());
60 label oldNRefine = nRefine;
62 if (
max(maxLevel) > 0)
92 labelList cellToCompact(mesh_.nCells(), -1);
93 labelList bFaceToCompact(mesh_.nFaces()-mesh_.nInternalFaces(), -1);
101 label faceI = testFaces[i];
102 label own = mesh_.faceOwner()[faceI];
103 if (cellToCompact[own] == -1)
105 cellToCompact[own] = compactToCc.size();
106 compactToCc.
append(cellCentres[own]);
107 compactToLevel.
append(cellLevel[own]);
109 if (mesh_.isInternalFace(faceI))
111 label nei = mesh_.faceNeighbour()[faceI];
112 if (cellToCompact[nei] == -1)
114 cellToCompact[nei] = compactToCc.size();
115 compactToCc.
append(cellCentres[nei]);
116 compactToLevel.
append(cellLevel[nei]);
121 label bFaceI = faceI - mesh_.nInternalFaces();
122 if (bFaceToCompact[bFaceI] == -1)
124 bFaceToCompact[bFaceI] = compactToCc.size();
125 compactToCc.
append(neiCc[bFaceI]);
126 compactToLevel.
append(neiLevel[bFaceI]);
131 shells_.findHigherGapLevel
142 surfaces_.extendedGapLevel();
144 surfaces_.extendedGapMode();
157 surfaces_.findNearestIntersection
159 identity(surfaces_.surfaces().size()),
191 label surfI = ccSurface1[i];
195 label globalRegionI =
196 surfaces_.globalRegion(surfI, ccRegion1[i]);
198 label faceI = testFaces[i];
199 const point& surfPt = ccHit1[i].hitPoint();
201 label own = mesh_.faceOwner()[faceI];
204 cellToCompact[own] != -1
205 && shellGapInfo[cellToCompact[own]][2] > 0
209 label compactI = cellToCompact[own];
214 shellGapInfo[compactI],
215 shellGapMode[compactI],
216 extendedGapLevel[globalRegionI],
217 extendedGapMode[globalRegionI],
222 const point& cc = cellCentres[own];
223 label nRays = generateRays
230 surfPt+((cc-surfPt)&ccNormal1[i])*ccNormal1[i],
241 for (
label j = 0; j < nRays; j++)
247 if (mesh_.isInternalFace(faceI))
249 label nei = mesh_.faceNeighbour()[faceI];
252 cellToCompact[nei] != -1
253 && shellGapInfo[cellToCompact[nei]][2] > 0
257 label compactI = cellToCompact[nei];
262 shellGapInfo[compactI],
263 shellGapMode[compactI],
264 extendedGapLevel[globalRegionI],
265 extendedGapMode[globalRegionI],
270 const point& cc = cellCentres[nei];
271 label nRays = generateRays
278 surfPt+((cc-surfPt)&ccNormal1[i])*ccNormal1[i],
289 for (
label j = 0; j < nRays; j++)
302 label bFaceI = faceI - mesh_.nInternalFaces();
306 bFaceToCompact[bFaceI] != -1
307 && shellGapInfo[bFaceToCompact[bFaceI]][2] > 0
311 label compactI = bFaceToCompact[bFaceI];
316 shellGapInfo[compactI],
317 shellGapMode[compactI],
318 extendedGapLevel[globalRegionI],
319 extendedGapMode[globalRegionI],
324 const point& cc = neiCc[bFaceI];
325 label nRays = generateRays
332 surfPt+((cc-surfPt)&ccNormal1[i])*ccNormal1[i],
343 for (
label j = 0; j < nRays; j++)
355 <<
" intersected faces" <<
endl;
379 surfaces_.findNearestIntersection
391 surfaces_.findNearestIntersection
402 if (surf1[i] != -1 && surf2[i] != -1)
405 label cellI = cellMap[i];
410 && (
mag(normal1[i]&normal2[i]) > planarCos)
412 magSqr(hit1[i].hitPoint()-hit2[i].hitPoint())
440 Info<<
"Reached refinement limit." <<
endl;
687 const point& nearPoint,
698 label nOldRays = start.size();
700 if (cLevel >= gapInfo[1] && cLevel < gapInfo[2] && gapInfo[0] > 0)
702 scalar cellSize = meshCutter_.level0EdgeLength()/
pow(2.0, cLevel);
705 scalar nearGap = gapInfo[0]*cellSize;
712 if (
mode == volumeType::OUTSIDE)
715 end.
append(nearPoint+nearGap*
n);
717 else if (
mode == volumeType::INSIDE)
720 end.
append(nearPoint-nearGap*
n);
722 else if (
mode == volumeType::MIXED)
725 end.
append(nearPoint+nearGap*
n);
728 end.
append(nearPoint-nearGap*
n);
732 return start.size()-nOldRays;
738 const bool useSurfaceNormal,
740 const point& nearPoint,
814 label nOldRays = start.size();
816 if (cLevel >= gapInfo[1] && cLevel < gapInfo[2] && gapInfo[0] > 0)
818 scalar cellSize = meshCutter_.level0EdgeLength()/
pow(2.0, cLevel);
821 scalar nearGap = gapInfo[0]*cellSize;
825 scalar magV =
mag(v);
827 if (useSurfaceNormal || magV < 0.5*cellSize)
834 if (
mode == volumeType::OUTSIDE)
837 end.
append(nearPoint+nearGap*
n);
842 gapSize2.
append(gapSize.last());
844 else if (
mode == volumeType::INSIDE)
847 end.
append(nearPoint-nearGap*
n);
852 gapSize2.
append(gapSize.last());
854 else if (
mode == volumeType::MIXED)
860 end.
append(nearPoint+nearGap*
n);
865 gapSize2.
append(gapSize.last());
870 end.
append(nearPoint-nearGap*
n);
875 gapSize2.
append(gapSize.last());
887 scalar
s = (v&nearNormal);
891 (
mode == volumeType::MIXED)
892 || (
mode == volumeType::OUTSIDE &&
s > SMALL)
893 || (
mode == volumeType::INSIDE &&
s < -SMALL)
971 end.
append(cc+nearGap*e2);
975 end2.
append(cc-nearGap*e2);
980 end.
append(cc+nearGap*e3);
984 end2.
append(cc-nearGap*e3);
990 return start.size()-nOldRays;
1004 const labelList& cellLevel = meshCutter_.cellLevel();
1005 const pointField& cellCentres = mesh_.cellCentres();
1015 cellMap[compactI++] = cellI;
1019 <<
" unmarked cells out of "
1020 << mesh_.globalData().nTotalCells() <<
endl;
1025 shells_.findHigherGapLevel
1039 if (shellGapInfo[i][2] > 0)
1041 map[compactI++] = i;
1046 <<
" cells inside gap shells out of "
1047 << mesh_.globalData().nTotalCells() <<
endl;
1066 if (surfGapInfo[0] == 0)
1068 gapInfo = shellGapInfo;
1069 gapMode = shellGapMode;
1071 else if (shellGapInfo[0] == 0)
1073 gapInfo = surfGapInfo;
1074 gapMode = surfGapMode;
1084 gapInfo = surfGapInfo;
1085 gapMode = surfGapMode;
1092 const scalar planarCos,
1093 const bool spreadGapSize,
1094 const label nAllowRefine,
1102 detectedGapSize.setSize(mesh_.nCells());
1103 detectedGapSize = GREAT;
1104 numGapCells.
setSize(mesh_.nCells());
1107 const labelList& cellLevel = meshCutter_.cellLevel();
1108 const pointField& cellCentres = mesh_.cellCentres();
1109 const scalar edge0Len = meshCutter_.level0EdgeLength();
1112 surfaces_.extendedGapLevel();
1116 const labelList maxLevel(shells_.maxGapLevel());
1118 label oldNRefine = nRefine;
1120 if (
max(maxLevel) > 0)
1147 label cellI = cellMap[i];
1148 scalar cellSize = edge0Len/
pow(2.0, cellLevel[cellI]);
1149 gapSize[i] = shellGapInfo[i][0]*cellSize;
1152 surfaces_.findNearestRegion
1154 identity(surfaces_.surfaces().size()),
1175 label nTestCells = 0;
1181 label globalRegionI = surfaces_.globalRegion
1194 extendedGapLevel[globalRegionI],
1195 extendedGapMode[globalRegionI],
1201 label cellI = cellMap[i];
1202 label cLevel = cellLevel[cellI];
1203 if (cLevel >= gapInfo[1] && cLevel < gapInfo[2])
1205 numGapCells[cellI] =
max(numGapCells[cellI], gapInfo[0]);
1209 label nRays = generateRays
1231 for (
label j = 0; j < nRays; j++)
1240 <<
" cells for testing out of "
1241 << mesh_.globalData().nTotalCells() <<
endl;
1253 shellGapInfo.
clear();
1254 shellGapMode.
clear();
1256 nearSurface.
clear();
1264 surfaces_.findNearestIntersection
1276 surfaces_.findNearestIntersection
1288 if (surf1[i] != -1 && surf2[i] != -1)
1294 label cellI = cellMap[i];
1296 scalar d2 =
magSqr(hit1[i].hitPoint()-hit2[i].hitPoint());
1301 && (
mag(normal1[i]&normal2[i]) > planarCos)
1305 detectedGapSize[cellI] =
min
1307 detectedGapSize[cellI],
1322 const pointField& faceCentres = mesh_.faceCentres();
1326 for (
label faceI = 0; faceI < mesh_.nInternalFaces(); faceI++)
1328 label own = mesh_.faceOwner()[faceI];
1329 label nei = mesh_.faceNeighbour()[faceI];
1331 scalar minSize =
min
1333 detectedGapSize[own],
1334 detectedGapSize[nei]
1337 if (minSize < GREAT)
1339 frontFaces.
append(faceI);
1353 label faceI = mesh_.nInternalFaces();
1354 faceI < mesh_.nFaces();
1358 label own = mesh_.faceOwner()[faceI];
1360 if (detectedGapSize[own] < GREAT)
1362 frontFaces.
append(faceI);
1368 detectedGapSize[own],
1377 <<
" faces for spreading gap size out of "
1378 << mesh_.globalData().nTotalFaces() <<
endl;
1390 mesh_.globalData().nTotalCells()+1,
1397 label cellI = cellMap[i];
1401 && cellData[cellI].valid(deltaCalc.
data())
1402 && numGapCells[cellI] != -1
1406 detectedGapSize[cellI] =
min
1408 detectedGapSize[cellI],
1409 cellData[cellI].
data()
1419 label cellI = cellMap[i];
1421 if (cellI != -1 && numGapCells[cellI] != -1)
1424 label cLevel = cellLevel[cellI];
1426 meshCutter_.level0EdgeLength()/
pow(2.0, cLevel);
1427 scalar neededGapSize = numGapCells[cellI]*cellSize;
1429 if (neededGapSize > detectedGapSize[cellI])
1455 Info<<
"Reached refinement limit." <<
endl;
1465 const scalar planarCos,
1466 const label nAllowRefine,
1474 const labelList& cellLevel = meshCutter_.cellLevel();
1475 const labelList& surfaceIndices = surfaces_.surfaces();
1477 surfaces_.extendedGapLevel();
1480 label oldNRefine = nRefine;
1483 labelList shellMaxLevel(shells_.maxGapLevel());
1485 if (
max(shellMaxLevel) == 0)
1491 (void)mesh_.tetBasePtIs();
1492 (void)mesh_.cellTree();
1495 forAll(surfaceIndices, surfI)
1497 label geomI = surfaceIndices[surfI];
1522 <<
" radius:" << radiusSqr[i]
1535 shells_.findHigherGapLevel
1551 label nTestCells = 0;
1555 if (shellGapInfo[i][2] > 0)
1557 label globalRegionI = surfaces_.globalRegion(surfI, region[i]);
1566 extendedGapLevel[globalRegionI],
1567 extendedGapMode[globalRegionI],
1590 label nRays = generateRays
1606 for (
label j = 0; j < nRays; j++)
1617 <<
" cells containing triangle centres out of "
1618 << mesh_.globalData().nTotalCells() <<
endl;
1626 shellGapInfo.
clear();
1627 shellGapMode.
clear();
1633 surfaces_.findNearestIntersection
1642 label nOldRefine = 0;
1647 if (surfaceHit[i] != -1)
1650 label cellI = cellMap[i];
1652 if (
mag(
normal[i]&surfaceNormal[i]) > planarCos)
1671 Info<<
"For surface " << geom.
name() <<
" found "
1673 <<
" cells in small gaps" <<
endl;
1681 Info<<
"Reached refinement limit." <<
endl;