39 Foam::refinementSurfaces::refinementSurfaces
45 allGeometry_(allGeometry),
46 surfaces_(surfaceDicts.
size()),
47 names_(surfaceDicts.
size()),
48 faceZoneNames_(surfaceDicts.
size()),
49 cellZoneNames_(surfaceDicts.
size()),
50 zoneInside_(surfaceDicts.
size()),
51 regionOffset_(surfaceDicts.
size())
64 forAll(surfaceDicts, surfI)
68 dict.
lookup(
"name") >> names_[surfI];
70 surfaces_[surfI] = allGeometry_.findSurfaceID(names_[surfI]);
73 globalMinLevel[surfI] = readLabel(dict.
lookup(
"minRefinementLevel"));
74 globalMaxLevel[surfI] = readLabel(dict.
lookup(
"maxRefinementLevel"));
77 if (dict.
found(
"faceZone"))
79 dict.
lookup(
"faceZone") >> faceZoneNames_[surfI];
80 dict.
lookup(
"cellZone") >> cellZoneNames_[surfI];
81 dict.
lookup(
"zoneInside") >> zoneInside_[surfI];
85 if (dict.
found(
"perpendicularAngle"))
97 if (dict.
found(
"regions"))
102 allGeometry_[surfaces_[surfI]].regions();
104 forAll(regionDicts, dictI)
106 const dictionary& regionDict = regionDicts[dictI];
116 "refinementSurfaces::refinementSurfaces"
117 "(const IOobject&, const PtrList<dictionary>&)"
118 ) <<
"No region called " <<
regionName <<
" on surface "
119 << allGeometry_[surfaces_[surfI]].name() <<
endl
120 <<
"Valid regions are " << regionNames
125 label
min = readLabel(regionDict.
lookup(
"minRefinementLevel"));
126 label
max = readLabel(regionDict.
lookup(
"maxRefinementLevel"));
128 bool hasInserted = regionMinLevel[surfI].insert(regionI, min);
133 "refinementSurfaces::refinementSurfaces"
134 "(const IOobject&, const PtrList<dictionary>&)"
136 <<
" on surface " << names_[surfI]
139 regionMaxLevel[surfI].insert(regionI, max);
141 if (regionDict.
found(
"perpendicularAngle"))
143 regionAngle[surfI].insert
160 if (!surfaceNames.insert(names_[surfI], surfI))
164 "refinementSurfaces::refinementSurfaces"
165 "(const IOobject&, const PtrList<dictionary>&)"
166 ) <<
"Duplicate surface name " << names_[surfI] <<
endl
167 <<
"Previous occurrence of name at surface "
168 << surfaceNames[names_[surfI]]
177 forAll(surfaceDicts, surfI)
179 regionOffset_[surfI] = nRegions;
181 nRegions += allGeometry_[surfaces_[surfI]].regions().size();
185 minLevel_.setSize(nRegions);
187 maxLevel_.setSize(nRegions);
189 perpendicularAngle_.setSize(nRegions);
190 perpendicularAngle_ = -GREAT;
194 forAll(surfaceDicts, surfI)
196 label nRegions = allGeometry_[surfaces_[surfI]].regions().size();
199 for (label i = 0; i < nRegions; i++)
201 minLevel_[regionOffset_[surfI] + i] = globalMinLevel[surfI];
202 maxLevel_[regionOffset_[surfI] + i] = globalMaxLevel[surfI];
203 perpendicularAngle_[regionOffset_[surfI] + i] = globalAngle[surfI];
209 label globalRegionI = regionOffset_[surfI] + iter.key();
211 minLevel_[globalRegionI] = iter();
212 maxLevel_[globalRegionI] = regionMaxLevel[surfI][iter.key()];
217 minLevel_[globalRegionI] < 0
218 || maxLevel_[globalRegionI] < minLevel_[globalRegionI]
223 "refinementSurfaces::refinementSurfaces"
224 "(const IOobject&, const PtrList<dictionary>&)"
225 ) <<
"Illegal level or layer specification for surface "
227 <<
" : minLevel:" << minLevel_[globalRegionI]
228 <<
" maxLevel:" << maxLevel_[globalRegionI]
234 label globalRegionI = regionOffset_[surfI] + iter.key();
236 perpendicularAngle_[globalRegionI] = regionAngle[surfI][iter.key()];
253 Foam::refinementSurfaces::refinementSurfaces
259 allGeometry_(allGeometry),
260 surfaces_(surfacesDict.
size()),
261 names_(surfacesDict.
size()),
262 faceZoneNames_(surfacesDict.
size()),
263 cellZoneNames_(surfacesDict.
size()),
264 zoneInside_(surfacesDict.
size()),
265 regionOffset_(surfacesDict.
size())
274 const word& geomName = allGeometry_.names()[geomI];
276 if (surfacesDict.
found(geomName))
283 surfaces_.setSize(surfI);
284 names_.setSize(surfI);
285 faceZoneNames_.setSize(surfI);
286 cellZoneNames_.setSize(surfI);
287 zoneInside_.setSize(surfI);
288 regionOffset_.setSize(surfI);
300 const word& geomName = allGeometry_.names()[geomI];
302 if (surfacesDict.
found(geomName))
306 names_[surfI] = geomName;
307 surfaces_[surfI] = geomI;
310 globalMinLevel[surfI] = refLevel[0];
311 globalMaxLevel[surfI] = refLevel[1];
314 if (dict.
found(
"faceZone"))
316 dict.
lookup(
"faceZone") >> faceZoneNames_[surfI];
317 dict.
lookup(
"cellZone") >> cellZoneNames_[surfI];
318 dict.
lookup(
"zoneInside") >> zoneInside_[surfI];
322 if (dict.
found(
"perpendicularAngle"))
326 dict.
lookup(
"perpendicularAngle")
330 if (dict.
found(
"regions"))
334 allGeometry_[surfaces_[surfI]].regions();
336 forAll(regionNames, regionI)
338 if (regionsDict.
found(regionNames[regionI]))
348 regionMinLevel[surfI].insert(regionI, refLevel[0]);
349 regionMaxLevel[surfI].insert(regionI, refLevel[1]);
351 if (regionDict.
found(
"perpendicularAngle"))
353 regionAngle[surfI].insert
358 regionDict.
lookup(
"perpendicularAngle")
374 regionOffset_[surfI] = nRegions;
375 nRegions += allGeometry_[surfaces_[surfI]].regions().size();
379 minLevel_.setSize(nRegions);
381 maxLevel_.setSize(nRegions);
383 perpendicularAngle_.setSize(nRegions);
384 perpendicularAngle_ = -GREAT;
387 forAll(globalMinLevel, surfI)
389 label nRegions = allGeometry_[surfaces_[surfI]].regions().size();
392 for (label i = 0; i < nRegions; i++)
394 minLevel_[regionOffset_[surfI] + i] = globalMinLevel[surfI];
395 maxLevel_[regionOffset_[surfI] + i] = globalMaxLevel[surfI];
396 perpendicularAngle_[regionOffset_[surfI] + i] = globalAngle[surfI];
402 label globalRegionI = regionOffset_[surfI] + iter.key();
404 minLevel_[globalRegionI] = iter();
405 maxLevel_[globalRegionI] = regionMaxLevel[surfI][iter.key()];
410 minLevel_[globalRegionI] < 0
411 || maxLevel_[globalRegionI] < minLevel_[globalRegionI]
416 "refinementSurfaces::refinementSurfaces"
417 "(const searchableSurfaces&, const dictionary>&"
418 ) <<
"Illegal level or layer specification for surface "
420 <<
" : minLevel:" << minLevel_[globalRegionI]
421 <<
" maxLevel:" << maxLevel_[globalRegionI]
427 label globalRegionI = regionOffset_[surfI] + iter.key();
429 perpendicularAngle_[globalRegionI] = regionAngle[surfI][iter.key()];
443 forAll(faceZoneNames_, surfI)
445 if (faceZoneNames_[surfI].empty())
447 anonymousSurfaces[i++] = surfI;
450 anonymousSurfaces.setSize(i);
452 return anonymousSurfaces;
459 labelList namedSurfaces(faceZoneNames_.size());
462 forAll(faceZoneNames_, surfI)
464 if (faceZoneNames_[surfI].size())
466 namedSurfaces[namedI++] = surfI;
469 namedSurfaces.setSize(namedI);
471 return namedSurfaces;
485 label surfI = named[i];
487 if (allGeometry_[surfaces_[surfI]].hasVolumeType())
489 closed[closedI++] = surfI;
596 minLevelField[i] = minLevel(surfI, region[i]);
604 shells.findHigherLevel(ctrs, minLevelField, shellLevel);
608 minLevelField[i] =
max(minLevelField[i], shellLevel[i]);
635 if (surfaces_.empty())
640 if (surfaces_.size() == 1)
655 geom.
getField(intersectionInfo, minLevelField);
656 bool haveLevelField =
666 intersectionInfo.size(),
669 haveLevelField =
true;
674 forAll(intersectionInfo, i)
678 intersectionInfo[i].hit()
679 && minLevelField[i] > currentLevel[i]
683 surfaceLevel[i] = minLevelField[i];
707 geom.
getField(intersectionInfo, minLevelField);
711 forAll(intersectionInfo, i)
714 label minLocalLevel = -1;
716 if (intersectionInfo[i].hit())
719 if (minLevelField.
size())
721 minLocalLevel = minLevelField[i];
727 minLocalLevel = minLevel(surfI, 0);
732 label pointI = intersectionToPoint[i];
734 if (minLocalLevel > currentLevel[pointI])
737 surfaces[pointI] = surfI;
738 surfaceLevel[pointI] = minLocalLevel;
742 p0[missI] = start[pointI];
743 p1[missI] = end[pointI];
744 intersectionToPoint[missI] = pointI;
758 intersectionToPoint.
setSize(missI);
759 intersectionInfo.setSize(missI);
777 if (surfaces_.empty())
789 allGeometry_[surfaces_[surfI]].findLineAll(start, end, hitInfo);
798 n += hitInfo[pointI].
size();
811 surfInfo[n] = pHits[i];
812 pointMap[n] = pointI;
819 allGeometry_[surfaces_[surfI]].getRegion(surfInfo, surfRegion);
820 allGeometry_[surfaces_[surfI]].getNormal(surfInfo, surfNormal);
830 label region = globalRegion(surfI, surfRegion[i]);
831 label pointI = pointMap[i];
833 if (maxLevel_[region] > currentLevel[pointI])
836 label sz = surfaceNormal[pointI].
size();
837 surfaceNormal[pointI].
setSize(sz+1);
838 surfaceNormal[pointI][sz] = surfNormal[i];
840 surfaceLevel[pointI].
setSize(sz+1);
841 surfaceLevel[pointI][sz] = maxLevel_[region];
877 forAll(surfacesToTest, testI)
879 label surfI = surfacesToTest[testI];
882 allGeometry_[surfaces_[surfI]].findLine
888 allGeometry_[surfaces_[surfI]].getRegion
894 forAll(nearestInfo, pointI)
896 if (nearestInfo[pointI].hit())
898 hit1[pointI] = nearestInfo[pointI];
899 surface1[pointI] = surfI;
900 region1[pointI] = region[pointI];
901 nearest[pointI] = hit1[pointI].hitPoint();
919 if (hit1[pointI].hit())
921 nearest[pointI] = hit1[pointI].hitPoint();
926 nearest[pointI] = end[pointI];
930 forAll(surfacesToTest, testI)
932 label surfI = surfacesToTest[testI];
935 allGeometry_[surfaces_[surfI]].findLine
941 allGeometry_[surfaces_[surfI]].getRegion
947 forAll(nearestInfo, pointI)
949 if (nearestInfo[pointI].hit())
951 hit2[pointI] = nearestInfo[pointI];
952 surface2[pointI] = surfI;
953 region2[pointI] = region[pointI];
954 nearest[pointI] = hit2[pointI].hitPoint();
964 if (hit1[pointI].hit() && !hit2[pointI].hit())
966 hit2[pointI] = hit1[pointI];
967 surface2[pointI] = surface1[pointI];
968 region2[pointI] = region1[pointI];
1018 forAll(hitSurface, pointI)
1020 if (hitSurface[pointI] != -1)
1022 hitSurface[pointI] = surfacesToTest[hitSurface[pointI]];
1052 forAll(hitSurface, pointI)
1054 if (hitSurface[pointI] != -1)
1056 hitSurface[pointI] = surfacesToTest[hitSurface[pointI]];
1064 forAll(surfacesToTest, i)
1066 label surfI = surfacesToTest[i];
1081 allGeometry_[surfaces_[surfI]].getRegion(localHits, localRegion);
1085 hitRegion[localIndices[i]] = localRegion[i];
1144 insideSurfaces = -1;
1148 label surfI = testSurfaces[i];
1150 if (allGeometry_[surfaces_[surfI]].hasVolumeType())
1153 allGeometry_[surfaces_[surfI]].getVolumeType(pt, volType);
1157 if (insideSurfaces[pointI] == -1)
1163 && zoneInside_[surfI]
1167 && !zoneInside_[surfI]
1171 insideSurfaces[pointI] = surfI;