mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
STYLE: reorder/refactor stream format options
- IOstreamOption class to encapsulate format, compression, version.
This is ordered to avoid internal padding in the structure, which
reduces several bytes of memory overhead for stream objects
and other things using this combination of data.
Byte-sizes:
old IOstream:48 PstreamBuffers:88 Time:928
new IOstream:24 PstreamBuffers:72 Time:904
====
STYLE: remove support for deprecated uncompressed/compressed selectors
In older versions, the system/controlDict used these types of
specifications:
writeCompression uncompressed;
writeCompression compressed;
As of DEC-2009, these were deprecated in favour of using normal switch
names:
writeCompression true;
writeCompression false;
writeCompression on;
writeCompression off;
Now removed these deprecated names and treat like any other unknown
input and issue a warning. Eg,
Unknown compression specifier 'compressed', assuming no compression
====
STYLE: provide Enum of stream format names (ascii, binary)
====
COMP: fixed incorrect IFstream construct in FIREMeshReader
- spurious bool argument (presumably meant as uncompressed) was being
implicitly converted to a versionNumber. Now caught by making
IOstreamOption::versionNumber constructor explicit.
- bad version specifier in changeDictionary
This commit is contained in:
@ -646,7 +646,7 @@ int main(int argc, char *argv[])
|
||||
dictList.writeObject
|
||||
(
|
||||
runTime.writeFormat(),
|
||||
runTime.writeFormat(),
|
||||
IOstream::currentVersion,
|
||||
IOstream::UNCOMPRESSED,
|
||||
true
|
||||
);
|
||||
|
||||
@ -158,6 +158,7 @@ Streams = db/IOstreams
|
||||
$(Streams)/token/tokenIO.C
|
||||
|
||||
IOstreams = $(Streams)/IOstreams
|
||||
$(IOstreams)/IOstreamOption.C
|
||||
$(IOstreams)/IOstream.C
|
||||
$(IOstreams)/Istream.C
|
||||
$(IOstreams)/Ostream.C
|
||||
|
||||
@ -72,8 +72,7 @@ namespace Foam
|
||||
::Foam::simpleRegIOobject(Foam::debug::addOptimisationObject, name)
|
||||
{}
|
||||
|
||||
virtual ~addfileModificationCheckingToOpt()
|
||||
{}
|
||||
virtual ~addfileModificationCheckingToOpt() = default;
|
||||
|
||||
virtual void readData(Foam::Istream& is)
|
||||
{
|
||||
|
||||
@ -60,7 +60,7 @@ class IOobjectList
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
//- No copy assignment
|
||||
void operator=(const IOobjectList&) = delete;
|
||||
|
||||
|
||||
|
||||
@ -644,7 +644,7 @@ Foam::autoPtr<Foam::ISstream> Foam::decomposedBlockData::readBlocks
|
||||
// version
|
||||
string versionString(realIsPtr().version().str());
|
||||
Pstream::scatter(versionString, Pstream::msgType(), comm);
|
||||
realIsPtr().version(IStringStream(versionString)());
|
||||
realIsPtr().version(IOstream::versionNumber(versionString));
|
||||
|
||||
// stream
|
||||
{
|
||||
@ -1071,7 +1071,7 @@ bool Foam::decomposedBlockData::writeData(Ostream& os) const
|
||||
writeHeader
|
||||
(
|
||||
os,
|
||||
IOstream::versionNumber(IStringStream(versionString)()),
|
||||
IOstream::versionNumber(versionString),
|
||||
IOstream::formatEnum(formatString),
|
||||
io.headerClassName(),
|
||||
io.note(),
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -23,35 +23,30 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "IOstreamOption.H"
|
||||
#include "IOstreams.H"
|
||||
#include "OFstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Define the default IOstream versions and precision
|
||||
|
||||
const IOstream::versionNumber IOstream::originalVersion(0.5);
|
||||
const IOstream::versionNumber IOstream::currentVersion(2.0);
|
||||
unsigned int IOstream::precision_(debug::infoSwitch("writePrecision", 6));
|
||||
// Default output precision
|
||||
unsigned int Foam::IOstream::precision_
|
||||
(
|
||||
Foam::debug::infoSwitch("writePrecision", 6)
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * Global Variables * * * * * * * * * * * * * * //
|
||||
|
||||
// Global IO streams
|
||||
|
||||
ISstream Sin(cin, "Sin");
|
||||
OSstream Sout(cout, "Sout");
|
||||
OSstream Serr(cerr, "Serr");
|
||||
OFstream Snull("/dev/null");
|
||||
Foam::ISstream Foam::Sin(std::cin, "Sin");
|
||||
Foam::OSstream Foam::Sout(std::cout, "Sout");
|
||||
Foam::OSstream Foam::Serr(std::cerr, "Serr");
|
||||
Foam::OFstream Foam::Snull("/dev/null");
|
||||
|
||||
prefixOSstream Pout(cout, "Pout");
|
||||
prefixOSstream Perr(cerr, "Perr");
|
||||
Foam::prefixOSstream Foam::Pout(std::cout, "Pout");
|
||||
Foam::prefixOSstream Foam::Perr(std::cerr, "Perr");
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -25,68 +25,12 @@ License
|
||||
|
||||
#include "IOstream.H"
|
||||
#include "error.H"
|
||||
#include "Switch.H"
|
||||
#include <sstream>
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
Foam::fileName Foam::IOstream::staticName_("IOstream");
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::IOstream::streamFormat
|
||||
Foam::IOstream::formatEnum(const word& format)
|
||||
{
|
||||
if (format == "ascii")
|
||||
{
|
||||
return IOstream::ASCII;
|
||||
}
|
||||
else if (format == "binary")
|
||||
{
|
||||
return IOstream::BINARY;
|
||||
}
|
||||
else
|
||||
{
|
||||
WarningInFunction
|
||||
<< "bad format specifier '" << format << "', using 'ascii'"
|
||||
<< endl;
|
||||
|
||||
return IOstream::ASCII;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::IOstream::compressionType
|
||||
Foam::IOstream::compressionEnum(const word& compression)
|
||||
{
|
||||
// get Switch (bool) value, but allow it to fail
|
||||
Switch sw(compression, true);
|
||||
|
||||
if (sw.valid())
|
||||
{
|
||||
return sw ? IOstream::COMPRESSED : IOstream::UNCOMPRESSED;
|
||||
}
|
||||
else if (compression == "uncompressed")
|
||||
{
|
||||
return IOstream::UNCOMPRESSED;
|
||||
}
|
||||
else if (compression == "compressed")
|
||||
{
|
||||
return IOstream::COMPRESSED;
|
||||
}
|
||||
else
|
||||
{
|
||||
WarningInFunction
|
||||
<< "bad compression specifier '" << compression
|
||||
<< "', using 'uncompressed'"
|
||||
<< endl;
|
||||
|
||||
return IOstream::UNCOMPRESSED;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::fileName& Foam::IOstream::name() const
|
||||
@ -125,32 +69,10 @@ void Foam::IOstream::fatalCheck(const char* operation) const
|
||||
}
|
||||
|
||||
|
||||
Foam::string Foam::IOstream::versionNumber::str() const
|
||||
{
|
||||
std::ostringstream os;
|
||||
os.precision(1);
|
||||
os.setf(ios_base::fixed, ios_base::floatfield);
|
||||
os << versionNumber_;
|
||||
return os.str();
|
||||
}
|
||||
|
||||
|
||||
void Foam::IOstream::print(Ostream& os) const
|
||||
{
|
||||
os << "IOstream: " << "Version " << version_ << ", format ";
|
||||
|
||||
switch (format_)
|
||||
{
|
||||
case ASCII:
|
||||
os << "ASCII";
|
||||
break;
|
||||
|
||||
case BINARY:
|
||||
os << "BINARY";
|
||||
break;
|
||||
}
|
||||
|
||||
os << ", line " << lineNumber();
|
||||
os << "IOstream: " << "Version " << version() << ", format "
|
||||
<< format() << ", line " << lineNumber();
|
||||
|
||||
if (opened())
|
||||
{
|
||||
@ -213,28 +135,6 @@ void Foam::IOstream::print(Ostream& os, const int streamState) const
|
||||
|
||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const IOstream::streamFormat& sf)
|
||||
{
|
||||
if (sf == IOstream::ASCII)
|
||||
{
|
||||
os << "ascii";
|
||||
}
|
||||
else
|
||||
{
|
||||
os << "binary";
|
||||
}
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const IOstream::versionNumber& vn)
|
||||
{
|
||||
os << vn.str().c_str();
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const InfoProxy<IOstream>& ip)
|
||||
{
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -49,6 +49,7 @@ SourceFiles
|
||||
#include "scalar.H"
|
||||
#include "fileName.H"
|
||||
#include "InfoProxy.H"
|
||||
#include "IOstreamOption.H"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
@ -70,165 +71,38 @@ namespace Foam
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class IOstream
|
||||
:
|
||||
public IOstreamOption
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
// Public data types
|
||||
// Public Data Types
|
||||
|
||||
//- Enumeration for whether the stream open or closed
|
||||
enum streamAccess
|
||||
enum streamAccess : char
|
||||
{
|
||||
OPENED,
|
||||
CLOSED
|
||||
};
|
||||
|
||||
//- Enumeration for the format of data in the stream
|
||||
enum streamFormat
|
||||
{
|
||||
ASCII,
|
||||
BINARY
|
||||
};
|
||||
|
||||
//- Ostream operator
|
||||
friend Ostream& operator<<(Ostream& os, const streamFormat& sf);
|
||||
|
||||
//- Version number type
|
||||
class versionNumber
|
||||
{
|
||||
//- The version number
|
||||
scalar versionNumber_;
|
||||
|
||||
//- The version number as an integer
|
||||
int index_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from number
|
||||
versionNumber(const scalar num)
|
||||
:
|
||||
versionNumber_(num),
|
||||
index_(numberToIndex(num))
|
||||
{}
|
||||
|
||||
//- Construct from Istream
|
||||
versionNumber(Istream& is)
|
||||
:
|
||||
versionNumber_(readScalar(is)),
|
||||
index_(numberToIndex(versionNumber_))
|
||||
{}
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
//- Convert a version number into an index
|
||||
int numberToIndex(const scalar num) const
|
||||
{
|
||||
return int(10*num + SMALL);
|
||||
}
|
||||
|
||||
//- Return major version
|
||||
int majorVersion() const
|
||||
{
|
||||
return int(versionNumber_);
|
||||
}
|
||||
|
||||
//- Return minor version
|
||||
int minorVersion() const
|
||||
{
|
||||
return int(10.0*(versionNumber_ - majorVersion()));
|
||||
}
|
||||
|
||||
//- Return the versionNumber as a character string
|
||||
string str() const;
|
||||
|
||||
|
||||
// Member operators
|
||||
|
||||
//- Are these versionNumbers the same?
|
||||
bool operator==(const versionNumber& vn)
|
||||
{
|
||||
return index_ == vn.index_;
|
||||
}
|
||||
|
||||
//- Are these versionNumbers different?
|
||||
bool operator!=(const versionNumber& vn)
|
||||
{
|
||||
return index_ != vn.index_;
|
||||
}
|
||||
|
||||
//- Is this version older than the one given
|
||||
bool operator<(const versionNumber& vn)
|
||||
{
|
||||
return index_ < vn.index_;
|
||||
}
|
||||
|
||||
//- Is this version the same as or older than the one given
|
||||
bool operator<=(const versionNumber& vn)
|
||||
{
|
||||
return index_ <= vn.index_;
|
||||
}
|
||||
|
||||
//- Is this version newer than the one given
|
||||
bool operator>(const versionNumber& vn)
|
||||
{
|
||||
return index_ > vn.index_;
|
||||
}
|
||||
|
||||
//- This version the same as or newer than the one given
|
||||
bool operator>=(const versionNumber& vn)
|
||||
{
|
||||
return index_ >= vn.index_;
|
||||
}
|
||||
|
||||
|
||||
//- Ostream operator
|
||||
friend Ostream& operator<<(Ostream& os, const versionNumber& vn);
|
||||
CLOSED = 0, //!< stream not open
|
||||
OPENED //!< stream is open
|
||||
};
|
||||
|
||||
|
||||
//- Enumeration for the format of data in the stream
|
||||
enum compressionType
|
||||
{
|
||||
UNCOMPRESSED,
|
||||
COMPRESSED
|
||||
};
|
||||
|
||||
|
||||
// Public static data
|
||||
|
||||
//- Original version number
|
||||
static const versionNumber originalVersion;
|
||||
|
||||
//- Current version number
|
||||
static const versionNumber currentVersion;
|
||||
// Public Static Data
|
||||
|
||||
//- Default precision
|
||||
static unsigned int precision_;
|
||||
|
||||
|
||||
private:
|
||||
protected:
|
||||
|
||||
// Private data
|
||||
// Protected Data
|
||||
|
||||
//- Name for any generic stream - normally treat as readonly
|
||||
static fileName staticName_;
|
||||
|
||||
streamFormat format_;
|
||||
versionNumber version_;
|
||||
compressionType compression_;
|
||||
|
||||
streamAccess openClosed_;
|
||||
|
||||
ios_base::iostate ioState_;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
label lineNumber_;
|
||||
|
||||
|
||||
@ -265,6 +139,17 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct with specified stream option
|
||||
explicit IOstream(const IOstreamOption option)
|
||||
:
|
||||
IOstreamOption(option),
|
||||
openClosed_(CLOSED),
|
||||
ioState_(ios_base::iostate(0)),
|
||||
lineNumber_(0)
|
||||
{
|
||||
setBad();
|
||||
}
|
||||
|
||||
//- Construct setting format and version
|
||||
IOstream
|
||||
(
|
||||
@ -273,23 +158,15 @@ public:
|
||||
compressionType compression=UNCOMPRESSED
|
||||
)
|
||||
:
|
||||
format_(format),
|
||||
version_(version),
|
||||
compression_(compression),
|
||||
openClosed_(CLOSED),
|
||||
ioState_(ios_base::iostate(0)),
|
||||
lineNumber_(0)
|
||||
{
|
||||
setBad();
|
||||
}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~IOstream()
|
||||
IOstream(IOstreamOption(format, version, compression))
|
||||
{}
|
||||
|
||||
|
||||
// Member functions
|
||||
//- Destructor
|
||||
virtual ~IOstream() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
@ -363,90 +240,27 @@ public:
|
||||
}
|
||||
|
||||
|
||||
// Stream state functions
|
||||
// Stream State Functions
|
||||
|
||||
//- Return stream format of given format name
|
||||
static streamFormat formatEnum(const word&);
|
||||
|
||||
//- Return current stream format
|
||||
streamFormat format() const
|
||||
{
|
||||
return format_;
|
||||
}
|
||||
|
||||
//- Set the stream format
|
||||
streamFormat format(const streamFormat fmt)
|
||||
{
|
||||
streamFormat fmt0 = format_;
|
||||
format_ = fmt;
|
||||
return fmt0;
|
||||
}
|
||||
|
||||
//- Set the stream format from word
|
||||
streamFormat format(const word& fmt)
|
||||
{
|
||||
streamFormat fmt0 = format_;
|
||||
format_ = formatEnum(fmt);
|
||||
return fmt0;
|
||||
}
|
||||
|
||||
//- Return the stream version
|
||||
versionNumber version() const
|
||||
{
|
||||
return version_;
|
||||
}
|
||||
|
||||
//- Set the stream version
|
||||
versionNumber version(const versionNumber ver)
|
||||
{
|
||||
versionNumber ver0 = version_;
|
||||
version_ = ver;
|
||||
return ver0;
|
||||
}
|
||||
|
||||
//- Return compression of given compression name
|
||||
static compressionType compressionEnum(const word&);
|
||||
|
||||
//- Return the stream compression
|
||||
compressionType compression() const
|
||||
{
|
||||
return compression_;
|
||||
}
|
||||
|
||||
//- Set the stream compression
|
||||
compressionType compression(const compressionType cmp)
|
||||
{
|
||||
compressionType cmp0 = compression_;
|
||||
compression_ = cmp;
|
||||
return cmp0;
|
||||
}
|
||||
|
||||
//- Set the stream compression from word
|
||||
compressionType compression(const word& cmp)
|
||||
{
|
||||
compressionType cmp0 = compression_;
|
||||
compression_ = compressionEnum(cmp);
|
||||
return cmp0;
|
||||
}
|
||||
|
||||
//- Return current stream line number
|
||||
//- Const access to the current stream line number
|
||||
label lineNumber() const
|
||||
{
|
||||
return lineNumber_;
|
||||
}
|
||||
|
||||
//- Return current stream line number
|
||||
//- Non-const access to the current stream line number
|
||||
label& lineNumber()
|
||||
{
|
||||
return lineNumber_;
|
||||
}
|
||||
|
||||
//- Set the stream line number
|
||||
label lineNumber(const label ln)
|
||||
// \return the previous value
|
||||
label lineNumber(const label num)
|
||||
{
|
||||
label ln0 = lineNumber_;
|
||||
lineNumber_ = ln;
|
||||
return ln0;
|
||||
label old(lineNumber_);
|
||||
lineNumber_ = num;
|
||||
return old;
|
||||
}
|
||||
|
||||
//- Return flags of stream
|
||||
@ -458,12 +272,13 @@ public:
|
||||
return precision_;
|
||||
}
|
||||
|
||||
//- Reset the default precision (and return old precision)
|
||||
static unsigned int defaultPrecision(unsigned int p)
|
||||
//- Reset the default precision
|
||||
// \return the previous value
|
||||
static unsigned int defaultPrecision(unsigned int prec)
|
||||
{
|
||||
unsigned int precision0 = precision_;
|
||||
precision_ = p;
|
||||
return precision0;
|
||||
unsigned int old(precision_);
|
||||
precision_ = prec;
|
||||
return old;
|
||||
}
|
||||
|
||||
//- Set stream to have reached eof
|
||||
@ -504,19 +319,19 @@ public:
|
||||
}
|
||||
|
||||
//- Unset flags of stream
|
||||
void unsetf(const ios_base::fmtflags uf)
|
||||
void unsetf(const ios_base::fmtflags f)
|
||||
{
|
||||
flags(flags()&~uf);
|
||||
flags(flags() & ~f);
|
||||
}
|
||||
|
||||
|
||||
// Print
|
||||
|
||||
//- Print description of IOstream to Ostream
|
||||
virtual void print(Ostream&) const;
|
||||
virtual void print(Ostream& os) const;
|
||||
|
||||
//- Check given stream state bits
|
||||
void print(Ostream&, const int streamState) const;
|
||||
//- Print information about the stream state bits
|
||||
void print(Ostream& os, const int streamState) const;
|
||||
|
||||
|
||||
// Info
|
||||
@ -530,8 +345,7 @@ public:
|
||||
};
|
||||
|
||||
|
||||
Ostream& operator<<(Ostream& os, const IOstream::streamFormat& sf);
|
||||
Ostream& operator<<(Ostream& os, const IOstream::versionNumber& vn);
|
||||
// Ostream operator
|
||||
|
||||
template<>
|
||||
Ostream& operator<<(Ostream& os, const InfoProxy<IOstream>& ip);
|
||||
|
||||
120
src/OpenFOAM/db/IOstreams/IOstreams/IOstreamOption.C
Normal file
120
src/OpenFOAM/db/IOstreams/IOstreams/IOstreamOption.C
Normal file
@ -0,0 +1,120 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "IOstreamOption.H"
|
||||
#include "error.H"
|
||||
#include "Enum.H"
|
||||
#include "Switch.H"
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::IOstreamOption::versionNumber
|
||||
Foam::IOstreamOption::originalVersion(0,5);
|
||||
|
||||
const Foam::IOstreamOption::versionNumber
|
||||
Foam::IOstreamOption::currentVersion(2,0);
|
||||
|
||||
|
||||
const Foam::Enum
|
||||
<
|
||||
Foam::IOstreamOption::streamFormat
|
||||
>
|
||||
Foam::IOstreamOption::formatNames
|
||||
{
|
||||
{ streamFormat::ASCII, "ascii" },
|
||||
{ streamFormat::BINARY, "binary" }
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::IOstreamOption::streamFormat
|
||||
Foam::IOstreamOption::formatEnum(const word& formatName)
|
||||
{
|
||||
// Handle bad input graciously
|
||||
if (formatNames.found(formatName))
|
||||
{
|
||||
return formatNames[formatName];
|
||||
}
|
||||
|
||||
WarningInFunction
|
||||
<< "Unknown format specifier '" << formatName
|
||||
<< "', using 'ascii'" << endl;
|
||||
|
||||
return streamFormat::ASCII;
|
||||
}
|
||||
|
||||
|
||||
Foam::IOstreamOption::compressionType
|
||||
Foam::IOstreamOption::compressionEnum(const word& compName)
|
||||
{
|
||||
// Handle bad input graciously
|
||||
|
||||
const Switch sw(compName, true);
|
||||
if (sw.valid())
|
||||
{
|
||||
return
|
||||
(
|
||||
sw
|
||||
? compressionType::COMPRESSED
|
||||
: compressionType::UNCOMPRESSED
|
||||
);
|
||||
}
|
||||
|
||||
WarningInFunction
|
||||
<< "Unknown compression specifier '" << compName
|
||||
<< "', assuming no compression" << endl;
|
||||
|
||||
return compressionType::UNCOMPRESSED;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||
|
||||
Foam::Ostream& Foam::operator<<
|
||||
(
|
||||
Ostream& os,
|
||||
const IOstreamOption::streamFormat& sf
|
||||
)
|
||||
{
|
||||
os << IOstreamOption::formatNames[sf];
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
Foam::Ostream& Foam::operator<<
|
||||
(
|
||||
Ostream& os,
|
||||
const IOstreamOption::versionNumber& vn
|
||||
)
|
||||
{
|
||||
// Emit as char sequence instead of as individual characters
|
||||
// in case this is needed for sending in parallel.
|
||||
os << vn.str().c_str();
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
347
src/OpenFOAM/db/IOstreams/IOstreams/IOstreamOption.H
Normal file
347
src/OpenFOAM/db/IOstreams/IOstreams/IOstreamOption.H
Normal file
@ -0,0 +1,347 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::IOstreamOption
|
||||
|
||||
Description
|
||||
The IOstreamOption is a simple container for options an IOstream
|
||||
can normally have. For example, ascii/binary, uncompressed/compressed, ...
|
||||
|
||||
SourceFiles
|
||||
IOstreamOption.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef IOstreamOption_H
|
||||
#define IOstreamOption_H
|
||||
|
||||
#include "scalar.H"
|
||||
#include "word.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declarations
|
||||
class Ostream;
|
||||
template<class EnumType> class Enum;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class IOstreamOption Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class IOstreamOption
|
||||
{
|
||||
public:
|
||||
|
||||
// Public Data Types
|
||||
|
||||
//- Data format (ascii | binary)
|
||||
enum streamFormat : char
|
||||
{
|
||||
ASCII, //!< "ascii"
|
||||
BINARY //!< "binary"
|
||||
};
|
||||
|
||||
//- Compression treatment (UNCOMPRESSED | COMPRESSED)
|
||||
enum compressionType : char
|
||||
{
|
||||
UNCOMPRESSED = 0, //!< compression = false
|
||||
COMPRESSED //!< compression = true
|
||||
};
|
||||
|
||||
|
||||
//- Representation of a major/minor version number
|
||||
class versionNumber
|
||||
{
|
||||
//- The combined major/version number.
|
||||
short number_;
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from major, number
|
||||
constexpr versionNumber(int major, int minor) noexcept
|
||||
:
|
||||
number_(10*major + (minor % 10))
|
||||
{}
|
||||
|
||||
//- Construct from floating-point version number
|
||||
explicit constexpr versionNumber(const float ver) noexcept
|
||||
:
|
||||
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"
|
||||
explicit versionNumber(const std::string& verNum)
|
||||
:
|
||||
versionNumber(readFloat(verNum))
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- The canonical major/minor pair as an integer value.
|
||||
inline int canonical() noexcept
|
||||
{
|
||||
return number_;
|
||||
}
|
||||
|
||||
//- The major version number
|
||||
inline int major() const noexcept
|
||||
{
|
||||
return int(number_ / 10);
|
||||
}
|
||||
|
||||
//- The minor version number
|
||||
inline int minor() const noexcept
|
||||
{
|
||||
return int(number_ % 10);
|
||||
}
|
||||
|
||||
//- A string representation of major.minor
|
||||
std::string str() const
|
||||
{
|
||||
return std::to_string(major()) + '.' + std::to_string(minor());
|
||||
}
|
||||
|
||||
|
||||
// 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_;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Public Static Data
|
||||
|
||||
//- Stream format names (ascii, binary)
|
||||
static const Enum<streamFormat> formatNames;
|
||||
|
||||
//- The original version number
|
||||
static const versionNumber originalVersion;
|
||||
|
||||
//- The current version number
|
||||
static const versionNumber currentVersion;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Private Data
|
||||
|
||||
// NB: ordered with adjacent enums to minimize gaps
|
||||
|
||||
//- Stream version number (eg, 2.0 for current dictionary format)
|
||||
versionNumber version_;
|
||||
|
||||
//- Format: (ascii | binary)
|
||||
streamFormat format_;
|
||||
|
||||
//- Compression: (on | off)
|
||||
compressionType compression_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null. (default: ASCII, uncompressed, currentVersion)
|
||||
IOstreamOption() noexcept
|
||||
:
|
||||
version_(currentVersion),
|
||||
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,
|
||||
compressionType compression,
|
||||
versionNumber version=currentVersion
|
||||
) noexcept
|
||||
:
|
||||
version_(version),
|
||||
format_(format),
|
||||
compression_(compression)
|
||||
{}
|
||||
|
||||
//- Construct with format, version, compression
|
||||
IOstreamOption
|
||||
(
|
||||
streamFormat format,
|
||||
versionNumber version,
|
||||
compressionType compression
|
||||
) noexcept
|
||||
:
|
||||
version_(version),
|
||||
format_(format),
|
||||
compression_(compression)
|
||||
{}
|
||||
|
||||
|
||||
// Static Member Functions
|
||||
|
||||
//- The stream format enum corresponding to the string
|
||||
// Expected "ascii", "binary"
|
||||
static streamFormat formatEnum(const word& formatName);
|
||||
|
||||
//- The compression enum corresponding to the string
|
||||
// Expected "true", "false", "on", "off", etc.
|
||||
static compressionType compressionEnum(const word& compName);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Get the current stream format
|
||||
streamFormat format() const noexcept
|
||||
{
|
||||
return format_;
|
||||
}
|
||||
|
||||
//- Set the stream format
|
||||
// \return the previous value
|
||||
streamFormat format(const streamFormat format) noexcept
|
||||
{
|
||||
streamFormat old(format_);
|
||||
format_ = format;
|
||||
return old;
|
||||
}
|
||||
|
||||
//- Set the stream format, from string value
|
||||
// \return the previous value
|
||||
streamFormat format(const word& formatName)
|
||||
{
|
||||
streamFormat old(format_);
|
||||
format_ = formatEnum(formatName);
|
||||
return old;
|
||||
}
|
||||
|
||||
//- Get the stream compression
|
||||
compressionType compression() const noexcept
|
||||
{
|
||||
return compression_;
|
||||
}
|
||||
|
||||
//- Set the stream compression
|
||||
// \return the previous value
|
||||
compressionType compression(const compressionType comp) noexcept
|
||||
{
|
||||
compressionType old(compression_);
|
||||
compression_ = comp;
|
||||
return old;
|
||||
}
|
||||
|
||||
//- Set the stream compression, from string value.
|
||||
// \return the previous value
|
||||
compressionType compression(const word& compressionName)
|
||||
{
|
||||
compressionType old(compression_);
|
||||
compression_ = compressionEnum(compressionName);
|
||||
return old;
|
||||
}
|
||||
|
||||
//- Get the stream version
|
||||
versionNumber version() const noexcept
|
||||
{
|
||||
return version_;
|
||||
}
|
||||
|
||||
//- Set the stream version
|
||||
// \return the previous value
|
||||
versionNumber version(const versionNumber verNum) noexcept
|
||||
{
|
||||
versionNumber old(version_);
|
||||
version_ = verNum;
|
||||
return old;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//- Output the format as text string (ascii | binary)
|
||||
Ostream& operator<<(Ostream& os, const IOstreamOption::streamFormat& sf);
|
||||
|
||||
//- Output the version as major.minor
|
||||
Ostream& operator<<(Ostream& os, const IOstreamOption::versionNumber& vn);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -86,8 +86,7 @@ public:
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~Istream()
|
||||
{}
|
||||
virtual ~Istream() = default;
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
@ -88,8 +88,7 @@ public:
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~Ostream()
|
||||
{}
|
||||
virtual ~Ostream() = default;
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
@ -432,8 +432,7 @@ namespace Foam
|
||||
::Foam::simpleRegIOobject(Foam::debug::addOptimisationObject, name)
|
||||
{}
|
||||
|
||||
virtual ~addcommsTypeToOpt()
|
||||
{}
|
||||
virtual ~addcommsTypeToOpt() = default;
|
||||
|
||||
virtual void readData(Foam::Istream& is)
|
||||
{
|
||||
|
||||
@ -77,7 +77,7 @@ class ISstream
|
||||
// Handles both "$var" and "${var}" forms.
|
||||
Istream& readVariable(string& str);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
//- No copy assignment
|
||||
void operator=(const ISstream&) = delete;
|
||||
|
||||
|
||||
@ -97,8 +97,7 @@ public:
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~ISstream()
|
||||
{}
|
||||
virtual ~ISstream() = default;
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
@ -61,7 +61,7 @@ class OSstream
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
//- No copy assignment
|
||||
void operator=(const OSstream&) = delete;
|
||||
|
||||
|
||||
@ -70,7 +70,7 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct as wrapper around std::ostream and set stream status
|
||||
OSstream
|
||||
inline OSstream
|
||||
(
|
||||
std::ostream& os,
|
||||
const string& name,
|
||||
|
||||
@ -160,8 +160,7 @@ public:
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~ITstream()
|
||||
{}
|
||||
virtual ~ITstream() = default;
|
||||
|
||||
|
||||
// Static Functions
|
||||
|
||||
@ -49,7 +49,6 @@ class dummyISstream
|
||||
:
|
||||
public IStringStream
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
@ -62,8 +61,7 @@ public:
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~dummyISstream()
|
||||
{}
|
||||
virtual ~dummyISstream() = default;
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -439,10 +439,7 @@ Foam::Time::Time
|
||||
writeOnce_(false),
|
||||
sigWriteNow_(*this, true),
|
||||
sigStopAtWriteNow_(*this, true),
|
||||
|
||||
writeFormat_(IOstream::ASCII),
|
||||
writeVersion_(IOstream::currentVersion),
|
||||
writeCompression_(IOstream::UNCOMPRESSED),
|
||||
writeStreamOption_(IOstream::ASCII),
|
||||
graphFormat_("raw"),
|
||||
runTimeModifiable_(false),
|
||||
|
||||
@ -508,10 +505,7 @@ Foam::Time::Time
|
||||
writeOnce_(false),
|
||||
sigWriteNow_(*this, true),
|
||||
sigStopAtWriteNow_(*this, true),
|
||||
|
||||
writeFormat_(IOstream::ASCII),
|
||||
writeVersion_(IOstream::currentVersion),
|
||||
writeCompression_(IOstream::UNCOMPRESSED),
|
||||
writeStreamOption_(IOstream::ASCII),
|
||||
graphFormat_("raw"),
|
||||
runTimeModifiable_(false),
|
||||
|
||||
@ -587,10 +581,7 @@ Foam::Time::Time
|
||||
writeOnce_(false),
|
||||
sigWriteNow_(*this, true),
|
||||
sigStopAtWriteNow_(*this, true),
|
||||
|
||||
writeFormat_(IOstream::ASCII),
|
||||
writeVersion_(IOstream::currentVersion),
|
||||
writeCompression_(IOstream::UNCOMPRESSED),
|
||||
writeStreamOption_(IOstream::ASCII),
|
||||
graphFormat_("raw"),
|
||||
runTimeModifiable_(false),
|
||||
|
||||
@ -655,9 +646,7 @@ Foam::Time::Time
|
||||
purgeWrite_(0),
|
||||
subCycling_(0),
|
||||
writeOnce_(false),
|
||||
writeFormat_(IOstream::ASCII),
|
||||
writeVersion_(IOstream::currentVersion),
|
||||
writeCompression_(IOstream::UNCOMPRESSED),
|
||||
writeStreamOption_(IOstream::ASCII),
|
||||
graphFormat_("raw"),
|
||||
runTimeModifiable_(false),
|
||||
|
||||
|
||||
@ -193,14 +193,8 @@ protected:
|
||||
|
||||
private:
|
||||
|
||||
//- Default write option
|
||||
IOstream::streamFormat writeFormat_;
|
||||
|
||||
//- Default output file format version number
|
||||
IOstream::versionNumber writeVersion_;
|
||||
|
||||
//- Default output compression
|
||||
IOstream::compressionType writeCompression_;
|
||||
//- Default write stream option (format, version, compression)
|
||||
IOstreamOption writeStreamOption_;
|
||||
|
||||
//- Default graph format
|
||||
word graphFormat_;
|
||||
@ -309,19 +303,19 @@ public:
|
||||
//- Default write format
|
||||
IOstream::streamFormat writeFormat() const
|
||||
{
|
||||
return writeFormat_;
|
||||
return writeStreamOption_.format();
|
||||
}
|
||||
|
||||
//- Default write version number
|
||||
IOstream::versionNumber writeVersion() const
|
||||
{
|
||||
return writeVersion_;
|
||||
return writeStreamOption_.version();
|
||||
}
|
||||
|
||||
//- Default write compression
|
||||
IOstream::compressionType writeCompression() const
|
||||
{
|
||||
return writeCompression_;
|
||||
return writeStreamOption_.compression();
|
||||
}
|
||||
|
||||
//- Default graph format
|
||||
|
||||
@ -442,18 +442,18 @@ void Foam::Time::readDict()
|
||||
|
||||
if (controlDict_.found("writeVersion"))
|
||||
{
|
||||
writeVersion_ = IOstream::versionNumber
|
||||
writeStreamOption_.version
|
||||
(
|
||||
IOstreamOption::versionNumber
|
||||
(
|
||||
controlDict_.lookup("writeVersion")
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (controlDict_.found("writeFormat"))
|
||||
{
|
||||
writeFormat_ = IOstream::formatEnum
|
||||
(
|
||||
controlDict_.lookup("writeFormat")
|
||||
);
|
||||
writeStreamOption_.format(word(controlDict_.lookup("writeFormat")));
|
||||
}
|
||||
|
||||
if (controlDict_.found("writePrecision"))
|
||||
@ -478,23 +478,23 @@ void Foam::Time::readDict()
|
||||
|
||||
if (controlDict_.found("writeCompression"))
|
||||
{
|
||||
writeCompression_ = IOstream::compressionEnum
|
||||
writeStreamOption_.compression
|
||||
(
|
||||
controlDict_.lookup("writeCompression")
|
||||
word(controlDict_.lookup("writeCompression"))
|
||||
);
|
||||
|
||||
if
|
||||
(
|
||||
writeFormat_ == IOstream::BINARY
|
||||
&& writeCompression_ == IOstream::COMPRESSED
|
||||
writeStreamOption_.compression() == IOstream::COMPRESSED
|
||||
&& writeStreamOption_.format() == IOstream::BINARY
|
||||
)
|
||||
{
|
||||
IOWarningInFunction(controlDict_)
|
||||
<< "Selecting compressed binary is inefficient and ineffective"
|
||||
", resetting to uncompressed binary"
|
||||
<< "Disabled binary format compression"
|
||||
<< " (inefficient/ineffective)"
|
||||
<< endl;
|
||||
|
||||
writeCompression_ = IOstream::UNCOMPRESSED;
|
||||
writeStreamOption_.compression(IOstream::UNCOMPRESSED);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -224,14 +224,10 @@ Foam::Field<Type>::Field
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (is.version() == IOstream::versionNumber(2,0))
|
||||
{
|
||||
if (is.version() == 2.0)
|
||||
{
|
||||
IOWarningInFunction
|
||||
(
|
||||
dict
|
||||
) << "expected keyword 'uniform' or 'nonuniform', "
|
||||
IOWarningInFunction(dict)
|
||||
<< "expected keyword 'uniform' or 'nonuniform', "
|
||||
"assuming deprecated Field format from "
|
||||
"Foam version 2.0." << endl;
|
||||
|
||||
@ -242,13 +238,9 @@ Foam::Field<Type>::Field
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalIOErrorInFunction
|
||||
(
|
||||
dict
|
||||
) << "expected keyword 'uniform' or 'nonuniform', found "
|
||||
<< firstToken.info()
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
FatalIOErrorInFunction(dict)
|
||||
<< "expected keyword 'uniform' or 'nonuniform', found "
|
||||
<< firstToken.info() << exit(FatalIOError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -165,7 +165,7 @@ inline bool Foam::operator!=(const face& a, const face& b)
|
||||
|
||||
inline Foam::Istream& Foam::operator>>(Istream& is, face& f)
|
||||
{
|
||||
if (is.version() == IOstream::originalVersion)
|
||||
if (is.version() == IOstreamOption::originalVersion)
|
||||
{
|
||||
// Read starting (
|
||||
is.readBegin("face");
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -405,7 +405,7 @@ bool Foam::fileFormats::FIREMeshReader::readGeometry(const scalar scaleFactor)
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
IFstream is(geometryFile_, fmt, false);
|
||||
IFstream is(geometryFile_, fmt);
|
||||
|
||||
readPoints(is, scaleFactor);
|
||||
readFaces(is);
|
||||
@ -459,17 +459,11 @@ Foam::fileFormats::FIREMeshReader::FIREMeshReader
|
||||
)
|
||||
:
|
||||
meshReader(name, scaleFactor),
|
||||
owner_(0),
|
||||
neigh_(0),
|
||||
faceZoneId_(0),
|
||||
owner_(),
|
||||
neigh_(),
|
||||
faceZoneId_(),
|
||||
faceNames_()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::fileFormats::FIREMeshReader::~FIREMeshReader()
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -47,7 +47,7 @@ SourceFiles
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
// forward declarations
|
||||
// Forward declarations
|
||||
class polyMesh;
|
||||
|
||||
namespace fileFormats
|
||||
@ -76,10 +76,10 @@ protected:
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
//- No copy construct
|
||||
FIREMeshReader(const FIREMeshReader&) = delete;
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
//- No copy assignment
|
||||
void operator=(const FIREMeshReader&) = delete;
|
||||
|
||||
|
||||
@ -113,7 +113,7 @@ public:
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~FIREMeshReader();
|
||||
virtual ~FIREMeshReader() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
@ -73,9 +73,12 @@ Foam::functionObjects::ensightWrite::ensightWrite
|
||||
fvMeshFunctionObject(name, runTime, dict),
|
||||
writeOpts_
|
||||
(
|
||||
dict.found("format")
|
||||
? IOstream::formatEnum(dict.lookup("format"))
|
||||
: runTime.writeFormat()
|
||||
IOstreamOption::formatNames.lookupOrFailsafe
|
||||
(
|
||||
"format",
|
||||
dict,
|
||||
runTime.writeFormat()
|
||||
)
|
||||
),
|
||||
caseOpts_(writeOpts_.format()),
|
||||
selectFields_(),
|
||||
|
||||
@ -875,32 +875,24 @@ Foam::tmp<Foam::pointField> Foam::mappedPatchBase::readListOrField
|
||||
is >> static_cast<List<vector>&>(fld);
|
||||
if (fld.size() != size)
|
||||
{
|
||||
FatalIOErrorInFunction
|
||||
(
|
||||
dict
|
||||
) << "size " << fld.size()
|
||||
FatalIOErrorInFunction(dict)
|
||||
<< "size " << fld.size()
|
||||
<< " is not equal to the given value of " << size
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalIOErrorInFunction
|
||||
(
|
||||
dict
|
||||
) << "expected keyword 'uniform' or 'nonuniform', found "
|
||||
FatalIOErrorInFunction(dict)
|
||||
<< "expected keyword 'uniform' or 'nonuniform', found "
|
||||
<< firstToken.wordToken()
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (is.version() == IOstream::versionNumber(2,0))
|
||||
{
|
||||
if (is.version() == 2.0)
|
||||
{
|
||||
IOWarningInFunction
|
||||
(
|
||||
dict
|
||||
) << "expected keyword 'uniform' or 'nonuniform', "
|
||||
IOWarningInFunction(dict)
|
||||
<< "expected keyword 'uniform' or 'nonuniform', "
|
||||
"assuming List format for backwards compatibility."
|
||||
"Foam version 2.0." << endl;
|
||||
|
||||
@ -908,7 +900,6 @@ Foam::tmp<Foam::pointField> Foam::mappedPatchBase::readListOrField
|
||||
is >> static_cast<List<vector>&>(fld);
|
||||
}
|
||||
}
|
||||
}
|
||||
return tfld;
|
||||
}
|
||||
|
||||
@ -1090,10 +1081,8 @@ Foam::mappedPatchBase::mappedPatchBase
|
||||
}
|
||||
else if (mode_ != NEARESTPATCHFACE && mode_ != NEARESTPATCHFACEAMI)
|
||||
{
|
||||
FatalIOErrorInFunction
|
||||
(
|
||||
dict
|
||||
) << "Please supply the offsetMode as one of "
|
||||
FatalIOErrorInFunction(dict)
|
||||
<< "Please supply the offsetMode as one of "
|
||||
<< offsetModeNames_
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
@ -1125,10 +1114,8 @@ Foam::mappedPatchBase::mappedPatchBase
|
||||
{
|
||||
if (mode != NEARESTPATCHFACE && mode != NEARESTPATCHFACEAMI)
|
||||
{
|
||||
FatalIOErrorInFunction
|
||||
(
|
||||
dict
|
||||
) << "Construct from sampleMode and dictionary only applicable for "
|
||||
FatalIOErrorInFunction(dict)
|
||||
<< "Construct from sampleMode and dictionary only applicable for "
|
||||
<< " collocated patches in modes "
|
||||
<< sampleModeNames_[NEARESTPATCHFACE] << ','
|
||||
<< sampleModeNames_[NEARESTPATCHFACEAMI]
|
||||
|
||||
@ -49,16 +49,17 @@ Foam::ensightSurfaceWriter::ensightSurfaceWriter()
|
||||
Foam::ensightSurfaceWriter::ensightSurfaceWriter(const dictionary& options)
|
||||
:
|
||||
surfaceWriter(),
|
||||
writeFormat_(IOstream::ASCII),
|
||||
collateTimes_(true)
|
||||
{
|
||||
// choose ascii or binary format
|
||||
if (options.found("format"))
|
||||
{
|
||||
writeFormat_ = IOstream::formatEnum(options.lookup("format"));
|
||||
}
|
||||
options.readIfPresent("collateTimes", collateTimes_);
|
||||
}
|
||||
writeFormat_
|
||||
(
|
||||
IOstreamOption::formatNames.lookupOrFailsafe
|
||||
(
|
||||
"format",
|
||||
options,
|
||||
IOstreamOption::ASCII
|
||||
)
|
||||
),
|
||||
collateTimes_(options.lookupOrDefault("collateTimes", true))
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Reference in New Issue
Block a user