45 const searchableSurface& geom,
46 const shellSurfaces& shells,
47 const List<pointIndexHit>& intersectionInfo,
48 const labelList& surfaceLevel
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;
160 const label gapLevelIncrement,
164 allGeometry_(allGeometry),
165 surfaces_(surfacesDict.size()),
166 names_(surfacesDict.size()),
167 surfZones_(surfacesDict.size()),
168 regionOffset_(surfacesDict.size()),
178 const word& geomName = allGeometry_.
names()[geomI];
180 if (surfacesDict.
found(geomName))
189 surfZones_.setSize(surfI);
229 const word& geomName = allGeometry_.
names()[geomI];
239 names_[surfI] = geomName;
240 surfaces_[surfI] = geomI;
244 meshRefinement::get<labelPair>
254 globalMinLevel[surfI] = refLevel[0];
255 globalMaxLevel[surfI] = refLevel[1];
264 globalMinLevel[surfI] < 0
265 || globalMaxLevel[surfI] < globalMinLevel[surfI]
266 || globalMaxLevel[surfI] < 0
267 || globalLevelIncr[surfI] < 0
271 <<
"Illegal level specification for surface "
273 <<
" : minLevel:" << globalMinLevel[surfI]
274 <<
" maxLevel:" << globalMaxLevel[surfI]
275 <<
" levelIncrement:" << globalLevelIncr[surfI]
287 globalGapMode[surfI] =
293 || globalGapLevel[surfI][0] < 0
294 || globalGapLevel[surfI][1] < 0
295 || globalGapLevel[surfI][2] < 0
296 || globalGapLevel[surfI][1] > globalGapLevel[surfI][2]
300 <<
"Illegal gapLevel specification for surface "
302 <<
" : gapLevel:" << globalGapLevel[surfI]
303 <<
" gapMode:" << globalGapMode[surfI].str()
307 globalGapSelf[surfI] =
355 meshRefinement::get<labelPair>
366 regionMinLevel[surfI].insert(regionI, refLevel[0]);
367 regionMaxLevel[surfI].insert(regionI, refLevel[1]);
373 regionLevelIncr[surfI].insert(regionI, levelIncr);
378 || refLevel[1] < refLevel[0]
383 <<
"Illegal level specification for surface "
384 << names_[surfI] <<
" region "
386 <<
" : minLevel:" << refLevel[0]
387 <<
" maxLevel:" << refLevel[1]
388 <<
" levelIncrement:" << levelIncr
404 regionGapLevel[surfI].insert(regionI, gapSpec);
411 regionGapMode[surfI].insert(regionI, gapModeSpec);
418 || gapSpec[1] > gapSpec[2]
422 <<
"Illegal gapLevel specification for surface "
424 <<
" : gapLevel:" << gapSpec
425 <<
" gapMode:" << gapModeSpec.
str()
428 regionGapSelf[surfI].insert
438 if (regionDict.
found(
"perpendicularAngle"))
440 regionAngle[surfI].insert
443 regionDict.
get<scalar>(
"perpendicularAngle")
447 if (regionDict.
found(
"patchInfo"))
449 regionPatchInfo[surfI].insert
459 regionBlockLevel[surfI].insert(regionI, l);
463 regionLeakLevel[surfI].insert(regionI, l);
472 if (unmatchedKeys.
size() > 0)
475 <<
"Not all entries in refinementSurfaces dictionary were used."
476 <<
" The following entries were not used : "
488 nRegions += allGeometry_[surfaces_[surfI]].regions().
size();
493 regionToSurface_ = calcSurfaceIndex(allGeometry_, surfaces_);
502 extendedGapLevel_.setSize(
nRegions);
503 extendedGapLevel_ = nullGapLevel;
507 selfProximity_ =
true;
509 perpendicularAngle_ = -GREAT;
517 forAll(globalMinLevel, surfI)
519 label
nRegions = allGeometry_[surfaces_[surfI]].regions().
size();
522 for (label i = 0; i <
nRegions; i++)
524 const label globalRegionI = regionOffset_[surfI] + i;
526 minLevel_[globalRegionI] = globalMinLevel[surfI];
527 maxLevel_[globalRegionI] = globalMaxLevel[surfI];
528 gapLevel_[globalRegionI] =
529 maxLevel_[globalRegionI]
530 + globalLevelIncr[surfI];
531 extendedGapLevel_[globalRegionI] = globalGapLevel[surfI];
532 extendedGapMode_[globalRegionI] = globalGapMode[surfI];
533 selfProximity_[globalRegionI] = globalGapSelf[surfI];
534 perpendicularAngle_[globalRegionI] = globalAngle[surfI];
535 if (globalPatchInfo.
set(surfI))
540 globalPatchInfo[surfI].clone()
543 blockLevel_[globalRegionI] = globalBlockLevel[surfI];
544 leakLevel_[globalRegionI] = globalLeakLevel[surfI];
550 const label globalRegionI = regionOffset_[surfI] + iter.key();
552 minLevel_[globalRegionI] = iter.val();
553 maxLevel_[globalRegionI] = regionMaxLevel[surfI][iter.key()];
554 gapLevel_[globalRegionI] =
555 maxLevel_[globalRegionI]
556 + regionLevelIncr[surfI][iter.key()];
557 extendedGapLevel_[globalRegionI] =
558 regionGapLevel[surfI][iter.key()];
559 extendedGapMode_[globalRegionI] =
560 regionGapMode[surfI][iter.key()];
561 selfProximity_[globalRegionI] =
562 regionGapSelf[surfI][iter.key()];
566 const label globalRegionI = regionOffset_[surfI] + iter.key();
568 perpendicularAngle_[globalRegionI] = iter.val();
574 const label globalRegionI = regionOffset_[surfI] + iter.key();
577 patchInfo_.set(globalRegionI,
dict.
clone());
582 const label globalRegionI = regionOffset_[surfI] + iter.key();
584 blockLevel_[globalRegionI] = iter.val();
585 leakLevel_[globalRegionI] = iter.val();
606 allGeometry_(allGeometry),
609 surfZones_(surfZones),
610 regionOffset_(regionOffset),
611 regionToSurface_(calcSurfaceIndex(allGeometry, surfaces)),
615 perpendicularAngle_(perpendicularAngle),
616 patchInfo_(patchInfo.size()),
623 patchInfo_.set(pI,
patchInfo.set(pI,
nullptr));
633 const label globalRegionI
636 const label surfI = regionToSurface_[globalRegionI];
637 const label localI = globalRegionI-regionOffset_[surfI];
707 label globalI = globalRegion(surfI, regionI);
709 surfaceMax[surfI] =
max(surfaceMax[surfI], gapInfo[2]);
753 minLevelField[i] = minLevel(surfI, region[i]);
761 shells.findHigherLevel(ctrs, minLevelField, shellLevel);
766 if (isA<triSurface>(geom))
772 const triSurface& ts = refCast<const triSurface>(geom);
781 label level = shellLevel[triI];
784 minPointLevel[t[tI]] =
min(minPointLevel[t[tI]], level);
791 shells.findHigherLevel(
points, minPointLevel, pointLevel);
798 label fLevel = shellLevel[triI];
801 (pointLevel[t[0]] != fLevel)
802 || (pointLevel[t[1]] != fLevel)
803 || (pointLevel[t[2]] != fLevel)
810 shellLevel[triI] = -1;
817 Info<<
"For geometry " << geom.
name()
820 <<
" uncached triangles out of " << geom.
globalSize()
831 if (
min(minLevelField[i], shellLevel[i]) < 0)
833 minLevelField[i] = -1;
837 minLevelField[i] =
max(minLevelField[i], shellLevel[i]);
867 if (surfaces_.empty())
872 if (surfaces_.size() == 1)
891 geom.
getRegion(intersectionInfo, region);
893 forAll(intersectionInfo, i)
895 if (intersectionInfo[i].hit())
897 surfaceOnlyLevel[i] = minLevel(surfI, region[i]);
919 if (localLevel[i] > currentLevel[i])
922 surfaceLevel[i] = localLevel[i];
950 geom.
getRegion(intersectionInfo, region);
952 forAll(intersectionInfo, i)
954 if (intersectionInfo[i].hit())
956 surfaceOnlyLevel[i] = minLevel(surfI, region[i]);
979 label pointI = intersectionToPoint[i];
981 if (localLevel[i] > currentLevel[pointI])
984 surfaces[pointI] = surfI;
985 surfaceLevel[pointI] = localLevel[i];
989 p0[missI] = start[pointI];
990 p1[missI] = end[pointI];
991 intersectionToPoint[missI] = pointI;
1006 intersectionToPoint.
setSize(missI);
1007 intersectionInfo.
setSize(missI);
1028 if (surfaces_.empty())
1042 surface.findLineAll(start, end, hitInfo);
1051 n += hitInfo[pointI].
size();
1064 surfInfo[
n] = pHits[i];
1065 pointMap[
n] = pointI;
1072 surface.getRegion(surfInfo, surfRegion);
1073 surface.getNormal(surfInfo, surfNormal);
1083 label region = globalRegion(surfI, surfRegion[i]);
1084 label pointI = pointMap[i];
1088 currentLevel[pointI] >= globalMinLevel[region]
1089 && currentLevel[pointI] < globalMaxLevel[region]
1093 label sz = surfaceNormal[pointI].
size();
1094 surfaceNormal[pointI].
setSize(sz+1);
1095 surfaceNormal[pointI][sz] = surfNormal[i];
1097 surfaceLevel[pointI].
setSize(sz+1);
1098 surfaceLevel[pointI][sz] = globalMaxLevel[region];
1123 if (surfaces_.empty())
1137 surface.findLineAll(start, end, hitInfo);
1146 n += hitInfo[pointI].
size();
1159 surfInfo[
n] = pHits[i];
1160 pointMap[
n] = pointI;
1167 surface.getRegion(surfInfo, surfRegion);
1168 surface.getNormal(surfInfo, surfNormal);
1175 label region = globalRegion(surfI, surfRegion[i]);
1176 label pointI = pointMap[i];
1180 currentLevel[pointI] >= globalMinLevel[region]
1181 && currentLevel[pointI] < globalMaxLevel[region]
1185 label sz = surfaceNormal[pointI].
size();
1189 surfaceNormal[pointI].
setSize(sz+1);
1190 surfaceNormal[pointI][sz] = surfNormal[i];
1192 surfaceLevel[pointI].
setSize(sz+1);
1195 surfaceLevel[pointI][sz] = globalMaxLevel[region];
1231 forAll(surfacesToTest, testI)
1233 label surfI = surfacesToTest[testI];
1250 forAll(nearestInfo, pointI)
1252 if (nearestInfo[pointI].hit())
1254 hit1[pointI] = nearestInfo[pointI];
1255 surface1[pointI] = surfI;
1256 region1[pointI] = region[pointI];
1257 nearest[pointI] = hit1[pointI].hitPoint();
1268 surface2 = surface1;
1275 if (hit1[pointI].hit())
1277 nearest[pointI] = hit1[pointI].hitPoint();
1282 nearest[pointI] = end[pointI];
1286 forAll(surfacesToTest, testI)
1288 label surfI = surfacesToTest[testI];
1305 forAll(nearestInfo, pointI)
1307 if (nearestInfo[pointI].hit())
1309 hit2[pointI] = nearestInfo[pointI];
1310 surface2[pointI] = surfI;
1311 region2[pointI] = region[pointI];
1312 nearest[pointI] = hit2[pointI].hitPoint();
1322 if (hit1[pointI].hit() && !hit2[pointI].hit())
1324 hit2[pointI] = hit1[pointI];
1325 surface2[pointI] = surface1[pointI];
1326 region2[pointI] = region1[pointI];
1368 forAll(surfacesToTest, testI)
1370 label surfI = surfacesToTest[testI];
1374 geom.
findLine(start, nearest, nearestInfo);
1378 forAll(nearestInfo, pointI)
1380 if (nearestInfo[pointI].hit())
1382 hit1[pointI] = nearestInfo[pointI];
1383 surface1[pointI] = surfI;
1384 region1[pointI] = region[pointI];
1385 normal1[pointI] = normal[pointI];
1386 nearest[pointI] = hit1[pointI].hitPoint();
1397 surface2 = surface1;
1405 if (hit1[pointI].hit())
1407 nearest[pointI] = hit1[pointI].hitPoint();
1412 nearest[pointI] = end[pointI];
1416 forAll(surfacesToTest, testI)
1418 label surfI = surfacesToTest[testI];
1422 geom.
findLine(end, nearest, nearestInfo);
1426 forAll(nearestInfo, pointI)
1428 if (nearestInfo[pointI].hit())
1430 hit2[pointI] = nearestInfo[pointI];
1431 surface2[pointI] = surfI;
1432 region2[pointI] = region[pointI];
1433 normal2[pointI] = normal[pointI];
1434 nearest[pointI] = hit2[pointI].hitPoint();
1444 if (hit1[pointI].hit() && !hit2[pointI].hit())
1446 hit2[pointI] = hit1[pointI];
1447 surface2[pointI] = surface1[pointI];
1448 region2[pointI] = region1[pointI];
1449 normal2[pointI] = normal1[pointI];
1482 geom.
findLine(start, nearest, nearestInfo);
1485 forAll(nearestInfo, pointI)
1487 if (nearestInfo[pointI].hit())
1489 surface1[pointI] = surfI;
1490 normal1[pointI] = normal[pointI];
1491 nearest[pointI] = nearestInfo[pointI].hitPoint();
1531 geom.
findLine(start, nearest, nearestInfo);
1534 forAll(nearestInfo, pointI)
1536 if (nearestInfo[pointI].hit())
1538 surface1[pointI] = surfI;
1539 hitInfo1[pointI] = nearestInfo[pointI];
1540 normal1[pointI] = normal[pointI];
1541 nearest[pointI] = nearestInfo[pointI].hitPoint();
1592 forAll(hitSurface, pointI)
1594 if (hitSurface[pointI] != -1)
1596 hitSurface[pointI] = surfacesToTest[hitSurface[pointI]];
1626 forAll(hitSurface, pointI)
1628 if (hitSurface[pointI] != -1)
1630 hitSurface[pointI] = surfacesToTest[hitSurface[pointI]];
1638 forAll(surfacesToTest, i)
1640 label surfI = surfacesToTest[i];
1655 allGeometry_[surfaces_[surfI]].getRegion(localHits, localRegion);
1659 hitRegion[localIndices[i]] = localRegion[i];
1690 forAll(hitSurface, pointI)
1692 if (hitSurface[pointI] != -1)
1694 hitSurface[pointI] = surfacesToTest[hitSurface[pointI]];
1704 forAll(surfacesToTest, i)
1706 label surfI = surfacesToTest[i];
1722 allGeometry_[surfaces_[surfI]].getRegion(localHits, localRegion);
1726 hitRegion[localIndices[i]] = localRegion[i];
1731 allGeometry_[surfaces_[surfI]].getNormal(localHits, localNormal);
1735 hitNormal[localIndices[i]] = localNormal[i];
1794 insideSurfaces = -1;
1798 label surfI = testSurfaces[i];
1803 surfZones_[surfI].zoneInside();
1812 <<
"Trying to use surface "
1814 <<
" which has non-geometric inside selection method "
1819 if (surface.hasVolumeType())
1822 surface.getVolumeType(pt, volType);
1826 if (insideSurfaces[pointI] == -1)
1840 insideSurfaces[pointI] = surfI;
1876 forAll(hitSurface, pointI)
1878 if (hitSurface[pointI] != -1)
1880 hitSurface[pointI] = surfacesToTest[hitSurface[pointI]];
1915 forAll(hitSurface, pointI)
1917 if (hitSurface[pointI] != -1)
1919 hitSurface[pointI] = surfacesToTest[hitSurface[pointI]];
1929 forAll(surfacesToTest, i)
1931 label surfI = surfacesToTest[i];
1947 allGeometry_[surfaces_[surfI]].getRegion(localHits, localRegion);
1951 hitRegion[localIndices[i]] = localRegion[i];
1956 allGeometry_[surfaces_[surfI]].getNormal(localHits, localNormal);
1960 hitNormal[localIndices[i]] = localNormal[i];
A 1D vector of objects of type <T> with a fixed length <N>.
List< Key > sortedToc() const
The table of contents (the keys) in sorted order.
label size() const noexcept
The number of elements in table.
bool erase(const iterator &iter)
Erase an entry specified by given iterator.
const word & name() const noexcept
Return the object name.
void setSize(const label n)
Alias for resize()
void clear()
Clear the list, i.e. set size to zero.
A HashTable to objects of type <T> with a label key.
const Field< point_type > & points() const noexcept
Return reference to global points.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
const T * set(const label i) const
A List with indirect addressing. Like IndirectList but does not store addressing.
void size(const label n)
Older name for setAddressableSize.
label size() const noexcept
The number of elements in the list.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
autoPtr< dictionary > clone() const
Construct and return clone.
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
entry * findEntry(const word &keyword, enum keyType::option matchOpt=keyType::REGEX)
Find for an entry (non-const access) with the given keyword.
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Search for an entry (const access) with the given keyword.
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
wordList toc() const
Return the table of contents.
A keyword and a list of tokens is an 'entry'.
const keyType & keyword() const noexcept
Return keyword.
virtual const dictionary & dict() const =0
Return dictionary, if entry is a dictionary.
@ REGEX
Regular expression.
A triFace with additional (region) index.
Container for data on surfaces used for surface-driven refinement. Contains all the data about the le...
labelList maxGapLevel() const
Per surface the maximum extendedGapLevel over all its regions.
void findAllIntersections(const pointField &start, const pointField &end, const labelList ¤tLevel, const labelList &globalMinLevel, const labelList &globalMaxLevel, List< vectorList > &surfaceNormal, labelListList &surfaceLevel) const
Find all intersections of edge with any surface with applicable.
const PtrList< dictionary > & patchInfo() const
From global region number to patch type.
labelPair whichSurface(const label globalRegionI) const
From global region to surface + region.
void findNearest(const labelList &surfacesToTest, const pointField &samples, const scalarField &nearestDistSqr, labelList &surfaces, List< pointIndexHit > &) const
Find nearest point on surfaces.
void findInside(const labelList &surfacesToTest, const pointField &pt, labelList &insideSurfaces) const
Detect if a point is 'inside' (closed) surfaces.
void findNearestRegion(const labelList &surfacesToTest, const pointField &samples, const scalarField &nearestDistSqr, labelList &hitSurface, labelList &hitRegion) const
Find nearest point on surfaces. Return surface and region on.
void findAnyIntersection(const pointField &start, const pointField &end, labelList &surfaces, List< pointIndexHit > &) const
Used for debugging only: find intersection of edge.
void findHigherIntersection(const shellSurfaces &shells, const pointField &start, const pointField &end, const labelList ¤tLevel, labelList &surfaces, labelList &surfaceLevel) const
Find intersection of edge. Return -1 or first surface.
void findNearestIntersection(const labelList &surfacesToTest, const pointField &start, const pointField &end, labelList &surface1, List< pointIndexHit > &hit1, labelList ®ion1, labelList &surface2, List< pointIndexHit > &hit2, labelList ®ion2) const
Find intersection nearest to the endpoints. surface1,2 are.
void setMinLevelFields(const shellSurfaces &shells)
Calculate minLevelFields.
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
virtual void getRegion(const List< pointIndexHit > &, labelList ®ion) const =0
From a set of points and indices get the region.
virtual void findLine(const pointField &start, const pointField &end, List< pointIndexHit > &) const =0
Find first intersection on segment from start to end.
virtual void findNearest(const pointField &sample, const scalarField &nearestDistSqr, List< pointIndexHit > &) const =0
virtual void findLineAny(const pointField &start, const pointField &end, List< pointIndexHit > &) const =0
Return any intersection on segment from start to end.
virtual label globalSize() const
Range of global indices that can be returned.
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const =0
From a set of points and indices get the normal.
virtual void boundingSpheres(pointField ¢res, scalarField &radiusSqr) const =0
Get bounding spheres (centre and radius squared), one per element.
static void findAnyIntersection(const PtrList< searchableSurface > &, const labelList &surfacesToTest, const pointField &start, const pointField &end, labelList &surfaces, List< pointIndexHit > &)
Find any intersection. Return hit point information and.
static void findNearest(const PtrList< searchableSurface > &, const labelList &surfacesToTest, const pointField &, const scalarField &nearestDistSqr, labelList &surfaces, List< pointIndexHit > &)
Find nearest. Return -1 (and a miss()) or surface and nearest.
Container for searchableSurfaces. The collection is specified as a dictionary. For example,...
const wordList & names() const
Surface names, not region names.
const List< wordList > & regionNames() const
Region names per surface.
Encapsulates queries for volume refinement ('refine all cells within shell').
Contains information about location on a triSurface.
areaSelectionAlgo
Types of selection of area.
static const Enum< areaSelectionAlgo > areaSelectionAlgoNames
Triangulated surface description with patch information.
An enumeration wrapper for classification of a location as being inside/outside of a volume.
const word & str() const
The string representation of the volume type enumeration.
@ OUTSIDE
A location outside the volume.
@ MIXED
A location that is partly inside and outside.
@ INSIDE
A location inside the volume.
A class for handling words, derived from Foam::string.
const volScalarField & p0
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define IOWarningInFunction(ios)
Report an IO warning using Foam::Warning.
Pair< label > labelPair
A pair of labels.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i)
List< label > labelList
A List of labels.
PointIndexHit< point > pointIndexHit
A PointIndexHit for 3D points.
messageStream Info
Information stream (stdout output on master, null elsewhere)
vectorField pointField
pointField is a vectorField.
Ostream & endl(Ostream &os)
Add newline and flush stream.
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
static constexpr const zero Zero
Global zero (0)
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce (copy) and return value.
labelList findIndices(const ListType &input, typename ListType::const_reference val, label start=0)
Linear search to find all occurrences of given element.
errorManipArg< error, int > exit(error &err, const int errNo=1)
UIndirectList< label > labelUIndList
UIndirectList of labels.
surfacesMesh setField(triSurfaceToAgglom)
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIters(container, iter)
Iterate across all elements of the container object with const access.
scalarField samples(nIntervals, Zero)