45namespace 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;
156 for (
const word& fieldName : fields_)
158 if (foundObject<volScalarField>(fieldName))
162 else if (foundObject<volVectorField>(fieldName))
169 <<
"Cannot find field " << fieldName <<
nl
170 <<
"Valid scalar fields: "
172 <<
"Valid vector fields: "
177 vsInterp.setSize(nScalar);
179 vvInterp.setSize(nVector);
182 for (
const word& fieldName : fields_)
184 if (foundObject<volScalarField>(fieldName))
192 interpolationScheme_,
197 else if (foundObject<volVectorField>(fieldName))
201 if (
f.name() == UName_)
211 interpolationScheme_,
219 scalarNames_.setSize(vsInterp.size());
222 scalarNames_[i] = vsInterp[i].psi().name();
224 vectorNames_.setSize(vvInterp.size());
227 vectorNames_[i] = vvInterp[i].psi().name();
235 <<
"Cannot find field to move particles with : " << UName_ <<
nl
236 <<
"This field has to be present in the sampled fields " << fields_
237 <<
" and in the objectRegistry."
246 allTracks_.setCapacity(nSeeds);
247 allScalars_.setSize(vsInterp.size());
250 allScalars_[i].clear();
251 allScalars_[i].setCapacity(nSeeds);
253 allVectors_.setSize(vvInterp.size());
256 allVectors_[i].clear();
257 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];
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)
362 mag(clipPt-startPt)/magD,
371 newTracks.last().shrink();
372 newScalars.last().shrink();
373 newVectors.last().shrink();
403 mag(clipPt-startPt)/magD,
426 mag(clipPt-startPt)/magD,
435 newTracks.last().shrink();
436 newScalars.last().shrink();
437 newVectors.last().shrink();
472 forAll(allTracks_, tracki)
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)
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)
517 vectorList& trackVals = allVectors_[vectori][tracki];
518 trackVals.
setSize(newVectors[tracki].size());
519 forAll(trackVals, samplei)
521 trackVals[samplei] = newVectors[tracki][samplei][vectori];
553 fromProc[i] = tracki++;
576 mapDistributeBase::distribute
588 allTracks_.setCapacity(allTracks_.size());
591 forAll(allScalars_, scalari)
593 allScalars_[scalari].shrink();
594 mapDistributeBase::distribute
603 allScalars_[scalari],
606 allScalars_[scalari].setCapacity(allScalars_[scalari].size());
609 forAll(allVectors_, vectori)
611 allVectors_[vectori].shrink();
612 mapDistributeBase::distribute
621 allVectors_[vectori],
624 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
665 /
name()/mesh_.regionName()
666 / mesh_.time().timeName()
675 labelList oldToNewTrack(allTracks_.size(), -1);
677 forAll(allTracks_, tracki)
679 if (allTracks_[tracki].size())
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())
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]);
757 time_.relativePath(outFile,
true)
762 if (!allVectors_.empty())
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]);
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");
883 dict.readEntry(
"fields", fields_);
885 if (!fields_.found(UName_))
888 <<
"Velocity field for tracking " << UName_
889 <<
" should be present in the list of fields " << fields_
894 Info<<
" Employing velocity field " << UName_ <<
endl;
897 if (
dict.readIfPresent(
"trackForward", trackForward))
902 ? trackDirType::FORWARD
903 : trackDirType::BACKWARD
906 if (
dict.found(
"direction"))
909 <<
"Cannot specify both 'trackForward' and 'direction'" <<
nl
915 trackDir_ = trackDirTypeNames.get(
"direction",
dict);
917 dict.readEntry(
"lifeTime", lifeTime_);
921 <<
"Illegal value " << lifeTime_ <<
" for lifeTime"
926 trackLength_ = VGREAT;
927 if (
dict.readIfPresent(
"trackLength", trackLength_))
929 Info<<
type() <<
" : fixed track length specified : "
930 << trackLength_ <<
nl <<
endl;
935 if (
dict.readIfPresent(
"bounds", bounds_) && !bounds_.empty())
937 Info<<
" clipping all segments to " << bounds_ <<
nl <<
endl;
941 interpolationScheme_ =
dict.getOrDefault
943 "interpolationScheme",
951 sampledSetPtr_.clear();
952 sampledSetAxis_.clear();
959 dict.subOrEmptyDict(
"formatOptions").optionalSubDict(
setFormat)
987 if (&mpm.
mesh() == &mesh_)
Field reading functions for post-processing utilities.
vtk::internalMeshWriter writer(topoMesh, topoCells, vtk::formatType::INLINE_ASCII, runTime.path()/"blockTopology")
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void setSize(const label n)
Same as resize()
void append(const T &val)
Copy append an element to the end of this list.
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
A HashTable similar to std::unordered_map.
bool insert(const Key &key, const T &obj)
Copy insert a new entry, not overwriting existing entries.
A List with indirect addressing.
void transfer(List< T > &list)
void setSize(const label n)
Alias for resize()
void resize(const label len)
Adjust allocated size of list.
label nProcs() const noexcept
Number of ranks associated with PstreamBuffers.
static void scatter(const List< commsStruct > &comms, T &value, const int tag, const label comm)
Broadcast data: Distribute without modification.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
const T * set(const label i) const
void append(T *ptr)
Append an element to the end of the list.
virtual bool read()
Re-read model coefficients if they have changed.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
void size(const label n)
Older name for setAddressableSize.
T & last()
Return the last element of the list.
static bool & parRun() noexcept
Test if this a parallel run.
bool empty() const noexcept
True if the list is empty (ie, size() is zero)
label size() const noexcept
The number of elements in the list.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
static const boundBox invertedBox
A large inverted boundBox: min/max == +/- ROOTVGREAT.
Holds list of sampling positions.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
A class for handling file names.
static word outputPrefix
Directory prefix.
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Computes the magnitude of an input field.
autoPtr< sampledSet > sampledSetPtr_
Seed set engine.
const sampledSet & sampledSetPoints() const
Demand driven construction of the sampledSet.
virtual ~streamLineBase()
Destructor.
word sampledSetAxis_
Axis of the sampled points to output.
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.
autoPtr< indirectPrimitivePatch > wallPatch() const
Construct patch out of all wall patch faces.
const word & sampledSetAxis() const
The axis of the sampledSet. Creates sampledSet if required.
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.
virtual void resetFieldNames(const word &newUName, const wordList &newFieldNames)
Reset the field names.
trackDirType
Enumeration defining the track direction.
static const Enum< trackDirType > trackDirTypeNames
Names for the trackDir.
virtual bool writeToFile()
Write tracks to file.
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 bool execute()
Execute the averaging.
virtual bool write()
Track and write.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
label localSize() const
My local size.
label totalSize() const
Global sum of localSizes.
Given cell centre values and point (vertex) values decompose into tetrahedra and linear interpolate w...
Abstract base class for volume field interpolation.
const labelListList & constructMap() const noexcept
From subsetted data to new reconstructed data.
static List< labelPair > schedule(const labelListList &subMap, const labelListList &constructMap, const int tag, const label comm=UPstream::worldComm)
Calculate a communication schedule. See above.
const labelListList & subMap() const noexcept
From subsetted data back to original data.
label constructSize() const noexcept
Constructed data size.
Class containing processor-to-processor mapping information.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
const polyMesh & mesh() const
Return polyMesh.
void movePoints()
Update for new mesh geometry.
void updateMesh()
Update for new mesh topology.
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
Mesh consisting of general polyhedral cells.
A patch is a list of labels that address the faces in the global face list.
Holds list of sampling points which is filled at construction time. Various implementations of this b...
splitCell * master() const
Standard boundBox with extra functionality for use in octree.
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,.
bool contains(const vector &dir, const point &) const
Contains point (inside or on edge) and moving in direction.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
const polyBoundaryMesh & patches
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
word outputName("finiteArea-edges.obj")
const labelList nFaces(UPstream::listGatherValues< label >(aMesh.nFaces()))
bool read(const char *buf, int32_t &val)
Same as readInt32.
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
messageStream Info
Information stream (stdout output on master, null elsewhere)
List< scalar > scalarList
A List of scalars.
vector point
Point is a vector.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
List< vector > vectorList
A List of vectors.
Ostream & endl(Ostream &os)
Add newline and flush stream.
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a)
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIters(container, iter)
Iterate across all elements of the container object with const access.
Functor to negate primitives. Dummy for most other types.
IOdictionary propsDict(dictIO)
word setFormat(propsDict.getOrDefault< word >("setFormat", "vtk"))