STYLE: IOstreams with float/double instead of floatScalar/doubleScalar

- consistent with defining IO of int32_t/int64_t and with recent
  changes to ensightFile. Using the primitives directly instead of
  typedefs to them makes the code somewhat less opaque.
This commit is contained in:
Mark Olesen 2022-07-22 15:37:34 +02:00
parent a4a8f77b7b
commit 6320bab2b5
30 changed files with 122 additions and 127 deletions

View File

@ -28,15 +28,14 @@ Description
\*---------------------------------------------------------------------------*/
using namespace Foam;
#include "floatScalar.H"
#include "doubleScalar.H"
#include "scalar.H"
#include "complex.H"
#include "Matrix.H"
#include "Random.H"
#include <chrono>
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Total number of unit tests

View File

@ -38,8 +38,7 @@ Description
#include "DiagonalMatrix.H"
#include "RectangularMatrix.H"
#include "floatScalar.H"
#include "doubleScalar.H"
#include "scalar.H"
#include "complex.H"
#include "TestTools.H"

View File

@ -44,8 +44,7 @@ Note
#include "RectangularMatrix.H"
#include "SquareMatrix.H"
#include "floatScalar.H"
#include "doubleScalar.H"
#include "scalar.H"
#include "complex.H"
#include "IOmanip.H"
#include "TestTools.H"

View File

@ -45,8 +45,7 @@ Note
#include "scalarMatrices.H"
#include "RectangularMatrix.H"
#include "SquareMatrix.H"
#include "floatScalar.H"
#include "doubleScalar.H"
#include "scalar.H"
#include "complex.H"
#include "IOmanip.H"
#include "TestTools.H"

View File

@ -46,8 +46,7 @@ Note
#include "RectangularMatrix.H"
#include "SquareMatrix.H"
#include "SymmetricSquareMatrix.H"
#include "floatScalar.H"
#include "doubleScalar.H"
#include "scalar.H"
#include "complex.H"
#include "IOmanip.H"
#include "Random.H"

View File

@ -232,13 +232,13 @@ vtk::outputOptions getOutputOptions(const argList& args)
if (!args.found("ascii"))
{
if (sizeof(floatScalar) != 4 || sizeof(label) != 4)
if (sizeof(float) != 4 || sizeof(label) != 4)
{
opts.ascii(true);
WarningInFunction
<< "Using ASCII rather than legacy binary VTK format since "
<< "floatScalar and/or label are not 4 bytes in size."
<< "float and/or label are not 4 bytes in size."
<< nl << endl;
}
else

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2021 OpenCFD Ltd.
Copyright (C) 2017-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -156,11 +156,11 @@ public:
//- Read a label
virtual Istream& read(label&) = 0;
//- Read a floatScalar
virtual Istream& read(floatScalar&) = 0;
//- Read a float
virtual Istream& read(float&) = 0;
//- Read a doubleScalar
virtual Istream& read(doubleScalar&) = 0;
//- Read a double
virtual Istream& read(double&) = 0;
//- Read binary block
virtual Istream& read(char*, std::streamsize) = 0;

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2021 OpenCFD Ltd.
Copyright (C) 2016-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -147,11 +147,11 @@ public:
//- Write int64_t
virtual Ostream& write(const int64_t val) = 0;
//- Write floatScalar
virtual Ostream& write(const floatScalar val) = 0;
//- Write float
virtual Ostream& write(const float val) = 0;
//- Write doubleScalar
virtual Ostream& write(const doubleScalar val) = 0;
//- Write double
virtual Ostream& write(const double val) = 0;
//- Write binary block.
virtual Ostream& write(const char* data, std::streamsize count) = 0;

View File

@ -156,11 +156,11 @@ public:
//- Read a label
Istream& read(label& val);
//- Read a floatScalar
Istream& read(floatScalar& val);
//- Read a float
Istream& read(float& val);
//- Read a doubleScalar
Istream& read(doubleScalar& val);
//- Read a double
Istream& read(double& val);
//- Read binary block with 8-byte alignment.
Istream& read(char* data, std::streamsize count);

View File

@ -359,7 +359,7 @@ Foam::Istream& Foam::UIPstreamBase::read(token& t)
// Float
case token::tokenType::FLOAT :
{
floatScalar val;
float val;
if (read(val))
{
t = val;
@ -374,7 +374,7 @@ Foam::Istream& Foam::UIPstreamBase::read(token& t)
// Double
case token::tokenType::DOUBLE :
{
doubleScalar val;
double val;
if (read(val))
{
t = val;
@ -432,14 +432,14 @@ Foam::Istream& Foam::UIPstreamBase::read(label& val)
}
Foam::Istream& Foam::UIPstreamBase::read(floatScalar& val)
Foam::Istream& Foam::UIPstreamBase::read(float& val)
{
readFromBuffer(val);
return *this;
}
Foam::Istream& Foam::UIPstreamBase::read(doubleScalar& val)
Foam::Istream& Foam::UIPstreamBase::read(double& val)
{
readFromBuffer(val);
return *this;

View File

@ -173,11 +173,11 @@ public:
//- Write int64_t as a label
virtual Ostream& write(const int64_t val);
//- Write floatScalar
virtual Ostream& write(const floatScalar val);
//- Write float
virtual Ostream& write(const float val);
//- Write doubleScalar
virtual Ostream& write(const doubleScalar val);
//- Write double
virtual Ostream& write(const double val);
//- Write binary block with 8-byte alignment.
virtual Ostream& write(const char* data, std::streamsize count);

View File

@ -304,7 +304,7 @@ Foam::Ostream& Foam::UOPstreamBase::write(const int64_t val)
}
Foam::Ostream& Foam::UOPstreamBase::write(const floatScalar val)
Foam::Ostream& Foam::UOPstreamBase::write(const float val)
{
putChar(token::tokenType::FLOAT);
writeToBuffer(val);
@ -312,7 +312,7 @@ Foam::Ostream& Foam::UOPstreamBase::write(const floatScalar val)
}
Foam::Ostream& Foam::UOPstreamBase::write(const doubleScalar val)
Foam::Ostream& Foam::UOPstreamBase::write(const double val)
{
putChar(token::tokenType::DOUBLE);
writeToBuffer(val);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2021 OpenCFD Ltd.
Copyright (C) 2017-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -1001,7 +1001,7 @@ Foam::Istream& Foam::ISstream::read(label& val)
}
Foam::Istream& Foam::ISstream::read(floatScalar& val)
Foam::Istream& Foam::ISstream::read(float& val)
{
is_ >> val;
setState(is_.rdstate());
@ -1009,7 +1009,7 @@ Foam::Istream& Foam::ISstream::read(floatScalar& val)
}
Foam::Istream& Foam::ISstream::read(doubleScalar& val)
Foam::Istream& Foam::ISstream::read(double& val)
{
is_ >> val;
setState(is_.rdstate());

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2012 OpenFOAM Foundation
Copyright (C) 2017-2021 OpenCFD Ltd.
Copyright (C) 2017-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -36,8 +36,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef ISstream_H
#define ISstream_H
#ifndef Foam_ISstream_H
#define Foam_ISstream_H
#include "Istream.H"
#include "fileName.H"
@ -183,11 +183,11 @@ public:
//- Read a label
virtual Istream& read(label& val);
//- Read a floatScalar
virtual Istream& read(floatScalar& val);
//- Read a float
virtual Istream& read(float& val);
//- Read a doubleScalar
virtual Istream& read(doubleScalar& val);
//- Read a double
virtual Istream& read(double& val);
//- Read binary block
virtual Istream& read(char* buf, std::streamsize count);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2021 OpenCFD Ltd.
Copyright (C) 2017-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -196,7 +196,7 @@ Foam::Ostream& Foam::OSstream::write(const int64_t val)
}
Foam::Ostream& Foam::OSstream::write(const floatScalar val)
Foam::Ostream& Foam::OSstream::write(const float val)
{
os_ << val;
setState(os_.rdstate());
@ -204,7 +204,7 @@ Foam::Ostream& Foam::OSstream::write(const floatScalar val)
}
Foam::Ostream& Foam::OSstream::write(const doubleScalar val)
Foam::Ostream& Foam::OSstream::write(const double val)
{
os_ << val;
setState(os_.rdstate());

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2014 OpenFOAM Foundation
Copyright (C) 2017-2021 OpenCFD Ltd.
Copyright (C) 2017-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -36,8 +36,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef OSstream_H
#define OSstream_H
#ifndef Foam_OSstream_H
#define Foam_OSstream_H
#include "Ostream.H"
#include "fileName.H"
@ -155,11 +155,11 @@ public:
//- Write int64_t
virtual Ostream& write(const int64_t val);
//- Write floatScalar
virtual Ostream& write(const floatScalar val);
//- Write float
virtual Ostream& write(const float val);
//- Write doubleScalar
virtual Ostream& write(const doubleScalar val);
//- Write double
virtual Ostream& write(const double val);
//- Write binary block
virtual Ostream& write(const char* data, std::streamsize count);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2014 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -140,14 +140,14 @@ Foam::Ostream& Foam::prefixOSstream::write(const int64_t val)
}
Foam::Ostream& Foam::prefixOSstream::write(const floatScalar val)
Foam::Ostream& Foam::prefixOSstream::write(const float val)
{
checkWritePrefix();
return OSstream::write(val);
}
Foam::Ostream& Foam::prefixOSstream::write(const doubleScalar val)
Foam::Ostream& Foam::prefixOSstream::write(const double val)
{
checkWritePrefix();
return OSstream::write(val);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2014 OpenFOAM Foundation
Copyright (C) 2020-2021 OpenCFD Ltd.
Copyright (C) 2020-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -38,8 +38,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef prefixOSstream_H
#define prefixOSstream_H
#ifndef Foam_prefixOSstream_H
#define Foam_prefixOSstream_H
#include "OSstream.H"
@ -143,11 +143,11 @@ public:
//- Write int64_t
virtual Ostream& write(const int64_t val);
//- Write floatScalar
virtual Ostream& write(const floatScalar val);
//- Write float
virtual Ostream& write(const float val);
//- Write doubleScalar
virtual Ostream& write(const doubleScalar val);
//- Write double
virtual Ostream& write(const double val);
//- Write binary block
virtual Ostream& write(const char* buf, std::streamsize count);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2017-2021 OpenCFD Ltd.
Copyright (C) 2017-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -530,14 +530,14 @@ Foam::Istream& Foam::ITstream::read(label&)
}
Foam::Istream& Foam::ITstream::read(floatScalar&)
Foam::Istream& Foam::ITstream::read(float&)
{
NotImplemented;
return *this;
}
Foam::Istream& Foam::ITstream::read(doubleScalar&)
Foam::Istream& Foam::ITstream::read(double&)
{
NotImplemented;
return *this;

View File

@ -304,11 +304,11 @@ public:
//- Read a label
virtual Istream& read(label&);
//- Read a floatScalar
virtual Istream& read(floatScalar&);
//- Read a float
virtual Istream& read(float&);
//- Read a doubleScalar
virtual Istream& read(doubleScalar&);
//- Read a double
virtual Istream& read(double&);
//- Read binary block
// \note Not implemented

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019-2021 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -125,7 +125,7 @@ Foam::Ostream& Foam::OTstream::write(const int64_t val)
}
Foam::Ostream& Foam::OTstream::write(const floatScalar val)
Foam::Ostream& Foam::OTstream::write(const float val)
{
append(token(val)); // tokenType::FLOAT
@ -133,7 +133,7 @@ Foam::Ostream& Foam::OTstream::write(const floatScalar val)
}
Foam::Ostream& Foam::OTstream::write(const doubleScalar val)
Foam::Ostream& Foam::OTstream::write(const double val)
{
append(token(val)); // tokenType::DOUBLE

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019-2021 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -38,8 +38,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef OTstream_H
#define OTstream_H
#ifndef Foam_OTstream_H
#define Foam_OTstream_H
#include "token.H"
#include "Ostream.H"
@ -146,11 +146,11 @@ public:
//- Write int64_t as a label
virtual Ostream& write(const int64_t val);
//- Write floatScalar
virtual Ostream& write(const floatScalar val);
//- Write float
virtual Ostream& write(const float val);
//- Write doubleScalar
virtual Ostream& write(const doubleScalar val);
//- Write double
virtual Ostream& write(const double val);
//- Write binary block with 8-byte alignment.
virtual Ostream& write(const char* data, std::streamsize count);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenFOAM Foundation
Copyright (C) 2019-2020 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -40,8 +40,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef dummyISstream_H
#define dummyISstream_H
#ifndef Foam_dummyISstream_H
#define Foam_dummyISstream_H
#include "StringStream.H"
@ -108,15 +108,15 @@ public:
return *this;
}
//- Read a floatScalar
virtual Istream& read(floatScalar&)
//- Read a float
virtual Istream& read(float&)
{
NotImplemented;
return *this;
}
//- Read a doubleScalar
virtual Istream& read(doubleScalar&)
//- Read a double
virtual Istream& read(double&)
{
NotImplemented;
return *this;

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2021 OpenCFD Ltd.
Copyright (C) 2017-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -307,8 +307,8 @@ private:
int flagVal; // bitmask - stored as int, not enum
punctuationToken punctuationVal;
label labelVal;
floatScalar floatVal;
doubleScalar doubleVal;
float floatVal;
double doubleVal;
// Pointers
word* wordPtr;
@ -365,10 +365,10 @@ public:
inline explicit token(const label val, label lineNum=0) noexcept;
//- Construct float token
inline explicit token(const floatScalar val, label lineNum=0) noexcept;
inline explicit token(const float val, label lineNum=0) noexcept;
//- Construct double token
inline explicit token(const doubleScalar val, label lineNum=0) noexcept;
inline explicit token(const double val, label lineNum=0) noexcept;
//- Copy construct word token
inline explicit token(const word& w, label lineNum=0);
@ -531,11 +531,11 @@ public:
//- Return float value.
// Report FatalIOError and return \b 0 if token is not FLOAT
inline floatScalar floatToken() const;
inline float floatToken() const;
//- Return double value.
// Report FatalIOError and return \b 0 if token is not DOUBLE
inline doubleScalar doubleToken() const;
inline double doubleToken() const;
//- Return float or double value.
// Report FatalIOError and return \b 0 if token is not a
@ -607,10 +607,10 @@ public:
inline void operator=(const label val);
//- Copy assign from float
inline void operator=(const floatScalar val);
inline void operator=(const float val);
//- Copy assign from double
inline void operator=(const doubleScalar val);
inline void operator=(const double val);
//- Copy assign from word content
inline void operator=(const word& w);
@ -636,8 +636,8 @@ public:
inline bool operator==(const token& tok) const;
inline bool operator==(const punctuationToken p) const noexcept;
inline bool operator==(const label val) const noexcept;
inline bool operator==(const floatScalar val) const noexcept;
inline bool operator==(const doubleScalar val) const noexcept;
inline bool operator==(const float val) const noexcept;
inline bool operator==(const double val) const noexcept;
inline bool operator==(const std::string& s) const;
@ -646,8 +646,8 @@ public:
inline bool operator!=(const token& tok) const;
inline bool operator!=(const punctuationToken p) const noexcept;
inline bool operator!=(const label val) const noexcept;
inline bool operator!=(const floatScalar val) const noexcept;
inline bool operator!=(const doubleScalar val) const noexcept;
inline bool operator!=(const float val) const noexcept;
inline bool operator!=(const double val) const noexcept;
inline bool operator!=(const std::string& s) const;
@ -677,11 +677,11 @@ public:
//- Return float value.
// \deprecated(2020-01) - floatToken()
floatScalar floatScalarToken() const { return floatToken(); }
float floatScalarToken() const { return floatToken(); }
//- Return double value.
// \deprecated(2020-01) - doubleToken()
doubleScalar doubleScalarToken() const { return doubleToken(); }
double doubleScalarToken() const { return doubleToken(); }
//- Deprecated(2017-11) transfer word pointer to the token
// \deprecated(2017-11) - use move assign from word

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2021 OpenCFD Ltd.
Copyright (C) 2017-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -174,7 +174,7 @@ inline Foam::token::token(const label val, label lineNum) noexcept
}
inline Foam::token::token(const floatScalar val, label lineNum) noexcept
inline Foam::token::token(const float val, label lineNum) noexcept
:
data_(),
type_(tokenType::FLOAT),
@ -184,7 +184,7 @@ inline Foam::token::token(const floatScalar val, label lineNum) noexcept
}
inline Foam::token::token(const doubleScalar val, label lineNum) noexcept
inline Foam::token::token(const double val, label lineNum) noexcept
:
data_(),
type_(tokenType::DOUBLE),
@ -528,7 +528,7 @@ inline bool Foam::token::isFloat() const noexcept
}
inline Foam::floatScalar Foam::token::floatToken() const
inline float Foam::token::floatToken() const
{
if (type_ == tokenType::FLOAT)
{
@ -546,7 +546,7 @@ inline bool Foam::token::isDouble() const noexcept
}
inline Foam::doubleScalar Foam::token::doubleToken() const
inline double Foam::token::doubleToken() const
{
if (type_ == tokenType::DOUBLE)
{
@ -817,7 +817,7 @@ inline void Foam::token::operator=(const label val)
}
inline void Foam::token::operator=(const floatScalar val)
inline void Foam::token::operator=(const float val)
{
reset();
type_ = tokenType::FLOAT;
@ -825,7 +825,7 @@ inline void Foam::token::operator=(const floatScalar val)
}
inline void Foam::token::operator=(const doubleScalar val)
inline void Foam::token::operator=(const double val)
{
reset();
type_ = tokenType::DOUBLE;
@ -955,7 +955,7 @@ inline bool Foam::token::operator==(const label val) const noexcept
}
inline bool Foam::token::operator==(const floatScalar val) const noexcept
inline bool Foam::token::operator==(const float val) const noexcept
{
return
(
@ -965,7 +965,7 @@ inline bool Foam::token::operator==(const floatScalar val) const noexcept
}
inline bool Foam::token::operator==(const doubleScalar val) const noexcept
inline bool Foam::token::operator==(const double val) const noexcept
{
return
(
@ -993,13 +993,13 @@ inline bool Foam::token::operator!=(const label val) const noexcept
}
inline bool Foam::token::operator!=(const floatScalar val) const noexcept
inline bool Foam::token::operator!=(const float val) const noexcept
{
return !operator==(val);
}
inline bool Foam::token::operator!=(const doubleScalar val) const noexcept
inline bool Foam::token::operator!=(const double val) const noexcept
{
return !operator==(val);
}

View File

@ -35,8 +35,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef doubleScalar_H
#define doubleScalar_H
#ifndef Foam_doubleScalar_H
#define Foam_doubleScalar_H
#include "scalarFwd.H"
#include "doubleFloat.H"

View File

@ -35,8 +35,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef floatScalar_H
#define floatScalar_H
#ifndef Foam_floatScalar_H
#define Foam_floatScalar_H
#include "scalarFwd.H"
#include "doubleFloat.H"

View File

@ -1,7 +1,7 @@
// Compatibility include
#ifndef doubleTensor_H
#define doubleTensor_H
#ifndef FoamCompat_doubleTensor_H
#define FoamCompat_doubleTensor_H
#include "tensor.H"

View File

@ -1,7 +1,7 @@
// Compatibility include
#ifndef floatTensor_H
#define floatTensor_H
#ifndef FoamCompat_floatTensor_H
#define FoamCompat_floatTensor_H
#include "tensor.H"

View File

@ -2460,7 +2460,7 @@ Foam::triSurface Foam::triSurfaceTools::delaunay2D(const List<vector2D>& pts)
{
// Vertices in geompack notation. Note that could probably just use
// pts.begin() if double precision.
List<doubleScalar> geompackVertices(2*pts.size());
List<double> geompackVertices(2*pts.size());
label doubleI = 0;
for (const vector2D& pt : pts)
{