Go to the documentation of this file.
43 searchableSurfaceCollection,
51 void Foam::searchableSurfaceCollection::findNearest
55 List<pointIndexHit>& nearestInfo,
60 nearestInfo.setSize(
samples.size());
62 nearestSurf.setSize(
samples.size());
65 List<pointIndexHit> hitInfo(
samples.size());
71 subGeom_[surfI].findNearest
75 transform_[surfI].localPosition(
samples),
84 if (hitInfo[pointi].hit())
88 point globalPt = transform_[surfI].globalPosition
92 hitInfo[pointi].rawPoint(),
99 if (distSqr < minDistSqr[pointi])
101 minDistSqr[pointi] = distSqr;
102 nearestInfo[pointi].setPoint(globalPt);
103 nearestInfo[pointi].setHit();
104 nearestInfo[pointi].setIndex
106 hitInfo[pointi].index()
107 + indexOffset_[surfI]
109 nearestSurf[pointi] = surfI;
119 void Foam::searchableSurfaceCollection::sortHits
121 const List<pointIndexHit>& info,
122 List<List<pointIndexHit>>& surfInfo,
131 if (info[pointi].hit())
133 label index = info[pointi].index();
134 label surfI =
findLower(indexOffset_, index+1);
140 surfInfo.setSize(subGeom_.size());
142 infoMap.setSize(subGeom_.size());
146 surfInfo[surfI].setSize(nHits[surfI]);
147 infoMap[surfI].setSize(nHits[surfI]);
153 if (info[pointi].hit())
155 label index = info[pointi].index();
156 label surfI =
findLower(indexOffset_, index+1);
160 label localI = nHits[surfI]++;
164 info[pointi].rawPoint(),
165 index-indexOffset_[surfI]
167 infoMap[surfI][localI] = pointi;
175 Foam::searchableSurfaceCollection::searchableSurfaceCollection
182 instance_(
dict.size()),
184 transform_(
dict.size()),
185 subGeom_(
dict.size()),
186 mergeSubRegions_(
dict.
get<
bool>(
"mergeSubRegions")),
187 indexOffset_(
dict.size()+1)
192 label startIndex = 0;
197 instance_[surfI] = dEntry.keyword();
204 if (coordDict.
found(
"coordinateSystem"))
223 const word subGeomName(sDict.
get<
word>(
"surface"));
232 if (
s.size() !=
s.globalSize())
235 <<
"Cannot use a distributed surface in a collection."
239 subGeom_.set(surfI, &
s);
241 indexOffset_[surfI] = startIndex;
242 startIndex += subGeom_[surfI].size();
244 Info<<
" instance : " << instance_[surfI] <<
endl;
245 Info<<
" surface : " <<
s.name() <<
endl;
246 Info<<
" scale : " << scale_[surfI] <<
endl;
247 Info<<
" transform: " << transform_[surfI] <<
endl;
252 indexOffset_[surfI] = startIndex;
254 instance_.setSize(surfI);
255 scale_.setSize(surfI);
256 transform_.setSize(surfI);
257 subGeom_.setSize(surfI);
258 indexOffset_.setSize(surfI+1);
265 const boundBox& surfBb = subGeom_[surfI].bounds();
268 const point surfBbMin = transform_[surfI].globalPosition
276 const point surfBbMax = transform_[surfI].globalPosition
285 bounds().
min() =
min(bounds().
min(), surfBbMin);
286 bounds().max() =
max(bounds().
max(), surfBbMax);
301 if (regions_.empty())
303 regionOffset_.
setSize(subGeom_.size());
308 regionOffset_[surfI] = allRegions.size();
310 if (mergeSubRegions_)
317 const wordList& subRegions = subGeom_[surfI].regions();
325 regions_.transfer(allRegions);
333 return indexOffset_.last();
341 auto& ctrs = tctrs.ref();
352 ctrs[coordI++] = transform_[surfI].globalPosition
373 centres.setSize(size());
374 radiusSqr.setSize(centres.size());
381 scalar maxScale =
cmptMax(scale_[surfI]);
385 subGeom_[surfI].boundingSpheres(subCentres, subRadiusSqr);
389 centres[coordI] = transform_[surfI].globalPosition
397 radiusSqr[coordI] = maxScale*subRadiusSqr[i];
412 nPoints += subGeom_[surfI].points()().size();
416 auto& pts = tpts.ref();
427 pts[
nPoints++] = transform_[surfI].globalPosition
442 void Foam::searchableSurfaceCollection::findNearest
483 transform_[surfI].localPosition
493 transform_[surfI].localPosition
500 subGeom_[surfI].findLine(e0, e1, hitInfo);
504 if (hitInfo[pointi].hit())
507 nearest[pointi] = transform_[surfI].globalPosition
511 hitInfo[pointi].rawPoint(),
515 info[pointi] = hitInfo[pointi];
516 info[pointi].rawPoint() = nearest[pointi];
517 info[pointi].setIndex
519 hitInfo[pointi].index()
520 + indexOffset_[surfI]
532 if (info[pointi].hit())
535 scalar magN =
mag(
n);
541 scalar
s = ((info[pointi].rawPoint()-start[pointi])&
n);
546 <<
"point:" << info[pointi]
548 <<
" outside vector "
549 <<
" start:" << start[pointi]
550 <<
" end:" <<
end[pointi]
568 findLine(start,
end, info);
581 findLine(start,
end, nearestInfo);
586 if (nearestInfo[pointi].hit())
589 info[pointi][0] = nearestInfo[pointi];
593 info[pointi].
clear();
605 if (subGeom_.size() == 0)
607 else if (subGeom_.size() == 1)
609 if (mergeSubRegions_)
612 region = regionOffset_[0];
616 subGeom_[0].getRegion(info, region);
627 sortHits(info, surfInfo, infoMap);
634 if (mergeSubRegions_)
642 region[map[i]] = regionOffset_[surfI];
651 subGeom_[surfI].getRegion(surfInfo[surfI], surfRegion);
656 region[map[i]] = regionOffset_[surfI] + surfRegion[i];
670 if (subGeom_.size() == 0)
672 else if (subGeom_.size() == 1)
674 subGeom_[0].getNormal(info, normal);
684 sortHits(info, surfInfo, infoMap);
686 normal.setSize(info.size());
692 subGeom_[surfI].getNormal(surfInfo[surfI], surfNormal);
695 surfNormal = transform_[surfI].globalVector(surfNormal);
700 normal[map[i]] = surfNormal[i];
714 <<
"Volume type not supported for collection."
722 const bool keepNonLocal,
739 subGeom_[surfI].distribute
754 subGeom_[surfI].setField
761 subGeom_[surfI].size(),
776 if (subGeom_.size() == 0)
778 else if (subGeom_.size() == 1)
780 subGeom_[0].getField(info,
values);
790 sortHits(info, surfInfo, infoMap);
796 subGeom_[surfI].getField(surfInfo[surfI], surfValues);
798 if (surfValues.size())
801 values.setSize(info.size());
806 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)
const objectRegistry & db() const
Return the local objectRegistry.
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 (uses stdout - output is on the master only)
word name(const complex &c)
Return string representation of complex.
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.
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 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.
Various functions to operate on Lists.
vector point
Point is a vector.
void setSize(const label newSize)
Alias for resize(const label)
defineTypeNameAndDebug(combustionModel, 0)
virtual void setField(const labelList &values)
WIP. Store element-wise field.