STYLE: code cleanup in fileFormats, conversion

This commit is contained in:
Mark Olesen
2018-07-24 16:12:32 +02:00
parent 4a3bb8a9bc
commit 3963cd95d9
34 changed files with 229 additions and 308 deletions

View File

@ -66,7 +66,8 @@ void Foam::ensightCase::initialize()
}
else
{
Info<<"Warning: re-using existing directory" << nl
DetailInfo
<<"Warning: re-using existing directory" << nl
<< " " << ensightDir_ << endl;
}
}

View File

@ -87,7 +87,7 @@ private:
//- Case name (with ".case" ending)
word caseName_;
//- Output stream
//- Output stream (master only)
mutable OFstream* os_;
//- Track state changes since last write

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -123,12 +123,6 @@ Foam::ensightFile::ensightFile
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::ensightFile::~ensightFile()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::ensightFile::allowUndef()
@ -137,10 +131,10 @@ bool Foam::ensightFile::allowUndef()
}
bool Foam::ensightFile::allowUndef(bool value)
bool Foam::ensightFile::allowUndef(bool enabled)
{
bool old = allowUndef_;
allowUndef_ = value;
allowUndef_ = enabled;
return old;
}

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -112,7 +112,7 @@ public:
//- Destructor
~ensightFile();
~ensightFile() = default;
// Access
@ -136,12 +136,13 @@ public:
// Edit
static bool allowUndef(bool);
//- Enable/disable use of \c undef keyword and value
static bool allowUndef(bool enabled);
//- Assign the value to represent undef in the results
// Returns the previous value
// NB: do not use values larger than floatScalarVGREAT
static scalar undefValue(const scalar);
static scalar undefValue(const scalar value);
// Output
@ -150,10 +151,10 @@ public:
using Ostream::write;
//- Binary write
virtual Ostream& write(const char*, std::streamsize count);
virtual Ostream& write(const char* buf, std::streamsize count);
//- Write element keyword with trailing newline, optionally with undef
virtual Ostream& writeKeyword(const keyType&);
virtual Ostream& writeKeyword(const keyType& key);
//- Write "C Binary" for binary files (eg, geometry/measured)
Ostream& writeBinaryHeader();
@ -182,7 +183,7 @@ public:
// Convenience Output Methods
//- Begin a part (0-based index).
//- Begin a part (0-based index internally).
void beginPart(const label index);
//- Begin a "particle coordinates" block (measured data)

View File

@ -80,17 +80,11 @@ Foam::ensightGeoFile::ensightGeoFile
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::ensightGeoFile::~ensightGeoFile()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::Ostream& Foam::ensightGeoFile::writeKeyword(const keyType& key)
{
// ensure we get ensightFile::write(const string&)
// Ensure we get ensightFile::write(const string&)
write(static_cast<const string&>(key));
newline();

View File

@ -91,7 +91,7 @@ public:
//- Destructor
~ensightGeoFile();
~ensightGeoFile() = default;
// Output
@ -102,6 +102,7 @@ public:
// Convenience Output Methods
//- Begin a part (0-based index).
using ensightFile::beginPart;
//- Begin a "part" (0-based index), with a description.

View File

@ -65,25 +65,25 @@ public:
// Constructors
//- Construct as copy
inline explicit FileName(const FileName&);
//- Copy construct
inline FileName(const FileName& fn);
//- Construct as copy of character array
inline explicit FileName(const char*);
inline explicit FileName(const char* s);
//- Construct as copy of std::string
inline explicit FileName(const std::string&);
inline explicit FileName(const std::string& s);
// Member functions
//- Is this character valid for an ensight file-name
inline static bool valid(char);
inline static bool valid(char c);
// Member operators
// Member Operators
// Assignment (disabled)
// Assignment (disabled)
void operator=(const fileName&) = delete;
void operator=(const word&) = delete;

View File

@ -67,25 +67,26 @@ public:
// Constructors
//- Construct as copy
inline explicit VarName(const VarName&);
//- Copy construct
inline VarName(const VarName& vn);
//- Construct as copy of character array
inline explicit VarName(const char*);
inline explicit VarName(const char* s);
//- Construct as copy of std::string
inline explicit VarName(const std::string&);
inline explicit VarName(const std::string& s);
// Member functions
// Member Functions
//- Is this character valid for an ensight var-name
inline static bool valid(char);
inline static bool valid(char c);
// Member operators
// Member Operators
// Assignment (disabled)
// Assignment (disabled)
void operator=(const word&) = delete;
void operator=(const string&) = delete;
void operator=(const std::string&) = delete;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -30,8 +30,6 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
const Foam::label Foam::ensightCells::nTypes = 5;
const char* Foam::ensightCells::elemNames[5] =
{ "tetra4", "pyramid5", "penta6", "hexa8", "nfaced" };
@ -62,6 +60,12 @@ void Foam::ensightCells::resizeAll()
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::ensightCells::ensightCells()
:
ensightCells(0)
{}
Foam::ensightCells::ensightCells(const label partIndex)
:
index_(partIndex),
@ -93,12 +97,6 @@ Foam::ensightCells::ensightCells(const ensightCells& obj)
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::ensightCells::~ensightCells()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::FixedList<Foam::label, 5> Foam::ensightCells::sizes() const

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -41,6 +41,7 @@ Description
namespace Foam
{
// Forward declarations
class polyMesh;
/*---------------------------------------------------------------------------*\
@ -64,7 +65,7 @@ public:
};
//- Number of element types (5)
static const label nTypes;
static constexpr label nTypes = 5;
//- The ensight element type names
static const char* elemNames[5];
@ -108,15 +109,18 @@ public:
// Constructors
//- Construct null, optionally with index
ensightCells(label partIndex = 0);
//- Construct null, with part index 0
ensightCells();
//- Construct null, with specified part index
explicit ensightCells(const label partIndex);
//- Copy constructor. Needed for lists etc.
ensightCells(const ensightCells& obj);
//- Destructor
~ensightCells();
~ensightCells() = default;
// Member Functions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -30,8 +30,6 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
const Foam::label Foam::ensightFaces::nTypes = 3;
const char* Foam::ensightFaces::elemNames[3] =
{ "tria3", "quad4", "nsided" };
@ -101,7 +99,13 @@ void Foam::ensightFaces::resizeAll()
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::ensightFaces::ensightFaces(label partIndex)
Foam::ensightFaces::ensightFaces()
:
ensightFaces(0)
{}
Foam::ensightFaces::ensightFaces(const label partIndex)
:
index_(partIndex),
address_(),
@ -134,12 +138,6 @@ Foam::ensightFaces::ensightFaces(const ensightFaces& obj)
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::ensightFaces::~ensightFaces()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::FixedList<Foam::label, 3> Foam::ensightFaces::sizes() const

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -62,7 +62,7 @@ public:
};
//- Number of element types (3)
static const label nTypes;
static constexpr label nTypes = 3;
//- The ensight element type names
static const char* elemNames[3];
@ -115,15 +115,18 @@ public:
// Constructors
//- Construct null, optionally with index
ensightFaces(label partIndex = 0);
//- Construct null, with part index 0
ensightFaces();
//- Construct null, with specified part index
explicit ensightFaces(const label partIndex);
//- Copy constructor. Needed for lists etc.
ensightFaces(const ensightFaces& obj);
//- Destructor
~ensightFaces();
~ensightFaces() = default;
// Member Functions

View File

@ -37,12 +37,6 @@ Foam::ensightReadFile::ensightReadFile
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::ensightReadFile::~ensightReadFile()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::Istream& Foam::ensightReadFile::read

View File

@ -62,7 +62,7 @@ public:
// Constructors
//- Construct from pathname
//- Construct from pathname. Default format is binary.
ensightReadFile
(
const fileName& pathname,
@ -71,7 +71,7 @@ public:
//- Destructor
~ensightReadFile();
~ensightReadFile() = default;
// Output

View File

@ -76,7 +76,7 @@ public:
appendBase64Formatter(std::ostream& os);
//- Destructor
//- Destructor. Closes/flushes the underlying layer.
virtual ~appendBase64Formatter();

View File

@ -55,12 +55,6 @@ Foam::vtk::appendRawFormatter::appendRawFormatter(std::ostream& os)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::vtk::appendRawFormatter::~appendRawFormatter()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
const Foam::vtk::outputOptions&

View File

@ -85,7 +85,7 @@ public:
//- Destructor
virtual ~appendRawFormatter();
virtual ~appendRawFormatter() = default;
// Member Functions

View File

@ -90,7 +90,7 @@ public:
asciiFormatter(std::ostream& os, unsigned precision);
//- Destructor
//- Destructor. Finishes the output line as required.
virtual ~asciiFormatter();

View File

@ -74,7 +74,7 @@ public:
base64Formatter(std::ostream& os);
//- Destructor
//- Destructor. Closes/flushes the underlying layer.
virtual ~base64Formatter();

View File

@ -80,7 +80,7 @@ protected:
public:
//- Destructor
//- Destructor. Closes/flushes the underlying layer
virtual ~foamVtkBase64Layer();

View File

@ -55,12 +55,6 @@ Foam::vtk::legacyAsciiFormatter::legacyAsciiFormatter
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::vtk::legacyAsciiFormatter::~legacyAsciiFormatter()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
const Foam::vtk::outputOptions&

View File

@ -80,7 +80,7 @@ public:
//- Destructor
virtual ~legacyAsciiFormatter();
virtual ~legacyAsciiFormatter() = default;
// Member Functions

View File

@ -58,12 +58,6 @@ Foam::vtk::legacyRawFormatter::legacyRawFormatter
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::vtk::legacyRawFormatter::~legacyRawFormatter()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
const Foam::vtk::outputOptions&

View File

@ -87,7 +87,7 @@ public:
//- Destructor
virtual ~legacyRawFormatter();
virtual ~legacyRawFormatter() = default;
// Member Functions

View File

@ -92,7 +92,7 @@ public:
// Member Functions
// Access
// Access
//- The output format type
inline formatType fmt() const;
@ -116,7 +116,7 @@ public:
inline unsigned precision() const;
// Edit
// Edit
//- Toggle ASCII mode on/off.
// In XML append mode, this switches between base64 and raw binary.

View File

@ -376,18 +376,10 @@ void Foam::vtkUnstructuredReader::readField
case VTK_ULONG:
case VTK_ID:
{
autoPtr<labelIOField> fieldVals
auto fieldVals = autoPtr<labelIOField>::New
(
new labelIOField
(
IOobject
(
arrayName,
"",
obj
),
size
)
IOobject(arrayName, "", obj),
size
);
readBlock(inFile, fieldVals().size(), fieldVals());
regIOobject::store(fieldVals);
@ -397,18 +389,10 @@ void Foam::vtkUnstructuredReader::readField
case VTK_FLOAT:
case VTK_DOUBLE:
{
autoPtr<scalarIOField> fieldVals
auto fieldVals = autoPtr<scalarIOField>::New
(
new scalarIOField
(
IOobject
(
arrayName,
"",
obj
),
size
)
IOobject(arrayName, "", obj),
size
);
readBlock(inFile, fieldVals().size(), fieldVals());
regIOobject::store(fieldVals);
@ -421,18 +405,10 @@ void Foam::vtkUnstructuredReader::readField
{
Info<< "Reading strings:" << size << endl;
}
autoPtr<stringIOList> fieldVals
auto fieldVals = autoPtr<stringIOList>::New
(
new stringIOList
(
IOobject
(
arrayName,
"",
obj
),
size
)
IOobject(arrayName, "", obj),
size
);
// Consume current line.
inFile.getLine(fieldVals()[0]);
@ -536,10 +512,8 @@ Foam::objectRegistry& Foam::vtkUnstructuredReader::selectRegistry
{
return pointData_;
}
else
{
return otherData_;
}
return otherData_;
}
@ -827,18 +801,10 @@ void Foam::vtkUnstructuredReader::read(ISstream& inFile)
objectRegistry::iterator iter = reg.find(dataName);
scalarField s(*dynamic_cast<const scalarField*>(iter()));
reg.erase(iter);
autoPtr<vectorIOField> fieldVals
auto fieldVals = autoPtr<vectorIOField>::New
(
new vectorIOField
(
IOobject
(
dataName,
"",
reg
),
s.size()/3
)
IOobject(dataName, "", reg),
s.size()/3
);
label elemI = 0;

View File

@ -163,7 +163,7 @@ private:
(
Istream& inFile,
const label n,
List<T>& lst
List<T>& list
) const;
void warnUnhandledType

View File

@ -37,13 +37,13 @@ void Foam::vtkUnstructuredReader::readBlock
(
Istream& inFile,
const label n,
List<T>& lst
List<T>& list
) const
{
lst.setSize(n);
forAll(lst, i)
list.setSize(n);
forAll(list, i)
{
inFile >> lst[i];
inFile >> list[i];
}
}
@ -59,13 +59,14 @@ void Foam::vtkUnstructuredReader::printFieldStats
if (fieldNames.size())
{
Info<< "Read " << fieldNames.size() << " " << Type::typeName
<< " fields:" << endl;
Info<< "Size\tName" << nl
<< " fields:" << nl
<< "Size\tName" << nl
<< "----\t----" << endl;
forAll(fieldNames, i)
for (const word& fieldName : fieldNames)
{
Info<< obj.lookupObject<Type>(fieldNames[i]).size()
<< "\t" << fieldNames[i]
Info<< obj.lookupObject<Type>(fieldName).size()
<< "\t" << fieldName
<< endl;
}
Info<< endl;