45 namespace functionObjects
58 { trackDirType::FORWARD,
"forward" },
59 { trackDirType::BACKWARD,
"backward" },
60 { trackDirType::BIDIRECTIONAL,
"bidirectional" }
88 dict_.subDict(
"seedSampleSet")
91 sampledSetAxis_ = sampledSetPtr_->axis();
94 return *sampledSetPtr_;
108 if (isA<wallPolyPatch>(pp))
118 for (
const polyPatch& pp :
patches)
121 if (isA<wallPolyPatch>(pp))
125 addressing[nFaces++] = pp.start()+i;
155 for (
const word& fieldName : fields_)
157 if (foundObject<volScalarField>(fieldName))
161 else if (foundObject<volVectorField>(fieldName))
168 <<
"Cannot find scalar/vector field " << fieldName <<
nl 169 <<
"Valid scalar fields: " 171 <<
"Valid vector fields: " 176 vsInterp.resize(nScalar);
177 vvInterp.resize(nVector);
181 for (
const word& fieldName : fields_)
183 if (foundObject<volScalarField>(fieldName))
193 else if (foundObject<volVectorField>(fieldName))
203 if (
f.name() == UName_)
206 UInterp.
cref(vvInterp[nVector]);
220 interpolationScheme_,
222 lookupObject<volVectorField>(UName_)
228 scalarNames_.resize(vsInterp.size());
231 scalarNames_[i] = vsInterp[i].psi().name();
233 vectorNames_.resize(vvInterp.size());
236 vectorNames_[i] = vvInterp[i].psi().name();
244 allTracks_.setCapacity(nSeeds);
245 allScalars_.resize(vsInterp.size());
248 allScalars_[i].clear();
249 allScalars_[i].setCapacity(nSeeds);
251 allVectors_.resize(vvInterp.size());
254 allVectors_[i].clear();
255 allVectors_[i].setCapacity(nSeeds);
275 const label sz = newTrack.
size();
279 newTrack.
append((1.0-w)*track[lefti] + w*track[righti]);
286 forAll(allScalars_, scalari)
288 const scalarList& trackVals = allScalars_[scalari][tracki];
289 newVals[scalari] = (1.0-w)*trackVals[lefti] + w*trackVals[righti];
298 forAll(allVectors_, vectori)
300 const vectorList& trackVals = allVectors_[vectori][tracki];
301 newVals[vectori] = (1.0-w)*trackVals[lefti] + w*trackVals[righti];
310 const treeBoundBox& bb,
312 PtrList<DynamicList<point>>& newTracks,
313 PtrList<DynamicList<scalarList>>& newScalars,
314 PtrList<DynamicList<vectorList>>& newVectors
317 const List<point>& track = allTracks_[tracki];
324 segmenti < track.size();
328 const point& startPt = track[segmenti-1];
329 const point& endPt = track[segmenti];
331 const vector d(endPt-startPt);
332 const scalar magD =
mag(d);
333 if (magD > ROOTVSMALL)
335 if (bb.contains(startPt))
351 if (!bb.contains(endPt))
354 if (bb.intersects(endPt, startPt, clipPt))
362 mag(clipPt-startPt)/magD,
371 newTracks.last().shrink();
372 newScalars.
last().shrink();
373 newVectors.
last().shrink();
382 if (bb.intersects(startPt, endPt, clipPt))
387 new DynamicList<point>(track.size()/10)
391 new DynamicList<scalarList>(track.size()/10)
395 new DynamicList<vectorList>(track.size()/10)
403 mag(clipPt-startPt)/magD,
412 if (!bb.contains(endPt))
426 mag(clipPt-startPt)/magD,
435 newTracks.last().shrink();
436 newScalars.
last().shrink();
437 newVectors.
last().shrink();
445 if (bb.contains(track.last()))
468 PtrList<DynamicList<point>> newTracks;
469 PtrList<DynamicList<scalarList>> newScalars;
470 PtrList<DynamicList<vectorList>> newVectors;
472 forAll(allTracks_, tracki)
474 const List<point>& track = allTracks_[tracki];
479 newTracks.append(
new DynamicList<point>(track.size()));
480 newScalars.append(
new DynamicList<scalarList>(track.size()));
481 newVectors.append(
new DynamicList<vectorList>(track.size()));
484 trimToBox(bb, tracki, newTracks, newScalars, newVectors);
489 allTracks_.setSize(newTracks.size());
490 forAll(allTracks_, tracki)
492 allTracks_[tracki].transfer(newTracks[tracki]);
495 forAll(allScalars_, scalari)
497 DynamicList<scalarList>& fieldVals = allScalars_[scalari];
498 fieldVals.setSize(newTracks.size());
502 scalarList& trackVals = allScalars_[scalari][tracki];
503 trackVals.
setSize(newScalars[tracki].size());
504 forAll(trackVals, samplei)
506 trackVals[samplei] = newScalars[tracki][samplei][scalari];
511 forAll(allVectors_, vectori)
513 DynamicList<vectorList>& fieldVals = allVectors_[vectori];
514 fieldVals.setSize(newTracks.size());
517 vectorList& trackVals = allVectors_[vectori][tracki];
518 trackVals.
setSize(newVectors[tracki].size());
519 forAll(trackVals, samplei)
521 trackVals[samplei] = newVectors[tracki][samplei][vectori];
535 globalIndex globalTrackIDs(allTracks_.size());
550 fromProc.
setSize(globalTrackIDs.localSize(proci));
553 fromProc[i] = tracki++;
559 toMaster.
setSize(globalTrackIDs.localSize());
565 const mapDistribute distMap
567 globalTrackIDs.totalSize(),
580 distMap.constructSize(),
583 distMap.constructMap(),
588 allTracks_.setCapacity(allTracks_.size());
591 forAll(allScalars_, scalari)
593 allScalars_[scalari].shrink();
598 distMap.constructSize(),
601 distMap.constructMap(),
603 allScalars_[scalari],
606 allScalars_[scalari].setCapacity(allScalars_[scalari].size());
609 forAll(allVectors_, vectori)
611 allVectors_[vectori].shrink();
616 distMap.constructSize(),
619 distMap.constructMap(),
621 allVectors_[vectori],
624 allVectors_[vectori].setCapacity(allVectors_[vectori].size());
630 HashTable<fileName> outputFileNames;
634 if (!bounds_.empty())
637 trimToBox(treeBoundBox(bounds_));
643 forAll(allTracks_, tracki)
645 if (allTracks_[tracki].size())
648 n += allTracks_[tracki].size();
652 Log <<
" Tracks:" << nTracks <<
nl 653 <<
" Total samples:" <<
n 665 /
name()/mesh_.regionName()
666 / mesh_.time().timeName()
673 PtrList<coordSet> tracks(nTracks);
675 labelList oldToNewTrack(allTracks_.size(), -1);
677 forAll(allTracks_, tracki)
679 if (allTracks_[tracki].size())
681 List<point>&
points = allTracks_[tracki];
684 for (label pointi = 1; pointi <
points.size(); ++pointi)
697 std::move(allTracks_[tracki]),
701 oldToNewTrack[tracki] = nTracks;
707 const bool canWrite =
711 && trackWriterPtr_->enabled()
712 && (!allScalars_.empty() || !allVectors_.empty())
717 auto&
writer = trackWriterPtr_();
719 writer.nFields(allScalars_.size() + allVectors_.size());
724 (vtkPath / tracks[0].
name())
729 if (!allScalars_.empty())
731 List<List<scalarField>> scalarValues(allScalars_.size());
733 forAll(allScalars_, scalari)
735 auto& allTrackVals = allScalars_[scalari];
736 scalarValues[scalari].resize(nTracks);
738 forAll(allTrackVals, tracki)
743 const label newTracki = oldToNewTrack[tracki];
744 scalarValues[scalari][newTracki].
transfer(vals);
752 writer.write(scalarNames_[i], scalarValues[i]);
754 outputFileNames.insert
757 time_.relativePath(outFile,
true)
762 if (!allVectors_.empty())
764 List<List<vectorField>> vectorValues(allVectors_.size());
766 forAll(allVectors_, vectori)
768 auto& allTrackVals = allVectors_[vectori];
769 vectorValues[vectori].setSize(nTracks);
771 forAll(allTrackVals, tracki)
776 const label newTracki = oldToNewTrack[tracki];
777 vectorValues[vectori][newTracki].
transfer(vals);
785 writer.write(vectorNames_[i], vectorValues[i]);
787 outputFileNames.insert
790 time_.relativePath(outFile,
true)
807 const word& fieldName = iter.key();
821 const word& newUName,
826 fields_ = newFieldNames;
879 UName_ =
dict.getOrDefault<
word>(
"U",
"U");
880 Info<<
" Employing velocity field " << UName_ <<
endl;
884 dict.readEntry(
"fields", fields_);
888 if (
dict.readIfPresent(
"trackForward", trackForward))
893 ? trackDirType::FORWARD
894 : trackDirType::BACKWARD
897 if (
dict.found(
"direction"))
900 <<
"Cannot specify both 'trackForward' and 'direction'" <<
nl 906 trackDir_ = trackDirTypeNames.getOrDefault
910 trackDirType::FORWARD
913 dict.readEntry(
"lifeTime", lifeTime_);
917 <<
"Illegal value " << lifeTime_ <<
" for lifeTime" 922 trackLength_ = VGREAT;
923 if (
dict.readIfPresent(
"trackLength", trackLength_))
925 Info<<
type() <<
" : fixed track length specified : " 926 << trackLength_ <<
nl <<
endl;
931 if (
dict.readIfPresent(
"bounds", bounds_) && !bounds_.empty())
933 Info<<
" clipping all segments to " << bounds_ <<
nl <<
endl;
937 interpolationScheme_ =
dict.getOrDefault
939 "interpolationScheme",
940 interpolationCellPoint<scalar>::typeName
945 cloudName_ =
dict.getOrDefault<word>(
"cloud",
type());
947 sampledSetPtr_.clear();
948 sampledSetAxis_.clear();
streamLineBase(const word &name, const Time &runTime, const dictionary &dict)
Construct for given objectRegistry and dictionary.
virtual void movePoints(const polyMesh &)
Update for mesh point-motion.
List< labelList > labelListList
A List of labelList.
const sampledSet & sampledSetPoints() const
Demand driven construction of the sampledSet.
void size(const label n)
Older name for setAddressableSize.
defineTypeNameAndDebug(ObukhovLength, 0)
word sampledSetAxis_
Axis of the sampled points to output.
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
virtual bool writeToFile()
Write tracks to file.
void transfer(List< T > &list)
Transfer the contents of the argument List into this list and annul the argument list.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
static autoPtr< sampledSet > New(const word &name, const polyMesh &mesh, const meshSearch &searchEngine, const dictionary &dict)
Return a reference to the selected sampledSet.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
static const meshSearchMeshObject & New(const polyMesh &mesh, Args &&... args)
Get existing or create a new MeshObject.
static autoPtr< interpolation< Type > > New(const word &interpolationType, const GeometricField< Type, fvPatchField, volMesh > &psi)
Return a reference to the specified interpolation scheme.
constexpr char nl
The newline '\n' character (0x0a)
trackDirType
Enumeration defining the track direction.
Ostream & endl(Ostream &os)
Add newline and flush stream.
static bool & parRun() noexcept
Test if this a parallel run.
refPtr< interpolation< vector > > initInterpolations(const label nSeeds, PtrList< interpolation< scalar >> &vsInterp, PtrList< interpolation< vector >> &vvInterp)
Initialise interpolators and track storage.
Field reading functions for post-processing utilities.
virtual ~streamLineBase()
Destructor.
const T & cref() const
Return const reference to the object or to the contents of a (non-null) managed pointer.
GeometricField< vector, fvPatchField, volMesh > volVectorField
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
A class for managing references or pointers (no reference counting)
List< vector > vectorList
A List of vectors.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
static void broadcast(Type &value, const label comm=UPstream::worldComm)
Broadcast content (contiguous or non-contiguous) to all processes in communicator.
IOdictionary propsDict(dictIO)
bool read(const char *buf, int32_t &val)
Same as readInt32.
#define forAll(list, i)
Loop across all elements in list.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
static autoPtr< coordSetWriter > New(const word &writeFormat)
Return a reference to the selected writer.
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator) is 1 for serial run.
word outputName("finiteArea-edges.obj")
void setSize(const label n)
Alias for resize()
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
virtual bool write()
Track and write.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
"scheduled" : (MPI_Send, MPI_Recv)
Holds list of sampling points which is filled at construction time. Various implementations of this b...
virtual bool read(const dictionary &)
Read the field average data.
A class for handling words, derived from Foam::string.
void storePoint(const label tracki, const scalar w, const label lefti, const label righti, DynamicList< point > &newTrack, DynamicList< List< scalar >> &newScalars, DynamicList< List< vector >> &newVectors) const
Generate point and values by interpolating from existing values.
List< scalar > scalarList
A List of scalars.
static const Enum< trackDirType > trackDirTypeNames
Names for the trackDir.
void trimToBox(const treeBoundBox &bb, const label tracki, PtrList< DynamicList< point >> &newTracks, PtrList< DynamicList< scalarList >> &newScalars, PtrList< DynamicList< vectorList >> &newVectors) const
Trim and possibly split a track.
void append(const T &val)
Copy append an element to the end of this list.
virtual void updateMesh(const mapPolyMesh &)
Update for changes of mesh.
virtual bool execute()
Execute the averaging.
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO...
autoPtr< sampledSet > sampledSetPtr_
Seed set engine.
vtk::internalMeshWriter writer(topoMesh, topoCells, vtk::formatType::INLINE_ASCII, runTime.path()/"blockTopology")
T & last()
Access last element of the list, position [size()-1].
virtual void resetFieldNames(const word &newUName, const wordList &newFieldNames)
Reset the field names.
vector point
Point is a vector.
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
static void distribute(const Pstream::commsTypes commsType, const List< labelPair > &schedule, const label constructSize, const labelListList &subMap, const bool subHasFlip, const labelListList &constructMap, const bool constructHasFlip, List< T > &field, const NegateOp &negOp, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Distribute data with specified negate operator (for flips).
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
const polyMesh & mesh() const
Return polyMesh.
static bool master(const label communicator=worldComm)
Am I the master rank.
const polyBoundaryMesh & patches
static word outputPrefix
Directory prefix.
messageStream Info
Information stream (stdout output on master, null elsewhere)
virtual bool read(const dictionary &dict)
Read optional controls.
const word & sampledSetAxis() const
The axis of the sampledSet. Creates sampledSet if required.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Mesh consisting of general polyhedral cells.
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
word setFormat(propsDict.getOrDefault< word >("setFormat", "vtk"))
List< label > labelList
A List of labels.
static autoPtr< T > New(Args &&... args)
Construct autoPtr with forwarding arguments.
A patch is a list of labels that address the faces in the global face list.
autoPtr< indirectPrimitivePatch > wallPatch() const
Construct patch out of all wall patch faces.
forAllConstIters(mixture.phases(), phase)
void reset(T *p=nullptr) noexcept
Delete managed pointer and set to new given pointer.
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...