diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/findClouds.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/findClouds.H new file mode 100644 index 0000000000..5637f22498 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/findClouds.H @@ -0,0 +1,71 @@ +// check all time directories for the following: + +// Any cloud names: +HashSet 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 + ); + + forAll(cloudDirs, cloudI) + { + const word& cloudName = cloudDirs[cloudI]; + + IOobjectList cloudObjs + ( + mesh, + timeName, + cloudPrefix/cloudName + ); + + // clouds always require "positions" + if (cloudObjs.found("positions")) + { + 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<< "("; + forAll(cloudNames, cloudNo) + { + Info<< ' ' << cloudNames[cloudNo]; + } + Info<< " ) " << endl; +} + + +// ************************************************************************* // diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C index 51a3563f5e..da66613c0c 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -71,6 +71,9 @@ Usage \param -noInternal \n Do not generate file for mesh, only for patches + \param -noLagrangian \n + Suppress writing lagrangian positions and fields. + \param -noPointValues \n No pointFields @@ -290,6 +293,12 @@ int main(int argc, char *argv[]) "noInternal", "do not generate file for mesh, only for patches" ); + argList::addBoolOption + ( + "noLagrangian", + "suppress writing lagrangian positions and fields" + ); + argList::addBoolOption ( "noPointValues", @@ -336,6 +345,7 @@ int main(int argc, char *argv[]) const bool doLinks = !args.optionFound("noLinks"); bool binary = !args.optionFound("ascii"); const bool useTimeName = args.optionFound("useTimeName"); + const bool noLagrangian = args.optionFound("noLagrangian"); // Decomposition of polyhedral cells into tets/pyramids cells vtkTopo::decomposePoly = !args.optionFound("poly"); @@ -406,9 +416,9 @@ int main(int argc, char *argv[]) // VTK/ directory in the case fileName fvPath(runTime.path()/"VTK"); - // Directory of mesh (region0 gets filtered out) - fileName regionPrefix = ""; + // Directory of mesh (region0 gets filtered out) + fileName regionPrefix; if (regionName != polyMesh::defaultRegion) { fvPath = fvPath/regionName; @@ -446,43 +456,7 @@ int main(int argc, char *argv[]) << timer.cpuTimeIncrement() << " s, " << mem.update().size() << " kB" << endl; - - // Scan for all possible lagrangian clouds - HashSet allCloudDirs; - forAll(timeDirs, timeI) - { - runTime.setTime(timeDirs[timeI], timeI); - fileNameList cloudDirs - ( - readDir - ( - runTime.timePath()/regionPrefix/cloud::prefix, - fileName::DIRECTORY - ) - ); - forAll(cloudDirs, i) - { - IOobjectList sprayObjs - ( - mesh, - runTime.timeName(), - cloud::prefix/cloudDirs[i] - ); - - IOobject* positionsPtr = sprayObjs.lookup(word("positions")); - - if (positionsPtr) - { - if (allCloudDirs.insert(cloudDirs[i])) - { - Info<< "At time: " << runTime.timeName() - << " detected cloud directory : " << cloudDirs[i] - << endl; - } - } - } - } - + #include "findClouds.H" forAll(timeDirs, timeI) { @@ -490,7 +464,7 @@ int main(int argc, char *argv[]) Info<< "Time: " << runTime.timeName() << endl; - word timeDesc = + const word timeDesc = useTimeName ? runTime.timeName() : Foam::name(runTime.timeIndex()); // Check for new polyMesh/ and update mesh, fvMeshSubset and cell @@ -662,7 +636,7 @@ int main(int argc, char *argv[]) + dtf.size(); - // Construct pointMesh only if nessecary since constructs edge + // Construct pointMesh only if necessary since constructs edge // addressing (expensive on polyhedral meshes) if (noPointValues) { @@ -1149,9 +1123,9 @@ int main(int argc, char *argv[]) // //--------------------------------------------------------------------- - forAllConstIter(HashSet, allCloudDirs, iter) + forAll(cloudNames, cloudNo) { - const fileName& cloudName = iter.key(); + const fileName& cloudName = cloudNames[cloudNo]; // Always create the cloud directory. mkDir(fvPath/cloud::prefix/cloudName); @@ -1172,9 +1146,7 @@ int main(int argc, char *argv[]) cloud::prefix/cloudName ); - IOobject* positionsPtr = sprayObjs.lookup(word("positions")); - - if (positionsPtr) + if (sprayObjs.found("positions")) { wordList labelNames(sprayObjs.names(labelIOField::typeName)); Info<< " labels :";