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]);
92 label nRetest =
returnReduce(retestSet.size(), sumOp<label>());
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 const searchableSurfaces& allGeometry,
136 globalI += allGeometry[surfaces[surfI]].regions().size();
143 const label nLocal = allGeometry[surfaces[surfI]].regions().size();
144 for (label i = 0; i < nLocal; i++)
146 regionToSurface[globalI++] = surfI;
150 return regionToSurface;
156 Foam::refinementSurfaces::refinementSurfaces
160 const label gapLevelIncrement,
164 allGeometry_(allGeometry),
165 surfaces_(surfacesDict.size()),
166 names_(surfacesDict.size()),
167 surfZones_(surfacesDict.size()),
168 regionOffset_(surfacesDict.size()),
176 forAll(allGeometry_.names(), geomI)
178 const word& geomName = allGeometry_.names()[geomI];
180 if (surfacesDict.
found(geomName))
187 surfaces_.setSize(surfI);
188 names_.setSize(surfI);
189 surfZones_.setSize(surfI);
190 regionOffset_.setSize(surfI);
225 forAll(allGeometry_.names(), geomI)
227 const word& geomName = allGeometry_.names()[geomI];
237 names_[surfI] = geomName;
238 surfaces_[surfI] = geomI;
242 meshRefinement::get<labelPair>
252 globalMinLevel[surfI] = refLevel[0];
253 globalMaxLevel[surfI] = refLevel[1];
262 globalMinLevel[surfI] < 0
263 || globalMaxLevel[surfI] < globalMinLevel[surfI]
264 || globalMaxLevel[surfI] < 0
265 || globalLevelIncr[surfI] < 0
269 <<
"Illegal level specification for surface "
271 <<
" : minLevel:" << globalMinLevel[surfI]
272 <<
" maxLevel:" << globalMaxLevel[surfI]
273 <<
" levelIncrement:" << globalLevelIncr[surfI]
285 globalGapMode[surfI] =
291 || globalGapLevel[surfI][0] < 0
292 || globalGapLevel[surfI][1] < 0
293 || globalGapLevel[surfI][2] < 0
294 || globalGapLevel[surfI][1] > globalGapLevel[surfI][2]
298 <<
"Illegal gapLevel specification for surface "
300 <<
" : gapLevel:" << globalGapLevel[surfI]
301 <<
" gapMode:" << globalGapMode[surfI].str()
305 globalGapSelf[surfI] =
318 allGeometry_.regionNames()[surfaces_[surfI]]
338 const wordList& regionNames = surface.regions();
340 forAll(regionNames, regionI)
342 if (regionsDict.
found(regionNames[regionI]))
352 meshRefinement::get<labelPair>
363 regionMinLevel[surfI].insert(regionI, refLevel[0]);
364 regionMaxLevel[surfI].insert(regionI, refLevel[1]);
370 regionLevelIncr[surfI].insert(regionI, levelIncr);
375 || refLevel[1] < refLevel[0]
380 <<
"Illegal level specification for surface "
381 << names_[surfI] <<
" region "
382 << regionNames[regionI]
383 <<
" : minLevel:" << refLevel[0]
384 <<
" maxLevel:" << refLevel[1]
385 <<
" levelIncrement:" << levelIncr
401 regionGapLevel[surfI].insert(regionI, gapSpec);
408 regionGapMode[surfI].insert(regionI, gapModeSpec);
415 || gapSpec[1] > gapSpec[2]
419 <<
"Illegal gapLevel specification for surface "
421 <<
" : gapLevel:" << gapSpec
422 <<
" gapMode:" << gapModeSpec.
str()
425 regionGapSelf[surfI].insert
435 if (regionDict.
found(
"perpendicularAngle"))
437 regionAngle[surfI].insert
440 regionDict.
get<scalar>(
"perpendicularAngle")
444 if (regionDict.
found(
"patchInfo"))
446 regionPatchInfo[surfI].insert
456 regionBlockLevel[surfI].insert(regionI, l);
465 if (unmatchedKeys.size() > 0)
468 <<
"Not all entries in refinementSurfaces dictionary were used."
469 <<
" The following entries were not used : "
470 << unmatchedKeys.sortedToc()
480 regionOffset_[surfI] = nRegions;
481 nRegions += allGeometry_[surfaces_[surfI]].regions().size();
486 regionToSurface_ = calcSurfaceIndex(allGeometry_, surfaces_);
489 minLevel_.setSize(nRegions);
491 maxLevel_.setSize(nRegions);
493 gapLevel_.setSize(nRegions);
495 extendedGapLevel_.setSize(nRegions);
496 extendedGapLevel_ = nullGapLevel;
497 extendedGapMode_.
setSize(nRegions);
499 selfProximity_.setSize(nRegions);
500 selfProximity_ =
true;
501 perpendicularAngle_.setSize(nRegions);
502 perpendicularAngle_ = -GREAT;
503 patchInfo_.setSize(nRegions);
504 blockLevel_.setSize(nRegions);
508 forAll(globalMinLevel, surfI)
510 label nRegions = allGeometry_[surfaces_[surfI]].regions().size();
513 for (label i = 0; i < nRegions; i++)
515 const label globalRegionI = regionOffset_[surfI] + i;
517 minLevel_[globalRegionI] = globalMinLevel[surfI];
518 maxLevel_[globalRegionI] = globalMaxLevel[surfI];
519 gapLevel_[globalRegionI] =
520 maxLevel_[globalRegionI]
521 + globalLevelIncr[surfI];
522 extendedGapLevel_[globalRegionI] = globalGapLevel[surfI];
523 extendedGapMode_[globalRegionI] = globalGapMode[surfI];
524 selfProximity_[globalRegionI] = globalGapSelf[surfI];
525 perpendicularAngle_[globalRegionI] = globalAngle[surfI];
526 if (globalPatchInfo.
set(surfI))
531 globalPatchInfo[surfI].clone()
534 blockLevel_[globalRegionI] = globalBlockLevel[surfI];
540 const label globalRegionI = regionOffset_[surfI] + iter.key();
542 minLevel_[globalRegionI] = iter.val();
543 maxLevel_[globalRegionI] = regionMaxLevel[surfI][iter.key()];
544 gapLevel_[globalRegionI] =
545 maxLevel_[globalRegionI]
546 + regionLevelIncr[surfI][iter.key()];
547 extendedGapLevel_[globalRegionI] =
548 regionGapLevel[surfI][iter.key()];
549 extendedGapMode_[globalRegionI] =
550 regionGapMode[surfI][iter.key()];
551 selfProximity_[globalRegionI] =
552 regionGapSelf[surfI][iter.key()];
556 const label globalRegionI = regionOffset_[surfI] + iter.key();
558 perpendicularAngle_[globalRegionI] = iter.val();
564 const label globalRegionI = regionOffset_[surfI] + iter.key();
572 const label globalRegionI = regionOffset_[surfI] + iter.key();
574 blockLevel_[globalRegionI] = iter.val();
580 Foam::refinementSurfaces::refinementSurfaces
595 allGeometry_(allGeometry),
598 surfZones_(surfZones),
599 regionOffset_(regionOffset),
600 regionToSurface_(calcSurfaceIndex(allGeometry, surfaces)),
604 perpendicularAngle_(perpendicularAngle),
605 patchInfo_(patchInfo.size()),
610 if (patchInfo.
set(pI))
612 patchInfo_.set(pI, patchInfo.
set(pI,
nullptr));
622 const label globalRegionI
625 const label surfI = regionToSurface_[globalRegionI];
626 const label localI = globalRegionI-regionOffset_[surfI];
692 const wordList& regionNames = allGeometry_[surfaces_[surfI]].regions();
694 forAll(regionNames, regionI)
696 label globalI = globalRegion(surfI, regionI);
698 surfaceMax[surfI] =
max(surfaceMax[surfI], gapInfo[2]);
742 minLevelField[i] = minLevel(surfI, region[i]);
750 shells.findHigherLevel(ctrs, minLevelField, shellLevel);
755 if (isA<triSurface>(geom))
761 const triSurface& ts = refCast<const triSurface>(geom);
770 label level = shellLevel[triI];
773 minPointLevel[t[tI]] =
min(minPointLevel[t[tI]], level);
780 shells.findHigherLevel(
points, minPointLevel, pointLevel);
787 label fLevel = shellLevel[triI];
790 (pointLevel[t[0]] != fLevel)
791 || (pointLevel[t[1]] != fLevel)
792 || (pointLevel[t[2]] != fLevel)
799 shellLevel[triI] = -1;
806 Info<<
"For geometry " << geom.
name()
809 <<
" uncached triangles out of " << geom.
globalSize()
820 if (
min(minLevelField[i], shellLevel[i]) < 0)
822 minLevelField[i] = -1;
826 minLevelField[i] =
max(minLevelField[i], shellLevel[i]);
851 surfaces.
setSize(start.size());
853 surfaceLevel.
setSize(start.size());
856 if (surfaces_.empty())
861 if (surfaces_.size() == 1)
876 labelList surfaceOnlyLevel(start.size(), -1);
880 geom.
getRegion(intersectionInfo, region);
882 forAll(intersectionInfo, i)
884 if (intersectionInfo[i].hit())
886 surfaceOnlyLevel[i] = minLevel(surfI, region[i]);
908 if (localLevel[i] > currentLevel[i])
911 surfaceLevel[i] = localLevel[i];
935 labelList surfaceOnlyLevel(intersectionInfo.size(), -1);
939 geom.
getRegion(intersectionInfo, region);
941 forAll(intersectionInfo, i)
943 if (intersectionInfo[i].hit())
945 surfaceOnlyLevel[i] = minLevel(surfI, region[i]);
968 label pointI = intersectionToPoint[i];
970 if (localLevel[i] > currentLevel[pointI])
973 surfaces[pointI] = surfI;
974 surfaceLevel[pointI] = localLevel[i];
978 p0[missI] = start[pointI];
979 p1[missI] =
end[pointI];
980 intersectionToPoint[missI] = pointI;
995 intersectionToPoint.
setSize(missI);
996 intersectionInfo.setSize(missI);
1014 surfaceLevel.
setSize(start.size());
1015 surfaceNormal.
setSize(start.size());
1017 if (surfaces_.empty())
1040 n += hitInfo[pointI].size();
1053 surfInfo[
n] = pHits[i];
1054 pointMap[
n] = pointI;
1061 surface.
getRegion(surfInfo, surfRegion);
1062 surface.
getNormal(surfInfo, surfNormal);
1072 label region = globalRegion(surfI, surfRegion[i]);
1073 label pointI = pointMap[i];
1077 currentLevel[pointI] >= globalMinLevel[region]
1078 && currentLevel[pointI] < globalMaxLevel[region]
1082 label sz = surfaceNormal[pointI].size();
1083 surfaceNormal[pointI].
setSize(sz+1);
1084 surfaceNormal[pointI][sz] = surfNormal[i];
1086 surfaceLevel[pointI].
setSize(sz+1);
1087 surfaceLevel[pointI][sz] = globalMaxLevel[region];
1108 surfaceLevel.
setSize(start.size());
1109 surfaceNormal.
setSize(start.size());
1112 if (surfaces_.empty())
1135 n += hitInfo[pointI].size();
1148 surfInfo[
n] = pHits[i];
1149 pointMap[
n] = pointI;
1156 surface.
getRegion(surfInfo, surfRegion);
1157 surface.
getNormal(surfInfo, surfNormal);
1164 label region = globalRegion(surfI, surfRegion[i]);
1165 label pointI = pointMap[i];
1169 currentLevel[pointI] >= globalMinLevel[region]
1170 && currentLevel[pointI] < globalMaxLevel[region]
1174 label sz = surfaceNormal[pointI].size();
1178 surfaceNormal[pointI].
setSize(sz+1);
1179 surfaceNormal[pointI][sz] = surfNormal[i];
1181 surfaceLevel[pointI].
setSize(sz+1);
1184 surfaceLevel[pointI][sz] = globalMaxLevel[region];
1209 surface1.
setSize(start.size());
1212 region1.
setSize(start.size());
1220 forAll(surfacesToTest, testI)
1222 label surfI = surfacesToTest[testI];
1239 forAll(nearestInfo, pointI)
1241 if (nearestInfo[pointI].hit())
1243 hit1[pointI] = nearestInfo[pointI];
1244 surface1[pointI] = surfI;
1245 region1[pointI] = region[pointI];
1246 nearest[pointI] = hit1[pointI].hitPoint();
1257 surface2 = surface1;
1264 if (hit1[pointI].hit())
1266 nearest[pointI] = hit1[pointI].hitPoint();
1271 nearest[pointI] =
end[pointI];
1275 forAll(surfacesToTest, testI)
1277 label surfI = surfacesToTest[testI];
1294 forAll(nearestInfo, pointI)
1296 if (nearestInfo[pointI].hit())
1298 hit2[pointI] = nearestInfo[pointI];
1299 surface2[pointI] = surfI;
1300 region2[pointI] = region[pointI];
1301 nearest[pointI] = hit2[pointI].hitPoint();
1311 if (hit1[pointI].hit() && !hit2[pointI].hit())
1313 hit2[pointI] = hit1[pointI];
1314 surface2[pointI] = surface1[pointI];
1315 region2[pointI] = region1[pointI];
1342 surface1.
setSize(start.size());
1345 region1.
setSize(start.size());
1347 normal1.setSize(start.size());
1357 forAll(surfacesToTest, testI)
1359 label surfI = surfacesToTest[testI];
1363 geom.
findLine(start, nearest, nearestInfo);
1367 forAll(nearestInfo, pointI)
1369 if (nearestInfo[pointI].hit())
1371 hit1[pointI] = nearestInfo[pointI];
1372 surface1[pointI] = surfI;
1373 region1[pointI] = region[pointI];
1374 normal1[pointI] = normal[pointI];
1375 nearest[pointI] = hit1[pointI].hitPoint();
1386 surface2 = surface1;
1394 if (hit1[pointI].hit())
1396 nearest[pointI] = hit1[pointI].hitPoint();
1401 nearest[pointI] =
end[pointI];
1405 forAll(surfacesToTest, testI)
1407 label surfI = surfacesToTest[testI];
1415 forAll(nearestInfo, pointI)
1417 if (nearestInfo[pointI].hit())
1419 hit2[pointI] = nearestInfo[pointI];
1420 surface2[pointI] = surfI;
1421 region2[pointI] = region[pointI];
1422 normal2[pointI] = normal[pointI];
1423 nearest[pointI] = hit2[pointI].hitPoint();
1433 if (hit1[pointI].hit() && !hit2[pointI].hit())
1435 hit2[pointI] = hit1[pointI];
1436 surface2[pointI] = surface1[pointI];
1437 region2[pointI] = region1[pointI];
1438 normal2[pointI] = normal1[pointI];
1454 surface1.
setSize(start.size());
1456 normal1.setSize(start.size());
1471 geom.
findLine(start, nearest, nearestInfo);
1474 forAll(nearestInfo, pointI)
1476 if (nearestInfo[pointI].hit())
1478 surface1[pointI] = surfI;
1479 normal1[pointI] = normal[pointI];
1480 nearest[pointI] = nearestInfo[pointI].hitPoint();
1501 surface1.
setSize(start.size());
1503 hitInfo1.
setSize(start.size());
1505 normal1.setSize(start.size());
1520 geom.
findLine(start, nearest, nearestInfo);
1523 forAll(nearestInfo, pointI)
1525 if (nearestInfo[pointI].hit())
1527 surface1[pointI] = surfI;
1528 hitInfo1[pointI] = nearestInfo[pointI];
1529 normal1[pointI] = normal[pointI];
1530 nearest[pointI] = nearestInfo[pointI].hitPoint();
1581 forAll(hitSurface, pointI)
1583 if (hitSurface[pointI] != -1)
1585 hitSurface[pointI] = surfacesToTest[hitSurface[pointI]];
1615 forAll(hitSurface, pointI)
1617 if (hitSurface[pointI] != -1)
1619 hitSurface[pointI] = surfacesToTest[hitSurface[pointI]];
1624 hitRegion.
setSize(hitSurface.size());
1627 forAll(surfacesToTest, i)
1629 label surfI = surfacesToTest[i];
1644 allGeometry_[surfaces_[surfI]].getRegion(localHits, localRegion);
1648 hitRegion[localIndices[i]] = localRegion[i];
1679 forAll(hitSurface, pointI)
1681 if (hitSurface[pointI] != -1)
1683 hitSurface[pointI] = surfacesToTest[hitSurface[pointI]];
1688 hitRegion.
setSize(hitSurface.size());
1690 hitNormal.setSize(hitSurface.size());
1693 forAll(surfacesToTest, i)
1695 label surfI = surfacesToTest[i];
1711 allGeometry_[surfaces_[surfI]].getRegion(localHits, localRegion);
1715 hitRegion[localIndices[i]] = localRegion[i];
1720 allGeometry_[surfaces_[surfI]].getNormal(localHits, localNormal);
1724 hitNormal[localIndices[i]] = localNormal[i];
1782 insideSurfaces.
setSize(pt.size());
1783 insideSurfaces = -1;
1787 label surfI = testSurfaces[i];
1792 surfZones_[surfI].zoneInside();
1801 <<
"Trying to use surface "
1803 <<
" which has non-geometric inside selection method "
1815 if (insideSurfaces[pointI] == -1)
1829 insideSurfaces[pointI] = surfI;
1865 forAll(hitSurface, pointI)
1867 if (hitSurface[pointI] != -1)
1869 hitSurface[pointI] = surfacesToTest[hitSurface[pointI]];
1904 forAll(hitSurface, pointI)
1906 if (hitSurface[pointI] != -1)
1908 hitSurface[pointI] = surfacesToTest[hitSurface[pointI]];
1913 hitRegion.
setSize(hitSurface.size());
1915 hitNormal.setSize(hitSurface.size());
1918 forAll(surfacesToTest, i)
1920 label surfI = surfacesToTest[i];
1936 allGeometry_[surfaces_[surfI]].getRegion(localHits, localRegion);
1940 hitRegion[localIndices[i]] = localRegion[i];
1945 allGeometry_[surfaces_[surfI]].getNormal(localHits, localNormal);
1949 hitNormal[localIndices[i]] = localNormal[i];