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));
340 const scalar level0EdgeLength,
341 const bool extendedRefinementSpan
377 minLevelField[i] = minLevel(surfi, region[i]);
387 if (extendedRefinementSpan)
390 shells.findHigherLevel
400 minLevelField[i] =
max(minLevelField[i], shellLevel[i]);
426 if (surfaces_.empty())
431 if (surfaces_.size() == 1)
446 geom.
getField(intersectionInfo, minLevelField);
447 bool haveLevelField =
457 intersectionInfo.size(),
460 haveLevelField =
true;
465 forAll(intersectionInfo, i)
469 intersectionInfo[i].hit()
470 && minLevelField[i] > currentLevel[i]
474 surfaceLevel[i] = minLevelField[i];
497 geom.
getField(intersectionInfo, minLevelField);
501 forAll(intersectionInfo, i)
504 label minLocalLevel = -1;
506 if (intersectionInfo[i].hit())
509 if (minLevelField.
size())
511 minLocalLevel = minLevelField[i];
517 minLocalLevel = minLevel(surfi, 0);
522 label pointi = intersectionToPoint[i];
524 if (minLocalLevel > currentLevel[pointi])
527 surfaces[pointi] = surfi;
528 surfaceLevel[pointi] = minLocalLevel;
532 p0[missI] = start[pointi];
533 p1[missI] = end[pointi];
534 intersectionToPoint[missI] = pointi;
548 intersectionToPoint.
setSize(missI);
549 intersectionInfo.setSize(missI);
569 if (surfaces_.empty())
592 n += hitinfo[pointi].
size();
605 surfinfo[
n] = pHits[i];
606 pointMap[
n] = pointi;
624 label region = globalRegion(surfi, surfRegion[i]);
625 label pointi = pointMap[i];
627 if (globalRegionLevel[region] > currentLevel[pointi])
631 surfaceNormal[pointi].
setSize(sz+1);
632 surfaceNormal[pointi][sz] = surfNormal[i];
634 surfaceLevel[pointi].
setSize(sz+1);
635 surfaceLevel[pointi][sz] = globalRegionLevel[region];
659 if (surfaces_.empty())
682 n += hitinfo[pointi].
size();
695 surfinfo[
n] = pHits[i];
696 pointMap[
n] = pointi;
711 label region = globalRegion(surfi, surfRegion[i]);
712 label pointi = pointMap[i];
714 if (globalRegionLevel[region] > currentLevel[pointi])
718 surfaceLocation[pointi].
setSize(sz+1);
719 surfaceLocation[pointi][sz] = surfinfo[i].hitPoint();
721 surfaceNormal[pointi].
setSize(sz+1);
722 surfaceNormal[pointi][sz] = surfNormal[i];
724 surfaceLevel[pointi].
setSize(sz+1);
725 surfaceLevel[pointi][sz] = globalRegionLevel[region];
761 forAll(surfacesToTest, testi)
763 label surfi = surfacesToTest[testi];
780 forAll(nearestInfo, pointi)
782 if (nearestInfo[pointi].hit())
784 hit1[pointi] = nearestInfo[pointi];
785 surface1[pointi] = surfi;
786 region1[pointi] = region[pointi];
787 nearest[pointi] = hit1[pointi].hitPoint();
805 if (hit1[pointi].hit())
807 nearest[pointi] = hit1[pointi].hitPoint();
812 nearest[pointi] = end[pointi];
816 forAll(surfacesToTest, testi)
818 label surfi = surfacesToTest[testi];
835 forAll(nearestInfo, pointi)
837 if (nearestInfo[pointi].hit())
839 hit2[pointi] = nearestInfo[pointi];
840 surface2[pointi] = surfi;
841 region2[pointi] = region[pointi];
842 nearest[pointi] = hit2[pointi].hitPoint();
852 if (hit1[pointi].hit() && !hit2[pointi].hit())
854 hit2[pointi] = hit1[pointi];
855 surface2[pointi] = surface1[pointi];
856 region2[pointi] = region1[pointi];
898 forAll(surfacesToTest, testi)
900 label surfi = surfacesToTest[testi];
904 geom.
findLine(start, nearest, nearestInfo);
908 forAll(nearestInfo, pointi)
910 if (nearestInfo[pointi].hit())
912 hit1[pointi] = nearestInfo[pointi];
913 surface1[pointi] = surfi;
914 region1[pointi] = region[pointi];
915 normal1[pointi] = normal[pointi];
916 nearest[pointi] = hit1[pointi].hitPoint();
935 if (hit1[pointi].hit())
937 nearest[pointi] = hit1[pointi].hitPoint();
942 nearest[pointi] = end[pointi];
946 forAll(surfacesToTest, testi)
948 label surfi = surfacesToTest[testi];
952 geom.
findLine(end, nearest, nearestInfo);
956 forAll(nearestInfo, pointi)
958 if (nearestInfo[pointi].hit())
960 hit2[pointi] = nearestInfo[pointi];
961 surface2[pointi] = surfi;
962 region2[pointi] = region[pointi];
963 normal2[pointi] = normal[pointi];
964 nearest[pointi] = hit2[pointi].hitPoint();
974 if (hit1[pointi].hit() && !hit2[pointi].hit())
976 hit2[pointi] = hit1[pointi];
977 surface2[pointi] = surface1[pointi];
978 region2[pointi] = region1[pointi];
979 normal2[pointi] = normal1[pointi];
994 searchableSurfacesQueries::findAnyIntersection
1018 searchableSurfacesQueries::findNearest
1029 forAll(hitSurface, pointi)
1031 if (hitSurface[pointi] != -1)
1033 hitSurface[pointi] = surfacesToTest[hitSurface[pointi]];
1052 searchableSurfacesQueries::findNearest
1063 forAll(hitSurface, pointi)
1065 if (hitSurface[pointi] != -1)
1067 hitSurface[pointi] = surfacesToTest[hitSurface[pointi]];
1075 forAll(surfacesToTest, i)
1077 label surfi = surfacesToTest[i];
1092 allGeometry_[surfaces_[surfi]].getRegion(localHits, localRegion);
1096 hitRegion[localIndices[i]] = localRegion[i];
1116 searchableSurfacesQueries::findNearest
1127 forAll(hitSurface, pointi)
1129 if (hitSurface[pointi] != -1)
1131 hitSurface[pointi] = surfacesToTest[hitSurface[pointi]];
1141 forAll(surfacesToTest, i)
1143 label surfi = surfacesToTest[i];
1159 allGeometry_[surfaces_[surfi]].getRegion(localHits, localRegion);
1163 hitRegion[localIndices[i]] = localRegion[i];
1168 allGeometry_[surfaces_[surfi]].getNormal(localHits, localNormal);
1172 hitNormal[localIndices[i]] = localNormal[i];
1186 insideSurfaces = -1;
1190 label surfi = testSurfaces[i];
1195 surfZones_[surfi].zoneInside();
1199 selectionMethod != surfaceZonesInfo::INSIDE
1200 && selectionMethod != surfaceZonesInfo::OUTSIDE
1204 <<
"Trying to use surface " 1206 <<
" which has non-geometric inside selection method " 1207 << surfaceZonesInfo::areaSelectionAlgoNames[selectionMethod]
1218 if (insideSurfaces[pointi] == -1)
1223 volType[pointi] == volumeType::inside
1224 && selectionMethod == surfaceZonesInfo::INSIDE
1227 volType[pointi] == volumeType::outside
1228 && selectionMethod == surfaceZonesInfo::OUTSIDE
1232 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.
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
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.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
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.
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.
void setMinLevelFields(const refinementRegions &shells, const scalar level0EdgeLength, const bool extendedRefinementSpan)
Calculate the refinement level for every element.
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.