97 for (
const word& fldName : allNames)
99 const auto iter = cloudObjects.
cfind(fldName);
100 if (!pred(fldName) || !iter.good())
119 filteredObjects.add(cloudObjects.
remove(fldName));
128 <<
"Cannot find field file matching " 132 return filteredObjects;
136 void 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);
154 using namespace Foam;
158 int 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" 173 "Alternative particleTrackDict dictionary" 181 #include "createControls.H" 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];
304 OFstream os(vtkTimePath/
"particleTracks.vtk");
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);
static void addNote(const string ¬e)
Add extra notes for the usage information.
void size(const label n)
Older name for setAddressableSize.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &f1)
A class for handling file names.
List of IOobjects with searching and retrieving facilities. Implemented as a HashTable, so the various sorted methods should be used if traversing in parallel.
void resize(const label len)
Adjust allocated size of list.
virtual const fileName & name() const override
Read/write access to the name of the stream.
Output to file stream, using an OSstream.
constexpr char nl
The newline '\n' character (0x0a)
wordList sortedNames() const
The sorted names of the IOobjects.
bool empty() const noexcept
True if List is empty (ie, size() is zero)
Ostream & endl(Ostream &os)
Add newline and flush stream.
bool found(const T &val, label pos=0) const
Same as contains()
static void noParallel()
Remove the parallel options.
const fileName & rootPath() const noexcept
Return the rootPath.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
A Cloud of passive particles.
#define forAll(list, i)
Loop across all elements in list.
bool insert(const Key &key, const T &obj)
Copy insert a new entry, not overwriting existing entries.
label size() const noexcept
The number of elements in table.
dimensionedScalar pos(const dimensionedScalar &ds)
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
label capacity() const noexcept
The size of the underlying table (the number of buckets)
const_iterator cfind(const Key &key) const
Find and return an const_iterator set at the hashed entry.
const word cloudName(propsDict.get< word >("cloud"))
A class for handling words, derived from Foam::string.
Functor wrapper of allow/deny lists of wordRe for filtering.
const fileName & globalCaseName() const noexcept
Return global case name.
A List of wordRe with additional matching capabilities.
static void addOption(const word &optName, const string ¶m="", const string &usage="", bool advanced=false)
Add an option to validOptions with usage information.
virtual void setTime(const Time &t)
Reset the time and time-index to those of the given time.
A HashTable similar to std::unordered_map.
A HashTable to objects of type <T> with a labelPair key. The hashing is based on labelPair (FixedList...
static void addVerboseOption(const string &usage="", bool advanced=false)
Enable a 'verbose' bool option, with usage information.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
static word timeName(const scalar t, const int precision=precision_)
Return a time name for the given scalar time value formatted with the given precision.
OBJstream os(runTime.globalPath()/outputName)
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...
#define WarningInFunction
Report a warning using Foam::Warning.
autoPtr< IOobject > remove(const IOobject &io)
Remove object from the list by its IOobject::name().
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
A List with indirect addressing. Like IndirectList but does not store addressing. ...
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
messageStream Info
Information stream (stdout output on master, null elsewhere)
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
A class for managing temporary objects.
Foam::argList args(argc, argv)
Defines the attributes of an object for which implicit objectRegistry management is supported...
A primitive field of type <T> with automated input and output.
static void addOptions(const bool constant=true, const bool withZero=false)
Add timeSelector options to argList::validOptions.
bool isHeaderClass() const
Check if headerClassName() equals Type::typeName.
static constexpr const zero Zero
Global zero (0)
static const word prefix
The prefix to local: lagrangian.