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))
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);
285 const scalarList& trackVals = allScalars_[i][tracki];
286 newVals[i] =
lerp(trackVals[lefti], trackVals[righti], w);
296 const vectorList& trackVals = allVectors_[i][tracki];
297 newVals[i] =
lerp(trackVals[lefti], trackVals[righti], w);
306 const treeBoundBox& bb,
308 PtrList<DynamicList<point>>& newTracks,
309 PtrList<DynamicList<scalarList>>& newScalars,
310 PtrList<DynamicList<vectorList>>& newVectors
313 const List<point>& track = allTracks_[tracki];
320 segmenti < track.size();
324 const point& startPt = track[segmenti-1];
325 const point& endPt = track[segmenti];
327 const vector d(endPt-startPt);
328 const scalar magD =
mag(d);
329 if (magD > ROOTVSMALL)
331 if (bb.contains(startPt))
347 if (!bb.contains(endPt))
350 if (bb.intersects(endPt, startPt, clipPt))
358 mag(clipPt-startPt)/magD,
367 newTracks.back().shrink();
368 newScalars.
back().shrink();
369 newVectors.
back().shrink();
378 if (bb.intersects(startPt, endPt, clipPt))
381 const label defltCapacity(track.size()/10);
388 mag(clipPt-startPt)/magD,
392 newTracks.emplace_back(defltCapacity),
397 if (!bb.contains(endPt))
411 mag(clipPt-startPt)/magD,
420 newTracks.back().shrink();
421 newScalars.
back().shrink();
422 newVectors.
back().shrink();
430 if (bb.contains(track.back()))
453 PtrList<DynamicList<point>> newTracks;
454 PtrList<DynamicList<scalarList>> newScalars;
455 PtrList<DynamicList<vectorList>> newVectors;
457 forAll(allTracks_, tracki)
459 const List<point>& track = allTracks_[tracki];
464 newTracks.emplace_back(track.size());
465 newScalars.emplace_back(track.size());
466 newVectors.emplace_back(track.size());
469 trimToBox(bb, tracki, newTracks, newScalars, newVectors);
474 allTracks_.setSize(newTracks.size());
475 forAll(allTracks_, tracki)
477 allTracks_[tracki].transfer(newTracks[tracki]);
480 forAll(allScalars_, scalari)
482 DynamicList<scalarList>& fieldVals = allScalars_[scalari];
483 fieldVals.setSize(newTracks.size());
487 scalarList& trackVals = allScalars_[scalari][tracki];
488 trackVals.
setSize(newScalars[tracki].size());
489 forAll(trackVals, samplei)
491 trackVals[samplei] = newScalars[tracki][samplei][scalari];
496 forAll(allVectors_, vectori)
498 DynamicList<vectorList>& fieldVals = allVectors_[vectori];
499 fieldVals.setSize(newTracks.size());
502 vectorList& trackVals = allVectors_[vectori][tracki];
503 trackVals.
setSize(newVectors[tracki].size());
504 forAll(trackVals, samplei)
506 trackVals[samplei] = newVectors[tracki][samplei][vectori];
520 globalIndex globalTrackIDs(allTracks_.size());
535 fromProc.
setSize(globalTrackIDs.localSize(proci));
538 fromProc[i] = tracki++;
544 toMaster.
setSize(globalTrackIDs.localSize());
550 const mapDistribute distMap
552 globalTrackIDs.totalSize(),
565 distMap.constructSize(),
568 distMap.constructMap(),
573 allTracks_.setCapacity(allTracks_.size());
576 forAll(allScalars_, scalari)
578 allScalars_[scalari].shrink();
583 distMap.constructSize(),
586 distMap.constructMap(),
588 allScalars_[scalari],
591 allScalars_[scalari].setCapacity(allScalars_[scalari].size());
594 forAll(allVectors_, vectori)
596 allVectors_[vectori].shrink();
601 distMap.constructSize(),
604 distMap.constructMap(),
606 allVectors_[vectori],
609 allVectors_[vectori].setCapacity(allVectors_[vectori].size());
615 HashTable<fileName> outputFileNames;
619 if (!bounds_.empty())
622 trimToBox(treeBoundBox(bounds_));
628 forAll(allTracks_, tracki)
630 if (allTracks_[tracki].size())
633 n += allTracks_[tracki].size();
637 Log <<
" Tracks:" << nTracks <<
nl 638 <<
" Total samples:" <<
n 650 /
name()/mesh_.regionName()
651 / mesh_.time().timeName()
658 PtrList<coordSet> tracks(nTracks);
660 labelList oldToNewTrack(allTracks_.size(), -1);
662 forAll(allTracks_, tracki)
664 if (allTracks_[tracki].size())
666 List<point>&
points = allTracks_[tracki];
669 for (label pointi = 1; pointi <
points.size(); ++pointi)
682 std::move(allTracks_[tracki]),
686 oldToNewTrack[tracki] = nTracks;
692 const bool canWrite =
696 && trackWriterPtr_->enabled()
697 && (!allScalars_.empty() || !allVectors_.empty())
702 auto&
writer = trackWriterPtr_();
704 writer.nFields(allScalars_.size() + allVectors_.size());
709 (vtkPath / tracks[0].
name())
714 if (!allScalars_.empty())
716 List<List<scalarField>> scalarValues(allScalars_.size());
718 forAll(allScalars_, scalari)
720 auto& allTrackVals = allScalars_[scalari];
721 scalarValues[scalari].resize(nTracks);
723 forAll(allTrackVals, tracki)
728 const label newTracki = oldToNewTrack[tracki];
729 scalarValues[scalari][newTracki].
transfer(vals);
737 writer.write(scalarNames_[i], scalarValues[i]);
739 outputFileNames.insert
742 time_.relativePath(outFile,
true)
747 if (!allVectors_.empty())
749 List<List<vectorField>> vectorValues(allVectors_.size());
751 forAll(allVectors_, vectori)
753 auto& allTrackVals = allVectors_[vectori];
754 vectorValues[vectori].setSize(nTracks);
756 forAll(allTrackVals, tracki)
761 const label newTracki = oldToNewTrack[tracki];
762 vectorValues[vectori][newTracki].
transfer(vals);
770 writer.write(vectorNames_[i], vectorValues[i]);
772 outputFileNames.insert
775 time_.relativePath(outFile,
true)
792 const word& fieldName = iter.key();
806 const word& newUName,
811 fields_ = newFieldNames;
864 UName_ =
dict.getOrDefault<
word>(
"U",
"U");
865 Info<<
" Employing velocity field " << UName_ <<
endl;
869 dict.readEntry(
"fields", fields_);
873 if (
dict.readIfPresent(
"trackForward", trackForward))
878 ? trackDirType::FORWARD
879 : trackDirType::BACKWARD
882 if (
dict.found(
"direction"))
885 <<
"Cannot specify both 'trackForward' and 'direction'" <<
nl 891 trackDir_ = trackDirTypeNames.getOrDefault
895 trackDirType::FORWARD
898 dict.readEntry(
"lifeTime", lifeTime_);
902 <<
"Illegal value " << lifeTime_ <<
" for lifeTime" 907 trackLength_ = VGREAT;
908 if (
dict.readIfPresent(
"trackLength", trackLength_))
910 Info<<
type() <<
" : fixed track length specified : " 911 << trackLength_ <<
nl <<
endl;
916 if (
dict.readIfPresent(
"bounds", bounds_) && !bounds_.empty())
918 Info<<
" clipping all segments to " << bounds_ <<
nl <<
endl;
922 interpolationScheme_ =
dict.getOrDefault
924 "interpolationScheme",
925 interpolationCellPoint<scalar>::typeName
930 cloudName_ =
dict.getOrDefault<word>(
"cloud",
type());
932 sampledSetPtr_.clear();
933 sampledSetAxis_.clear();
List< scalar > scalarList
List of scalar.
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.
const sampledSet & sampledSetPoints() const
Demand driven construction of the sampledSet.
defineTypeNameAndDebug(ObukhovLength, 0)
const polyMesh & mesh() const noexcept
Return polyMesh.
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.
vtk::lineWriter writer(edgeCentres, edgeList::null(), fileName(aMesh.time().globalPath()/"finiteArea-edgesCentres"))
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 MeshObject registered with typeName.
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.
List< vector > vectorList
List of vector.
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
List< labelList > labelListList
List of labelList.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
A class for managing references or pointers (no reference counting)
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 communicator ranks. Does nothing in non-paral...
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). It 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 expressions::valueTypeCode::INVALID.
"scheduled" (MPI standard) : (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.
T & emplace_back(Args &&... args)
Construct an element at the end of the list, return reference to the new list element.
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.
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.
dimensioned< Type > lerp(const dimensioned< Type > &a, const dimensioned< Type > &b, const scalar t)
void push_back(const T &val)
Copy append an element to the end of this list.
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...
#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...
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
const polyBoundaryMesh & patches
static word outputPrefix
Directory prefix.
T & back()
Access last element of the list, position [size()-1].
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.
static void distribute(const UPstream::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 T &nullValue, const CombineOp &cop, const NegateOp &negOp, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Distribute combine data with specified combine operation and negate operator (for flips)...
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
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 ...