mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: emit number of blocks for decomposedBlockData in header
- better documentation of the file contents. - quicker to obtain number of blocks without reading an entire file.
This commit is contained in:
@ -30,8 +30,9 @@ License
|
|||||||
#include "Fstream.H"
|
#include "Fstream.H"
|
||||||
#include "StringStream.H"
|
#include "StringStream.H"
|
||||||
#include "dictionary.H"
|
#include "dictionary.H"
|
||||||
#include <sys/time.h>
|
|
||||||
#include "objectRegistry.H"
|
#include "objectRegistry.H"
|
||||||
|
#include "foamVersion.H"
|
||||||
|
#include <sys/time.h>
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -204,6 +205,20 @@ void Foam::decomposedBlockData::writeHeader
|
|||||||
<< " version " << version << ";\n"
|
<< " version " << version << ";\n"
|
||||||
<< " format " << format << ";\n"
|
<< " format " << format << ";\n"
|
||||||
<< " class " << type << ";\n";
|
<< " class " << type << ";\n";
|
||||||
|
|
||||||
|
// This may be useful to have as well
|
||||||
|
/*
|
||||||
|
if (os.format() == IOstream::BINARY)
|
||||||
|
{
|
||||||
|
os << " arch " << Foam::FOAMbuildArch << ";\n";
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (Pstream::parRun())
|
||||||
|
{
|
||||||
|
os << " blocks " << Pstream::nProcs() << ";\n";
|
||||||
|
}
|
||||||
|
|
||||||
if (note.size())
|
if (note.size())
|
||||||
{
|
{
|
||||||
os << " note " << note << ";\n";
|
os << " note " << note << ";\n";
|
||||||
@ -938,7 +953,7 @@ Foam::label Foam::decomposedBlockData::numBlocks(const fileName& fName)
|
|||||||
return nBlocks;
|
return nBlocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip header
|
// FoamFile header
|
||||||
token firstToken(is);
|
token firstToken(is);
|
||||||
|
|
||||||
if
|
if
|
||||||
@ -951,8 +966,15 @@ Foam::label Foam::decomposedBlockData::numBlocks(const fileName& fName)
|
|||||||
dictionary headerDict(is);
|
dictionary headerDict(is);
|
||||||
is.version(headerDict.lookup("version"));
|
is.version(headerDict.lookup("version"));
|
||||||
is.format(headerDict.lookup("format"));
|
is.format(headerDict.lookup("format"));
|
||||||
|
|
||||||
|
// Obtain number of blocks directly
|
||||||
|
if (headerDict.readIfPresent("blocks", nBlocks))
|
||||||
|
{
|
||||||
|
return nBlocks;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fallback to brute force read of each data block
|
||||||
List<char> data;
|
List<char> data;
|
||||||
while (is.good())
|
while (is.good())
|
||||||
{
|
{
|
||||||
|
|||||||
@ -200,7 +200,7 @@ Foam::fileOperations::collatedFileOperation::collatedFileOperation
|
|||||||
<< " may \"hang\". If thread support cannot be "
|
<< " may \"hang\". If thread support cannot be "
|
||||||
"enabled, deactivate threading" << nl
|
"enabled, deactivate threading" << nl
|
||||||
<< " by setting maxThreadFileBufferSize to 0 in "
|
<< " by setting maxThreadFileBufferSize to 0 in "
|
||||||
"$FOAM_ETC/controlDict"
|
"the OpenFOAM etc/controlDict"
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user