Go to the documentation of this file.
42 searchableSurfaceCollection,
48 searchableSurfaceCollection,
57 void Foam::searchableSurfaceCollection::findNearest
61 List<pointIndexHit>& nearestInfo,
66 nearestInfo.setSize(
samples.size());
68 nearestSurf.setSize(
samples.size());
71 List<pointIndexHit> hitInfo(
samples.size());
77 subGeom_[surfI].findNearest
81 transform_[surfI].localPosition(
samples),
90 if (hitInfo[pointi].hit())
94 point globalPt = transform_[surfI].globalPosition
98 hitInfo[pointi].rawPoint(),
105 if (distSqr < minDistSqr[pointi])
107 minDistSqr[pointi] = distSqr;
108 nearestInfo[pointi].setPoint(globalPt);
109 nearestInfo[pointi].setHit();
110 nearestInfo[pointi].setIndex
112 hitInfo[pointi].index()
113 + indexOffset_[surfI]
115 nearestSurf[pointi] = surfI;
125 void Foam::searchableSurfaceCollection::sortHits
127 const List<pointIndexHit>& info,
128 List<List<pointIndexHit>>& surfInfo,
137 if (info[pointi].hit())
139 label index = info[pointi].index();
140 label surfI =
findLower(indexOffset_, index+1);
146 surfInfo.setSize(subGeom_.size());
148 infoMap.setSize(subGeom_.size());
152 surfInfo[surfI].setSize(nHits[surfI]);
153 infoMap[surfI].setSize(nHits[surfI]);
159 if (info[pointi].hit())
161 label index = info[pointi].index();
162 label surfI =
findLower(indexOffset_, index+1);
166 label localI = nHits[surfI]++;
170 info[pointi].rawPoint(),
171 index-indexOffset_[surfI]
173 infoMap[surfI][localI] = pointi;
181 Foam::searchableSurfaceCollection::searchableSurfaceCollection
188 instance_(
dict.size()),
190 transform_(
dict.size()),
191 subGeom_(
dict.size()),
192 mergeSubRegions_(
dict.
get<
bool>(
"mergeSubRegions")),
193 indexOffset_(
dict.size()+1)
198 label startIndex = 0;
203 instance_[surfI] = dEntry.keyword();
210 if (coordDict.
found(
"coordinateSystem"))
229 const word subGeomName(sDict.
get<
word>(
"surface"));
238 if (
s.size() !=
s.globalSize())
241 <<
"Cannot use a distributed surface in a collection."
245 subGeom_.set(surfI, &
s);
247 indexOffset_[surfI] = startIndex;
248 startIndex += subGeom_[surfI].size();
250 Info<<
" instance : " << instance_[surfI] <<
endl;
251 Info<<
" surface : " <<
s.name() <<
endl;
252 Info<<
" scale : " << scale_[surfI] <<
endl;
253 Info<<
" transform: " << transform_[surfI] <<
endl;
258 indexOffset_[surfI] = startIndex;
260 instance_.setSize(surfI);
261 scale_.setSize(surfI);
262 transform_.setSize(surfI);
263 subGeom_.setSize(surfI);
264 indexOffset_.setSize(surfI+1);
271 const boundBox& surfBb = subGeom_[surfI].bounds();
274 const point surfBbMin = transform_[surfI].globalPosition
282 const point surfBbMax = transform_[surfI].globalPosition
291 bounds().
min() =
min(bounds().
min(), surfBbMin);
292 bounds().max() =
max(bounds().
max(), surfBbMax);
307 if (regions_.empty())
309 regionOffset_.
setSize(subGeom_.size());
314 regionOffset_[surfI] = allRegions.size();
316 if (mergeSubRegions_)
323 const wordList& subRegions = subGeom_[surfI].regions();
331 regions_.transfer(allRegions);
339 return indexOffset_.last();
347 auto& ctrs = tctrs.ref();
358 ctrs[coordI++] = transform_[surfI].globalPosition
379 centres.setSize(size());
380 radiusSqr.setSize(centres.size());
387 scalar maxScale =
cmptMax(scale_[surfI]);
391 subGeom_[surfI].boundingSpheres(subCentres, subRadiusSqr);
395 centres[coordI] = transform_[surfI].globalPosition
403 radiusSqr[coordI] = maxScale*subRadiusSqr[i];
418 nPoints += subGeom_[surfI].points()().size();
422 auto& pts = tpts.ref();
433 pts[
nPoints++] = transform_[surfI].globalPosition
448 void Foam::searchableSurfaceCollection::findNearest
489 transform_[surfI].localPosition
499 transform_[surfI].localPosition
506 subGeom_[surfI].findLine(e0, e1, hitInfo);
510 if (hitInfo[pointi].hit())
513 nearest[pointi] = transform_[surfI].globalPosition
517 hitInfo[pointi].rawPoint(),
521 info[pointi] = hitInfo[pointi];
522 info[pointi].rawPoint() = nearest[pointi];
523 info[pointi].setIndex
525 hitInfo[pointi].index()
526 + indexOffset_[surfI]
538 if (info[pointi].hit())
541 scalar magN =
mag(
n);
547 scalar
s = ((info[pointi].rawPoint()-start[pointi])&
n);
552 <<
"point:" << info[pointi]
554 <<
" outside vector "
555 <<
" start:" << start[pointi]
556 <<
" end:" <<
end[pointi]
574 findLine(start,
end, info);
587 findLine(start,
end, nearestInfo);
592 if (nearestInfo[pointi].hit())
595 info[pointi][0] = nearestInfo[pointi];
599 info[pointi].
clear();
611 if (subGeom_.size() == 0)
613 else if (subGeom_.size() == 1)
615 if (mergeSubRegions_)
618 region = regionOffset_[0];
622 subGeom_[0].getRegion(info, region);
633 sortHits(info, surfInfo, infoMap);
640 if (mergeSubRegions_)
648 region[map[i]] = regionOffset_[surfI];
657 subGeom_[surfI].getRegion(surfInfo[surfI], surfRegion);
662 region[map[i]] = regionOffset_[surfI] + surfRegion[i];
676 if (subGeom_.size() == 0)
678 else if (subGeom_.size() == 1)
680 subGeom_[0].getNormal(info, normal);
690 sortHits(info, surfInfo, infoMap);
692 normal.setSize(info.size());
698 subGeom_[surfI].getNormal(surfInfo[surfI], surfNormal);
701 surfNormal = transform_[surfI].globalVector(surfNormal);
706 normal[map[i]] = surfNormal[i];
720 <<
"Volume type not supported for collection."
728 const bool keepNonLocal,
745 subGeom_[surfI].distribute
760 subGeom_[surfI].setField
767 subGeom_[surfI].size(),
782 if (subGeom_.size() == 0)
784 else if (subGeom_.size() == 1)
786 subGeom_[0].getField(info,
values);
796 sortHits(info, surfInfo, infoMap);
802 subGeom_[surfI].getField(surfInfo[surfI], surfValues);
804 if (surfValues.size())
807 values.setSize(info.size());
812 values[map[i]] = surfValues[i];
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
A keyword and a list of tokens is an 'entry'.
List< label > labelList
A List of labels.
vectorField pointField
pointField is a vectorField.
virtual void getRegion(const List< pointIndexHit > &, labelList ®ion) const
From a set of points and indices get the region.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
A class for handling words, derived from Foam::string.
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
dimensioned< Type > cmptMultiply(const dimensioned< Type > &, const dimensioned< Type > &)
virtual void getVolumeType(const pointField &points, List< volumeType > &volType) const
Determine type (inside/outside/mixed) for point.
A class for managing temporary objects.
static constexpr const zero Zero
Global zero (0)
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Search for an entry (const access) with the given keyword.
List< T > values(const HashTable< T, Key, Hash > &tbl, const bool doSort=false)
List of values from HashTable, optionally sorted.
virtual void findLine(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Find first intersection on segment from start to end.
A List obtained as a section of another List.
static const boundBox invertedBox
A large inverted boundBox: min/max == +/- ROOTVGREAT.
virtual ~searchableSurfaceCollection()
Destructor.
virtual tmp< pointField > points() const
Get the points that define the surface.
virtual void distribute(const List< treeBoundBox > &, const bool keepNonLocal, autoPtr< mapDistribute > &faceMap, autoPtr< mapDistribute > &pointMap)
Set bounds of surface. Bounds currently set as list of.
virtual const wordList & regions() const
Names of regions.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const point & max() const
Maximum describing the bounding box.
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
entry * set(entry *entryPtr)
Assign a new entry, overwriting any existing entry.
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const
From a set of points and indices get the normal.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
virtual void boundingSpheres(pointField ¢res, scalarField &radiusSqr) const
Get bounding spheres (centre and radius squared), one per element.
const point & min() const
Minimum describing the bounding box.
#define forAll(list, i)
Loop across all elements in list.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
virtual void findLineAll(const pointField &start, const pointField &end, List< List< pointIndexHit >> &) const
Get all intersections in order from start to end.
virtual label size() const
Range of local indices that can be returned.
void cmptMax(FieldField< Field, typename FieldField< Field, Type >::cmptType > &cf, const FieldField< Field, Type > &f)
label findLower(const ListType &input, const T &val, const label start, const ComparePredicate &comp)
messageStream Info
Information stream (stdout output on master, null elsewhere)
void setSize(const label n)
Alias for resize()
DynamicList< T, SizeMin > & append(const T &val)
Append an element to the end of this list.
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
PtrList< coordinateSystem > coordinates(solidRegions.size())
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
addNamedToRunTimeSelectionTable(topoSetCellSource, badQualityToCell, word, badQuality)
virtual tmp< pointField > coordinates() const
Get representative set of element coordinates.
virtual void getField(const List< pointIndexHit > &, labelList &) const
WIP. From a set of hits (points and.
bool readEntry(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX, bool mandatory=true) const
virtual void findLineAny(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Return any intersection on segment from start to end.
scalarField samples(nIntervals, Zero)
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Macros for easy insertion into run-time selection tables.
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
errorManip< error > abort(error &err)
errorManipArg< error, int > exit(error &err, const int errNo=1)
Type & lookupObjectRef(const word &name, const bool recursive=false) const
dimensioned< Type > cmptDivide(const dimensioned< Type > &, const dimensioned< Type > &)
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
List< labelList > labelListList
A List of labelList.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
PointIndexHit< point > pointIndexHit
A PointIndexHit for 3D points.
A Cartesian coordinate system.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
void clear()
Clear the list, i.e. set size to zero.
static tmp< T > New(Args &&... args)
Construct tmp of T with forwarding arguments.
A bounding box defined in terms of min/max extrema points.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Various functions to operate on Lists.
vector point
Point is a vector.
defineTypeNameAndDebug(combustionModel, 0)
virtual void setField(const labelList &values)
WIP. Store element-wise field.
const objectRegistry & db() const noexcept
Return the local objectRegistry.