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
119 "refinementSurfaces::refinementSurfaces" 120 "(const searchableSurfaces&, const dictionary>&",
122 ) <<
"Illegal level specification for surface " 124 <<
" : minLevel:" << globalMinLevel[surfI]
125 <<
" maxLevel:" << globalMaxLevel[surfI]
126 <<
" levelIncrement:" << globalLevelIncr[surfI]
136 if (dict.
found(
"patchInfo"))
144 dict.
readIfPresent(
"perpendicularAngle", globalAngle[surfI]);
146 if (dict.
found(
"regions"))
151 forAll(regionNames, regionI)
153 if (regionsDict.
found(regionNames[regionI]))
163 regionMinLevel[surfI].insert(regionI, refLevel[0]);
164 regionMaxLevel[surfI].insert(regionI, refLevel[1]);
170 regionLevelIncr[surfI].insert(regionI, levelIncr);
175 || refLevel[1] < refLevel[0]
181 "refinementSurfaces::refinementSurfaces" 182 "(const searchableSurfaces&, const dictionary&",
184 ) <<
"Illegal level specification for surface " 185 << names_[surfI] <<
" region " 186 << regionNames[regionI]
187 <<
" : minLevel:" << refLevel[0]
188 <<
" maxLevel:" << refLevel[1]
189 <<
" levelIncrement:" << levelIncr
193 if (regionDict.
found(
"perpendicularAngle"))
195 regionAngle[surfI].insert
200 regionDict.
lookup(
"perpendicularAngle")
205 if (regionDict.
found(
"patchInfo"))
207 regionPatchInfo[surfI].insert
220 if (unmatchedKeys.size() > 0)
224 "refinementSurfaces::refinementSurfaces(..)",
226 ) <<
"Not all entries in refinementSurfaces dictionary were used." 227 <<
" The following entries were not used : " 228 << unmatchedKeys.sortedToc()
238 regionOffset_[surfI] = nRegions;
239 nRegions += allGeometry_[surfaces_[surfI]].regions().size();
243 minLevel_.setSize(nRegions);
245 maxLevel_.setSize(nRegions);
247 gapLevel_.setSize(nRegions);
249 perpendicularAngle_.setSize(nRegions);
250 perpendicularAngle_ = -GREAT;
251 patchInfo_.setSize(nRegions);
254 forAll(globalMinLevel, surfI)
256 label nRegions = allGeometry_[surfaces_[surfI]].regions().size();
259 for (
label i = 0; i < nRegions; i++)
261 label globalRegionI = regionOffset_[surfI] + i;
262 minLevel_[globalRegionI] = globalMinLevel[surfI];
263 maxLevel_[globalRegionI] = globalMaxLevel[surfI];
264 gapLevel_[globalRegionI] =
265 maxLevel_[globalRegionI]
266 + globalLevelIncr[surfI];
268 perpendicularAngle_[globalRegionI] = globalAngle[surfI];
269 if (globalPatchInfo.
set(surfI))
274 globalPatchInfo[surfI].clone()
282 label globalRegionI = regionOffset_[surfI] + iter.key();
284 minLevel_[globalRegionI] = iter();
285 maxLevel_[globalRegionI] = regionMaxLevel[surfI][iter.key()];
286 gapLevel_[globalRegionI] =
287 maxLevel_[globalRegionI]
288 + regionLevelIncr[surfI][iter.key()];
292 label globalRegionI = regionOffset_[surfI] + iter.key();
294 perpendicularAngle_[globalRegionI] = regionAngle[surfI][iter.key()];
300 label globalRegionI = regionOffset_[surfI] + iter.key();
302 patchInfo_.set(globalRegionI, iter()().clone());
308 Foam::refinementSurfaces::refinementSurfaces
322 allGeometry_(allGeometry),
325 surfZones_(surfZones),
326 regionOffset_(regionOffset),
330 perpendicularAngle_(perpendicularAngle),
331 patchInfo_(patchInfo.
size())
335 if (patchInfo.
set(pI))
337 patchInfo_.set(pI, patchInfo.
set(pI, NULL));
440 minLevelField[i] = minLevel(surfI, region[i]);
448 shells.findHigherLevel(ctrs, minLevelField, shellLevel);
452 minLevelField[i] =
max(minLevelField[i], shellLevel[i]);
479 if (surfaces_.empty())
484 if (surfaces_.size() == 1)
499 geom.
getField(intersectionInfo, minLevelField);
500 bool haveLevelField =
510 intersectionInfo.size(),
513 haveLevelField =
true;
518 forAll(intersectionInfo, i)
522 intersectionInfo[i].hit()
523 && minLevelField[i] > currentLevel[i]
527 surfaceLevel[i] = minLevelField[i];
551 geom.
getField(intersectionInfo, minLevelField);
555 forAll(intersectionInfo, i)
558 label minLocalLevel = -1;
560 if (intersectionInfo[i].hit())
563 if (minLevelField.
size())
565 minLocalLevel = minLevelField[i];
571 minLocalLevel = minLevel(surfI, 0);
576 label pointI = intersectionToPoint[i];
578 if (minLocalLevel > currentLevel[pointI])
581 surfaces[pointI] = surfI;
582 surfaceLevel[pointI] = minLocalLevel;
586 p0[missI] = start[pointI];
587 p1[missI] = end[pointI];
588 intersectionToPoint[missI] = pointI;
602 intersectionToPoint.
setSize(missI);
603 intersectionInfo.setSize(missI);
623 if (surfaces_.empty())
646 n += hitInfo[pointI].
size();
659 surfInfo[
n] = pHits[i];
660 pointMap[
n] = pointI;
678 label region = globalRegion(surfI, surfRegion[i]);
679 label pointI = pointMap[i];
681 if (globalRegionLevel[region] > currentLevel[pointI])
685 surfaceNormal[pointI].
setSize(sz+1);
686 surfaceNormal[pointI][sz] = surfNormal[i];
688 surfaceLevel[pointI].
setSize(sz+1);
689 surfaceLevel[pointI][sz] = globalRegionLevel[region];
713 if (surfaces_.empty())
736 n += hitInfo[pointI].
size();
749 surfInfo[
n] = pHits[i];
750 pointMap[
n] = pointI;
765 label region = globalRegion(surfI, surfRegion[i]);
766 label pointI = pointMap[i];
768 if (globalRegionLevel[region] > currentLevel[pointI])
772 surfaceLocation[pointI].
setSize(sz+1);
773 surfaceLocation[pointI][sz] = surfInfo[i].hitPoint();
775 surfaceNormal[pointI].
setSize(sz+1);
776 surfaceNormal[pointI][sz] = surfNormal[i];
778 surfaceLevel[pointI].
setSize(sz+1);
779 surfaceLevel[pointI][sz] = globalRegionLevel[region];
815 forAll(surfacesToTest, testI)
817 label surfI = surfacesToTest[testI];
834 forAll(nearestInfo, pointI)
836 if (nearestInfo[pointI].hit())
838 hit1[pointI] = nearestInfo[pointI];
839 surface1[pointI] = surfI;
840 region1[pointI] = region[pointI];
841 nearest[pointI] = hit1[pointI].hitPoint();
859 if (hit1[pointI].hit())
861 nearest[pointI] = hit1[pointI].hitPoint();
866 nearest[pointI] = end[pointI];
870 forAll(surfacesToTest, testI)
872 label surfI = surfacesToTest[testI];
889 forAll(nearestInfo, pointI)
891 if (nearestInfo[pointI].hit())
893 hit2[pointI] = nearestInfo[pointI];
894 surface2[pointI] = surfI;
895 region2[pointI] = region[pointI];
896 nearest[pointI] = hit2[pointI].hitPoint();
906 if (hit1[pointI].hit() && !hit2[pointI].hit())
908 hit2[pointI] = hit1[pointI];
909 surface2[pointI] = surface1[pointI];
910 region2[pointI] = region1[pointI];
943 normal1 = vector::zero;
952 forAll(surfacesToTest, testI)
954 label surfI = surfacesToTest[testI];
958 geom.
findLine(start, nearest, nearestInfo);
962 forAll(nearestInfo, pointI)
964 if (nearestInfo[pointI].hit())
966 hit1[pointI] = nearestInfo[pointI];
967 surface1[pointI] = surfI;
968 region1[pointI] = region[pointI];
969 normal1[pointI] = normal[pointI];
970 nearest[pointI] = hit1[pointI].hitPoint();
989 if (hit1[pointI].hit())
991 nearest[pointI] = hit1[pointI].hitPoint();
996 nearest[pointI] = end[pointI];
1000 forAll(surfacesToTest, testI)
1002 label surfI = surfacesToTest[testI];
1006 geom.
findLine(end, nearest, nearestInfo);
1010 forAll(nearestInfo, pointI)
1012 if (nearestInfo[pointI].hit())
1014 hit2[pointI] = nearestInfo[pointI];
1015 surface2[pointI] = surfI;
1016 region2[pointI] = region[pointI];
1017 normal2[pointI] = normal[pointI];
1018 nearest[pointI] = hit2[pointI].hitPoint();
1028 if (hit1[pointI].hit() && !hit2[pointI].hit())
1030 hit2[pointI] = hit1[pointI];
1031 surface2[pointI] = surface1[pointI];
1032 region2[pointI] = region1[pointI];
1033 normal2[pointI] = normal1[pointI];
1048 searchableSurfacesQueries::findAnyIntersection
1072 searchableSurfacesQueries::findNearest
1083 forAll(hitSurface, pointI)
1085 if (hitSurface[pointI] != -1)
1087 hitSurface[pointI] = surfacesToTest[hitSurface[pointI]];
1106 searchableSurfacesQueries::findNearest
1117 forAll(hitSurface, pointI)
1119 if (hitSurface[pointI] != -1)
1121 hitSurface[pointI] = surfacesToTest[hitSurface[pointI]];
1129 forAll(surfacesToTest, i)
1131 label surfI = surfacesToTest[i];
1146 allGeometry_[surfaces_[surfI]].getRegion(localHits, localRegion);
1150 hitRegion[localIndices[i]] = localRegion[i];
1170 searchableSurfacesQueries::findNearest
1181 forAll(hitSurface, pointI)
1183 if (hitSurface[pointI] != -1)
1185 hitSurface[pointI] = surfacesToTest[hitSurface[pointI]];
1193 hitNormal = vector::zero;
1195 forAll(surfacesToTest, i)
1197 label surfI = surfacesToTest[i];
1213 allGeometry_[surfaces_[surfI]].getRegion(localHits, localRegion);
1217 hitRegion[localIndices[i]] = localRegion[i];
1222 allGeometry_[surfaces_[surfI]].getNormal(localHits, localNormal);
1226 hitNormal[localIndices[i]] = localNormal[i];
1285 insideSurfaces = -1;
1289 label surfI = testSurfaces[i];
1294 surfZones_[surfI].zoneInside();
1298 selectionMethod != surfaceZonesInfo::INSIDE
1299 && selectionMethod != surfaceZonesInfo::OUTSIDE
1303 <<
"Trying to use surface " 1305 <<
" which has non-geometric inside selection method " 1306 << surfaceZonesInfo::areaSelectionAlgoNames[selectionMethod]
1317 if (insideSurfaces[pointI] == -1)
1322 volType[pointI] == volumeType::INSIDE
1323 && selectionMethod == surfaceZonesInfo::INSIDE
1326 volType[pointI] == volumeType::OUTSIDE
1327 && selectionMethod == surfaceZonesInfo::OUTSIDE
1331 insideSurfaces[pointI] = surfI;
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
virtual void findLine(const pointField &start, const pointField &end, List< pointIndexHit > &) const =0
Find first intersection on segment from start to end.
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.
label size() const
Return the number of elements in the PtrList.
bool set(const label) const
Is element set.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
An ordered pair of two objects of type <T> with first() and second() elements.
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.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Base class of (analytical or triangulated) surface. Encapsulates all the search routines. WIP.
virtual bool hasVolumeType() const =0
Whether supports volume type below.
virtual const dictionary & dict() const =0
Return dictionary if this entry is a dictionary.
areaSelectionAlgo
Types of selection of area.
A class for handling words, derived from string.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
void size(const label)
Override size to be inconsistent with allocated storage.
errorManipArg< error, int > exit(error &err, const int errNo=1)
surfacesMesh setField(triSurfaceToAgglom)
A list of keyword definitions, which are a keyword followed by any number of values (e...
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
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.
label size() const
Return number of elements in list.
#define IOWarningIn(functionName, ios)
Report an IO warning using Foam::Warning.
const keyType & keyword() const
Return keyword.
const entry * lookupEntryPtr(const word &, bool recursive, bool patternMatch) const
Find and return an entry data stream pointer if present.
virtual void findLineAny(const pointField &start, const pointField &end, List< pointIndexHit > &) const =0
Return any intersection on segment from start to end.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
void findInside(const labelList &surfacesToTest, const pointField &pt, labelList &insideSurfaces) const
Detect if a point is 'inside' (closed) surfaces.
virtual void findLineAll(const pointField &start, const pointField &end, List< List< pointIndexHit > > &) const =0
Get all intersections in order from start to end.
void clear()
Clear the list, i.e. set size to zero.
void setSize(const label)
Reset size of List.
Ostream & endl(Ostream &os)
Add newline and flush stream.
A List with indirect addressing.
wordList toc() const
Return the table of contents.
virtual void boundingSpheres(pointField ¢res, scalarField &radiusSqr) const =0
Get bounding spheres (centre and radius squared), one per element.
bool erase(T *p)
Remove the specified element from the list and delete it.
virtual void getField(const List< pointIndexHit > &, labelList &values) const
WIP. From a set of hits (points and.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
void findNearest(const labelList &surfacesToTest, const pointField &samples, const scalarField &nearestDistSqr, labelList &surfaces, List< pointIndexHit > &) const
Find nearest point on surfaces.
void setMinLevelFields(const shellSurfaces &shells)
Calculate minLevelFields.
virtual void getRegion(const List< pointIndexHit > &, labelList ®ion) const =0
From a set of points and indices get the region.
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
void findAnyIntersection(const pointField &start, const pointField &end, labelList &surfaces, List< pointIndexHit > &) const
Used for debugging only: find intersection of edge.
const word & name() const
Return name.
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
A keyword and a list of tokens is an 'entry'.
autoPtr< dictionary > clone() const
Construct and return clone.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
virtual label globalSize() const
Range of global indices that can be returned.
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
List< label > labelList
A List of labels.
A HashTable with keys but without contents.
A normal distribution model.
bool readIfPresent(const word &, T &, bool recursive=false, bool patternMatch=true) const
Find an entry if present, and assign to T.
Container for searchableSurfaces.
virtual void findNearest(const pointField &sample, const scalarField &nearestDistSqr, List< pointIndexHit > &) const =0
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const =0
From a set of points and indices get the normal.
virtual const wordList & regions() const =0
Names of regions.
#define FatalIOErrorIn(functionName, ios)
Report an error message using Foam::FatalIOError.
labelList findIndices(const ListType &, typename ListType::const_reference, const label start=0)
Find all occurences of given element. Linear search.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
virtual void getVolumeType(const pointField &, List< volumeType > &) const =0
Determine type (inside/outside) for point. unknown if.
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.
Encapsulates queries for volume refinement ('refine all cells within shell').