97 for (
const word& fldName : allNames)
99 const auto iter = cloudObjects.
cfind(fldName);
100 if (!pred(fldName) || !iter.found())
119 filteredObjects.add(cloudObjects.
remove(fldName));
128 <<
"Cannot find field file matching "
132 return filteredObjects;
136void readFieldsAndWriteVTK
143 processFields<label>(
os, particleMap, filteredObjects);
144 processFields<scalar>(
os, particleMap, filteredObjects);
145 processFields<vector>(
os, particleMap, filteredObjects);
146 processFields<sphericalTensor>(
os, particleMap, filteredObjects);
147 processFields<symmTensor>(
os, particleMap, filteredObjects);
148 processFields<tensor>(
os, particleMap, filteredObjects);
158int main(
int argc,
char *argv[])
162 "Generate a legacy VTK file of particle tracks for cases that were"
163 " computed using a steady-state cloud"
166 argList::noParallel();
167 timeSelector::addOptions();
173 "Alternative particleTrackDict dictionary"
175 argList::addVerboseOption(
"Additional verbosity");
181 #include "createControls.H"
190 runTime.setTime(timeDirs[timeI], timeI);
202 Info<<
" Reading particle positions" <<
endl;
206 <<
" particles" <<
endl;
208 const label nParticles = myCloud.size();
210 particlePosition.
resize(nParticles);
211 particleToTrack.
resize(nParticles);
218 const label origId =
p.origId();
219 const label origProc =
p.origProc();
220 particlePosition[np] =
p.position();
224 const auto iter = trackTable.
cfind(key);
228 particleToTrack[np] = *iter;
232 particleToTrack[np] = trackTable.
size();
239 nTracks = trackTable.
size();
248 Info<<
"\n Generating " << nTracks <<
" tracks" <<
endl;
252 for (
const label tracki : particleToTrack)
254 ++trackLengths[tracki];
263 const label length = trackLengths[i];
264 agePerTrack[i].setSize(length);
265 particleMap[i].setSize(length);
279 readParticleField<scalar>(
"age", cloudObjects);
281 const auto& age = tage();
285 forAll(particleToTrack, i)
287 const label tracki = particleToTrack[i];
288 const label samplei = trackSamples[tracki];
289 agePerTrack[tracki][samplei] = age[i];
290 particleMap[tracki][samplei] = i;
291 ++trackSamples[tracki];
302 if (Pstream::master())
304 OFstream os(vtkTimePath/
"particleTracks.vtk");
306 Info<<
"\n Writing particle tracks to " <<
os.name() <<
endl;
310 os <<
"# vtk DataFile Version 2.0" <<
nl
311 <<
"particleTracks" <<
nl
313 <<
"DATASET POLYDATA" <<
nl
314 <<
"POINTS " <<
nPoints <<
" float" <<
nl;
321 agePerTrack[i].sort();
323 const labelList& ids = agePerTrack[i].indices();
331 sortedIds[j] = particleIds[ids[j]];
333 particleIds = sortedIds;
338 const label localId = particleIds[j];
339 const point&
pos = particlePosition[localId];
349 Info<<
"\n Writing track lines" <<
endl;
350 os <<
"\nLINES " << nTracks <<
' ' <<
nPoints + nTracks <<
nl;
357 os << particleMap[i].size() <<
nl;
361 os <<
' ' << globalPtI++;
363 if (((j + 1) % 10 == 0) && (j != 0))
374 const label nFields = filteredObjects.size();
377 <<
"FIELD attributes " << nFields <<
nl;
381 readFieldsAndWriteVTK(
os, particleMap, filteredObjects);
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.
const_iterator cfind(const Key &key) const
Find and return an const_iterator set at the hashed entry.
bool insert(const Key &key, const T &obj)
Copy insert a new entry, not overwriting existing entries.
label capacity() const noexcept
The size of the underlying table.
label size() const noexcept
The number of elements in table.
A primitive field of type <T> with automated input and output.
List of IOobjects with searching and retrieving facilities.
wordList sortedNames() const
The sorted names of the IOobjects.
bool remove(const IOobject &io)
Remove IOobject from the list.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
const word & headerClassName() const noexcept
Return name of the class name read from header.
void resize(const label len)
Adjust allocated size of list.
Output to file stream, using an OSstream.
A List with indirect addressing. Like IndirectList but does not store addressing.
bool found(const T &val, label pos=0) const
True if the value if found in the list.
bool empty() const noexcept
True if the UList is empty (ie, size() is zero)
void size(const label n)
Older name for setAddressableSize.
A class for handling file names.
A Cloud of passive particles.
A class for managing temporary objects.
A List of wordRe with additional matching capabilities.
A class for handling words, derived from Foam::string.
OBJstream os(runTime.globalPath()/outputName)
A HashTable to objects of type <T> with a labelPair key. The hashing is based on labelPair (FixedList...
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
#define WarningInFunction
Report a warning using Foam::Warning.
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
dimensionedScalar pos(const dimensionedScalar &ds)
List< word > wordList
A List of words.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce (copy) and return value.
constexpr char nl
The newline '\n' character (0x0a)
Foam::argList args(argc, argv)
#define forAll(list, i)
Loop across all elements in list.
static const char *const typeName
The type name used in ensight case files.
Functor wrapper of allow/deny lists of wordRe for filtering.
const word cloudName(propsDict.get< word >("cloud"))