openfoam/applications/utilities/postProcessing/dataConversion/foamToVTK/findClouds.H
Andrew Heather 2defba00a9 ENH: Lagrangian - provided backwards compatibility for cases using the
old "positions" file form

The change to barycentric-based tracking changed the contents of the
cloud "positions" file to a new format comprising the barycentric
co-ordinates and other cell position-based info.  This broke
backwards compatibility, providing no option to restart old cases
(v1706 and earlier), and caused difficulties for dependent code, e.g.
for post-processing utilities that could only infer the contents only
after reading.

The barycentric position info is now written to a file called
"coordinates" with provision to restart old cases for which only the
"positions" file is available. Related utilities, e.g. for parallel
running and data conversion have been updated to be able to support both
file types.

To write the "positions" file by default, use set the following option
in the InfoSwitches section of the controlDict:

    writeLagrangianPositions 1;
2017-09-13 13:13:36 +01:00

70 lines
1.7 KiB
C

// check all time directories for the following:
// Any cloud names:
HashSet<fileName> allCloudDirs;
if (timeDirs.size() && !noLagrangian)
{
const fileName& baseDir = mesh.time().path();
const fileName& cloudPrefix = regionPrefix/cloud::prefix;
Info<< "Searching for lagrangian ... " << flush;
forAll(timeDirs, timeI)
{
const word& timeName = timeDirs[timeI].name();
// DO NOT USE -->> runTime.setTime(timeDirs[timeI], timeI); <<--
// It incurs a large overhead when done so frequently.
fileNameList cloudDirs = readDir
(
baseDir/timeName/cloudPrefix,
fileName::DIRECTORY
);
for (const word& cloudName : cloudDirs)
{
IOobjectList cloudObjs
(
mesh,
timeName,
cloudPrefix/cloudName
);
// Clouds always require "positions"/"coordinates"
if (cloudObjs.found("positions") || cloudObjs.found("coordinates"))
{
if (allCloudDirs.insert(cloudName))
{
Info<< "At time: " << timeName
<< " detected cloud directory : " << cloudName
<< endl;
}
}
}
}
if (allCloudDirs.empty())
{
Info<< "none detected." << endl;
}
}
// sorted list of cloud names
const fileNameList cloudNames(allCloudDirs.sortedToc());
if (cloudNames.size())
{
// complete the echo information
Info<< "(";
for (const word& cloudName : cloudNames)
{
Info<< ' ' << cloudName;
}
Info<< " ) " << endl;
}
// ************************************************************************* //