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());
70 subGeom_[surfI].findNearest
74 transform_[surfI].localPosition(
samples),
83 if (hitInfo[pointi].hit())
87 point globalPt = transform_[surfI].globalPosition
91 hitInfo[pointi].rawPoint(),
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();
211 const word subGeomName(subDict.
lookup(
"surface"));
220 if (
s.size() !=
s.globalSize())
223 <<
"Cannot use a distributed surface in a collection."
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;
244 transform_.setSize(surfI);
245 subGeom_.setSize(surfI);
253 const boundBox& surfBb = subGeom_[surfI].bounds();
256 const point surfBbMin = transform_[surfI].globalPosition
264 const point surfBbMax = transform_[surfI].globalPosition
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);
571 info.setSize(start.
size());
574 if (nearestInfo[pointi].hit())
576 info[pointi].setSize(1);
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
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];
Various functions to operate on Lists.
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
Macros for easy insertion into run-time selection tables.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & shrink()
Shrink the allocated space to the number of elements used.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
const objectRegistry & db() const
Return the local objectRegistry.
const word & name() const
Return name.
void size(const label)
Override size to be inconsistent with allocated storage.
void clear()
Clear the list, i.e. set size to zero.
void setSize(const label)
Reset size of List.
A List obtained as a section of another List.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
A bounding box defined in terms of the points at its extremities.
const point & min() const
Minimum point defining the bounding box.
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.
A list of keyword definitions, which are a keyword followed by any number of values (e....
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type and name.
Makes a collection of surface geometries by copying from an existing defined surface geometry....
virtual void getVolumeType(const pointField &, List< volumeType > &) const
Determine type (inside/outside/mixed) for point. unknown if.
virtual void findLine(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Find first intersection on segment from start to end.
virtual void findLineAny(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Return any intersection on segment from start to end.
virtual label size() const
Range of local indices that can be returned.
virtual void boundingSpheres(pointField ¢res, scalarField &radiusSqr) const
Get bounding spheres (centre and radius squared), one per element.
virtual void setField(const labelList &values)
WIP. Store element-wise field.
virtual void getField(const List< pointIndexHit > &, labelList &) const
WIP. From a set of hits (points and.
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const
From a set of points and indices get the normal.
searchableSurfaceCollection(const IOobject &io, const dictionary &dict)
Construct from dictionary (used by searchableSurface)
virtual void getRegion(const List< pointIndexHit > &, labelList ®ion) const
From a set of points and indices get the region.
virtual const wordList & regions() const
Names of regions.
virtual ~searchableSurfaceCollection()
Destructor.
virtual tmp< pointField > coordinates() const
Get representative set of element coordinates.
virtual void findLineAll(const pointField &start, const pointField &end, List< List< pointIndexHit >> &) const
Get all intersections in order from start to end.
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.
virtual tmp< pointField > points() const
Get the points that define the surface.
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
const boundBox & bounds() const
Return const reference to boundBox.
A class for managing temporary objects.
T & ref() const
Return non-const reference or generate a fatal error.
A class for handling words, derived from string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
volScalarField scalarField(fieldObject, mesh)
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.name(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
errorManipArg< error, int > exit(error &err, const int errNo=1)
List< label > labelList
A List of labels.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
addToRunTimeSelectionTable(polyPatch, mergedCyclicPolyPatch, word)
PointIndexHit< point > pointIndexHit
Ostream & endl(Ostream &os)
Add newline and flush stream.
word name(const bool)
Return a word representation of a bool.
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,.
errorManip< error > abort(error &err)
const dimensionSet dimless
vectorField pointField
pointField is a vectorField.
vector point
Point is a vector.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
List< labelList > labelListList
A List of labelList.
dimensioned< scalar > mag(const dimensioned< Type > &)
defineTypeNameAndDebug(combustionModel, 0)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
dimensioned< Type > cmptMultiply(const dimensioned< Type > &, const dimensioned< Type > &)
void cmptMax(FieldField< Field, typename FieldField< Field, Type >::cmptType > &cf, const FieldField< Field, Type > &f)
dimensioned< Type > cmptDivide(const dimensioned< Type > &, const dimensioned< Type > &)
dimensioned< scalar > magSqr(const dimensioned< Type > &)
scalarField samples(nIntervals, 0)