Go to the documentation of this file.
44 namespace functionObjects
57 { trackDirType::FORWARD,
"forward" },
58 { trackDirType::BACKWARD,
"backward" },
59 { trackDirType::BIDIRECTIONAL,
"bidirectional" }
87 dict_.subDict(
"seedSampleSet")
90 sampledSetAxis_ = sampledSetPtr_->axis();
93 return *sampledSetPtr_;
107 if (isA<wallPolyPatch>(pp))
120 if (isA<wallPolyPatch>(pp))
124 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 field " << fieldName <<
nl
169 <<
"Valid scalar fields are:"
170 <<
flatOutput(mesh_.names(volScalarField::typeName)) <<
nl
171 <<
"Valid vector fields are:"
172 <<
flatOutput(mesh_.names(volVectorField::typeName))
176 vsInterp.setSize(nScalar);
178 vvInterp.setSize(nVector);
181 for (
const word& fieldName : fields_)
183 if (foundObject<volScalarField>(fieldName))
191 interpolationScheme_,
196 else if (foundObject<volVectorField>(fieldName))
200 if (
f.name() == UName_)
210 interpolationScheme_,
218 scalarNames_.setSize(vsInterp.size());
221 scalarNames_[i] = vsInterp[i].psi().name();
223 vectorNames_.setSize(vvInterp.size());
226 vectorNames_[i] = vvInterp[i].psi().name();
234 <<
"Cannot find field to move particles with : " << UName_ <<
nl
235 <<
"This field has to be present in the sampled fields " << fields_
236 <<
" and in the objectRegistry."
245 allTracks_.setCapacity(nSeeds);
246 allScalars_.setSize(vsInterp.size());
249 allScalars_[i].clear();
250 allScalars_[i].setCapacity(nSeeds);
252 allVectors_.setSize(vvInterp.size());
255 allVectors_[i].clear();
256 allVectors_[i].setCapacity(nSeeds);
274 const label sz = newTrack.size();
278 newTrack.
append((1.0-w)*track[lefti] + w*track[righti]);
285 forAll(allScalars_, scalari)
287 const scalarList& trackVals = allScalars_[scalari][tracki];
288 newVals[scalari] = (1.0-w)*trackVals[lefti] + w*trackVals[righti];
297 forAll(allVectors_, vectori)
299 const vectorList& trackVals = allVectors_[vectori][tracki];
300 newVals[vectori] = (1.0-w)*trackVals[lefti] + w*trackVals[righti];
323 segmenti < track.size();
327 const point& startPt = track[segmenti-1];
328 const point& endPt = track[segmenti];
330 const vector d(endPt-startPt);
331 const scalar magD =
mag(d);
332 if (magD > ROOTVSMALL)
361 mag(clipPt-startPt)/magD,
370 newTracks.last().shrink();
371 newScalars.last().
shrink();
372 newVectors.last().
shrink();
402 mag(clipPt-startPt)/magD,
425 mag(clipPt-startPt)/magD,
434 newTracks.last().shrink();
435 newScalars.last().
shrink();
436 newVectors.last().
shrink();
471 forAll(allTracks_, tracki)
483 trimToBox(bb, tracki, newTracks, newScalars, newVectors);
488 allTracks_.setSize(newTracks.size());
489 forAll(allTracks_, tracki)
491 allTracks_[tracki].transfer(newTracks[tracki]);
494 forAll(allScalars_, scalari)
497 fieldVals.
setSize(newTracks.size());
501 scalarList& trackVals = allScalars_[scalari][tracki];
502 trackVals.
setSize(newScalars[tracki].size());
503 forAll(trackVals, samplei)
505 trackVals[samplei] = newScalars[tracki][samplei][scalari];
510 forAll(allVectors_, vectori)
513 fieldVals.
setSize(newTracks.size());
516 vectorList& trackVals = allVectors_[vectori][tracki];
517 trackVals.
setSize(newVectors[tracki].size());
518 forAll(trackVals, samplei)
520 trackVals[samplei] = newVectors[tracki][samplei][vectori];
549 fromProc.
setSize(globalTrackIDs.localSize(proci));
552 fromProc[i] = tracki++;
558 toMaster.
setSize(globalTrackIDs.localSize());
566 globalTrackIDs.size(),
579 distMap.constructSize(),
582 distMap.constructMap(),
587 allTracks_.setCapacity(allTracks_.size());
590 forAll(allScalars_, scalari)
592 allScalars_[scalari].shrink();
597 distMap.constructSize(),
600 distMap.constructMap(),
602 allScalars_[scalari],
605 allScalars_[scalari].setCapacity(allScalars_[scalari].size());
608 forAll(allVectors_, vectori)
610 allVectors_[vectori].shrink();
615 distMap.constructSize(),
618 distMap.constructMap(),
620 allVectors_[vectori],
623 allVectors_[vectori].setCapacity(allVectors_[vectori].size());
634 if (!bounds_.empty())
643 forAll(allTracks_, tracki)
645 if (allTracks_[tracki].size())
648 n += allTracks_[tracki].size();
652 Log <<
" Tracks:" << nTracks <<
nl
653 <<
" Total samples:" <<
n
668 vtkPath = vtkPath/mesh_.
name();
670 vtkPath = vtkPath/mesh_.time().timeName();
678 labelList oldToNewTrack(allTracks_.size(), -1);
680 forAll(allTracks_, tracki)
682 if (allTracks_[tracki].size())
687 for (label pointi = 1; pointi <
points.size(); ++pointi)
700 std::move(allTracks_[tracki]),
704 oldToNewTrack[tracki] = nTracks;
711 if (!allScalars_.empty() && !tracks.empty())
715 forAll(allScalars_, scalari)
718 scalarValues[scalari].
setSize(nTracks);
720 forAll(allTrackVals, tracki)
725 const label newTracki = oldToNewTrack[tracki];
726 scalarValues[scalari][newTracki].
transfer(vals);
734 / scalarFormatterPtr_().getFileName
741 Log <<
" Writing data to " << scalarVtkFile.
path() <<
endl;
743 scalarFormatterPtr_().
write
756 if (!allVectors_.empty() && !tracks.empty())
760 forAll(allVectors_, vectori)
763 vectorValues[vectori].
setSize(nTracks);
765 forAll(allTrackVals, tracki)
770 const label newTracki = oldToNewTrack[tracki];
771 vectorValues[vectori][newTracki].
transfer(vals);
779 / vectorFormatterPtr_().getFileName(tracks[0], vectorNames_)
784 vectorFormatterPtr_().write
800 for (
const word& fieldName : scalarNames_)
806 time_.relativePath(scalarVtkFile,
true)
812 for (
const word& fieldName : vectorNames_)
818 time_.relativePath(vectorVtkFile,
true)
829 const word& newUName,
834 fields_ = newFieldNames;
887 UName_ =
dict.getOrDefault<
word>(
"U",
"U");
891 dict.readEntry(
"fields", fields_);
893 if (!fields_.found(UName_))
896 <<
"Velocity field for tracking " << UName_
897 <<
" should be present in the list of fields " << fields_
902 Info<<
" Employing velocity field " << UName_ <<
endl;
905 if (
dict.readIfPresent(
"trackForward", trackForward))
910 ? trackDirType::FORWARD
911 : trackDirType::BACKWARD
914 if (
dict.found(
"direction"))
917 <<
"Cannot specify both 'trackForward' and 'direction'" <<
nl
923 trackDir_ = trackDirTypeNames.get(
"direction",
dict);
925 dict.readEntry(
"lifeTime", lifeTime_);
929 <<
"Illegal value " << lifeTime_ <<
" for lifeTime"
934 trackLength_ = VGREAT;
935 if (
dict.readIfPresent(
"trackLength", trackLength_))
937 Info<<
type() <<
" : fixed track length specified : "
938 << trackLength_ <<
nl <<
endl;
943 if (
dict.readIfPresent(
"bounds", bounds_) && !bounds_.empty())
945 Info<<
" clipping all segments to " << bounds_ <<
nl <<
endl;
949 interpolationScheme_ =
dict.getOrDefault
951 "interpolationScheme",
959 sampledSetPtr_.clear();
960 sampledSetAxis_.clear();
990 if (&mpm.
mesh() == &mesh_)
Holds list of sampling points which is filled at construction time. Various implementations of this b...
static autoPtr< sampledSet > New(const word &name, const polyMesh &mesh, const meshSearch &searchEngine, const dictionary &dict)
Return a reference to the selected sampledSet.
static autoPtr< T > New(Args &&... args)
Construct autoPtr of T with forwarding arguments.
trackDirType
Enumeration defining the track direction.
List< scalar > scalarList
A List of scalars.
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
A class for handling words, derived from Foam::string.
A class for handling file names.
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
static word defaultRegion
Return the default region name.
static std::string path(const std::string &str)
Return directory path name (part before last /)
virtual ~streamLineBase()
Destructor.
static const boundBox invertedBox
A large inverted boundBox: min/max == +/- ROOTVGREAT.
virtual bool write()
Track and write.
static std::string name(const std::string &str)
Return basename (part beyond last /), including its extension.
Standard boundBox with extra functionality for use in octree.
bool read(const char *buf, int32_t &val)
Same as readInt32.
const sampledSet & sampledSetPoints() const
Demand driven construction of the sampledSet.
static const meshSearchMeshObject & New(const polyMesh &mesh, Args &&... args)
Get existing or create a new MeshObject.
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.
autoPtr< indirectPrimitivePatch > wallPatch() const
Construct patch out of all wall patch faces.
static bool master(const label communicator=worldComm)
Am I the master process.
static void scatter(const List< commsStruct > &comms, T &Value, const int tag, const label comm)
Scatter data. Distribute without modification. Reverse of gather.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const T * set(const label i) const
Return const pointer to element (can be nullptr),.
virtual void movePoints(const polyMesh &)
Update for mesh point-motion.
DynamicList< T, SizeMin > & shrink()
Shrink the allocated space to the number of elements used.
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Mesh consisting of general polyhedral cells.
virtual bool read(const dictionary &)
Read the field average data.
#define forAll(list, i)
Loop across all elements in list.
virtual bool writeToFile()
Write tracks to file.
autoPtr< sampledSet > sampledSetPtr_
Seed set engine.
virtual void updateMesh(const mapPolyMesh &)
Update for changes of mesh.
Given cell centre values and point (vertex) values decompose into tetrahedra and linear interpolate w...
virtual bool execute()
Execute the averaging.
messageStream Info
Information stream (stdout output on master, null elsewhere)
bool intersects(const point &overallStart, const vector &overallVec, const point &start, const point &end, point &pt, direction &ptBits) const
Intersects segment; set point to intersection position and face,.
A patch is a list of labels that address the faces in the global face list.
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 > &, const negateOp &negOp, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Distribute data. Note:schedule only used for.
void setSize(const label n)
Alias for resize()
DynamicList< T, SizeMin > & append(const T &val)
Append an element to the end of this list.
Class containing processor-to-processor mapping information.
A List with indirect addressing.
IOdictionary propsDict(IOobject("particleTrackProperties", runTime.constant(), mesh, IOobject::MUST_READ_IF_MODIFIED))
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
void initInterpolations(const label nSeeds, label &UIndex, PtrList< volScalarField > &vsFlds, PtrList< interpolation< scalar >> &vsInterp, PtrList< volVectorField > &vvFlds, PtrList< interpolation< vector >> &vvInterp)
Initialise fields, interpolators and track storage.
static word outputPrefix
Directory prefix.
void append(T *ptr)
Append an element to the end of the list.
void setSize(const label n)
Same as resize()
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
const wordRes fieldNames(propsDict.getOrDefault< wordRes >("fields", wordRes()))
virtual bool read(const dictionary &dict)
Read optional controls.
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
Holds list of sampling positions.
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
errorManipArg< error, int > exit(error &err, const int errNo=1)
Output to file stream, using an OSstream.
static const Enum< trackDirType > trackDirTypeNames
Names for the trackDir.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
List< vector > vectorList
A List of vectors.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Field reading functions for post-processing utilities.
bool contains(const vector &dir, const point &) const
Contains point (inside or on edge) and moving in direction.
static bool & parRun() noexcept
Test if this a parallel run.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
defineTypeNameAndDebug(ObukhovLength, 0)
const polyBoundaryMesh & patches
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.
word sampledSetAxis_
Axis of the sampled points to output.
void transfer(List< T > &list)
Transfer contents of the argument List into this.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
streamLineBase(const word &name, const Time &runTime, const dictionary &dict)
Construct for given objectRegistry and dictionary.
vector point
Point is a vector.
const polyMesh & mesh() const
Return polyMesh.
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
static label nProcs(const label communicator=worldComm)
Number of processes in parallel run, and 1 for serial run.
Functor to negate primitives. Dummy for most other types.
virtual void resetFieldNames(const word &newUName, const wordList &newFieldNames)
Reset the field names.
static autoPtr< writer > New(const word &writeFormat)
Return a reference to the selected writer.
const word & sampledSetAxis() const
The axis of the sampledSet. Creates sampledSet if required.