60 for (
const word& fieldName : fieldTable.sortedToc())
63 auto&
input = fieldTable[fieldName];
78 int main(
int argc,
char *argv[])
82 "Generate a file of particle tracks for cases that were" 83 " computed using a tracked-parcel-type cloud" 95 "Alternative particleTracksProperties dictionary" 101 "Override the sample-frequency" 107 "Specify single or multiple fields to write " 108 "(default: all or 'fields' from dictionary)\n" 109 "Eg, 'T' or '( \"U.*\" )'" 116 "(default: vtk or 'setFormat' from dictionary)" 128 #include "createControls.H" 144 writerPtr().useTracks(
true);
148 writerPtr().verbose(
true);
155 Info<<
"Scanning times to determine track data for cloud " <<
cloudName 168 <<
" particles" <<
endl;
172 const label origId =
p.origId();
173 const label origProc =
p.origProc();
177 if (origProc >= maxIds.size())
179 maxIds.
resize(origProc+1, -1);
182 maxIds[origProc] =
max(maxIds[origProc], origId);
187 maxIds.resize(maxNProcs, -1);
195 trackSampler.
reset(numIds);
198 <<
"Detected particles originating from " 199 << maxNProcs <<
" processors." <<
nl 200 <<
"Particle statistics:" <<
endl;
206 for (
const label proci : parcelAddr.
allProcs())
209 <<
" particles originating" 210 <<
" from processor " << proci <<
nl;
219 const label nTracks = trackSampler.
nTracks();
235 <<
"Generating " << nTracks
258 origIds[np] =
p.origId();
259 origProcs[np] =
p.origProc();
260 localPositions[np] =
p.position();
297 const label nFields =
300 + scalarFields.
size()
301 + vectorFields.
size()
302 + sphericalTensorFields.
size()
303 + symmTensorFields.
size()
304 + tensorFields.
size()
308 <<
"Extracted " << nFields <<
" cloud fields" <<
nl;
313 #define doLocalCode(FieldContent) \ 314 if (!FieldContent.empty()) \ 317 for (const word& fieldName : FieldContent.sortedToc()) \ 319 Info<< ' ' << fieldName; \ 334 <<
"Writing particle tracks (" <<
setFormat <<
" format)" <<
nl;
347 tracks[tracki].transfer(allTrackPos[tracki]);
348 times[tracki].transfer(allTrackTimes[tracki]);
350 if (!tracki) tracks[0].rename(
"tracks");
370 auto&
writer = *writerPtr;
375 /
"particleTracks" /
"tracks" 382 writer.setTrackTimes(times);
385 writeTrackFields(
writer, labelFields);
386 writeTrackFields(
writer, scalarFields);
387 writeTrackFields(
writer, vectorFields);
388 writeTrackFields(
writer, sphericalTensorFields);
389 writeTrackFields(
writer, symmTensorFields);
390 writeTrackFields(
writer, tensorFields);
394 Info<<
"Warning: no fields, did not write" <<
endl;
labelField origProcIds_
The originating processor ids.
const Type & value() const noexcept
Return const reference to value.
static void addNote(const string ¬e)
Add extra notes for the usage information.
A class for handling file names.
static void setAdvanced(const word &optName, bool advanced=true)
Set an existing option as being 'advanced' or normal.
vtk::lineWriter writer(edgeCentres, edgeList::null(), fileName(aMesh.time().globalPath()/"finiteArea-edgesCentres"))
void resize(const label len)
Adjust allocated size of list.
labelField origParcelIds_
The originating parcel ids.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
constexpr char nl
The newline '\n' character (0x0a)
Ostream & endl(Ostream &os)
Add newline and flush stream.
fileName relativePath(const fileName &input, const bool caseTag=false) const
Return the input relative to the globalPath by stripping off a leading value of the globalPath...
void gatherInplace(List< Type > &fld) const
void reset(const labelUList &origParcelCounts)
Define the orig parcel mappings.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
#define doLocalCode(FieldType, Variable)
void write(const word &fieldName, const UList< Type > &field)
Write primitive field of CellData (Poly or Line) or PointData values.
A Cloud of passive particles.
multivariateSurfaceInterpolationScheme< scalar >::fieldTable fields
#define forAll(list, i)
Loop across all elements in list.
label setTrackFields(const objectRegistry &obr, HashTable< List< DynamicList< Type >>> &fieldTable) const
label size() const noexcept
The number of elements in table.
const dictionary & optionalSubDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary, otherwise return this dictionary.
static autoPtr< coordSetWriter > New(const word &writeFormat)
Return a reference to the selected writer.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run. ...
Holds list of sampling positions.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
const word cloudName(propsDict.get< word >("cloud"))
label setSampleRate(const label sampleFreq, const label maxPositions, const label maxTracks=-1)
Set the sampling stride, upper limits.
A class for handling words, derived from Foam::string.
static Istream & input(Istream &is, IntRange< T > &range)
Helper class when generating particle tracks. The interface is fairly rudimentary.
Base class for writing coordSet(s) and tracks with fields.
static void addOption(const word &optName, const string ¶m="", const string &usage="", bool advanced=false)
Add an option to validOptions with usage information.
label localSize(const label proci) const
Size of proci data.
virtual void setTime(const Time &t)
Reset the time and time-index to those of the given time.
label maxPositions(propsDict.get< label >("maxPositions"))
A HashTable similar to std::unordered_map.
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings...
label nTracks() const noexcept
Number of tracks to generate.
static void addVerboseOption(const string &usage="", bool advanced=false)
Enable a 'verbose' bool option, with usage information.
static word timeName(const scalar t, const int precision=precision_)
Return a time name for the given scalar time value formatted with the given precision.
bool readListIfPresent(const word &optName, List< T > &list) const
If named option is present, get a List of values treating a single entry like a list of size 1...
virtual bool open(const fileName &file, bool parallel=UPstream::parRun())
Open file for writing (creates parent directory).
static instantList select0(Time &runTime, const argList &args)
Return the set of times selected based on the argList options and also set the runTime to the first i...
const globalIndex & parcelAddr() const noexcept
The original parcel addressing.
labelRange allProcs() const noexcept
Range of process indices for all addressed offsets (processes)
label maxTracks(propsDict.getOrDefault< label >("maxTracks", -1))
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
label sampleFrequency(propsDict.get< label >("sampleFrequency"))
void createTrackField(const UList< Type > &values, List< DynamicList< Type >> &trackValues) const
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
static word outputPrefix
Directory prefix.
void resetCloud(const label localCloudSize)
messageStream Info
Information stream (stdout output on master, null elsewhere)
word setFormat(propsDict.getOrDefault< word >("setFormat", "vtk"))
bool readIfPresent(const word &optName, T &val) const
Read a value from the named option if present.
Registry of regIOobjects.
Foam::argList args(argc, argv)
Defines the attributes of an object for which implicit objectRegistry management is supported...
int verbose() const noexcept
Return the verbose flag.
static void addOptions(const bool constant=true, const bool withZero=false)
Add timeSelector options to argList::validOptions.
const dictionary formatOptions(propsDict.subOrEmptyDict("formatOptions", keyType::LITERAL))
static void listCombineReduce(List< T > &values, const CombineOp &cop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Combines List elements. After completion all processors have the same data.
static const word prefix
The prefix to local: lagrangian.