mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: improvements to IOstreamOption
* Support default values for format/compress enum lookups.
- Avoids situations where the preferred default format is not ASCII.
For example, with dictionary input:
format binar;
The typing mistake would previously have caused formatEnum to
default to ASCII. We can now properly control its behaviour.
IOstream::formatEnum
(
dict.get<word>("format"), IOstream::BINARY
);
Allowing us to switch ascii/binary, using BINARY by default even in
the case of spelling mistakes. The mistakes are flagged, but the
return value can be non-ASCII.
* The format/compression lookup behave as pass-through if the lookup
string is empty.
- Allows the following to work without complaint
IOstream::formatEnum
(
dict.getOrDefault("format", word::null), IOstream::BINARY
);
- Or use constructor-like failsafe method
IOstream::formatEnum("format", dict, IOstream::BINARY);
- Apply the same behaviour with setting stream format/compression
from a word.
is.format("binar");
will emit a warning, but leave the stream format UNCHANGED
* Rationalize versionNumber construction
- constexpr constructors where possible.
Default construct is the "currentVersion"
- Construct from token to shift the burden to versionNumber.
Support token as argument to version().
Now:
is.version(headerDict.get<token>("version"));
or failsafe constructor method
is.version
(
IOstreamOption::versionNumber("version", headerDict)
);
Before (controlled input):
is.version
(
IOstreamOption::versionNumber
(
headerDict.get<float>("version")
)
);
Old, uncontrolled input - has been removed:
is.version(headerDict.lookup("version"));
* improve consistency, default behaviour for IOstreamOption construct
- constexpr constructors where possible
- add copy construct with change of format.
- construct IOstreamOption from streamFormat is now non-explicit.
This is a commonly expected result with no ill-effects
This commit is contained in:
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011 OpenFOAM Foundation
|
Copyright (C) 2011 OpenFOAM Foundation
|
||||||
Copyright (C) 2019 OpenCFD Ltd.
|
Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -66,20 +66,23 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (true)
|
if (true)
|
||||||
{
|
{
|
||||||
|
cout<<"IOstreamOption:" << sizeof(IOstreamOption) << nl;
|
||||||
cout<<"IOstream:" << sizeof(IOstream) << nl;
|
cout<<"IOstream:" << sizeof(IOstream) << nl;
|
||||||
cout<<"Istream:" << sizeof(Istream) << nl;
|
cout<<"Istream:" << sizeof(Istream) << nl;
|
||||||
cout<<"IPstream:" << sizeof(IPstream) << nl;
|
|
||||||
cout<<"ISstream:" << sizeof(ISstream) << nl;
|
|
||||||
|
|
||||||
cout<<"Ostream:" << sizeof(Ostream) << nl;
|
cout<<"Ostream:" << sizeof(Ostream) << nl;
|
||||||
cout<<"OPstream:" << sizeof(OPstream) << nl;
|
|
||||||
|
cout<<"ISstream:" << sizeof(ISstream) << nl;
|
||||||
cout<<"OSstream:" << sizeof(OSstream) << nl;
|
cout<<"OSstream:" << sizeof(OSstream) << nl;
|
||||||
|
|
||||||
|
cout<<"IPstream:" << sizeof(IPstream) << nl;
|
||||||
|
cout<<"OPstream:" << sizeof(OPstream) << nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
nil x;
|
nil x;
|
||||||
cout<<"nil:" << sizeof(x) << nl;
|
cout<<"nil:" << sizeof(x) << nl;
|
||||||
}
|
}
|
||||||
|
#if 0
|
||||||
{
|
{
|
||||||
argList x(argc, argv);
|
argList x(argc, argv);
|
||||||
cout<<"argList:" << sizeof(x) << nl;
|
cout<<"argList:" << sizeof(x) << nl;
|
||||||
@ -87,6 +90,7 @@ int main(int argc, char *argv[])
|
|||||||
TimePaths y(x);
|
TimePaths y(x);
|
||||||
cout<<"TimePaths:" << sizeof(y) << nl;
|
cout<<"TimePaths:" << sizeof(y) << nl;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
zero x;
|
zero x;
|
||||||
cout<<"zero:" << sizeof(x) << nl;
|
cout<<"zero:" << sizeof(x) << nl;
|
||||||
@ -117,6 +121,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
cout<<"short:" << sizeof(short) << nl;
|
||||||
cout<<"int:" << sizeof(int) << nl;
|
cout<<"int:" << sizeof(int) << nl;
|
||||||
cout<<"long:" << sizeof(long) << nl;
|
cout<<"long:" << sizeof(long) << nl;
|
||||||
cout<<"float:" << sizeof(float) << nl;
|
cout<<"float:" << sizeof(float) << nl;
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2019 OpenCFD Ltd.
|
Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -71,14 +71,7 @@ bool Foam::IOobject::readHeader(Istream& is)
|
|||||||
{
|
{
|
||||||
const dictionary headerDict(is);
|
const dictionary headerDict(is);
|
||||||
|
|
||||||
is.version
|
is.version(headerDict.get<token>("version"));
|
||||||
(
|
|
||||||
IOstreamOption::versionNumber
|
|
||||||
(
|
|
||||||
headerDict.get<float>("version")
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
is.format(headerDict.get<word>("format"));
|
is.format(headerDict.get<word>("format"));
|
||||||
|
|
||||||
headerClassName_ = headerDict.get<word>("class");
|
headerClassName_ = headerDict.get<word>("class");
|
||||||
|
|||||||
@ -1196,13 +1196,7 @@ Foam::label Foam::decomposedBlockData::numBlocks(const fileName& fName)
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
dictionary headerDict(is);
|
dictionary headerDict(is);
|
||||||
is.version
|
is.version(headerDict.get<token>("version"));
|
||||||
(
|
|
||||||
IOstreamOption::versionNumber
|
|
||||||
(
|
|
||||||
headerDict.get<float>("version")
|
|
||||||
)
|
|
||||||
);
|
|
||||||
is.format(headerDict.get<word>("format"));
|
is.format(headerDict.get<word>("format"));
|
||||||
|
|
||||||
// Obtain number of blocks directly
|
// Obtain number of blocks directly
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2018 OpenCFD Ltd.
|
Copyright (C) 2018-2020 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -27,14 +27,13 @@ License
|
|||||||
|
|
||||||
#include "IOstreamOption.H"
|
#include "IOstreamOption.H"
|
||||||
#include "error.H"
|
#include "error.H"
|
||||||
|
#include "dictionary.H"
|
||||||
#include "Enum.H"
|
#include "Enum.H"
|
||||||
#include "Switch.H"
|
#include "Switch.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
const Foam::IOstreamOption::versionNumber
|
const Foam::IOstreamOption::versionNumber Foam::IOstreamOption::currentVersion;
|
||||||
Foam::IOstreamOption::currentVersion(2,0);
|
|
||||||
|
|
||||||
|
|
||||||
const Foam::Enum
|
const Foam::Enum
|
||||||
<
|
<
|
||||||
@ -50,28 +49,57 @@ Foam::IOstreamOption::formatNames
|
|||||||
// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::IOstreamOption::streamFormat
|
Foam::IOstreamOption::streamFormat
|
||||||
Foam::IOstreamOption::formatEnum(const word& formatName)
|
Foam::IOstreamOption::formatEnum
|
||||||
|
(
|
||||||
|
const word& formatName,
|
||||||
|
const streamFormat deflt
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// Handle bad input graciously. A no-op for an empty string
|
||||||
|
|
||||||
|
if (!formatName.empty())
|
||||||
{
|
{
|
||||||
// Handle bad input graciously
|
|
||||||
if (formatNames.found(formatName))
|
if (formatNames.found(formatName))
|
||||||
{
|
{
|
||||||
return formatNames[formatName];
|
return formatNames[formatName];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fall-through to warning
|
||||||
|
|
||||||
WarningInFunction
|
WarningInFunction
|
||||||
<< "Unknown format specifier '" << formatName
|
<< "Unknown format specifier '" << formatName
|
||||||
<< "', using 'ascii'" << endl;
|
<< "', using '" << formatNames[deflt] << "'\n";
|
||||||
|
}
|
||||||
|
|
||||||
return streamFormat::ASCII;
|
return deflt;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::IOstreamOption::streamFormat
|
||||||
|
Foam::IOstreamOption::formatEnum
|
||||||
|
(
|
||||||
|
const word& key,
|
||||||
|
const dictionary& dict,
|
||||||
|
const streamFormat deflt
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return formatNames.getOrDefault(key, dict, deflt, true); // failsafe=true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::IOstreamOption::compressionType
|
Foam::IOstreamOption::compressionType
|
||||||
Foam::IOstreamOption::compressionEnum(const word& compName)
|
Foam::IOstreamOption::compressionEnum
|
||||||
|
(
|
||||||
|
const word& compName,
|
||||||
|
const compressionType deflt
|
||||||
|
)
|
||||||
{
|
{
|
||||||
// Handle bad input graciously
|
// Handle bad input graciously. A no-op for an empty string
|
||||||
|
|
||||||
|
if (!compName.empty())
|
||||||
|
{
|
||||||
const Switch sw = Switch::find(compName);
|
const Switch sw = Switch::find(compName);
|
||||||
|
|
||||||
if (sw.good())
|
if (sw.good())
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
@ -82,23 +110,90 @@ Foam::IOstreamOption::compressionEnum(const word& compName)
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fall-through to warning
|
||||||
|
|
||||||
WarningInFunction
|
WarningInFunction
|
||||||
<< "Unknown compression specifier '" << compName
|
<< "Unknown compression specifier '" << compName
|
||||||
<< "', assuming no compression" << endl;
|
<< "', using compression "
|
||||||
|
<< (deflt ? "on" : "off" ) << nl;
|
||||||
|
}
|
||||||
|
|
||||||
return compressionType::UNCOMPRESSED;
|
return deflt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
Foam::IOstreamOption::compressionType
|
||||||
|
Foam::IOstreamOption::compressionEnum
|
||||||
|
(
|
||||||
|
const word& key,
|
||||||
|
const dictionary& dict,
|
||||||
|
const compressionType deflt
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return
|
||||||
|
(
|
||||||
|
Switch(key, dict, Switch(bool(deflt)), true) // failsafe=true
|
||||||
|
? compressionType::COMPRESSED
|
||||||
|
: compressionType::UNCOMPRESSED
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::IOstreamOption::versionNumber::versionNumber(const std::string& verNum)
|
||||||
|
:
|
||||||
|
versionNumber(readFloat(verNum))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::IOstreamOption::versionNumber::versionNumber(const token& tok)
|
||||||
|
:
|
||||||
|
versionNumber()
|
||||||
|
{
|
||||||
|
if (tok.isStringType())
|
||||||
|
{
|
||||||
|
(*this) = versionNumber(tok.stringToken());
|
||||||
|
}
|
||||||
|
else if (tok.isScalar())
|
||||||
|
{
|
||||||
|
(*this) = versionNumber(float(tok.scalarToken()));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WarningInFunction
|
||||||
|
<< "Wrong token for version - expected word/float, found "
|
||||||
|
<< tok.info() << nl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::IOstreamOption::versionNumber::versionNumber
|
||||||
|
(
|
||||||
|
const word& key,
|
||||||
|
const dictionary& dict
|
||||||
|
)
|
||||||
|
:
|
||||||
|
versionNumber()
|
||||||
|
{
|
||||||
|
token tok;
|
||||||
|
|
||||||
|
if (dict.readIfPresent<token>(key, tok, keyType::LITERAL))
|
||||||
|
{
|
||||||
|
(*this) = versionNumber(tok);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::Ostream& Foam::operator<<
|
Foam::Ostream& Foam::operator<<
|
||||||
(
|
(
|
||||||
Ostream& os,
|
Ostream& os,
|
||||||
const IOstreamOption::streamFormat& sf
|
const IOstreamOption::streamFormat& fmt
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
os << IOstreamOption::formatNames[sf];
|
os << IOstreamOption::formatNames[fmt];
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,12 +201,13 @@ Foam::Ostream& Foam::operator<<
|
|||||||
Foam::Ostream& Foam::operator<<
|
Foam::Ostream& Foam::operator<<
|
||||||
(
|
(
|
||||||
Ostream& os,
|
Ostream& os,
|
||||||
const IOstreamOption::versionNumber& vn
|
const IOstreamOption::versionNumber& ver
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Emit as char sequence instead of as individual characters
|
// Emit unquoted char sequence (eg, word)
|
||||||
// in case this is needed for sending in parallel.
|
// for correct behaviour when sending in parallel
|
||||||
os << vn.str().c_str();
|
|
||||||
|
os.writeQuoted(ver.str(), false);
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2015 OpenFOAM Foundation
|
Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
Copyright (C) 2018 OpenCFD Ltd.
|
Copyright (C) 2018-2020 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -29,7 +29,13 @@ Class
|
|||||||
|
|
||||||
Description
|
Description
|
||||||
The IOstreamOption is a simple container for options an IOstream
|
The IOstreamOption is a simple container for options an IOstream
|
||||||
can normally have. For example, ascii/binary, uncompressed/compressed, ...
|
can normally have.
|
||||||
|
|
||||||
|
The format (ASCII | BINARY) is typically controlled by enumerated
|
||||||
|
names (ascii, binary).
|
||||||
|
|
||||||
|
The compression (UNCOMPRESSED | COMPRESSED) is typically controlled
|
||||||
|
by switch values (true/false, on/off, ...).
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
IOstreamOption.C
|
IOstreamOption.C
|
||||||
@ -39,7 +45,6 @@ SourceFiles
|
|||||||
#ifndef IOstreamOption_H
|
#ifndef IOstreamOption_H
|
||||||
#define IOstreamOption_H
|
#define IOstreamOption_H
|
||||||
|
|
||||||
#include "scalar.H"
|
|
||||||
#include "word.H"
|
#include "word.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
@ -47,8 +52,9 @@ SourceFiles
|
|||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
// Forward declarations
|
// Forward Declarations
|
||||||
class Ostream;
|
class token;
|
||||||
|
class dictionary;
|
||||||
template<class EnumType> class Enum;
|
template<class EnumType> class Enum;
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
@ -64,7 +70,7 @@ public:
|
|||||||
//- Data format (ascii | binary)
|
//- Data format (ascii | binary)
|
||||||
enum streamFormat : char
|
enum streamFormat : char
|
||||||
{
|
{
|
||||||
ASCII, //!< "ascii"
|
ASCII = 0, //!< "ascii" (normal default)
|
||||||
BINARY //!< "binary"
|
BINARY //!< "binary"
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -86,6 +92,13 @@ public:
|
|||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
|
//- Default construct \em current version.
|
||||||
|
//- The value (2.0) corresponds to the \em current version.
|
||||||
|
constexpr versionNumber() noexcept
|
||||||
|
:
|
||||||
|
number_(20)
|
||||||
|
{}
|
||||||
|
|
||||||
//- Construct from major, number
|
//- Construct from major, number
|
||||||
constexpr versionNumber(int major, int minor) noexcept
|
constexpr versionNumber(int major, int minor) noexcept
|
||||||
:
|
:
|
||||||
@ -98,36 +111,40 @@ public:
|
|||||||
number_(10*ver + 0.001) // Allow some rounding
|
number_(10*ver + 0.001) // Allow some rounding
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//- Construct from Istream by reading in a float.
|
|
||||||
// Non-explicit for convenience
|
|
||||||
versionNumber(Istream& is)
|
|
||||||
:
|
|
||||||
versionNumber(readFloat(is))
|
|
||||||
{}
|
|
||||||
|
|
||||||
//- Construct by parsing string "major.minor"
|
//- Construct by parsing string "major.minor"
|
||||||
explicit versionNumber(const std::string& verNum)
|
explicit versionNumber(const std::string& verNum);
|
||||||
:
|
|
||||||
versionNumber(readFloat(verNum))
|
//- Construct from token (float, word, string)
|
||||||
{}
|
explicit versionNumber(const token& tok);
|
||||||
|
|
||||||
|
//- Failsafe construct from dictionary lookup.
|
||||||
|
versionNumber(const word& keyword, const dictionary& dict);
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
|
//- Compare differences in the versions
|
||||||
|
// Negative when 'this' is less than other.
|
||||||
|
// Positive when 'this' is greater than other.
|
||||||
|
int compare(const versionNumber& other) const noexcept
|
||||||
|
{
|
||||||
|
return number_ - other.number_;
|
||||||
|
}
|
||||||
|
|
||||||
//- The canonical major/minor pair as an integer value.
|
//- The canonical major/minor pair as an integer value.
|
||||||
inline int canonical() noexcept
|
int canonical() noexcept
|
||||||
{
|
{
|
||||||
return number_;
|
return number_;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Return the major version number.
|
//- Return the major version number.
|
||||||
inline int getMajor() const noexcept
|
int getMajor() const noexcept
|
||||||
{
|
{
|
||||||
return int(number_ / 10);
|
return int(number_ / 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Return the minor version number
|
//- Return the minor version number
|
||||||
inline int getMinor() const noexcept
|
int getMinor() const noexcept
|
||||||
{
|
{
|
||||||
return int(number_ % 10);
|
return int(number_ % 10);
|
||||||
}
|
}
|
||||||
@ -140,45 +157,6 @@ public:
|
|||||||
+ '.'
|
+ '.'
|
||||||
+ std::to_string(getMinor());
|
+ std::to_string(getMinor());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Member Operators
|
|
||||||
|
|
||||||
//- Version number equality
|
|
||||||
bool operator==(const versionNumber& rhs) const noexcept
|
|
||||||
{
|
|
||||||
return number_ == rhs.number_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Version number inequality
|
|
||||||
bool operator!=(const versionNumber& rhs) const noexcept
|
|
||||||
{
|
|
||||||
return number_ != rhs.number_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Version number older than rhs
|
|
||||||
bool operator<(const versionNumber& rhs) const noexcept
|
|
||||||
{
|
|
||||||
return number_ < rhs.number_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Version number is the same or older than rhs
|
|
||||||
bool operator<=(const versionNumber& rhs) const noexcept
|
|
||||||
{
|
|
||||||
return number_ <= rhs.number_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Version number newer than rhs
|
|
||||||
bool operator>(const versionNumber& rhs) const noexcept
|
|
||||||
{
|
|
||||||
return number_ > rhs.number_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Version number same or newer than rhs
|
|
||||||
bool operator>=(const versionNumber& rhs) const noexcept
|
|
||||||
{
|
|
||||||
return number_ >= rhs.number_;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -187,7 +165,7 @@ public:
|
|||||||
//- Stream format names (ascii, binary)
|
//- Stream format names (ascii, binary)
|
||||||
static const Enum<streamFormat> formatNames;
|
static const Enum<streamFormat> formatNames;
|
||||||
|
|
||||||
//- The current version number
|
//- The current version number (2.0)
|
||||||
static const versionNumber currentVersion;
|
static const versionNumber currentVersion;
|
||||||
|
|
||||||
|
|
||||||
@ -195,7 +173,8 @@ private:
|
|||||||
|
|
||||||
// Private Data
|
// Private Data
|
||||||
|
|
||||||
// NB: ordered with adjacent enums to minimize gaps
|
// NB: ordered with versionNumber first (short) and
|
||||||
|
// adjacent enums to minimize gaps
|
||||||
|
|
||||||
//- Stream version number (eg, 2.0 for current dictionary format)
|
//- Stream version number (eg, 2.0 for current dictionary format)
|
||||||
versionNumber version_;
|
versionNumber version_;
|
||||||
@ -211,58 +190,98 @@ public:
|
|||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct null. (default: ASCII, uncompressed, currentVersion)
|
//- Default construct (ASCII, UNCOMPRESSED, currentVersion)
|
||||||
IOstreamOption() noexcept
|
//- or construct with format, compression
|
||||||
:
|
// \note non-explicit for convenient construction
|
||||||
version_(currentVersion),
|
constexpr IOstreamOption
|
||||||
format_(ASCII),
|
|
||||||
compression_(compressionType::UNCOMPRESSED)
|
|
||||||
{}
|
|
||||||
|
|
||||||
//- Construct with format. (default: uncompressed, currentVersion)
|
|
||||||
explicit IOstreamOption(streamFormat format) noexcept
|
|
||||||
:
|
|
||||||
version_(currentVersion),
|
|
||||||
format_(format),
|
|
||||||
compression_(compressionType::UNCOMPRESSED)
|
|
||||||
{}
|
|
||||||
|
|
||||||
//- Construct with format and compression, optionally with version.
|
|
||||||
IOstreamOption
|
|
||||||
(
|
(
|
||||||
streamFormat format,
|
streamFormat fmt = streamFormat::ASCII,
|
||||||
compressionType compression,
|
compressionType comp = compressionType::UNCOMPRESSED
|
||||||
versionNumber version=currentVersion
|
|
||||||
) noexcept
|
) noexcept
|
||||||
:
|
:
|
||||||
version_(version),
|
version_(),
|
||||||
format_(format),
|
format_(fmt),
|
||||||
compression_(compression)
|
compression_(comp)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//- Construct with format, version, compression
|
//- Construct from components (format, compression, version)
|
||||||
IOstreamOption
|
constexpr IOstreamOption
|
||||||
(
|
(
|
||||||
streamFormat format,
|
streamFormat fmt,
|
||||||
versionNumber version,
|
compressionType comp,
|
||||||
compressionType compression
|
versionNumber ver
|
||||||
) noexcept
|
) noexcept
|
||||||
:
|
:
|
||||||
version_(version),
|
version_(ver),
|
||||||
format_(format),
|
format_(fmt),
|
||||||
compression_(compression)
|
compression_(comp)
|
||||||
|
{}
|
||||||
|
|
||||||
|
//- Construct from components (format, version, compression)
|
||||||
|
constexpr IOstreamOption
|
||||||
|
(
|
||||||
|
streamFormat fmt,
|
||||||
|
versionNumber ver,
|
||||||
|
compressionType comp = compressionType::UNCOMPRESSED
|
||||||
|
) noexcept
|
||||||
|
:
|
||||||
|
version_(ver),
|
||||||
|
format_(fmt),
|
||||||
|
compression_(comp)
|
||||||
|
{}
|
||||||
|
|
||||||
|
//- Copy construct with change of format
|
||||||
|
IOstreamOption(const IOstreamOption& opt, streamFormat fmt) noexcept
|
||||||
|
:
|
||||||
|
version_(opt.version_),
|
||||||
|
format_(fmt),
|
||||||
|
compression_(opt.compression_)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
// Static Member Functions
|
// Static Member Functions
|
||||||
|
|
||||||
//- The stream format enum corresponding to the string
|
//- The stream format enum corresponding to the string
|
||||||
// Expected "ascii", "binary"
|
//- (ascii | binary).
|
||||||
static streamFormat formatEnum(const word& formatName);
|
//
|
||||||
|
// If the string is not recognized, emit warning and return default.
|
||||||
|
// Silent if the string itself is empty.
|
||||||
|
//
|
||||||
|
// \note Can be used as constructor substitute for the enumeration
|
||||||
|
static streamFormat formatEnum
|
||||||
|
(
|
||||||
|
const word& formatName,
|
||||||
|
const streamFormat deflt = streamFormat::ASCII
|
||||||
|
);
|
||||||
|
|
||||||
//- The compression enum corresponding to the string
|
//- Failsafe construct streamFormat from optional dictionary lookup
|
||||||
// Expected "true", "false", "on", "off", etc.
|
static streamFormat formatEnum
|
||||||
static compressionType compressionEnum(const word& compName);
|
(
|
||||||
|
const word& key, //!< Lookup key. Uses LITERAL (not REGEX)
|
||||||
|
const dictionary& dict, //!< dictionary
|
||||||
|
const streamFormat deflt = streamFormat::ASCII
|
||||||
|
);
|
||||||
|
|
||||||
|
//- The compression enum corresponding to the string.
|
||||||
|
// Expects switch values (true/false, on/off, ...)
|
||||||
|
//
|
||||||
|
// If the string is not recognized, emit warning and return default.
|
||||||
|
// Silent if the string itself is empty.
|
||||||
|
//
|
||||||
|
// \note Can be used as constructor substitute for the enumeration
|
||||||
|
static compressionType compressionEnum
|
||||||
|
(
|
||||||
|
const word& compName,
|
||||||
|
const compressionType deflt = compressionType::UNCOMPRESSED
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Failsafe construct compressionType from optional dictionary lookup
|
||||||
|
static compressionType compressionEnum
|
||||||
|
(
|
||||||
|
const word& key, //!< Lookup key. Uses LITERAL (not REGEX)
|
||||||
|
const dictionary& dict, //!< dictionary
|
||||||
|
const compressionType deflt = compressionType::UNCOMPRESSED
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
@ -275,19 +294,21 @@ public:
|
|||||||
|
|
||||||
//- Set the stream format
|
//- Set the stream format
|
||||||
// \return the previous value
|
// \return the previous value
|
||||||
streamFormat format(const streamFormat format) noexcept
|
streamFormat format(const streamFormat fmt) noexcept
|
||||||
{
|
{
|
||||||
streamFormat old(format_);
|
streamFormat old(format_);
|
||||||
format_ = format;
|
format_ = fmt;
|
||||||
return old;
|
return old;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Set the stream format, from string value
|
//- Set the stream format from string value.
|
||||||
|
// If the string is not recognized, emit warning and leave unchanged.
|
||||||
|
// Silent if the string itself is empty.
|
||||||
// \return the previous value
|
// \return the previous value
|
||||||
streamFormat format(const word& formatName)
|
streamFormat format(const word& formatName)
|
||||||
{
|
{
|
||||||
streamFormat old(format_);
|
streamFormat old(format_);
|
||||||
format_ = formatEnum(formatName);
|
format_ = formatEnum(formatName, format_);
|
||||||
return old;
|
return old;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -306,12 +327,14 @@ public:
|
|||||||
return old;
|
return old;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Set the stream compression, from string value.
|
//- Set the stream compression from string value.
|
||||||
|
// If the string is not recognized, emit warning and leave unchanged.
|
||||||
|
// Silent if the string itself is empty.
|
||||||
// \return the previous value
|
// \return the previous value
|
||||||
compressionType compression(const word& compressionName)
|
compressionType compression(const word& compName)
|
||||||
{
|
{
|
||||||
compressionType old(compression_);
|
compressionType old(compression_);
|
||||||
compression_ = compressionEnum(compressionName);
|
compression_ = compressionEnum(compName, compression_);
|
||||||
return old;
|
return old;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -323,20 +346,92 @@ public:
|
|||||||
|
|
||||||
//- Set the stream version
|
//- Set the stream version
|
||||||
// \return the previous value
|
// \return the previous value
|
||||||
versionNumber version(const versionNumber verNum) noexcept
|
versionNumber version(const versionNumber ver) noexcept
|
||||||
{
|
{
|
||||||
versionNumber old(version_);
|
versionNumber old(version_);
|
||||||
version_ = verNum;
|
version_ = ver;
|
||||||
|
return old;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Set the stream version from token
|
||||||
|
// \return the previous value
|
||||||
|
versionNumber version(const token& tok)
|
||||||
|
{
|
||||||
|
versionNumber old(version_);
|
||||||
|
version_ = versionNumber(tok);
|
||||||
return old;
|
return old;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//- Output the format as text string (ascii | binary)
|
//- Output format type as text string (ascii | binary)
|
||||||
Ostream& operator<<(Ostream& os, const IOstreamOption::streamFormat& sf);
|
Ostream& operator<<(Ostream& os, const IOstreamOption::streamFormat& fmt);
|
||||||
|
|
||||||
//- Output the version as major.minor
|
//- Output version as major.minor text string
|
||||||
Ostream& operator<<(Ostream& os, const IOstreamOption::versionNumber& vn);
|
Ostream& operator<<(Ostream& os, const IOstreamOption::versionNumber& ver);
|
||||||
|
|
||||||
|
|
||||||
|
// Comparison Operators
|
||||||
|
|
||||||
|
//- Version number equality
|
||||||
|
inline bool operator==
|
||||||
|
(
|
||||||
|
const IOstreamOption::versionNumber& a,
|
||||||
|
const IOstreamOption::versionNumber& b
|
||||||
|
) noexcept
|
||||||
|
{
|
||||||
|
return a.compare(b) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Version number inequality
|
||||||
|
inline bool operator!=
|
||||||
|
(
|
||||||
|
const IOstreamOption::versionNumber& a,
|
||||||
|
const IOstreamOption::versionNumber& b
|
||||||
|
) noexcept
|
||||||
|
{
|
||||||
|
return a.compare(b) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Version A older than B
|
||||||
|
inline bool operator<
|
||||||
|
(
|
||||||
|
const IOstreamOption::versionNumber& a,
|
||||||
|
const IOstreamOption::versionNumber& b
|
||||||
|
) noexcept
|
||||||
|
{
|
||||||
|
return a.compare(b) < 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Version A same or older than B
|
||||||
|
inline bool operator<=
|
||||||
|
(
|
||||||
|
const IOstreamOption::versionNumber& a,
|
||||||
|
const IOstreamOption::versionNumber& b
|
||||||
|
) noexcept
|
||||||
|
{
|
||||||
|
return a.compare(b) <= 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Version A newer than B
|
||||||
|
inline bool operator>
|
||||||
|
(
|
||||||
|
const IOstreamOption::versionNumber& a,
|
||||||
|
const IOstreamOption::versionNumber& b
|
||||||
|
) noexcept
|
||||||
|
{
|
||||||
|
return a.compare(b) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Version A same or newer than B
|
||||||
|
inline bool operator>=
|
||||||
|
(
|
||||||
|
const IOstreamOption::versionNumber& a,
|
||||||
|
const IOstreamOption::versionNumber& b
|
||||||
|
) noexcept
|
||||||
|
{
|
||||||
|
return a.compare(b) >= 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
Copyright (C) 2016-2019 OpenCFD Ltd.
|
Copyright (C) 2016-2020 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -360,13 +360,7 @@ void Foam::Time::readDict()
|
|||||||
|
|
||||||
if (controlDict_.found("writeVersion"))
|
if (controlDict_.found("writeVersion"))
|
||||||
{
|
{
|
||||||
writeStreamOption_.version
|
writeStreamOption_.version(controlDict_.get<token>("writeVersion"));
|
||||||
(
|
|
||||||
IOstreamOption::versionNumber
|
|
||||||
(
|
|
||||||
controlDict_.get<float>("writeVersion")
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (controlDict_.found("writeFormat"))
|
if (controlDict_.found("writeFormat"))
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2018-2019 OpenCFD Ltd.
|
Copyright (C) 2018-2020 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -381,8 +381,8 @@ bool Foam::functionObjects::vtkCloud::read(const dictionary& dict)
|
|||||||
|
|
||||||
writeOpts_.ascii
|
writeOpts_.ascii
|
||||||
(
|
(
|
||||||
dict.found("format")
|
IOstream::ASCII
|
||||||
&& (IOstream::formatEnum(dict.get<word>("format")) == IOstream::ASCII)
|
== IOstream::formatEnum("format", dict, IOstream::BINARY)
|
||||||
);
|
);
|
||||||
|
|
||||||
writeOpts_.append(false); // No append supported
|
writeOpts_.append(false); // No append supported
|
||||||
@ -390,11 +390,7 @@ bool Foam::functionObjects::vtkCloud::read(const dictionary& dict)
|
|||||||
|
|
||||||
writeOpts_.precision
|
writeOpts_.precision
|
||||||
(
|
(
|
||||||
dict.lookupOrDefault
|
dict.getOrDefault("precision", IOstream::defaultPrecision())
|
||||||
(
|
|
||||||
"precision",
|
|
||||||
IOstream::defaultPrecision()
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Info<< type() << " " << name() << " output-format: "
|
// Info<< type() << " " << name() << " output-format: "
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2016-2018 OpenCFD Ltd.
|
Copyright (C) 2016-2020 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -80,13 +80,7 @@ Foam::functionObjects::ensightWrite::ensightWrite
|
|||||||
writeOpts_(),
|
writeOpts_(),
|
||||||
caseOpts_
|
caseOpts_
|
||||||
(
|
(
|
||||||
IOstreamOption::formatNames.lookupOrDefault
|
IOstreamOption::formatEnum("format", dict, runTime.writeFormat())
|
||||||
(
|
|
||||||
"format",
|
|
||||||
dict,
|
|
||||||
runTime.writeFormat(),
|
|
||||||
true // Failsafe behaviour
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
outputDir_(),
|
outputDir_(),
|
||||||
consecutive_(false),
|
consecutive_(false),
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2017-2019 OpenCFD Ltd.
|
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -183,22 +183,15 @@ bool Foam::functionObjects::vtkWrite::read(const dictionary& dict)
|
|||||||
|
|
||||||
writeOpts_.ascii
|
writeOpts_.ascii
|
||||||
(
|
(
|
||||||
dict.found("format")
|
IOstream::ASCII
|
||||||
&& (IOstream::formatEnum(dict.get<word>("format")) == IOstream::ASCII)
|
== IOstream::formatEnum("format", dict, IOstream::BINARY)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (dict.lookupOrDefault("legacy", false))
|
writeOpts_.legacy(dict.getOrDefault("legacy", false));
|
||||||
{
|
|
||||||
writeOpts_.legacy(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
writeOpts_.precision
|
writeOpts_.precision
|
||||||
(
|
(
|
||||||
dict.lookupOrDefault
|
dict.getOrDefault("precision", IOstream::defaultPrecision())
|
||||||
(
|
|
||||||
"precision",
|
|
||||||
IOstream::defaultPrecision()
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Info<< type() << " " << name() << " output-format: "
|
// Info<< type() << " " << name() << " output-format: "
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2017-2019 OpenCFD Ltd.
|
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -40,19 +40,15 @@ Foam::fileFormats::VTKsurfaceFormatCore::formatOptions
|
|||||||
opts.legacy(true); // Legacy. Use VTPsurfaceFormat for non-legacy
|
opts.legacy(true); // Legacy. Use VTPsurfaceFormat for non-legacy
|
||||||
opts.append(false); // No append format for legacy
|
opts.append(false); // No append format for legacy
|
||||||
|
|
||||||
const word formatName = dict.lookupOrDefault<word>("format", "");
|
opts.ascii
|
||||||
if (formatName.size())
|
(
|
||||||
{
|
IOstream::ASCII
|
||||||
opts.ascii(IOstream::formatEnum(formatName) == IOstream::ASCII);
|
== IOstream::formatEnum("format", dict, IOstream::ASCII)
|
||||||
}
|
);
|
||||||
|
|
||||||
opts.precision
|
opts.precision
|
||||||
(
|
(
|
||||||
dict.lookupOrDefault
|
dict.getOrDefault("precision", IOstream::defaultPrecision())
|
||||||
(
|
|
||||||
"precision",
|
|
||||||
IOstream::defaultPrecision()
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return opts;
|
return opts;
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2017-2019 OpenCFD Ltd.
|
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -40,19 +40,15 @@ Foam::fileFormats::VTPsurfaceFormatCore::formatOptions
|
|||||||
opts.legacy(false); // Non-legacy. Use VTKsurfaceFormat for legacy
|
opts.legacy(false); // Non-legacy. Use VTKsurfaceFormat for legacy
|
||||||
opts.append(false); // No append format
|
opts.append(false); // No append format
|
||||||
|
|
||||||
const word formatName = dict.lookupOrDefault<word>("format", "");
|
opts.ascii
|
||||||
if (formatName.size())
|
(
|
||||||
{
|
IOstream::ASCII
|
||||||
opts.ascii(IOstream::formatEnum(formatName) == IOstream::ASCII);
|
== IOstream::formatEnum("format", dict, IOstream::BINARY)
|
||||||
}
|
);
|
||||||
|
|
||||||
opts.precision
|
opts.precision
|
||||||
(
|
(
|
||||||
dict.lookupOrDefault
|
dict.getOrDefault("precision", IOstream::defaultPrecision())
|
||||||
(
|
|
||||||
"precision",
|
|
||||||
IOstream::defaultPrecision()
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return opts;
|
return opts;
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2014 OpenFOAM Foundation
|
Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||||
Copyright (C) 2015-2019 OpenCFD Ltd.
|
Copyright (C) 2015-2020 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -188,13 +188,7 @@ Foam::surfaceWriters::ensightWriter::ensightWriter
|
|||||||
surfaceWriter(options),
|
surfaceWriter(options),
|
||||||
writeFormat_
|
writeFormat_
|
||||||
(
|
(
|
||||||
IOstreamOption::formatNames.getOrDefault
|
IOstreamOption::formatEnum("format", options, IOstream::ASCII)
|
||||||
(
|
|
||||||
"format",
|
|
||||||
options,
|
|
||||||
IOstreamOption::ASCII,
|
|
||||||
true // Failsafe behaviour
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
collateTimes_(options.getOrDefault("collateTimes", true))
|
collateTimes_(options.getOrDefault("collateTimes", true))
|
||||||
{}
|
{}
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2015-2019 OpenCFD Ltd.
|
Copyright (C) 2015-2020 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -84,10 +84,7 @@ Foam::surfaceWriters::rawWriter::rawWriter
|
|||||||
surfaceWriter(options),
|
surfaceWriter(options),
|
||||||
writeCompression_
|
writeCompression_
|
||||||
(
|
(
|
||||||
IOstream::compressionEnum
|
IOstream::compressionEnum("compression", options)
|
||||||
(
|
|
||||||
options.lookupOrDefault<word>("compression", "false")
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2019 OpenCFD Ltd.
|
Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -104,19 +104,13 @@ Foam::surfaceWriters::vtkWriter::vtkWriter
|
|||||||
|
|
||||||
vtk::outputOptions opts(vtk::formatType::INLINE_BASE64);
|
vtk::outputOptions opts(vtk::formatType::INLINE_BASE64);
|
||||||
|
|
||||||
const word formatName = options.lookupOrDefault<word>("format", "");
|
|
||||||
if (formatName.size())
|
|
||||||
{
|
|
||||||
opts.ascii
|
opts.ascii
|
||||||
(
|
(
|
||||||
IOstream::formatEnum(formatName) == IOstream::ASCII
|
IOstream::ASCII
|
||||||
|
== IOstream::formatEnum("format", options, IOstream::BINARY)
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
if (options.lookupOrDefault("legacy", false))
|
opts.legacy(options.getOrDefault("legacy", false));
|
||||||
{
|
|
||||||
opts.legacy(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert back to raw data type
|
// Convert back to raw data type
|
||||||
fmtType_ = static_cast<unsigned>(opts.fmt());
|
fmtType_ = static_cast<unsigned>(opts.fmt());
|
||||||
|
|||||||
Reference in New Issue
Block a user