Go to the documentation of this file.
44 namespace functionObjects
57 { trackDirType::FORWARD,
"forward" },
58 { trackDirType::BACKWARD,
"backward" },
59 { trackDirType::BIDIRECTIONAL,
"bidirectional" }
80 if (sampledSetPtr_.empty())
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
755 if (!allVectors_.empty() && !tracks.empty())
759 forAll(allVectors_, vectori)
762 vectorValues[vectori].
setSize(nTracks);
764 forAll(allTrackVals, tracki)
769 const label newTracki = oldToNewTrack[tracki];
770 vectorValues[vectori][newTracki].
transfer(vals);
778 / vectorFormatterPtr_().getFileName(tracks[0], vectorNames_)
783 vectorFormatterPtr_().write
798 for (
const word& fieldName : scalarNames_)
804 time_.relativePath(scalarVtkFile,
true)
810 for (
const word& fieldName : vectorNames_)
816 time_.relativePath(vectorVtkFile,
true)
827 const word& newUName,
832 fields_ = newFieldNames;
885 UName_ =
dict.lookupOrDefault<
word>(
"U",
"U");
889 dict.readEntry(
"fields", fields_);
891 if (!fields_.found(UName_))
894 <<
"Velocity field for tracking " << UName_
895 <<
" should be present in the list of fields " << fields_
900 Info<<
" Employing velocity field " << UName_ <<
endl;
903 if (
dict.readIfPresent(
"trackForward", trackForward))
908 ? trackDirType::FORWARD
909 : trackDirType::BACKWARD
912 if (
dict.found(
"direction"))
915 <<
"\"trackForward\" and \"direction\""
921 trackDir_ = trackDirTypeNames.get(
"direction",
dict);
923 dict.readEntry(
"lifeTime", lifeTime_);
927 <<
"Illegal value " << lifeTime_ <<
" for lifeTime"
932 trackLength_ = VGREAT;
933 if (
dict.readIfPresent(
"trackLength", trackLength_))
935 Info<<
type() <<
" : fixed track length specified : "
936 << trackLength_ <<
nl <<
endl;
941 if (
dict.readIfPresent(
"bounds", bounds_) && !bounds_.empty())
943 Info<<
" clipping all segments to " << bounds_ <<
nl <<
endl;
947 interpolationScheme_ =
dict.lookupOrDefault
949 "interpolationScheme",
955 cloudName_ =
dict.lookupOrDefault<
word>(
"cloud",
type());
957 sampledSetPtr_.clear();
958 sampledSetAxis_.clear();
988 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 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())
Distribute data. Note:schedule only used for.
static const boundBox invertedBox
A large inverted boundBox: min/max == +/- ROOTVGREAT.
static label nProcs(const label communicator=0)
Number of processes in parallel run.
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 bool & parRun()
Is this a parallel run?
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 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.
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.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
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 (uses stdout - output is on the master only)
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.
word name(const complex &c)
Return string representation of complex.
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.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
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.
const T * set(const label i) const
Return const pointer to element (if set) or nullptr.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
void setSize(const label nElem)
Alter addressable list size.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Output to file stream, using an OSstream.
static bool master(const label communicator=0)
Am I the master process.
static const Enum< trackDirType > trackDirTypeNames
Names for the trackDir.
defineTypeNameAndDebug(fvMeshFunctionObject, 0)
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.
FlatOutput< Container > flatOutput(const Container &obj, label len=0)
Global flatOutput function.
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.
void transfer(List< T > &lst)
Transfer contents of the argument List into this.
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.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
#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.
void setSize(const label newSize)
Alias for resize(const label)
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.
#define Log
Report write to Foam::Info if the local log switch is true.
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.