41 searchableSurfaceCollection,
50 void Foam::searchableSurfaceCollection::findNearest
54 List<pointIndexHit>& nearestInfo,
59 nearestInfo.setSize(samples.size());
61 nearestSurf.setSize(samples.size());
64 List<pointIndexHit> hitInfo(samples.size());
66 const scalarField localMinDistSqr(samples.size(), great);
70 subGeom_[surfI].findNearest
74 transform_[surfI].localPosition(samples),
83 if (hitInfo[pointi].hit())
87 point globalPt = transform_[surfI].globalPosition
91 hitInfo[pointi].rawPoint(),
96 scalar distSqr =
magSqr(globalPt - samples[pointi]);
98 if (distSqr < minDistSqr[pointi])
100 minDistSqr[pointi] = distSqr;
101 nearestInfo[pointi].setPoint(globalPt);
102 nearestInfo[pointi].setHit();
103 nearestInfo[pointi].setIndex
105 hitInfo[pointi].index()
106 + indexOffset_[surfI]
108 nearestSurf[pointi] = surfI;
118 void Foam::searchableSurfaceCollection::sortHits
120 const List<pointIndexHit>& info,
121 List<List<pointIndexHit>>& surfInfo,
130 if (info[pointi].hit())
132 label index = info[pointi].index();
139 surfInfo.setSize(subGeom_.size());
141 infoMap.setSize(subGeom_.size());
145 surfInfo[surfI].setSize(nHits[surfI]);
146 infoMap[surfI].setSize(nHits[surfI]);
152 if (info[pointi].hit())
154 label index = info[pointi].index();
159 label localI = nHits[surfI]++;
163 info[pointi].rawPoint(),
164 index-indexOffset_[surfI]
166 infoMap[surfI][localI] = pointi;
181 instance_(dict.size()),
183 transform_(dict.size()),
184 subGeom_(dict.size()),
185 mergeSubRegions_(dict.
lookup(
"mergeSubRegions")),
186 indexOffset_(dict.size()+1)
191 label startIndex = 0;
194 if (dict.
isDict(iter().keyword()))
196 instance_[surfI] = iter().keyword();
200 scale_[surfI] = subDict.
lookup(
"scale");
211 const word subGeomName(subDict.
lookup(
"surface"));
220 if (s.size() != s.globalSize())
223 <<
"Cannot use a distributed surface in a collection." 227 subGeom_.set(surfI, &const_cast<searchableSurface&>(s));
229 indexOffset_[surfI] = startIndex;
230 startIndex += subGeom_[surfI].size();
232 Info<<
" instance : " << instance_[surfI] <<
endl;
233 Info<<
" surface : " << s.name() <<
endl;
234 Info<<
" scale : " << scale_[surfI] <<
endl;
235 Info<<
" coordsys : " << transform_[surfI] <<
endl;
240 indexOffset_[surfI] = startIndex;
242 instance_.setSize(surfI);
243 scale_.setSize(surfI);
244 transform_.setSize(surfI);
245 subGeom_.setSize(surfI);
246 indexOffset_.setSize(surfI+1);
253 const boundBox& surfBb = subGeom_[surfI].bounds();
256 const point surfBbMin = transform_[surfI].globalPosition
264 const point surfBbMax = transform_[surfI].globalPosition
273 bounds().
min() =
min(bounds().
min(), surfBbMin);
274 bounds().max() =
max(bounds().
max(), surfBbMax);
289 if (regions_.size() == 0)
291 regionOffset_.
setSize(subGeom_.size());
296 regionOffset_[surfI] = allRegions.
size();
298 if (mergeSubRegions_)
305 const wordList& subRegions = subGeom_[surfI].regions();
309 allRegions.
append(instance_[surfI] +
"_" + subRegions[i]);
313 regions_.transfer(allRegions.
shrink());
321 return indexOffset_.last();
336 const pointField subCoords(subGeom_[surfI].coordinates());
340 ctrs[coordI++] = transform_[surfI].globalPosition
369 scalar maxScale =
cmptMax(scale_[surfI]);
373 subGeom_[surfI].boundingSpheres(subCentres, subRadiusSqr);
377 centres[coordI] = transform_[surfI].globalPosition
385 radiusSqr[coordI] = maxScale*subRadiusSqr[i];
400 nPoints += subGeom_[surfI].points()().size();
415 pts[nPoints++] = transform_[surfI].globalPosition
430 void Foam::searchableSurfaceCollection::findNearest
471 transform_[surfI].localPosition
481 transform_[surfI].localPosition
488 subGeom_[surfI].findLine(e0, e1, hitInfo);
492 if (hitInfo[pointi].hit())
495 nearest[pointi] = transform_[surfI].globalPosition
499 hitInfo[pointi].rawPoint(),
503 info[pointi] = hitInfo[pointi];
504 info[pointi].rawPoint() = nearest[pointi];
505 info[pointi].setIndex
507 hitInfo[pointi].index()
508 + indexOffset_[surfI]
520 if (info[pointi].hit())
522 vector n(end[pointi] - start[pointi]);
523 scalar magN =
mag(n);
529 scalar
s = ((info[pointi].rawPoint()-start[pointi])&n);
534 <<
"point:" << info[pointi]
536 <<
" outside vector " 537 <<
" start:" << start[pointi]
538 <<
" end:" << end[pointi]
556 findLine(start, end, info);
569 findLine(start, end, nearestInfo);
574 if (nearestInfo[pointi].hit())
577 info[pointi][0] = nearestInfo[pointi];
581 info[pointi].
clear();
593 if (subGeom_.size() == 0)
595 else if (subGeom_.size() == 1)
597 if (mergeSubRegions_)
600 region = regionOffset_[0];
604 subGeom_[0].getRegion(info, region);
615 sortHits(info, surfInfo, infoMap);
622 if (mergeSubRegions_)
630 region[map[i]] = regionOffset_[surfI];
639 subGeom_[surfI].getRegion(surfInfo[surfI], surfRegion);
644 region[map[i]] = regionOffset_[surfI] + surfRegion[i];
658 if (subGeom_.size() == 0)
660 else if (subGeom_.size() == 1)
662 subGeom_[0].getNormal(info, normal);
672 sortHits(info, surfInfo, infoMap);
680 subGeom_[surfI].getNormal(surfInfo[surfI], surfNormal);
683 surfNormal = transform_[surfI].globalVector(surfNormal);
688 normal[map[i]] = surfNormal[i];
702 <<
"Volume type not supported for collection." 710 const bool keepNonLocal,
730 subGeom_[surfI].distribute
745 subGeom_[surfI].setField
747 static_cast<const labelList&>
752 subGeom_[surfI].size(),
767 if (subGeom_.size() == 0)
769 else if (subGeom_.size() == 1)
771 subGeom_[0].getField(info, values);
781 sortHits(info, surfInfo, infoMap);
787 subGeom_[surfI].getField(surfInfo[surfI], surfValues);
789 if (surfValues.
size())
797 values[map[i]] = surfValues[i];
virtual ~searchableSurfaceCollection()
Destructor.
List< labelList > labelListList
A List of labelList.
void cmptMax(FieldField< Field, typename FieldField< Field, Type >::cmptType > &cf, const FieldField< Field, Type > &f)
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const
From a set of points and indices get the normal.
#define forAll(list, i)
Loop across all elements in list.
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
FvWallInfoData< WallInfo, label > label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
virtual void boundingSpheres(pointField ¢res, scalarField &radiusSqr) const
Get bounding spheres (centre and radius squared), one per element.
static const Vector< scalar > max
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.
virtual void getRegion(const List< pointIndexHit > &, labelList ®ion) const
From a set of points and indices get the region.
T & ref() const
Return non-const reference or generate a fatal error.
void size(const label)
Override size to be inconsistent with allocated storage.
searchableSurfaceCollection(const IOobject &io, const dictionary &dict)
Construct from dictionary (used by searchableSurface)
Ostream & endl(Ostream &os)
Add newline and flush stream.
virtual void findLineAny(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Return any intersection on segment from start to end.
A bounding box defined in terms of the points at its extremities.
PointIndexHit< point > pointIndexHit
Base class of (analytical or triangulated) surface. Encapsulates all the search routines. WIP.
virtual void distribute(const List< treeBoundBox > &, const bool keepNonLocal, autoPtr< distributionMap > &faceMap, autoPtr< distributionMap > &pointMap)
Set bounds of surface. Bounds currently set as list of.
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type.
virtual void getVolumeType(const pointField &, List< volumeType > &) const
Determine type (inside/outside/mixed) for point. unknown if.
Macros for easy insertion into run-time selection tables.
bool isDict(const word &) const
Check if entry is a sub-dictionary.
dimensioned< Type > cmptDivide(const dimensioned< Type > &, const dimensioned< Type > &)
static const Vector< scalar > min
Various functions to operate on Lists.
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
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.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().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))
vectorField pointField
pointField is a vectorField.
virtual tmp< pointField > points() const
Get the points that define the surface.
void clear()
Clear the list, i.e. set size to zero.
A class for handling words, derived from string.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
virtual void findLineAll(const pointField &start, const pointField &end, List< List< pointIndexHit >> &) const
Get all intersections in order from start to end.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
virtual label size() const
Range of local indices that can be returned.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
List< label > labelList
A List of labels.
errorManip< error > abort(error &err)
dimensioned< Type > cmptMultiply(const dimensioned< Type > &, const dimensioned< Type > &)
dimensioned< scalar > magSqr(const dimensioned< Type > &)
DynamicList< T, SizeInc, SizeMult, SizeDiv > & shrink()
Shrink the allocated space to the number of elements used.
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
defineTypeNameAndDebug(combustionModel, 0)
virtual void getField(const List< pointIndexHit > &, labelList &) const
WIP. From a set of hits (points and.
word name(const complex &)
Return a string representation of a complex.
virtual void setField(const labelList &values)
WIP. Store element-wise field.
void setSize(const label)
Reset size of List.
const point & max() const
Maximum point defining the bounding box.
static autoPtr< coordinateSystem > New(const objectRegistry &obr, const dictionary &dict)
Select constructed from dictionary and objectRegistry.
vector point
Point is a vector.
virtual tmp< pointField > coordinates() const
Get representative set of element coordinates.
label findLower(const ListType &, typename ListType::const_reference, const label stary, const BinaryOp &bop)
Find last element < given value in sorted list and return index,.
dimensioned< scalar > mag(const dimensioned< Type > &)
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
const point & min() const
Minimum point defining the bounding box.
A class for managing temporary objects.
const objectRegistry & db() const
Return the local objectRegistry.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
virtual const wordList & regions() const
Names of regions.