69 ok[i] = ok[i] || fieldOk<label>(cloudObjs, userFields[i]);
70 ok[i] = ok[i] || fieldOk<scalar>(cloudObjs, userFields[i]);
71 ok[i] = ok[i] || fieldOk<vector>(cloudObjs, userFields[i]);
72 ok[i] = ok[i] || fieldOk<sphericalTensor>(cloudObjs, userFields[i]);
73 ok[i] = ok[i] || fieldOk<symmTensor>(cloudObjs, userFields[i]);
74 ok[i] = ok[i] || fieldOk<tensor>(cloudObjs, userFields[i]);
86 Info <<
"\n*** Warning: user specified field '" << userFields[i]
87 <<
"' unavailable" <<
endl;
112 int main(
int argc,
char *argv[])
124 #include "createFields.H" 128 const fileName vtkPath(runTime.rootPath()/runTime.globalCaseName()/
"VTK");
135 runTime.setTime(timeDirs[timeI], timeI);
136 Info<<
"Time = " << runTime.userTimeName() <<
endl;
138 const fileName vtkTimePath(vtkPath/runTime.timeName());
141 Info<<
" Reading particle positions" <<
endl;
149 <<
" particles" <<
endl;
151 particles.setSize(ppc.size());
156 particles.set(i++, ppc.remove(&iter()));
166 trackTableType trackTable;
169 const label origProc = particles[i].origProc();
170 const label origId = particles[i].origId();
172 const trackTableType::const_iterator& iter =
173 trackTable.find(
labelPair(origProc, origId));
175 if (iter == trackTable.end())
177 particleToTrack[i] = nTracks;
178 trackTable.insert(
labelPair(origProc, origId), nTracks);
183 particleToTrack[i] = iter();
195 Info<<
"\n Generating " << nTracks <<
" tracks" <<
endl;
199 forAll(particleToTrack, i)
201 const label trackI = particleToTrack[i];
202 trackLengths[trackI]++;
211 const label length = trackLengths[i];
212 agePerTrack[i].setSize(length);
213 particleMap[i].setSize(length);
227 readParticleField<scalar>(
"age", cloudObjs);
233 forAll(particleToTrack, i)
235 const label trackI = particleToTrack[i];
236 const label sampleI = trackSamples[trackI];
237 agePerTrack[trackI][sampleI] = age[i];
238 particleMap[trackI][sampleI] = i;
239 trackSamples[trackI]++;
247 OFstream os(vtkTimePath/
"particleTracks.vtk");
249 Info<<
"\n Writing particle tracks to " << os.name() <<
endl;
253 os <<
"# vtk DataFile Version 2.0" << nl
254 <<
"particleTracks" << nl
256 <<
"DATASET POLYDATA" << nl
257 <<
"POINTS " << nPoints <<
" float" <<
nl;
264 agePerTrack[i].sort();
266 const labelList& ids = agePerTrack[i].indices();
274 sortedIds[j] = particleIds[ids[j]];
276 particleIds = sortedIds;
281 const label localId = particleIds[j];
282 const vector& pos = particles[localId].position();
283 os << pos.
x() <<
' ' << pos.
y() <<
' ' << pos.
z()
292 Info<<
"\n Writing track lines" <<
endl;
293 os <<
"\nLINES " << nTracks <<
' ' << nPoints + nTracks <<
nl;
300 os << particleMap[i].size() <<
nl;
304 os <<
' ' << globalPtI++;
306 if (((j + 1) % 10 == 0) && (j != 0))
317 const label nFields = validateFields(userFields, cloudObjs);
319 os <<
"POINT_DATA " << nPoints << nl
320 <<
"FIELD attributes " << nFields <<
nl;
322 Info<<
"\n Processing fields" << nl <<
endl;
324 processFields<label>(os, particleMap,
userFields, cloudObjs);
325 processFields<scalar>(os, particleMap,
userFields, cloudObjs);
326 processFields<vector>(os, particleMap,
userFields, cloudObjs);
327 processFields<sphericalTensor>
329 processFields<symmTensor>
331 processFields<tensor>(os, particleMap,
userFields, cloudObjs);
#define forAll(list, i)
Loop across all elements in list.
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.