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;
174 Foam::searchableSurfaceCollection::searchableSurfaceCollection
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");
210 const word subGeomName(subDict.
lookup(
"surface"));
219 if (s.size() != s.globalSize())
223 "searchableSurfaceCollection::searchableSurfaceCollection" 224 "(const IOobject&, const dictionary&)" 225 ) <<
"Cannot use a distributed surface in a collection." 229 subGeom_.set(surfI, &const_cast<searchableSurface&>(s));
231 indexOffset_[surfI] = startIndex;
232 startIndex += subGeom_[surfI].size();
234 Info<<
" instance : " << instance_[surfI] <<
endl;
235 Info<<
" surface : " << s.name() <<
endl;
236 Info<<
" scale : " << scale_[surfI] <<
endl;
237 Info<<
" coordsys : " << transform_[surfI] <<
endl;
242 indexOffset_[surfI] = startIndex;
244 instance_.setSize(surfI);
245 scale_.setSize(surfI);
246 transform_.setSize(surfI);
247 subGeom_.setSize(surfI);
248 indexOffset_.setSize(surfI+1);
255 const boundBox& surfBb = subGeom_[surfI].bounds();
258 const point surfBbMin = transform_[surfI].globalPosition
266 const point surfBbMax = transform_[surfI].globalPosition
275 bounds().
min() =
min(bounds().
min(), surfBbMin);
276 bounds().max() =
max(bounds().
max(), surfBbMax);
291 if (regions_.size() == 0)
293 regionOffset_.
setSize(subGeom_.size());
298 regionOffset_[surfI] = allRegions.
size();
300 if (mergeSubRegions_)
307 const wordList& subRegions = subGeom_[surfI].regions();
311 allRegions.
append(instance_[surfI] +
"_" + subRegions[i]);
315 regions_.transfer(allRegions.
shrink());
323 return indexOffset_.last();
342 ctrs[coordI++] = transform_[surfI].globalPosition
371 scalar maxScale =
cmptMax(scale_[surfI]);
375 subGeom_[surfI].boundingSpheres(subCentres, subRadiusSqr);
379 centres[coordI] = transform_[surfI].globalPosition
387 radiusSqr[coordI] = maxScale*subRadiusSqr[i];
402 nPoints += subGeom_[surfI].points()().size();
417 pts[nPoints++] = transform_[surfI].globalPosition
432 void Foam::searchableSurfaceCollection::findNearest
473 transform_[surfI].localPosition
483 transform_[surfI].localPosition
490 subGeom_[surfI].findLine(e0, e1, hitInfo);
494 if (hitInfo[pointI].hit())
497 nearest[pointI] = transform_[surfI].globalPosition
501 hitInfo[pointI].rawPoint(),
505 info[pointI] = hitInfo[pointI];
506 info[pointI].rawPoint() = nearest[pointI];
507 info[pointI].setIndex
509 hitInfo[pointI].index()
510 + indexOffset_[surfI]
522 if (info[pointI].hit())
524 vector n(end[pointI] - start[pointI]);
525 scalar magN =
mag(n);
531 scalar
s = ((info[pointI].rawPoint()-start[pointI])&n);
537 "searchableSurfaceCollection::findLine(..)" 538 ) <<
"point:" << info[pointI]
540 <<
" outside vector " 541 <<
" start:" << start[pointI]
542 <<
" end:" << end[pointI]
560 findLine(start, end, info);
573 findLine(start, end, nearestInfo);
578 if (nearestInfo[pointI].hit())
581 info[pointI][0] = nearestInfo[pointI];
585 info[pointI].
clear();
597 if (subGeom_.size() == 0)
599 else if (subGeom_.size() == 1)
601 if (mergeSubRegions_)
604 region = regionOffset_[0];
608 subGeom_[0].getRegion(info, region);
619 sortHits(info, surfInfo, infoMap);
626 if (mergeSubRegions_)
634 region[map[i]] = regionOffset_[surfI];
643 subGeom_[surfI].getRegion(surfInfo[surfI], surfRegion);
648 region[map[i]] = regionOffset_[surfI] + surfRegion[i];
662 if (subGeom_.size() == 0)
664 else if (subGeom_.size() == 1)
666 subGeom_[0].getNormal(info, normal);
676 sortHits(info, surfInfo, infoMap);
684 subGeom_[surfI].getNormal(surfInfo[surfI], surfNormal);
687 surfNormal = transform_[surfI].globalVector(surfNormal);
692 normal[map[i]] = surfNormal[i];
707 "searchableSurfaceCollection::getVolumeType(const pointField&" 708 ", List<volumeType>&) const" 709 ) <<
"Volume type not supported for collection." 717 const bool keepNonLocal,
737 subGeom_[surfI].distribute
752 subGeom_[surfI].setField
754 static_cast<const labelList&>
759 subGeom_[surfI].size(),
774 if (subGeom_.size() == 0)
776 else if (subGeom_.size() == 1)
778 subGeom_[0].getField(info, values);
788 sortHits(info, surfInfo, infoMap);
794 subGeom_[surfI].getField(surfInfo[surfI], surfValues);
796 if (surfValues.
size())
804 values[map[i]] = surfValues[i];
const pointField & points
const point & min() const
Minimum describing the bounding box.
vector point
Point is a vector.
PtrList< coordinateSystem > coordinates(solidRegions.size())
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 ))
virtual tmp< pointField > points() const
Get the points that define the surface.
Base class of (analytical or triangulated) surface. Encapsulates all the search routines. WIP.
dimensioned< scalar > mag(const dimensioned< Type > &)
word name(const complex &)
Return a string representation of a complex.
virtual tmp< pointField > coordinates() const
Get representative set of element coordinates.
dimensioned< scalar > magSqr(const dimensioned< Type > &)
virtual void getVolumeType(const pointField &, List< volumeType > &) const
Determine type (inside/outside/mixed) for point. unknown if.
void cmptMax(FieldField< Field, typename FieldField< Field, Type >::cmptType > &cf, const FieldField< Field, Type > &f)
A class for handling words, derived from string.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
void size(const label)
Override size to be inconsistent with allocated storage.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
errorManipArg< error, int > exit(error &err, const int errNo=1)
virtual void findLineAll(const pointField &start, const pointField &end, List< List< pointIndexHit > > &) const
Get all intersections in order from start to end.
Various functions to operate on Lists.
PointIndexHit< point > pointIndexHit
virtual void getField(const List< pointIndexHit > &, labelList &) const
WIP. From a set of hits (points and.
A list of keyword definitions, which are a keyword followed by any number of values (e...
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.
label size() const
Return number of elements in list.
vectorField pointField
pointField is a vectorField.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
virtual void getRegion(const List< pointIndexHit > &, labelList ®ion) const
From a set of points and indices get the region.
void clear()
Clear the list, i.e. set size to zero.
void setSize(const label)
Reset size of List.
Ostream & endl(Ostream &os)
Add newline and flush stream.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
virtual void findLineAny(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Return any intersection on segment from start to end.
dimensioned< Type > cmptDivide(const dimensioned< Type > &, const dimensioned< Type > &)
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.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const
From a set of points and indices get the normal.
virtual void boundingSpheres(pointField ¢res, scalarField &radiusSqr) const
Get bounding spheres (centre and radius squared), one per element.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & shrink()
Shrink the allocated space to the number of elements used.
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type.
Macros for easy insertion into run-time selection tables.
virtual ~searchableSurfaceCollection()
Destructor.
const point & max() const
Maximum describing the bounding box.
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)
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
A bounding box defined in terms of the points at its extremities.
bool isDict(const word &) const
Check if entry is a sub-dictionary.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
dimensioned< Type > cmptMultiply(const dimensioned< Type > &, const dimensioned< Type > &)
List< label > labelList
A List of labels.
virtual const wordList & regions() const
Names of regions.
virtual void setField(const labelList &values)
WIP. Store element-wise field.
A List obtained as a section of another List.
virtual label size() const
Range of local indices that can be returned.
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
List< labelList > labelListList
A List of labelList.
const objectRegistry & db() const
Return the local objectRegistry.
static autoPtr< coordinateSystem > New(const objectRegistry &obr, const dictionary &dict)
Select constructed from dictionary and objectRegistry.
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
A class for managing temporary objects.
defineTypeNameAndDebug(combustionModel, 0)