mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: provide machine/OpenFOAM architecture hint in output files (issue #271)
FoamFile
{
version 2.0;
format binary;
arch "LSB;label=32;scalar=64";
class vectorField;
object points;
}
There is otherwise no simple indication in any of the files as to the
sizes used (Int32 vs Int64, SP vs DP). This makes it difficult for the
end-user and also for any third-party consumers.
--
The architecture information contains three items in the following format:
(LSB|MSB);label=(32|64);scalar=(32|64)
- The endian value always appears first, without any leading space.
This make it trivial to check later. Either the first 3 letters (LSB
vs MSB) or even just the first letter ('L' vs 'M').
- Subsequent key=value pairs for 'label' and 'scalar' are separated
by semicolons. The ordering of label vs scalar is not specified.
Note that this 'arch' information is purely informational.
It is currently not used by the OpenFOAM input mechanism itself.
This commit is contained in:
@ -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.
|
||||||
@ -29,11 +29,30 @@ Description
|
|||||||
|
|
||||||
#include "IOobject.H"
|
#include "IOobject.H"
|
||||||
#include "objectRegistry.H"
|
#include "objectRegistry.H"
|
||||||
|
#include "endian.H"
|
||||||
|
#include "label.H"
|
||||||
|
#include "scalar.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
bool Foam::IOobject::writeHeader(Ostream& os, const word& type) const
|
bool Foam::IOobject::writeHeader(Ostream& os, const word& type) const
|
||||||
{
|
{
|
||||||
|
static std::string archHint;
|
||||||
|
|
||||||
|
// Hint about machine endian, OpenFOAM label and scalar sizes
|
||||||
|
if (archHint.empty())
|
||||||
|
{
|
||||||
|
#ifdef WM_LITTLE_ENDIAN
|
||||||
|
archHint.append("LSB;");
|
||||||
|
#elif defined (WM_BIG_ENDIAN)
|
||||||
|
archHint.append("MSB;");
|
||||||
|
#endif
|
||||||
|
archHint.append("label=");
|
||||||
|
archHint.append(std::to_string(8*sizeof(label)));
|
||||||
|
archHint.append(";scalar=");
|
||||||
|
archHint.append(std::to_string(8*sizeof(scalar)));
|
||||||
|
}
|
||||||
|
|
||||||
if (!os.good())
|
if (!os.good())
|
||||||
{
|
{
|
||||||
InfoInFunction
|
InfoInFunction
|
||||||
@ -47,6 +66,7 @@ bool Foam::IOobject::writeHeader(Ostream& os, const word& type) const
|
|||||||
<< "FoamFile\n{\n"
|
<< "FoamFile\n{\n"
|
||||||
<< " version " << os.version() << ";\n"
|
<< " version " << os.version() << ";\n"
|
||||||
<< " format " << os.format() << ";\n"
|
<< " format " << os.format() << ";\n"
|
||||||
|
<< " arch " << archHint << ";\n"
|
||||||
<< " class " << type << ";\n";
|
<< " class " << type << ";\n";
|
||||||
|
|
||||||
if (note().size())
|
if (note().size())
|
||||||
|
|||||||
Reference in New Issue
Block a user