97 for (
const word& fldName : allNames)
99 const auto iter = cloudObjects.
cfind(fldName);
100 if (!pred(fldName) || !iter.good())
110 filteredObjects.add(cloudObjects.
remove(fldName));
119 <<
"Cannot find field file matching "
123 return filteredObjects;
127void readFieldsAndWriteVTK
149int main(
int argc,
char *argv[])
153 "Generate a legacy VTK file of particle tracks for cases that were"
154 " computed using a steady-state cloud"
164 "Alternative particleTrackDict dictionary"
181 runTime.setTime(timeDirs[timeI], timeI);
193 Info<<
" Reading particle positions" <<
endl;
197 <<
" particles" <<
endl;
199 const label nParticles = myCloud.size();
201 particlePosition.
resize(nParticles);
202 particleToTrack.
resize(nParticles);
209 const label origId =
p.origId();
210 const label origProc =
p.origProc();
211 particlePosition[np] =
p.position();
215 const auto iter = trackTable.
cfind(key);
219 particleToTrack[np] = *iter;
223 particleToTrack[np] = trackTable.
size();
230 nTracks = trackTable.
size();
239 Info<<
"\n Generating " << nTracks <<
" tracks" <<
endl;
243 for (
const label tracki : particleToTrack)
245 ++trackLengths[tracki];
249 List<SortableList<scalar>> agePerTrack(nTracks);
250 List<List<label>> particleMap(nTracks);
254 const label length = trackLengths[i];
255 agePerTrack[i].setSize(length);
256 particleMap[i].setSize(length);
272 const auto& age = tage();
276 forAll(particleToTrack, i)
278 const label tracki = particleToTrack[i];
279 const label samplei = trackSamples[tracki];
280 agePerTrack[tracki][samplei] = age[i];
281 particleMap[tracki][samplei] = i;
282 ++trackSamples[tracki];
295 OFstream os(vtkTimePath/
"particleTracks.vtk");
297 Info<<
"\n Writing particle tracks to " <<
os.name() <<
endl;
301 os <<
"# vtk DataFile Version 2.0" <<
nl
302 <<
"particleTracks" <<
nl
304 <<
"DATASET POLYDATA" <<
nl
305 <<
"POINTS " <<
nPoints <<
" float" <<
nl;
312 agePerTrack[i].sort();
314 const labelList& ids = agePerTrack[i].indices();
319 List<label> sortedIds(ids);
322 sortedIds[j] = particleIds[ids[j]];
324 particleIds = sortedIds;
329 const label localId = particleIds[j];
330 const point&
pos = particlePosition[localId];
340 Info<<
"\n Writing track lines" <<
endl;
341 os <<
"\nLINES " << nTracks <<
' ' <<
nPoints + nTracks <<
nl;
348 os << particleMap[i].size() <<
nl;
352 os <<
' ' << globalPtI++;
354 if (((j + 1) % 10 == 0) && (j != 0))
365 const label nFields = filteredObjects.size();
368 <<
"FIELD attributes " << nFields <<
nl;
372 readFieldsAndWriteVTK(
os, particleMap, filteredObjects);
const word cloudName(propsDict.get< word >("cloud"))
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
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 (the number of buckets).
label size() const noexcept
The number of elements in table.
List of IOobjects with searching and retrieving facilities. Implemented as a HashTable,...
wordList sortedNames() const
The sorted names of the IOobjects.
autoPtr< IOobject > remove(const IOobject &io)
Remove object from the list by its IOobject::name().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void resize(const label len)
Adjust allocated size of list.
Output to file stream as an OSstream, normally using std::ofstream for the actual output.
A List with indirect addressing. Like IndirectList but does not store addressing.
bool found(const T &val, label pos=0) const
Same as contains().
bool empty() const noexcept
True if List is empty (ie, size() is zero).
void size(const label n)
Older name for setAddressableSize.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
static void addVerboseOption(const string &usage="", bool advanced=false)
Enable a 'verbose' bool option, with usage information.
static void noParallel()
Remove the parallel options.
static void addOption(const word &optName, const string ¶m="", const string &usage="", bool advanced=false)
Add an option to validOptions with usage information.
static void addNote(const string ¬e)
Add extra notes for the usage information.
static const word prefix
The prefix to local: lagrangian.
A class for handling file names.
A Cloud of passive particles.
static void addOptions(const bool constant=true, const bool withZero=false)
Add timeSelector options to argList::validOptions.
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...
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...
return returnReduce(nRefine-oldNRefine, sumOp< label >())
#define WarningInFunction
Report a warning using Foam::Warning.
bool is_basic(const word &clsName)
Test if the class name appears to be a basic field.
constexpr auto key(const Type &t) noexcept
Helper function to return the enum value.
dimensionedScalar pos(const dimensionedScalar &ds)
Pair< label > labelPair
A pair of labels.
List< word > wordList
List of word.
List< label > labelList
A List of labels.
HashTable< T, labelPair, Foam::Hash< labelPair > > LabelPairMap
messageStream Info
Information stream (stdout output on master, null elsewhere).
List< instant > instantList
List of instants.
Ostream & endl(Ostream &os)
Add newline and flush stream.
void processFields(OFstream &os, const List< labelList > &addr, const IOobjectList &cloudObjects)
vector point
Point is a vector.
tmp< IOField< Type > > readParticleField(const word &fieldName, const IOobjectList &cloudObjects)
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &f1, const label comm)
static constexpr const zero Zero
Global zero (0).
vectorField pointField
pointField is a vectorField.
constexpr char nl
The newline '\n' character (0x0a).
Foam::argList args(argc, argv)
#define forAll(list, i)
Loop across all elements in list.
Functor wrapper of allow/deny lists of wordRe for filtering.