68 ok[i] = ok[i] || fieldOk<label>(cloudObjs, userFields[i]);
69 ok[i] = ok[i] || fieldOk<scalar>(cloudObjs, userFields[i]);
70 ok[i] = ok[i] || fieldOk<vector>(cloudObjs, userFields[i]);
71 ok[i] = ok[i] || fieldOk<sphericalTensor>(cloudObjs, userFields[i]);
72 ok[i] = ok[i] || fieldOk<symmTensor>(cloudObjs, userFields[i]);
73 ok[i] = ok[i] || fieldOk<tensor>(cloudObjs, userFields[i]);
85 Info <<
"\n*** Warning: user specified field '" << userFields[i]
86 <<
"' unavailable" <<
endl;
111 int main(
int argc,
char *argv[])
123 #include "createFields.H" 127 fileName vtkPath(runTime.path()/
"VTK");
134 runTime.setTime(timeDirs[timeI], timeI);
135 Info<<
"Time = " << runTime.timeName() <<
endl;
137 fileName vtkTimePath(runTime.path()/
"VTK"/runTime.timeName());
140 Info<<
" Reading particle positions" <<
endl;
148 <<
" particles" <<
endl;
150 particles.setSize(ppc.size());
155 particles.set(i++, ppc.remove(&iter()));
165 trackTableType trackTable;
168 const label origProc = particles[i].origProc();
169 const label origId = particles[i].origId();
171 const trackTableType::const_iterator& iter =
172 trackTable.find(
labelPair(origProc, origId));
174 if (iter == trackTable.end())
176 particleToTrack[i] = nTracks;
177 trackTable.insert(
labelPair(origProc, origId), nTracks);
182 particleToTrack[i] = iter();
194 Info<<
"\n Generating " << nTracks <<
" tracks" <<
endl;
198 forAll(particleToTrack, i)
200 const label trackI = particleToTrack[i];
201 trackLengths[trackI]++;
210 const label length = trackLengths[i];
211 agePerTrack[i].setSize(length);
212 particleMap[i].setSize(length);
226 readParticleField<scalar>(
"age", cloudObjs);
232 forAll(particleToTrack, i)
234 const label trackI = particleToTrack[i];
235 const label sampleI = trackSamples[trackI];
236 agePerTrack[trackI][sampleI] = age[i];
237 particleMap[trackI][sampleI] = i;
238 trackSamples[trackI]++;
246 OFstream os(vtkTimePath/
"particleTracks.vtk");
248 Info<<
"\n Writing particle tracks to " << os.name() <<
endl;
252 os <<
"# vtk DataFile Version 2.0" << nl
253 <<
"particleTracks" << nl
255 <<
"DATASET POLYDATA" << nl
256 <<
"POINTS " << nPoints <<
" float" <<
nl;
263 agePerTrack[i].sort();
265 const labelList& ids = agePerTrack[i].indices();
273 sortedIds[j] = particleIds[ids[j]];
275 particleIds = sortedIds;
280 const label localId = particleIds[j];
281 const vector& pos = particles[localId].position();
282 os << pos.
x() <<
' ' << pos.
y() <<
' ' << pos.
z()
291 Info<<
"\n Writing track lines" <<
endl;
292 os <<
"\nLINES " << nTracks <<
' ' << nPoints + nTracks <<
nl;
299 os << particleMap[i].size() <<
nl;
303 os <<
' ' << globalPtI++;
305 if (((j + 1) % 10 == 0) && (j != 0))
316 const label nFields = validateFields(userFields, cloudObjs);
318 os <<
"POINT_DATA " << nPoints << nl
319 <<
"FIELD attributes " << nFields <<
nl;
321 Info<<
"\n Processing fields" << nl <<
endl;
323 processFields<label>(os, particleMap,
userFields, cloudObjs);
324 processFields<scalar>(os, particleMap,
userFields, cloudObjs);
325 processFields<vector>(os, particleMap,
userFields, cloudObjs);
326 processFields<sphericalTensor>
328 processFields<symmTensor>
330 processFields<tensor>(os, particleMap,
userFields, cloudObjs);
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
A class for handling file names.
void clear() const
If object pointer points to valid object:
List of IOobjects with searching and retrieving facilities.
#define forAllIter(Container, container, iter)
Iterate across all elements in the container object of type.
void size(const label)
Override size to be inconsistent with allocated storage.
Ostream & endl(Ostream &os)
Add newline and flush stream.
static bool master(const label communicator=0)
Am I the master process.
static void noParallel()
Remove the parallel options.
A Cloud of passive particles.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
List< word > userFields(propsDict.lookup("fields"))
Pair< label > labelPair
Label pair.
An STL-conforming hash table.
static const word prefix
The prefix to local: lagrangian.
static instantList select0(Time &runTime, const argList &args)
Return the set of times selected based on the argList options.
bool mkDir(const fileName &, mode_t=0777)
Make a directory and return an error if it could not be created.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
const word cloudName(propsDict.lookup("cloudName"))
void writeVTK(OFstream &os, const Type &value)
A class for managing temporary objects.
Foam::argList args(argc, argv)
static void addOptions(const bool constant=true, const bool withZero=false)
Add the options handled by timeSelector to argList::validOptions.