42 const label gapLevelIncrement
45 allGeometry_(allGeometry),
46 surfaces_(surfacesDict.size()),
47 names_(surfacesDict.size()),
48 surfZones_(surfacesDict.size()),
49 regionOffset_(surfacesDict.size())
56 forAll(allGeometry_.names(), geomI)
58 const word& geomName = allGeometry_.names()[geomI];
60 if (surfacesDict.
found(geomName))
67 surfaces_.setSize(surfI);
68 names_.setSize(surfI);
69 surfZones_.setSize(surfI);
70 regionOffset_.setSize(surfI);
87 forAll(allGeometry_.names(), geomI)
89 const word& geomName = allGeometry_.names()[geomI];
98 names_[surfI] = geomName;
99 surfaces_[surfI] = geomI;
102 globalMinLevel[surfI] = refLevel[0];
103 globalMaxLevel[surfI] = refLevel[1];
112 globalMinLevel[surfI] < 0
113 || globalMaxLevel[surfI] < globalMinLevel[surfI]
114 || globalLevelIncr[surfI] < 0
120 ) <<
"Illegal level specification for surface " 122 <<
" : minLevel:" << globalMinLevel[surfI]
123 <<
" maxLevel:" << globalMaxLevel[surfI]
124 <<
" levelIncrement:" << globalLevelIncr[surfI]
134 if (dict.
found(
"patchInfo"))
142 dict.
readIfPresent(
"perpendicularAngle", globalAngle[surfI]);
144 if (dict.
found(
"regions"))
149 forAll(regionNames, regionI)
151 if (regionsDict.
found(regionNames[regionI]))
161 regionMinLevel[surfI].insert(regionI, refLevel[0]);
162 regionMaxLevel[surfI].insert(regionI, refLevel[1]);
168 regionLevelIncr[surfI].insert(regionI, levelIncr);
173 || refLevel[1] < refLevel[0]
180 ) <<
"Illegal level specification for surface " 181 << names_[surfI] <<
" region " 182 << regionNames[regionI]
183 <<
" : minLevel:" << refLevel[0]
184 <<
" maxLevel:" << refLevel[1]
185 <<
" levelIncrement:" << levelIncr
189 if (regionDict.
found(
"perpendicularAngle"))
191 regionAngle[surfI].insert
194 regionDict.
lookup<scalar>(
"perpendicularAngle")
198 if (regionDict.
found(
"patchInfo"))
200 regionPatchInfo[surfI].insert
213 if (unmatchedKeys.size() > 0)
218 ) <<
"Not all entries in refinementSurfaces dictionary were used." 219 <<
" The following entries were not used : " 220 << unmatchedKeys.sortedToc()
230 regionOffset_[surfI] = nRegions;
231 nRegions += allGeometry_[surfaces_[surfI]].regions().size();
235 minLevel_.setSize(nRegions);
237 maxLevel_.setSize(nRegions);
239 gapLevel_.setSize(nRegions);
241 perpendicularAngle_.setSize(nRegions);
242 perpendicularAngle_ = -great;
243 patchInfo_.setSize(nRegions);
246 forAll(globalMinLevel, surfI)
248 label nRegions = allGeometry_[surfaces_[surfI]].regions().size();
251 for (
label i = 0; i < nRegions; i++)
253 label globalRegionI = regionOffset_[surfI] + i;
254 minLevel_[globalRegionI] = globalMinLevel[surfI];
255 maxLevel_[globalRegionI] = globalMaxLevel[surfI];
256 gapLevel_[globalRegionI] =
257 maxLevel_[globalRegionI]
258 + globalLevelIncr[surfI];
260 perpendicularAngle_[globalRegionI] = globalAngle[surfI];
261 if (globalPatchInfo.
set(surfI))
266 globalPatchInfo[surfI].
clone()
274 label globalRegionI = regionOffset_[surfI] + iter.key();
276 minLevel_[globalRegionI] = iter();
277 maxLevel_[globalRegionI] = regionMaxLevel[surfI][iter.key()];
278 gapLevel_[globalRegionI] =
279 maxLevel_[globalRegionI]
280 + regionLevelIncr[surfI][iter.key()];
284 label globalRegionI = regionOffset_[surfI] + iter.key();
286 perpendicularAngle_[globalRegionI] = regionAngle[surfI][iter.key()];
292 label globalRegionI = regionOffset_[surfI] + iter.key();
294 patchInfo_.set(globalRegionI, iter()().
clone());
314 allGeometry_(allGeometry),
317 surfZones_(surfZones),
318 regionOffset_(regionOffset),
322 perpendicularAngle_(perpendicularAngle),
323 patchInfo_(patchInfo.
size())
327 if (patchInfo.
set(pI))
329 patchInfo_.set(pI, patchInfo.
set(pI,
nullptr));
432 minLevelField[i] = minLevel(surfI, region[i]);
481 if (surfaces_.empty())
486 if (surfaces_.size() == 1)
501 geom.
getField(intersectionInfo, minLevelField);
502 bool haveLevelField =
512 intersectionInfo.size(),
515 haveLevelField =
true;
520 forAll(intersectionInfo, i)
524 intersectionInfo[i].hit()
525 && minLevelField[i] > currentLevel[i]
529 surfaceLevel[i] = minLevelField[i];
553 geom.
getField(intersectionInfo, minLevelField);
557 forAll(intersectionInfo, i)
560 label minLocalLevel = -1;
562 if (intersectionInfo[i].hit())
565 if (minLevelField.
size())
567 minLocalLevel = minLevelField[i];
573 minLocalLevel = minLevel(surfI, 0);
578 label pointi = intersectionToPoint[i];
580 if (minLocalLevel > currentLevel[pointi])
583 surfaces[pointi] = surfI;
584 surfaceLevel[pointi] = minLocalLevel;
588 p0[missI] = start[pointi];
589 p1[missI] = end[pointi];
590 intersectionToPoint[missI] = pointi;
604 intersectionToPoint.
setSize(missI);
605 intersectionInfo.setSize(missI);
625 if (surfaces_.empty())
648 n += hitInfo[pointi].
size();
661 surfInfo[
n] = pHits[i];
662 pointMap[
n] = pointi;
680 label region = globalRegion(surfI, surfRegion[i]);
681 label pointi = pointMap[i];
683 if (globalRegionLevel[region] > currentLevel[pointi])
687 surfaceNormal[pointi].
setSize(sz+1);
688 surfaceNormal[pointi][sz] = surfNormal[i];
690 surfaceLevel[pointi].
setSize(sz+1);
691 surfaceLevel[pointi][sz] = globalRegionLevel[region];
715 if (surfaces_.empty())
738 n += hitInfo[pointi].
size();
751 surfInfo[
n] = pHits[i];
752 pointMap[
n] = pointi;
767 label region = globalRegion(surfI, surfRegion[i]);
768 label pointi = pointMap[i];
770 if (globalRegionLevel[region] > currentLevel[pointi])
774 surfaceLocation[pointi].
setSize(sz+1);
775 surfaceLocation[pointi][sz] = surfInfo[i].hitPoint();
777 surfaceNormal[pointi].
setSize(sz+1);
778 surfaceNormal[pointi][sz] = surfNormal[i];
780 surfaceLevel[pointi].
setSize(sz+1);
781 surfaceLevel[pointi][sz] = globalRegionLevel[region];
817 forAll(surfacesToTest, testI)
819 label surfI = surfacesToTest[testI];
836 forAll(nearestInfo, pointi)
838 if (nearestInfo[pointi].hit())
840 hit1[pointi] = nearestInfo[pointi];
841 surface1[pointi] = surfI;
842 region1[pointi] = region[pointi];
843 nearest[pointi] = hit1[pointi].hitPoint();
861 if (hit1[pointi].hit())
863 nearest[pointi] = hit1[pointi].hitPoint();
868 nearest[pointi] = end[pointi];
872 forAll(surfacesToTest, testI)
874 label surfI = surfacesToTest[testI];
891 forAll(nearestInfo, pointi)
893 if (nearestInfo[pointi].hit())
895 hit2[pointi] = nearestInfo[pointi];
896 surface2[pointi] = surfI;
897 region2[pointi] = region[pointi];
898 nearest[pointi] = hit2[pointi].hitPoint();
908 if (hit1[pointi].hit() && !hit2[pointi].hit())
910 hit2[pointi] = hit1[pointi];
911 surface2[pointi] = surface1[pointi];
912 region2[pointi] = region1[pointi];
954 forAll(surfacesToTest, testI)
956 label surfI = surfacesToTest[testI];
960 geom.
findLine(start, nearest, nearestInfo);
964 forAll(nearestInfo, pointi)
966 if (nearestInfo[pointi].hit())
968 hit1[pointi] = nearestInfo[pointi];
969 surface1[pointi] = surfI;
970 region1[pointi] = region[pointi];
971 normal1[pointi] = normal[pointi];
972 nearest[pointi] = hit1[pointi].hitPoint();
991 if (hit1[pointi].hit())
993 nearest[pointi] = hit1[pointi].hitPoint();
998 nearest[pointi] = end[pointi];
1002 forAll(surfacesToTest, testI)
1004 label surfI = surfacesToTest[testI];
1008 geom.
findLine(end, nearest, nearestInfo);
1012 forAll(nearestInfo, pointi)
1014 if (nearestInfo[pointi].hit())
1016 hit2[pointi] = nearestInfo[pointi];
1017 surface2[pointi] = surfI;
1018 region2[pointi] = region[pointi];
1019 normal2[pointi] = normal[pointi];
1020 nearest[pointi] = hit2[pointi].hitPoint();
1030 if (hit1[pointi].hit() && !hit2[pointi].hit())
1032 hit2[pointi] = hit1[pointi];
1033 surface2[pointi] = surface1[pointi];
1034 region2[pointi] = region1[pointi];
1035 normal2[pointi] = normal1[pointi];
1050 searchableSurfacesQueries::findAnyIntersection
1074 searchableSurfacesQueries::findNearest
1085 forAll(hitSurface, pointi)
1087 if (hitSurface[pointi] != -1)
1089 hitSurface[pointi] = surfacesToTest[hitSurface[pointi]];
1108 searchableSurfacesQueries::findNearest
1119 forAll(hitSurface, pointi)
1121 if (hitSurface[pointi] != -1)
1123 hitSurface[pointi] = surfacesToTest[hitSurface[pointi]];
1131 forAll(surfacesToTest, i)
1133 label surfI = surfacesToTest[i];
1148 allGeometry_[surfaces_[surfI]].getRegion(localHits, localRegion);
1152 hitRegion[localIndices[i]] = localRegion[i];
1172 searchableSurfacesQueries::findNearest
1183 forAll(hitSurface, pointi)
1185 if (hitSurface[pointi] != -1)
1187 hitSurface[pointi] = surfacesToTest[hitSurface[pointi]];
1197 forAll(surfacesToTest, i)
1199 label surfI = surfacesToTest[i];
1215 allGeometry_[surfaces_[surfI]].getRegion(localHits, localRegion);
1219 hitRegion[localIndices[i]] = localRegion[i];
1224 allGeometry_[surfaces_[surfI]].getNormal(localHits, localNormal);
1228 hitNormal[localIndices[i]] = localNormal[i];
1287 insideSurfaces = -1;
1291 label surfI = testSurfaces[i];
1296 surfZones_[surfI].zoneInside();
1300 selectionMethod != surfaceZonesInfo::INSIDE
1301 && selectionMethod != surfaceZonesInfo::OUTSIDE
1305 <<
"Trying to use surface " 1307 <<
" which has non-geometric inside selection method " 1308 << surfaceZonesInfo::areaSelectionAlgoNames[selectionMethod]
1319 if (insideSurfaces[pointi] == -1)
1324 volType[pointi] == volumeType::inside
1325 && selectionMethod == surfaceZonesInfo::INSIDE
1328 volType[pointi] == volumeType::outside
1329 && selectionMethod == surfaceZonesInfo::OUTSIDE
1333 insideSurfaces[pointi] = surfI;
A HashTable with keys but without contents.
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
const word & name() const
Return name.
const entry * lookupEntryPtr(const word &, bool recursive, bool patternMatch) const
Find and return an entry data stream pointer if present.
virtual const wordList & regions() const =0
Names of regions.
bool set(const label) const
Is element set.
const keyType & keyword() const
Return keyword.
errorManipArg< error, int > exit(error &err, const int errNo=1)
A list of keyword definitions, which are a keyword followed by any number of values (e...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
void findAllHigherIntersections(const pointField &start, const pointField &end, const labelList ¤tLevel, const labelList &globalRegionLevel, List< vectorList > &surfaceNormal, labelListList &surfaceLevel) const
Find all intersections of edge. Unsorted order.
void size(const label)
Override size to be inconsistent with allocated storage.
Ostream & endl(Ostream &os)
Add newline and flush stream.
virtual const dictionary & dict() const =0
Return dictionary if this entry is a dictionary.
void findAnyIntersection(const pointField &start, const pointField &end, labelList &surfaces, List< pointIndexHit > &) const
Used for debugging only: find intersection of edge.
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
Encapsulates queries for volume refinement ('refine all cells within shell').
Base class of (analytical or triangulated) surface. Encapsulates all the search routines. WIP.
virtual void findLineAny(const pointField &start, const pointField &end, List< pointIndexHit > &) const =0
Return any intersection on segment from start to end.
labelList findIndices(const ListType &, typename ListType::const_reference, const label start=0)
Find all occurrences of given element. Linear search.
virtual void getField(const List< pointIndexHit > &, labelList &values) const
WIP. From a set of hits (points and.
void findNearest(const labelList &surfacesToTest, const pointField &samples, const scalarField &nearestDistSqr, labelList &surfaces, List< pointIndexHit > &) const
Find nearest point on surfaces.
bool erase(T *p)
Remove the specified element from the list and delete it.
autoPtr< dictionary > clone() const
Construct and return clone.
wordList toc() const
Return the table of contents.
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
void setMinLevelFields(const refinementRegions &shells)
Calculate minLevelFields.
An ordered pair of two objects of type <T> with first() and second() elements.
virtual void findNearest(const pointField &sample, const scalarField &nearestDistSqr, List< pointIndexHit > &) const =0
surfacesMesh setField(triSurfaceToAgglom)
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 clear()
Clear the list, i.e. set size to zero.
virtual void findLineAll(const pointField &start, const pointField &end, List< List< pointIndexHit >> &) const =0
Get all intersections in order from start to end.
A class for handling words, derived from string.
bool readIfPresent(const word &, T &, bool recursive=false, bool patternMatch=true) const
Find an entry if present, and assign to T.
Container for searchableSurfaces.
List< label > labelList
A List of labels.
virtual label globalSize() const
Range of global indices that can be returned.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
refinementSurfaces(const searchableSurfaces &allGeometry, const dictionary &, const label gapLevelIncrement)
Construct from surfaces and dictionary.
label size() const
Return the number of elements in the UPtrList.
void setSize(const label)
Reset size of List.
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
A List with indirect addressing.
virtual void getVolumeType(const pointField &, List< volumeType > &) const =0
Determine type (inside/outside) for point. unknown if.
virtual void getRegion(const List< pointIndexHit > &, labelList ®ion) const =0
From a set of points and indices get the region.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
#define IOWarningInFunction(ios)
Report an IO warning using Foam::Warning.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
void findHigherIntersection(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.
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const =0
From a set of points and indices get the normal.
areaSelectionAlgo
Types of selection of area.
virtual void findLine(const pointField &start, const pointField &end, List< pointIndexHit > &) const =0
Find first intersection on segment from start to end.
virtual bool hasVolumeType() const =0
Whether supports volume type below.
A keyword and a list of tokens is an 'entry'.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
void findInside(const labelList &surfacesToTest, const pointField &pt, labelList &insideSurfaces) const
Detect if a point is 'inside' (closed) surfaces.
virtual void boundingSpheres(pointField ¢res, scalarField &radiusSqr) const =0
Get bounding spheres (centre and radius squared), one per element.