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:
parent
10c512f9ef
commit
e16121af68
@ -30,8 +30,9 @@ License
|
||||
#include "Fstream.H"
|
||||
#include "StringStream.H"
|
||||
#include "dictionary.H"
|
||||
#include <sys/time.h>
|
||||
#include "objectRegistry.H"
|
||||
#include "foamVersion.H"
|
||||
#include <sys/time.h>
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
@ -204,6 +205,20 @@ void Foam::decomposedBlockData::writeHeader
|
||||
<< " version " << version << ";\n"
|
||||
<< " format " << format << ";\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())
|
||||
{
|
||||
os << " note " << note << ";\n";
|
||||
@ -938,7 +953,7 @@ Foam::label Foam::decomposedBlockData::numBlocks(const fileName& fName)
|
||||
return nBlocks;
|
||||
}
|
||||
|
||||
// Skip header
|
||||
// FoamFile header
|
||||
token firstToken(is);
|
||||
|
||||
if
|
||||
@ -951,8 +966,15 @@ Foam::label Foam::decomposedBlockData::numBlocks(const fileName& fName)
|
||||
dictionary headerDict(is);
|
||||
is.version(headerDict.lookup("version"));
|
||||
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;
|
||||
while (is.good())
|
||||
{
|
||||
|
@ -200,7 +200,7 @@ Foam::fileOperations::collatedFileOperation::collatedFileOperation
|
||||
<< " may \"hang\". If thread support cannot be "
|
||||
"enabled, deactivate threading" << nl
|
||||
<< " by setting maxThreadFileBufferSize to 0 in "
|
||||
"$FOAM_ETC/controlDict"
|
||||
"the OpenFOAM etc/controlDict"
|
||||
<< endl;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user