60 for (
const word& fieldName : fieldTable.sortedToc())
63 auto& input = fieldTable[fieldName];
68 fields[tracki].transfer(input[tracki]);
78int main(
int argc,
char *argv[])
82 "Generate a file of particle tracks for cases that were"
83 " computed using a tracked-parcel-type cloud"
85 timeSelector::addOptions();
89 argList::setAdvanced(
"decomposeParDict");
90 argList::setAdvanced(
"noFunctionObjects");
96 "Alternative particleTracksProperties dictionary"
102 "Override the sample-frequency"
108 "Specify single or multiple fields to write "
109 "(default: all or 'fields' from dictionary)\n"
110 "Eg, 'T' or '( \"U.*\" )'"
117 "(default: vtk or 'setFormat' from dictionary)"
119 argList::addVerboseOption(
"Additional verbosity");
129 #include "createControls.H"
145 writerPtr().useTracks(
true);
149 writerPtr().verbose(
true);
156 Info<<
"Scanning times to determine track data for cloud " <<
cloudName
163 runTime.setTime(timeDirs[timei], timei);
169 <<
" particles" <<
endl;
173 const label origId =
p.origId();
174 const label origProc =
p.origProc();
178 if (origProc >= maxIds.size())
180 maxIds.resize(origProc+1, -1);
183 maxIds[origProc] =
max(maxIds[origProc], origId);
188 maxIds.resize(maxNProcs, -1);
196 trackSampler.
reset(numIds);
199 <<
"Detected particles originating from "
200 << maxNProcs <<
" processors." <<
nl
201 <<
"Particle statistics:" <<
endl;
203 if (Pstream::master())
207 for (
const label proci : parcelAddr.
allProcs())
210 <<
" particles originating"
211 <<
" from processor " << proci <<
nl;
220 const label nTracks = trackSampler.
nTracks();
236 <<
"Generating " << nTracks
241 runTime.setTime(timeDirs[timei], timei);
259 origIds[np] =
p.origId();
260 origProcs[np] =
p.origProc();
261 localPositions[np] =
p.position();
298 const label nFields =
301 + scalarFields.
size()
302 + vectorFields.
size()
303 + sphericalTensorFields.
size()
304 + symmTensorFields.
size()
305 + tensorFields.
size()
309 <<
"Extracted " << nFields <<
" cloud fields" <<
nl;
314 #define doLocalCode(FieldContent) \
315 if (!FieldContent.empty()) \
318 for (const word& fieldName : FieldContent.sortedToc()) \
320 Info<< ' ' << fieldName; \
335 <<
"Writing particle tracks (" <<
setFormat <<
" format)" <<
nl;
337 if (Pstream::master())
348 tracks[tracki].transfer(allTrackPos[tracki]);
349 times[tracki].transfer(allTrackTimes[tracki]);
351 if (!tracki) tracks[0].rename(
"tracks");
371 auto&
writer = *writerPtr;
375 functionObject::outputPrefix/cloud::prefix/
cloudName
376 /
"particleTracks" /
"tracks"
382 writer.open(tracks, outputPath);
383 writer.setTrackTimes(times);
387 writeTrackFields(
writer, scalarFields);
388 writeTrackFields(
writer, vectorFields);
389 writeTrackFields(
writer, sphericalTensorFields);
390 writeTrackFields(
writer, symmTensorFields);
391 writeTrackFields(
writer, tensorFields);
395 Info<<
"Warning: no fields, did not write" <<
endl;
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.
A HashTable similar to std::unordered_map.
label size() const noexcept
The number of elements in table.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
int verbose() const noexcept
Return the verbose flag.
bool readListIfPresent(const word &optName, List< T > &list) const
bool readIfPresent(const word &optName, T &val) const
Read a value from the named option if present.
Base class for writing coordSet(s) and tracks with fields.
Holds list of sampling positions.
A class for handling file names.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
label localSize() const
My local size.
labelRange allProcs() const noexcept
Range of process indices for all addressed offsets (processes)
Registry of regIOobjects.
Helper class when generating particle tracks. The interface is fairly rudimentary.
labelField origProcIds_
The originating processor ids.
void resetCloud(const label localCloudSize)
const globalIndex & parcelAddr() const noexcept
The original parcel addressing.
void reset(const labelUList &origParcelCounts)
Define the orig parcel mappings.
label setSampleRate(const label sampleFreq, const label maxPositions, const label maxTracks=-1)
Set the sampling stride, upper limits.
label nTracks() const noexcept
Number of tracks to generate.
void createTrackField(const UList< Type > &values, List< DynamicList< Type > > &trackValues) const
void gatherInplace(List< Type > &fld) const
label setTrackFields(const objectRegistry &obr, HashTable< List< DynamicList< Type > > > &fieldTable) const
labelField origParcelIds_
The originating parcel ids.
A Cloud of passive particles.
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings.
A class for handling words, derived from Foam::string.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce (copy) and return value.
constexpr char nl
The newline '\n' character (0x0a)
Foam::argList args(argc, argv)
multivariateSurfaceInterpolationScheme< scalar >::fieldTable fields
#define forAll(list, i)
Loop across all elements in list.
label maxTracks(propsDict.getOrDefault< label >("maxTracks", -1))
label maxPositions(propsDict.get< label >("maxPositions"))
label sampleFrequency(propsDict.get< label >("sampleFrequency"))
word setFormat(propsDict.getOrDefault< word >("setFormat", "vtk"))
const dictionary formatOptions(propsDict.subOrEmptyDict("formatOptions", keyType::LITERAL))
const word cloudName(propsDict.get< word >("cloud"))
#define doLocalCode(GeoField)