45 const searchableSurface& geom,
46 const shellSurfaces& shells,
47 const List<pointIndexHit>& intersectionInfo,
53 geom.getField(intersectionInfo, minLevelField);
64 DynamicList<label> retestSet;
67 forAll(intersectionInfo, i)
69 if (intersectionInfo[i].hit())
74 if (minLevelField.size())
76 if (minLevelField[i] == -1)
82 localLevel[i] =
max(localLevel[i], minLevelField[i]);
95 reduce(nHits, sumOp<label>());
105 samples[i] = intersectionInfo[retestSet[i]].hitPoint();
108 shells.findHigherLevel
116 label sampleI = retestSet[i];
117 localLevel[sampleI] =
max(localLevel[sampleI], shellLevel[i]);
128 Foam::refinementSurfaces::refinementSurfaces
132 const label gapLevelIncrement,
136 allGeometry_(allGeometry),
137 surfaces_(surfacesDict.size()),
138 names_(surfacesDict.size()),
139 surfZones_(surfacesDict.size()),
140 regionOffset_(surfacesDict.size()),
148 forAll(allGeometry_.names(), geomI)
150 const word& geomName = allGeometry_.names()[geomI];
152 if (surfacesDict.
found(geomName))
159 surfaces_.setSize(surfI);
160 names_.setSize(surfI);
161 surfZones_.setSize(surfI);
162 regionOffset_.setSize(surfI);
195 forAll(allGeometry_.names(), geomI)
197 const word& geomName = allGeometry_.names()[geomI];
207 names_[surfI] = geomName;
208 surfaces_[surfI] = geomI;
212 meshRefinement::get<labelPair>
222 globalMinLevel[surfI] = refLevel[0];
223 globalMaxLevel[surfI] = refLevel[1];
232 globalMinLevel[surfI] < 0
233 || globalMaxLevel[surfI] < globalMinLevel[surfI]
234 || globalMaxLevel[surfI] < 0
235 || globalLevelIncr[surfI] < 0
239 <<
"Illegal level specification for surface "
241 <<
" : minLevel:" << globalMinLevel[surfI]
242 <<
" maxLevel:" << globalMaxLevel[surfI]
243 <<
" levelIncrement:" << globalLevelIncr[surfI]
255 globalGapMode[surfI] =
261 || globalGapLevel[surfI][0] < 0
262 || globalGapLevel[surfI][1] < 0
263 || globalGapLevel[surfI][2] < 0
264 || globalGapLevel[surfI][1] > globalGapLevel[surfI][2]
268 <<
"Illegal gapLevel specification for surface "
270 <<
" : gapLevel:" << globalGapLevel[surfI]
271 <<
" gapMode:" << globalGapMode[surfI].str()
299 forAll(regionNames, regionI)
301 if (regionsDict.
found(regionNames[regionI]))
311 meshRefinement::get<labelPair>
322 regionMinLevel[surfI].insert(regionI, refLevel[0]);
323 regionMaxLevel[surfI].insert(regionI, refLevel[1]);
329 regionLevelIncr[surfI].insert(regionI, levelIncr);
334 || refLevel[1] < refLevel[0]
339 <<
"Illegal level specification for surface "
340 << names_[surfI] <<
" region "
341 << regionNames[regionI]
342 <<
" : minLevel:" << refLevel[0]
343 <<
" maxLevel:" << refLevel[1]
344 <<
" levelIncrement:" << levelIncr
360 regionGapLevel[surfI].insert(regionI, gapSpec);
367 regionGapMode[surfI].insert(regionI, gapModeSpec);
374 || gapSpec[1] > gapSpec[2]
378 <<
"Illegal gapLevel specification for surface "
380 <<
" : gapLevel:" << gapSpec
381 <<
" gapMode:" << gapModeSpec.
str()
386 if (regionDict.
found(
"perpendicularAngle"))
388 regionAngle[surfI].insert
391 regionDict.
get<scalar>(
"perpendicularAngle")
395 if (regionDict.
found(
"patchInfo"))
397 regionPatchInfo[surfI].insert
407 regionBlockLevel[surfI].insert(regionI, l);
416 if (unmatchedKeys.size() > 0)
419 <<
"Not all entries in refinementSurfaces dictionary were used."
420 <<
" The following entries were not used : "
421 << unmatchedKeys.sortedToc()
431 regionOffset_[surfI] = nRegions;
432 nRegions += allGeometry_[surfaces_[surfI]].regions().size();
436 minLevel_.setSize(nRegions);
438 maxLevel_.setSize(nRegions);
440 gapLevel_.setSize(nRegions);
442 extendedGapLevel_.setSize(nRegions);
443 extendedGapLevel_ = nullGapLevel;
444 extendedGapMode_.
setSize(nRegions);
446 perpendicularAngle_.setSize(nRegions);
447 perpendicularAngle_ = -GREAT;
448 patchInfo_.setSize(nRegions);
449 blockLevel_.setSize(nRegions);
453 forAll(globalMinLevel, surfI)
455 label nRegions = allGeometry_[surfaces_[surfI]].regions().size();
458 for (
label i = 0; i < nRegions; i++)
460 const label globalRegionI = regionOffset_[surfI] + i;
462 minLevel_[globalRegionI] = globalMinLevel[surfI];
463 maxLevel_[globalRegionI] = globalMaxLevel[surfI];
464 gapLevel_[globalRegionI] =
465 maxLevel_[globalRegionI]
466 + globalLevelIncr[surfI];
467 extendedGapLevel_[globalRegionI] = globalGapLevel[surfI];
468 extendedGapMode_[globalRegionI] = globalGapMode[surfI];
469 perpendicularAngle_[globalRegionI] = globalAngle[surfI];
470 if (globalPatchInfo.
set(surfI))
475 globalPatchInfo[surfI].clone()
478 blockLevel_[globalRegionI] = globalBlockLevel[surfI];
484 const label globalRegionI = regionOffset_[surfI] + iter.key();
486 minLevel_[globalRegionI] = iter.val();
487 maxLevel_[globalRegionI] = regionMaxLevel[surfI][iter.key()];
488 gapLevel_[globalRegionI] =
489 maxLevel_[globalRegionI]
490 + regionLevelIncr[surfI][iter.key()];
491 extendedGapLevel_[globalRegionI] =
492 regionGapLevel[surfI][iter.key()];
493 extendedGapMode_[globalRegionI] =
494 regionGapMode[surfI][iter.key()];
498 const label globalRegionI = regionOffset_[surfI] + iter.key();
500 perpendicularAngle_[globalRegionI] = iter.val();
506 const label globalRegionI = regionOffset_[surfI] + iter.key();
514 const label globalRegionI = regionOffset_[surfI] + iter.key();
516 blockLevel_[globalRegionI] = iter.val();
522 Foam::refinementSurfaces::refinementSurfaces
537 allGeometry_(allGeometry),
540 surfZones_(surfZones),
541 regionOffset_(regionOffset),
545 perpendicularAngle_(perpendicularAngle),
546 patchInfo_(patchInfo.size()),
551 if (patchInfo.
set(pI))
553 patchInfo_.set(pI, patchInfo.
set(pI,
nullptr));
622 const wordList& regionNames = allGeometry_[surfaces_[surfI]].regions();
624 forAll(regionNames, regionI)
626 label globalI = globalRegion(surfI, regionI);
628 surfaceMax[surfI] =
max(surfaceMax[surfI], gapInfo[2]);
672 minLevelField[i] = minLevel(surfI, region[i]);
680 shells.findHigherLevel(ctrs, minLevelField, shellLevel);
685 if (isA<triSurface>(geom))
691 const triSurface& ts = refCast<const triSurface>(geom);
700 label level = shellLevel[triI];
703 minPointLevel[t[tI]] =
min(minPointLevel[t[tI]], level);
710 shells.findHigherLevel(
points, minPointLevel, pointLevel);
717 label fLevel = shellLevel[triI];
720 (pointLevel[t[0]] != fLevel)
721 || (pointLevel[t[1]] != fLevel)
722 || (pointLevel[t[2]] != fLevel)
729 shellLevel[triI] = -1;
736 Info<<
"For geometry " << geom.
name()
739 <<
" uncached triangles out of " << geom.
globalSize()
750 if (
min(minLevelField[i], shellLevel[i]) < 0)
752 minLevelField[i] = -1;
756 minLevelField[i] =
max(minLevelField[i], shellLevel[i]);
786 if (surfaces_.empty())
791 if (surfaces_.size() == 1)
810 geom.
getRegion(intersectionInfo, region);
812 forAll(intersectionInfo, i)
814 if (intersectionInfo[i].hit())
816 surfaceOnlyLevel[i] = minLevel(surfI, region[i]);
838 if (localLevel[i] > currentLevel[i])
841 surfaceLevel[i] = localLevel[i];
865 labelList surfaceOnlyLevel(intersectionInfo.size(), -1);
869 geom.
getRegion(intersectionInfo, region);
871 forAll(intersectionInfo, i)
873 if (intersectionInfo[i].hit())
875 surfaceOnlyLevel[i] = minLevel(surfI, region[i]);
898 label pointI = intersectionToPoint[i];
900 if (localLevel[i] > currentLevel[pointI])
903 surfaces[pointI] = surfI;
904 surfaceLevel[pointI] = localLevel[i];
909 p1[missI] =
end[pointI];
910 intersectionToPoint[missI] = pointI;
925 intersectionToPoint.
setSize(missI);
926 intersectionInfo.setSize(missI);
947 if (surfaces_.empty())
970 n += hitInfo[pointI].size();
983 surfInfo[
n] = pHits[i];
984 pointMap[
n] = pointI;
1002 label region = globalRegion(surfI, surfRegion[i]);
1003 label pointI = pointMap[i];
1007 currentLevel[pointI] >= globalMinLevel[region]
1008 && currentLevel[pointI] < globalMaxLevel[region]
1012 label sz = surfaceNormal[pointI].size();
1013 surfaceNormal[pointI].
setSize(sz+1);
1014 surfaceNormal[pointI][sz] = surfNormal[i];
1016 surfaceLevel[pointI].
setSize(sz+1);
1017 surfaceLevel[pointI][sz] = globalMaxLevel[region];
1042 if (surfaces_.empty())
1065 n += hitInfo[pointI].size();
1078 surfInfo[
n] = pHits[i];
1079 pointMap[
n] = pointI;
1086 surface.
getRegion(surfInfo, surfRegion);
1087 surface.
getNormal(surfInfo, surfNormal);
1094 label region = globalRegion(surfI, surfRegion[i]);
1095 label pointI = pointMap[i];
1099 currentLevel[pointI] >= globalMinLevel[region]
1100 && currentLevel[pointI] < globalMaxLevel[region]
1104 label sz = surfaceNormal[pointI].size();
1108 surfaceNormal[pointI].
setSize(sz+1);
1109 surfaceNormal[pointI][sz] = surfNormal[i];
1111 surfaceLevel[pointI].
setSize(sz+1);
1114 surfaceLevel[pointI][sz] = globalMaxLevel[region];
1150 forAll(surfacesToTest, testI)
1152 label surfI = surfacesToTest[testI];
1169 forAll(nearestInfo, pointI)
1171 if (nearestInfo[pointI].hit())
1173 hit1[pointI] = nearestInfo[pointI];
1174 surface1[pointI] = surfI;
1175 region1[pointI] = region[pointI];
1176 nearest[pointI] = hit1[pointI].hitPoint();
1187 surface2 = surface1;
1194 if (hit1[pointI].hit())
1196 nearest[pointI] = hit1[pointI].hitPoint();
1201 nearest[pointI] =
end[pointI];
1205 forAll(surfacesToTest, testI)
1207 label surfI = surfacesToTest[testI];
1224 forAll(nearestInfo, pointI)
1226 if (nearestInfo[pointI].hit())
1228 hit2[pointI] = nearestInfo[pointI];
1229 surface2[pointI] = surfI;
1230 region2[pointI] = region[pointI];
1231 nearest[pointI] = hit2[pointI].hitPoint();
1241 if (hit1[pointI].hit() && !hit2[pointI].hit())
1243 hit2[pointI] = hit1[pointI];
1244 surface2[pointI] = surface1[pointI];
1245 region2[pointI] = region1[pointI];
1277 normal1.setSize(
start.size());
1287 forAll(surfacesToTest, testI)
1289 label surfI = surfacesToTest[testI];
1297 forAll(nearestInfo, pointI)
1299 if (nearestInfo[pointI].hit())
1301 hit1[pointI] = nearestInfo[pointI];
1302 surface1[pointI] = surfI;
1303 region1[pointI] = region[pointI];
1304 normal1[pointI] = normal[pointI];
1305 nearest[pointI] = hit1[pointI].hitPoint();
1316 surface2 = surface1;
1324 if (hit1[pointI].hit())
1326 nearest[pointI] = hit1[pointI].hitPoint();
1331 nearest[pointI] =
end[pointI];
1335 forAll(surfacesToTest, testI)
1337 label surfI = surfacesToTest[testI];
1345 forAll(nearestInfo, pointI)
1347 if (nearestInfo[pointI].hit())
1349 hit2[pointI] = nearestInfo[pointI];
1350 surface2[pointI] = surfI;
1351 region2[pointI] = region[pointI];
1352 normal2[pointI] = normal[pointI];
1353 nearest[pointI] = hit2[pointI].hitPoint();
1363 if (hit1[pointI].hit() && !hit2[pointI].hit())
1365 hit2[pointI] = hit1[pointI];
1366 surface2[pointI] = surface1[pointI];
1367 region2[pointI] = region1[pointI];
1368 normal2[pointI] = normal1[pointI];
1386 normal1.setSize(
start.size());
1404 forAll(nearestInfo, pointI)
1406 if (nearestInfo[pointI].hit())
1408 surface1[pointI] = surfI;
1409 normal1[pointI] = normal[pointI];
1410 nearest[pointI] = nearestInfo[pointI].hitPoint();
1435 normal1.setSize(
start.size());
1453 forAll(nearestInfo, pointI)
1455 if (nearestInfo[pointI].hit())
1457 surface1[pointI] = surfI;
1458 hitInfo1[pointI] = nearestInfo[pointI];
1459 normal1[pointI] = normal[pointI];
1460 nearest[pointI] = nearestInfo[pointI].hitPoint();
1511 forAll(hitSurface, pointI)
1513 if (hitSurface[pointI] != -1)
1515 hitSurface[pointI] = surfacesToTest[hitSurface[pointI]];
1545 forAll(hitSurface, pointI)
1547 if (hitSurface[pointI] != -1)
1549 hitSurface[pointI] = surfacesToTest[hitSurface[pointI]];
1554 hitRegion.
setSize(hitSurface.size());
1557 forAll(surfacesToTest, i)
1559 label surfI = surfacesToTest[i];
1562 const labelList localIndices(findIndices(hitSurface, surfI));
1574 allGeometry_[surfaces_[surfI]].getRegion(localHits, localRegion);
1578 hitRegion[localIndices[i]] = localRegion[i];
1609 forAll(hitSurface, pointI)
1611 if (hitSurface[pointI] != -1)
1613 hitSurface[pointI] = surfacesToTest[hitSurface[pointI]];
1618 hitRegion.
setSize(hitSurface.size());
1620 hitNormal.setSize(hitSurface.size());
1623 forAll(surfacesToTest, i)
1625 label surfI = surfacesToTest[i];
1628 const labelList localIndices(findIndices(hitSurface, surfI));
1641 allGeometry_[surfaces_[surfI]].getRegion(localHits, localRegion);
1645 hitRegion[localIndices[i]] = localRegion[i];
1650 allGeometry_[surfaces_[surfI]].getNormal(localHits, localNormal);
1654 hitNormal[localIndices[i]] = localNormal[i];
1712 insideSurfaces.
setSize(pt.size());
1713 insideSurfaces = -1;
1717 label surfI = testSurfaces[i];
1722 surfZones_[surfI].zoneInside();
1731 <<
"Trying to use surface "
1733 <<
" which has non-geometric inside selection method "
1745 if (insideSurfaces[pointI] == -1)
1759 insideSurfaces[pointI] = surfI;
1795 forAll(hitSurface, pointI)
1797 if (hitSurface[pointI] != -1)
1799 hitSurface[pointI] = surfacesToTest[hitSurface[pointI]];
1834 forAll(hitSurface, pointI)
1836 if (hitSurface[pointI] != -1)
1838 hitSurface[pointI] = surfacesToTest[hitSurface[pointI]];
1843 hitRegion.
setSize(hitSurface.size());
1845 hitNormal.setSize(hitSurface.size());
1848 forAll(surfacesToTest, i)
1850 label surfI = surfacesToTest[i];
1853 const labelList localIndices(findIndices(hitSurface, surfI));
1866 allGeometry_[surfaces_[surfI]].getRegion(localHits, localRegion);
1870 hitRegion[localIndices[i]] = localRegion[i];
1875 allGeometry_[surfaces_[surfI]].getNormal(localHits, localNormal);
1879 hitNormal[localIndices[i]] = localNormal[i];