36 namespace searchableSurfaces
52 searchableSurfaceCollection,
53 "searchableSurfaceCollection"
61 void Foam::searchableSurfaces::collection::findNearest
65 List<pointIndexHit>& nearestInfo,
70 nearestInfo.setSize(
samples.size());
72 nearestSurf.setSize(
samples.size());
75 List<pointIndexHit> hitInfo(
samples.size());
81 subGeom_[surfI].findNearest
85 transform_[surfI].localPosition(
samples),
94 if (hitInfo[pointi].hit())
98 point globalPt = transform_[surfI].globalPosition
102 hitInfo[pointi].rawPoint(),
109 if (distSqr < minDistSqr[pointi])
111 minDistSqr[pointi] = distSqr;
112 nearestInfo[pointi].setPoint(globalPt);
113 nearestInfo[pointi].setHit();
114 nearestInfo[pointi].setIndex
116 hitInfo[pointi].index()
117 + indexOffset_[surfI]
119 nearestSurf[pointi] = surfI;
129 void Foam::searchableSurfaces::collection::sortHits
131 const List<pointIndexHit>& info,
132 List<List<pointIndexHit>>& surfInfo,
141 if (info[pointi].hit())
143 label index = info[pointi].index();
150 surfInfo.setSize(subGeom_.size());
152 infoMap.setSize(subGeom_.size());
156 surfInfo[surfI].setSize(nHits[surfI]);
157 infoMap[surfI].setSize(nHits[surfI]);
163 if (info[pointi].hit())
165 label index = info[pointi].index();
170 label localI = nHits[surfI]++;
174 info[pointi].rawPoint(),
175 index-indexOffset_[surfI]
177 infoMap[surfI][localI] = pointi;
192 instance_(
dict.size()),
194 transform_(
dict.size()),
195 subGeom_(
dict.size()),
196 mergeSubRegions_(
dict.lookup(
"mergeSubRegions")),
197 indexOffset_(
dict.size()+1)
202 label startIndex = 0;
205 if (
dict.isDict(iter().keyword()))
207 instance_[surfI] = iter().keyword();
222 const word subGeomName(subDict.
lookup(
"surface"));
231 if (
s.size() !=
s.globalSize())
234 <<
"Cannot use a distributed surface in a collection."
240 indexOffset_[surfI] = startIndex;
241 startIndex += subGeom_[surfI].size();
243 Info<<
" instance : " << instance_[surfI] <<
endl;
244 Info<<
" surface : " <<
s.name() <<
endl;
245 Info<<
" scale : " << scale_[surfI] <<
endl;
246 Info<<
" coordsys : " << transform_[surfI] <<
endl;
251 indexOffset_[surfI] = startIndex;
255 transform_.setSize(surfI);
256 subGeom_.setSize(surfI);
264 const boundBox& surfBb = subGeom_[surfI].bounds();
267 const point surfBbMin = transform_[surfI].globalPosition
275 const point surfBbMax = transform_[surfI].globalPosition
300 if (regions_.size() == 0)
302 regionOffset_.
setSize(subGeom_.size());
307 regionOffset_[surfI] = allRegions.
size();
309 if (mergeSubRegions_)
316 const wordList& subRegions = subGeom_[surfI].regions();
320 allRegions.
append(instance_[surfI] +
"_" + subRegions[i]);
324 regions_.transfer(allRegions.
shrink());
332 return indexOffset_.last();
351 ctrs[coordI++] = transform_[surfI].globalPosition
380 scalar maxScale =
cmptMax(scale_[surfI]);
384 subGeom_[surfI].boundingSpheres(subCentres, subRadiusSqr);
388 centres[coordI] = transform_[surfI].globalPosition
396 radiusSqr[coordI] = maxScale*subRadiusSqr[i];
411 nPoints += subGeom_[surfI].points()().size();
426 pts[
nPoints++] = transform_[surfI].globalPosition
441 void Foam::searchableSurfaces::collection::findNearest
482 transform_[surfI].localPosition
492 transform_[surfI].localPosition
499 subGeom_[surfI].findLine(e0, e1, hitInfo);
503 if (hitInfo[pointi].hit())
506 nearest[pointi] = transform_[surfI].globalPosition
510 hitInfo[pointi].rawPoint(),
514 info[pointi] = hitInfo[pointi];
515 info[pointi].rawPoint() = nearest[pointi];
516 info[pointi].setIndex
518 hitInfo[pointi].index()
519 + indexOffset_[surfI]
531 if (info[pointi].hit())
533 vector n(end[pointi] - start[pointi]);
534 scalar magN =
mag(
n);
540 scalar
s = ((info[pointi].rawPoint()-start[pointi])&
n);
545 <<
"point:" << info[pointi]
547 <<
" outside vector "
548 <<
" start:" << start[pointi]
549 <<
" end:" << end[pointi]
567 findLine(start, end, info);
580 findLine(start, end, nearestInfo);
582 info.setSize(start.
size());
585 if (nearestInfo[pointi].hit())
587 info[pointi].setSize(1);
588 info[pointi][0] = nearestInfo[pointi];
592 info[pointi].
clear();
604 if (subGeom_.size() == 0)
606 else if (subGeom_.size() == 1)
608 if (mergeSubRegions_)
611 region = regionOffset_[0];
615 subGeom_[0].getRegion(info, region);
626 sortHits(info, surfInfo, infoMap);
633 if (mergeSubRegions_)
641 region[map[i]] = regionOffset_[surfI];
650 subGeom_[surfI].getRegion(surfInfo[surfI], surfRegion);
655 region[map[i]] = regionOffset_[surfI] + surfRegion[i];
669 if (subGeom_.size() == 0)
671 else if (subGeom_.size() == 1)
673 subGeom_[0].getNormal(info, normal);
683 sortHits(info, surfInfo, infoMap);
691 subGeom_[surfI].getNormal(surfInfo[surfI], surfNormal);
694 surfNormal = transform_[surfI].globalVector(surfNormal);
699 normal[map[i]] = surfNormal[i];
713 <<
"Volume type not supported for collection."
721 const bool keepNonLocal,
741 subGeom_[surfI].distribute
756 subGeom_[surfI].setField
763 subGeom_[surfI].size(),
778 if (subGeom_.size() == 0)
780 else if (subGeom_.size() == 1)
782 subGeom_[0].getField(info, values);
792 sortHits(info, surfInfo, infoMap);
798 subGeom_[surfI].getField(surfInfo[surfI], surfValues);
800 if (surfValues.
size())
808 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 keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
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.
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
const boundBox & bounds() const
Return const reference to boundBox.
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.
collection(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 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 ~collection()
Destructor.
virtual tmp< pointField > points() const
Get the points that define the surface.
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(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.name(), lagrangian::cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
addToRunTimeSelectionTable(searchableSurface, box, dictionary)
defineTypeNameAndDebug(box, 0)
addBackwardCompatibleToRunTimeSelectionTable(searchableSurface, box, dictionary, searchableBox, "searchableBox")
barycentric coordinates(const polyMesh &mesh, const point &position, const label celli, const label facei, const label faceTrii, const scalar stepFraction)
Return the coordinates given the position and tet topology.
errorManipArg< error, int > exit(error &err, const int errNo=1)
void cmptMultiply(LagrangianPatchField< Type > &f, const LagrangianPatchField< Type > &f1, const LagrangianPatchField< Type > &f2)
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.
PointIndexHit< point > pointIndexHit
void cmptDivide(LagrangianPatchField< Type > &f, const LagrangianPatchField< Type > &f1, const LagrangianPatchField< Type > &f2)
Ostream & endl(Ostream &os)
Add newline and flush stream.
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.
void mag(LagrangianPatchField< scalar > &f, const LagrangianPatchField< Type > &f1)
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
List< labelList > labelListList
A List of labelList.
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
void cmptMax(FieldField< Field, typename FieldField< Field, Type >::cmptType > &cf, const FieldField< Field, Type > &f)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
void magSqr(LagrangianPatchField< scalar > &f, const LagrangianPatchField< Type > &f1)
scalarField samples(nIntervals, 0)