38 Foam::refinementSurfaces::refinementSurfaces
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
196 regionDict.
lookup(
"perpendicularAngle")
201 if (regionDict.
found(
"patchInfo"))
203 regionPatchInfo[surfI].insert
216 if (unmatchedKeys.size() > 0)
221 ) <<
"Not all entries in refinementSurfaces dictionary were used." 222 <<
" The following entries were not used : " 223 << unmatchedKeys.sortedToc()
233 regionOffset_[surfI] = nRegions;
234 nRegions += allGeometry_[surfaces_[surfI]].regions().size();
238 minLevel_.setSize(nRegions);
240 maxLevel_.setSize(nRegions);
242 gapLevel_.setSize(nRegions);
244 perpendicularAngle_.setSize(nRegions);
245 perpendicularAngle_ = -great;
246 patchInfo_.setSize(nRegions);
249 forAll(globalMinLevel, surfI)
251 label nRegions = allGeometry_[surfaces_[surfI]].regions().size();
254 for (
label i = 0; i < nRegions; i++)
256 label globalRegionI = regionOffset_[surfI] + i;
257 minLevel_[globalRegionI] = globalMinLevel[surfI];
258 maxLevel_[globalRegionI] = globalMaxLevel[surfI];
259 gapLevel_[globalRegionI] =
260 maxLevel_[globalRegionI]
261 + globalLevelIncr[surfI];
263 perpendicularAngle_[globalRegionI] = globalAngle[surfI];
264 if (globalPatchInfo.
set(surfI))
269 globalPatchInfo[surfI].clone()
277 label globalRegionI = regionOffset_[surfI] + iter.key();
279 minLevel_[globalRegionI] = iter();
280 maxLevel_[globalRegionI] = regionMaxLevel[surfI][iter.key()];
281 gapLevel_[globalRegionI] =
282 maxLevel_[globalRegionI]
283 + regionLevelIncr[surfI][iter.key()];
287 label globalRegionI = regionOffset_[surfI] + iter.key();
289 perpendicularAngle_[globalRegionI] = regionAngle[surfI][iter.key()];
295 label globalRegionI = regionOffset_[surfI] + iter.key();
297 patchInfo_.set(globalRegionI, iter()().clone());
303 Foam::refinementSurfaces::refinementSurfaces
317 allGeometry_(allGeometry),
320 surfZones_(surfZones),
321 regionOffset_(regionOffset),
325 perpendicularAngle_(perpendicularAngle),
326 patchInfo_(patchInfo.
size())
330 if (patchInfo.
set(pI))
332 patchInfo_.set(pI, patchInfo.
set(pI,
nullptr));
435 minLevelField[i] = minLevel(surfI, region[i]);
443 shells.findHigherLevel(ctrs, minLevelField, shellLevel);
447 minLevelField[i] =
max(minLevelField[i], shellLevel[i]);
474 if (surfaces_.empty())
479 if (surfaces_.size() == 1)
494 geom.
getField(intersectionInfo, minLevelField);
495 bool haveLevelField =
505 intersectionInfo.size(),
508 haveLevelField =
true;
513 forAll(intersectionInfo, i)
517 intersectionInfo[i].hit()
518 && minLevelField[i] > currentLevel[i]
522 surfaceLevel[i] = minLevelField[i];
546 geom.
getField(intersectionInfo, minLevelField);
550 forAll(intersectionInfo, i)
553 label minLocalLevel = -1;
555 if (intersectionInfo[i].hit())
558 if (minLevelField.
size())
560 minLocalLevel = minLevelField[i];
566 minLocalLevel = minLevel(surfI, 0);
571 label pointi = intersectionToPoint[i];
573 if (minLocalLevel > currentLevel[pointi])
576 surfaces[pointi] = surfI;
577 surfaceLevel[pointi] = minLocalLevel;
581 p0[missI] = start[pointi];
582 p1[missI] = end[pointi];
583 intersectionToPoint[missI] = pointi;
597 intersectionToPoint.
setSize(missI);
598 intersectionInfo.setSize(missI);
618 if (surfaces_.empty())
641 n += hitInfo[pointi].
size();
654 surfInfo[
n] = pHits[i];
655 pointMap[
n] = pointi;
673 label region = globalRegion(surfI, surfRegion[i]);
674 label pointi = pointMap[i];
676 if (globalRegionLevel[region] > currentLevel[pointi])
680 surfaceNormal[pointi].
setSize(sz+1);
681 surfaceNormal[pointi][sz] = surfNormal[i];
683 surfaceLevel[pointi].
setSize(sz+1);
684 surfaceLevel[pointi][sz] = globalRegionLevel[region];
708 if (surfaces_.empty())
731 n += hitInfo[pointi].
size();
744 surfInfo[
n] = pHits[i];
745 pointMap[
n] = pointi;
760 label region = globalRegion(surfI, surfRegion[i]);
761 label pointi = pointMap[i];
763 if (globalRegionLevel[region] > currentLevel[pointi])
767 surfaceLocation[pointi].
setSize(sz+1);
768 surfaceLocation[pointi][sz] = surfInfo[i].hitPoint();
770 surfaceNormal[pointi].
setSize(sz+1);
771 surfaceNormal[pointi][sz] = surfNormal[i];
773 surfaceLevel[pointi].
setSize(sz+1);
774 surfaceLevel[pointi][sz] = globalRegionLevel[region];
810 forAll(surfacesToTest, testI)
812 label surfI = surfacesToTest[testI];
829 forAll(nearestInfo, pointi)
831 if (nearestInfo[pointi].hit())
833 hit1[pointi] = nearestInfo[pointi];
834 surface1[pointi] = surfI;
835 region1[pointi] = region[pointi];
836 nearest[pointi] = hit1[pointi].hitPoint();
854 if (hit1[pointi].hit())
856 nearest[pointi] = hit1[pointi].hitPoint();
861 nearest[pointi] = end[pointi];
865 forAll(surfacesToTest, testI)
867 label surfI = surfacesToTest[testI];
884 forAll(nearestInfo, pointi)
886 if (nearestInfo[pointi].hit())
888 hit2[pointi] = nearestInfo[pointi];
889 surface2[pointi] = surfI;
890 region2[pointi] = region[pointi];
891 nearest[pointi] = hit2[pointi].hitPoint();
901 if (hit1[pointi].hit() && !hit2[pointi].hit())
903 hit2[pointi] = hit1[pointi];
904 surface2[pointi] = surface1[pointi];
905 region2[pointi] = region1[pointi];
947 forAll(surfacesToTest, testI)
949 label surfI = surfacesToTest[testI];
953 geom.
findLine(start, nearest, nearestInfo);
957 forAll(nearestInfo, pointi)
959 if (nearestInfo[pointi].hit())
961 hit1[pointi] = nearestInfo[pointi];
962 surface1[pointi] = surfI;
963 region1[pointi] = region[pointi];
964 normal1[pointi] = normal[pointi];
965 nearest[pointi] = hit1[pointi].hitPoint();
984 if (hit1[pointi].hit())
986 nearest[pointi] = hit1[pointi].hitPoint();
991 nearest[pointi] = end[pointi];
995 forAll(surfacesToTest, testI)
997 label surfI = surfacesToTest[testI];
1001 geom.
findLine(end, nearest, nearestInfo);
1005 forAll(nearestInfo, pointi)
1007 if (nearestInfo[pointi].hit())
1009 hit2[pointi] = nearestInfo[pointi];
1010 surface2[pointi] = surfI;
1011 region2[pointi] = region[pointi];
1012 normal2[pointi] = normal[pointi];
1013 nearest[pointi] = hit2[pointi].hitPoint();
1023 if (hit1[pointi].hit() && !hit2[pointi].hit())
1025 hit2[pointi] = hit1[pointi];
1026 surface2[pointi] = surface1[pointi];
1027 region2[pointi] = region1[pointi];
1028 normal2[pointi] = normal1[pointi];
1043 searchableSurfacesQueries::findAnyIntersection
1067 searchableSurfacesQueries::findNearest
1078 forAll(hitSurface, pointi)
1080 if (hitSurface[pointi] != -1)
1082 hitSurface[pointi] = surfacesToTest[hitSurface[pointi]];
1101 searchableSurfacesQueries::findNearest
1112 forAll(hitSurface, pointi)
1114 if (hitSurface[pointi] != -1)
1116 hitSurface[pointi] = surfacesToTest[hitSurface[pointi]];
1124 forAll(surfacesToTest, i)
1126 label surfI = surfacesToTest[i];
1141 allGeometry_[surfaces_[surfI]].getRegion(localHits, localRegion);
1145 hitRegion[localIndices[i]] = localRegion[i];
1165 searchableSurfacesQueries::findNearest
1176 forAll(hitSurface, pointi)
1178 if (hitSurface[pointi] != -1)
1180 hitSurface[pointi] = surfacesToTest[hitSurface[pointi]];
1190 forAll(surfacesToTest, i)
1192 label surfI = surfacesToTest[i];
1208 allGeometry_[surfaces_[surfI]].getRegion(localHits, localRegion);
1212 hitRegion[localIndices[i]] = localRegion[i];
1217 allGeometry_[surfaces_[surfI]].getNormal(localHits, localNormal);
1221 hitNormal[localIndices[i]] = localNormal[i];
1280 insideSurfaces = -1;
1284 label surfI = testSurfaces[i];
1289 surfZones_[surfI].zoneInside();
1293 selectionMethod != surfaceZonesInfo::INSIDE
1294 && selectionMethod != surfaceZonesInfo::OUTSIDE
1298 <<
"Trying to use surface " 1300 <<
" which has non-geometric inside selection method " 1301 << surfaceZonesInfo::areaSelectionAlgoNames[selectionMethod]
1312 if (insideSurfaces[pointi] == -1)
1317 volType[pointi] == volumeType::INSIDE
1318 && selectionMethod == surfaceZonesInfo::INSIDE
1321 volType[pointi] == volumeType::OUTSIDE
1322 && selectionMethod == surfaceZonesInfo::OUTSIDE
1326 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...
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
#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.
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.
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.
Encapsulates queries for volume refinement ('refine all cells within shell').
virtual label globalSize() const
Range of global indices that can be returned.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
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.
void setMinLevelFields(const shellSurfaces &shells)
Calculate minLevelFields.
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.