60 for (
const word& fieldName : fieldTable.sortedToc())
63 auto& input = fieldTable[fieldName];
65 List<Field<Type>>
fields(input.size());
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"
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)"
144 writerPtr().useTracks(
true);
148 writerPtr().verbose(
true);
155 Info<<
"Scanning times to determine track data for cloud " <<
cloudName
162 runTime.setTime(timeDirs[timei], timei);
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] =
Foam::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();
223 List<DynamicList<point>> allTrackPos(nTracks);
224 List<DynamicList<scalar>> allTrackTimes(nTracks);
235 <<
"Generating " << nTracks
240 runTime.setTime(timeDirs[timei], timei);
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;
339 List<scalarField> times(allTrackPos.size());
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"
381 writer.open(tracks, outputPath);
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;
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"))
vtk::lineWriter writer(edgeCentres, edgeList::null(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-edgesCentres")))
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,...
static void listReduce(UList< T > &values, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce list elements (list must be equal size on all ranks), applying bop to each list element.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run.
static void addVerboseOption(const string &usage="", bool advanced=false)
Enable a 'verbose' bool option, with usage information.
static void setAdvanced(const word &optName, bool advanced=true)
Set an existing option as being 'advanced' or normal.
static void addOption(const word &optName, const string ¶m="", const string &usage="", bool advanced=false)
Add an option to validOptions with usage information.
static void addNote(const string ¬e)
Add extra notes for the usage information.
static const word prefix
The prefix to local: lagrangian.
Base class for writing coordSet(s) and tracks with fields.
static autoPtr< coordSetWriter > New(const word &writeFormat)
Return a reference to the selected writer.
Holds list of sampling positions.
A class for handling file names.
static word outputPrefix
Directory prefix.
Calculates a non-overlapping list of offsets based on an input size (eg, number of cells) from differ...
labelRange allProcs() const noexcept
Range of process indices for all addressed offsets (processes).
label localSize(const label proci) const
Size of proci data.
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.
static void addOptions(const bool constant=true, const bool withZero=false)
Add timeSelector options to argList::validOptions.
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...
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.
#define doLocalCode(FieldType, Variable)
return returnReduce(nRefine-oldNRefine, sumOp< label >())
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
List< label > labelList
A List of labels.
messageStream Info
Information stream (stdout output on master, null elsewhere).
List< instant > instantList
List of instants.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Field< label > labelField
Specialisation of Field<T> for label.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
vectorField pointField
pointField is a vectorField.
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.