mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: reduce startup time for foamToVTK conversion
- Similar to ensight converters (issue #240), improve speed for detection of lagrangian clouds. - provide a -noLagrangian option for symmetry
This commit is contained in:
@ -0,0 +1,71 @@
|
|||||||
|
// 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
|
||||||
|
);
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -71,6 +71,9 @@ Usage
|
|||||||
\param -noInternal \n
|
\param -noInternal \n
|
||||||
Do not generate file for mesh, only for patches
|
Do not generate file for mesh, only for patches
|
||||||
|
|
||||||
|
\param -noLagrangian \n
|
||||||
|
Suppress writing lagrangian positions and fields.
|
||||||
|
|
||||||
\param -noPointValues \n
|
\param -noPointValues \n
|
||||||
No pointFields
|
No pointFields
|
||||||
|
|
||||||
@ -290,6 +293,12 @@ int main(int argc, char *argv[])
|
|||||||
"noInternal",
|
"noInternal",
|
||||||
"do not generate file for mesh, only for patches"
|
"do not generate file for mesh, only for patches"
|
||||||
);
|
);
|
||||||
|
argList::addBoolOption
|
||||||
|
(
|
||||||
|
"noLagrangian",
|
||||||
|
"suppress writing lagrangian positions and fields"
|
||||||
|
);
|
||||||
|
|
||||||
argList::addBoolOption
|
argList::addBoolOption
|
||||||
(
|
(
|
||||||
"noPointValues",
|
"noPointValues",
|
||||||
@ -336,6 +345,7 @@ int main(int argc, char *argv[])
|
|||||||
const bool doLinks = !args.optionFound("noLinks");
|
const bool doLinks = !args.optionFound("noLinks");
|
||||||
bool binary = !args.optionFound("ascii");
|
bool binary = !args.optionFound("ascii");
|
||||||
const bool useTimeName = args.optionFound("useTimeName");
|
const bool useTimeName = args.optionFound("useTimeName");
|
||||||
|
const bool noLagrangian = args.optionFound("noLagrangian");
|
||||||
|
|
||||||
// Decomposition of polyhedral cells into tets/pyramids cells
|
// Decomposition of polyhedral cells into tets/pyramids cells
|
||||||
vtkTopo::decomposePoly = !args.optionFound("poly");
|
vtkTopo::decomposePoly = !args.optionFound("poly");
|
||||||
@ -406,9 +416,9 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
// VTK/ directory in the case
|
// VTK/ directory in the case
|
||||||
fileName fvPath(runTime.path()/"VTK");
|
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)
|
if (regionName != polyMesh::defaultRegion)
|
||||||
{
|
{
|
||||||
fvPath = fvPath/regionName;
|
fvPath = fvPath/regionName;
|
||||||
@ -446,43 +456,7 @@ int main(int argc, char *argv[])
|
|||||||
<< timer.cpuTimeIncrement() << " s, "
|
<< timer.cpuTimeIncrement() << " s, "
|
||||||
<< mem.update().size() << " kB" << endl;
|
<< mem.update().size() << " kB" << endl;
|
||||||
|
|
||||||
|
#include "findClouds.H"
|
||||||
// Scan for all possible lagrangian clouds
|
|
||||||
HashSet<fileName> 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
forAll(timeDirs, timeI)
|
forAll(timeDirs, timeI)
|
||||||
{
|
{
|
||||||
@ -490,7 +464,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
Info<< "Time: " << runTime.timeName() << endl;
|
Info<< "Time: " << runTime.timeName() << endl;
|
||||||
|
|
||||||
word timeDesc =
|
const word timeDesc =
|
||||||
useTimeName ? runTime.timeName() : Foam::name(runTime.timeIndex());
|
useTimeName ? runTime.timeName() : Foam::name(runTime.timeIndex());
|
||||||
|
|
||||||
// Check for new polyMesh/ and update mesh, fvMeshSubset and cell
|
// Check for new polyMesh/ and update mesh, fvMeshSubset and cell
|
||||||
@ -662,7 +636,7 @@ int main(int argc, char *argv[])
|
|||||||
+ dtf.size();
|
+ dtf.size();
|
||||||
|
|
||||||
|
|
||||||
// Construct pointMesh only if nessecary since constructs edge
|
// Construct pointMesh only if necessary since constructs edge
|
||||||
// addressing (expensive on polyhedral meshes)
|
// addressing (expensive on polyhedral meshes)
|
||||||
if (noPointValues)
|
if (noPointValues)
|
||||||
{
|
{
|
||||||
@ -1149,9 +1123,9 @@ int main(int argc, char *argv[])
|
|||||||
//
|
//
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
|
|
||||||
forAllConstIter(HashSet<fileName>, allCloudDirs, iter)
|
forAll(cloudNames, cloudNo)
|
||||||
{
|
{
|
||||||
const fileName& cloudName = iter.key();
|
const fileName& cloudName = cloudNames[cloudNo];
|
||||||
|
|
||||||
// Always create the cloud directory.
|
// Always create the cloud directory.
|
||||||
mkDir(fvPath/cloud::prefix/cloudName);
|
mkDir(fvPath/cloud::prefix/cloudName);
|
||||||
@ -1172,9 +1146,7 @@ int main(int argc, char *argv[])
|
|||||||
cloud::prefix/cloudName
|
cloud::prefix/cloudName
|
||||||
);
|
);
|
||||||
|
|
||||||
IOobject* positionsPtr = sprayObjs.lookup(word("positions"));
|
if (sprayObjs.found("positions"))
|
||||||
|
|
||||||
if (positionsPtr)
|
|
||||||
{
|
{
|
||||||
wordList labelNames(sprayObjs.names(labelIOField::typeName));
|
wordList labelNames(sprayObjs.names(labelIOField::typeName));
|
||||||
Info<< " labels :";
|
Info<< " labels :";
|
||||||
|
|||||||
Reference in New Issue
Block a user