Go to the documentation of this file.
50 #define createTrack(field, trackValues) \
62 #define setFields(fields, fieldNames) \
76 #define writeFields(fields, fieldNames, tracks, times, dirs) \
112 const label nTracks = trackValues.size();
116 forAll(procField[proci], i)
118 const label globalId =
119 startIds[allOrigProcs[proci][i]] + allOrigIds[proci][i];
131 trackValues[trackId].append(procField[proci][i]);
140 void writeTrackFields
152 if (fieldValues.empty())
176 fields[fieldi].setSize(fieldValues[fieldi].size());
179 fields[fieldi][tracki].transfer(fieldValues[fieldi][tracki]);
188 Foam::label setTrackFields
220 fields[i].setSize(nTracks);
243 int main(
int argc,
char *argv[])
247 "Generate a file of particle tracks for cases that were"
248 " computed using a tracked-parcel-type cloud"
259 #include "createFields.H"
266 Info<<
"Scanning times to determine track data for cloud " <<
cloudName
275 Info<<
" Reading particle positions" <<
endl;
279 <<
" particles" <<
endl;
283 const label origId =
p.origId();
284 const label origProc =
p.origProc();
288 if (origProc >= maxIds.size())
290 maxIds.setSize(origProc+1, -1);
293 maxIds[origProc] =
max(maxIds[origProc], origId);
299 Info<<
"Detected particles originating from " << maxNProcs
300 <<
" processors." <<
nl <<
endl;
302 maxIds.setSize(maxNProcs, -1);
312 Info<<
" Found " << numIds[proci] <<
" particles originating"
313 <<
" from processor " << proci <<
endl;
320 for (label i = 0; i < numIds.size()-1; ++i)
322 startIds[i+1] += startIds[i] + numIds[i];
324 label nParticle = startIds.last() + numIds[startIds.size()-1];
328 const label nTracks =
351 Info<<
"\nGenerating " << nTracks <<
" particle tracks for cloud "
360 Info<<
" Reading particle positions" <<
endl;
378 localPositions[i] =
p.position();
402 createTrack(localPositions, allTracks);
403 createTrack(localTimes, allTrackTimes);
408 setFields(scalarFields, scalarFieldNames);
409 setFields(vectorFields, vectorFieldNames);
410 setFields(sphTensorFields, sphTensorFieldNames);
411 setFields(symTensorFields, symTensorFieldNames);
412 setFields(tensorFields, tensorFieldNames);
427 tracks[tracki].
transfer(allTracks[tracki]);
428 times[tracki].
transfer(allTrackTimes[tracki]);
433 const label Uid = vectorFieldNames.find(
UName);
438 const auto& UTracks = vectorFields[Uid];
441 const auto&
U = UTracks[tracki];
442 dirs[tracki] =
U/(
mag(
U) + ROOTVSMALL);
449 writeFields(scalarFields, scalarFieldNames, tracks, times, dirs);
450 writeFields(vectorFields, vectorFieldNames, tracks, times, dirs);
451 writeFields(sphTensorFields, sphTensorFieldNames, tracks, times, dirs);
452 writeFields(symTensorFields, symTensorFieldNames, tracks, times, dirs);
453 writeFields(tensorFields, tensorFieldNames, tracks, times, dirs);
const fileName & globalCaseName() const
Defines the attributes of an object for which implicit objectRegistry management is supported,...
const label sampleFrequency(propsDict.get< label >("sampleFrequency"))
const word cloudName(propsDict.get< word >("cloud"))
A class for handling words, derived from Foam::string.
A class for handling file names.
A primitive field of type <T> with automated input and output.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
virtual const fileName & name() const
static constexpr const zero Zero
List< T > values(const HashTable< T, Key, Hash > &tbl, const bool doSort=false)
const word setFormat(propsDict.getOrDefault< word >("setFormat", "vtk"))
const word UName(propsDict.getOrDefault< word >("U", "U"))
static word timeName(const scalar t, const int precision=precision_)
static void addNote(const string ¬e)
static bool master(const label communicator=worldComm)
const label maxPositions(propsDict.get< label >("maxPositions"))
Ostream & endl(Ostream &os)
const T * set(const label i) const
const Type & value() const
const label maxTracks(propsDict.getOrDefault< label >("maxTracks", -1))
label min(const labelHashSet &set, label minValue=labelMax)
const dictionary formatOptions
List< word > wordList
A List of words.
Registry of regIOobjects.
HashTable< const Type * > lookupClass(const bool strict=false) const
void setSize(const label n)
void transfer(List< T > &list)
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
label max(const labelHashSet &set, label maxValue=labelMin)
A Cloud of passive particles.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
const wordRes fieldNames(propsDict.getOrDefault< wordRes >("fields", wordRes()))
OBJstream os(runTime.globalPath()/outputName)
Holds list of sampling positions.
static void combineGather(const List< commsStruct > &comms, T &Value, const CombineOp &cop, const int tag, const label comm)
Output to file stream, using an OSstream.
static void listCombineGather(const List< commsStruct > &comms, List< T > &Value, const CombineOp &cop, const int tag, const label comm)
static void gatherList(const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
const Type * cfindObject(const word &name, const bool recursive=false) const
static int myProcNo(const label communicator=worldComm)
static void addOptions(const bool constant=true, const bool withZero=false)
const fileName & rootPath() const
static bool & parRun() noexcept
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
A traits class, which is primarily used for primitives.
virtual void setTime(const Time &t)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
word name(const expressions::valueTypeCode typeCode)
Various functions to operate on Lists.
static void listCombineScatter(const List< commsStruct > &comms, List< T > &Value, const int tag, const label comm)
static instantList select0(Time &runTime, const argList &args)
Foam::argList args(argc, argv)
bool mkDir(const fileName &pathName, mode_t mode=0777)
static void combineScatter(const List< commsStruct > &comms, T &Value, const int tag, const label comm)
multivariateSurfaceInterpolationScheme< scalar >::fieldTable fields
static label nProcs(const label communicator=worldComm)
void writeFields(const fvMesh &mesh, const wordHashSet &selectedFields, const bool writeFaceFields)
void transfer(PtrList< T > &list)
static autoPtr< writer > New(const word &writeFormat)