mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: consolidate arch and version strings (issue #513)
- make some IOobject writing routines non-templated. - relocate more IOobject methods into the IOobjectI.H (generally cleanup the main header).
This commit is contained in:
@ -45,6 +45,7 @@ Description
|
|||||||
#include "fvMesh.H"
|
#include "fvMesh.H"
|
||||||
#include "cellModeller.H"
|
#include "cellModeller.H"
|
||||||
#include "globalFoam.H"
|
#include "globalFoam.H"
|
||||||
|
#include "foamVersion.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|||||||
@ -351,6 +351,12 @@ const Foam::Time& Foam::IOobject::time() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const Foam::fileName& Foam::IOobject::rootPath() const
|
||||||
|
{
|
||||||
|
return time().rootPath();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const Foam::fileName& Foam::IOobject::caseName() const
|
const Foam::fileName& Foam::IOobject::caseName() const
|
||||||
{
|
{
|
||||||
return time().caseName();
|
return time().caseName();
|
||||||
@ -387,12 +393,6 @@ Foam::word Foam::IOobject::member() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const Foam::fileName& Foam::IOobject::rootPath() const
|
|
||||||
{
|
|
||||||
return time().rootPath();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Foam::fileName Foam::IOobject::path() const
|
Foam::fileName Foam::IOobject::path() const
|
||||||
{
|
{
|
||||||
if (instance().isAbsolute())
|
if (instance().isAbsolute())
|
||||||
@ -617,6 +617,8 @@ void Foam::IOobject::setBad(const string& s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::IOobject::operator=(const IOobject& io)
|
void Foam::IOobject::operator=(const IOobject& io)
|
||||||
{
|
{
|
||||||
name_ = io.name_;
|
name_ = io.name_;
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -191,6 +191,12 @@ public:
|
|||||||
TypeName("IOobject");
|
TypeName("IOobject");
|
||||||
|
|
||||||
|
|
||||||
|
// Static data members
|
||||||
|
|
||||||
|
//- Type of file modification checking
|
||||||
|
static fileCheckTypes fileModificationChecking;
|
||||||
|
|
||||||
|
|
||||||
// Static Member Functions
|
// Static Member Functions
|
||||||
|
|
||||||
//- Split path into instance, local, name components
|
//- Split path into instance, local, name components
|
||||||
@ -202,11 +208,9 @@ public:
|
|||||||
word& name
|
word& name
|
||||||
);
|
);
|
||||||
|
|
||||||
template<class Name>
|
//- Create dot-delimited name.group
|
||||||
static inline word groupName(Name name, const word& group);
|
template<class StringType>
|
||||||
|
static inline word groupName(StringType name, const word& group);
|
||||||
//- Type of file modification checking
|
|
||||||
static fileCheckTypes fileModificationChecking;
|
|
||||||
|
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
@ -280,214 +284,162 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
// General access
|
// General access
|
||||||
|
|
||||||
//- Return time
|
//- Return the local objectRegistry
|
||||||
const Time& time() const;
|
const objectRegistry& db() const;
|
||||||
|
|
||||||
//- Return the local objectRegistry
|
//- Return time
|
||||||
const objectRegistry& db() const;
|
const Time& time() const;
|
||||||
|
|
||||||
//- Return name
|
//- Return name
|
||||||
const word& name() const
|
inline const word& name() const;
|
||||||
{
|
|
||||||
return name_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Return name of the class name read from header
|
//- Return name of the class name read from header
|
||||||
const word& headerClassName() const
|
inline const word& headerClassName() const;
|
||||||
{
|
|
||||||
return headerClassName_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Return non-constant access to the optional note
|
//- Return the optional note
|
||||||
string& note()
|
inline const string& note() const;
|
||||||
{
|
|
||||||
return note_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Return the optional note
|
//- Return non-constant access to the optional note
|
||||||
const string& note() const
|
inline string& note();
|
||||||
{
|
|
||||||
return note_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Rename
|
//- Rename
|
||||||
virtual void rename(const word& newName)
|
virtual void rename(const word& newName)
|
||||||
{
|
{
|
||||||
name_ = newName;
|
name_ = newName;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Register object created from this IOobject with registry if true
|
//- Register object created from this IOobject with registry if true
|
||||||
bool& registerObject()
|
inline bool registerObject() const;
|
||||||
{
|
|
||||||
return registerObject_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Register object created from this IOobject with registry if true
|
//- Register object created from this IOobject with registry if true
|
||||||
bool registerObject() const
|
inline bool& registerObject();
|
||||||
{
|
|
||||||
return registerObject_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Is object same for all processors
|
//- Is object same for all processors
|
||||||
bool& globalObject()
|
inline bool globalObject() const;
|
||||||
{
|
|
||||||
return globalObject_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Is object same for all processors
|
//- Is object same for all processors
|
||||||
bool globalObject() const
|
inline bool& globalObject();
|
||||||
{
|
|
||||||
return globalObject_;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Read/write options
|
// Read/write options
|
||||||
|
|
||||||
readOption readOpt() const
|
//- The read option
|
||||||
{
|
inline readOption readOpt() const;
|
||||||
return rOpt_;
|
|
||||||
}
|
|
||||||
|
|
||||||
readOption& readOpt()
|
//- Non-constant access to the read option
|
||||||
{
|
inline readOption& readOpt();
|
||||||
return rOpt_;
|
|
||||||
}
|
|
||||||
|
|
||||||
writeOption writeOpt() const
|
//- The write option
|
||||||
{
|
inline writeOption writeOpt() const;
|
||||||
return wOpt_;
|
|
||||||
}
|
|
||||||
|
|
||||||
writeOption& writeOpt()
|
//- Non-constant access to the write option
|
||||||
{
|
inline writeOption& writeOpt();
|
||||||
return wOpt_;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Path components
|
// Path components
|
||||||
|
|
||||||
//- Return group (extension part of name)
|
//- Return group (extension part of name)
|
||||||
word group() const;
|
word group() const;
|
||||||
|
|
||||||
//- Return member (name without the extension)
|
//- Return member (name without the extension)
|
||||||
word member() const;
|
word member() const;
|
||||||
|
|
||||||
const fileName& rootPath() const;
|
const fileName& rootPath() const;
|
||||||
|
|
||||||
const fileName& caseName() const;
|
const fileName& caseName() const;
|
||||||
|
|
||||||
const fileName& instance() const
|
inline const fileName& instance() const;
|
||||||
{
|
|
||||||
return instance_;
|
|
||||||
}
|
|
||||||
|
|
||||||
fileName& instance()
|
inline fileName& instance();
|
||||||
{
|
|
||||||
return instance_;
|
|
||||||
}
|
|
||||||
|
|
||||||
const fileName& local() const
|
inline const fileName& local() const;
|
||||||
{
|
|
||||||
return local_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Return complete path
|
//- Return complete path
|
||||||
fileName path() const;
|
fileName path() const;
|
||||||
|
|
||||||
//- Return complete path with alternative instance and local
|
//- Return complete path with alternative instance and local
|
||||||
fileName path
|
fileName path
|
||||||
(
|
(
|
||||||
const word& instance,
|
const word& instance,
|
||||||
const fileName& local = fileName::null
|
const fileName& local = fileName::null
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Return complete path + object name
|
//- Return complete path + object name
|
||||||
fileName objectPath() const
|
inline fileName objectPath() const;
|
||||||
{
|
|
||||||
return path()/name();
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Helper for filePath that searches locally.
|
//- Helper for filePath that searches locally.
|
||||||
// When search is false, simply use the current instance,
|
// When search is false, simply use the current instance,
|
||||||
// otherwise search previous instances.
|
// otherwise search previous instances.
|
||||||
fileName localFilePath(const bool search=true) const;
|
fileName localFilePath(const bool search=true) const;
|
||||||
|
|
||||||
//- Helper for filePath that searches up if in parallel
|
//- Helper for filePath that searches up if in parallel
|
||||||
// When search is false, simply use the current instance,
|
// When search is false, simply use the current instance,
|
||||||
// otherwise search previous instances.
|
// otherwise search previous instances.
|
||||||
fileName globalFilePath(const bool search=true) const;
|
fileName globalFilePath(const bool search=true) const;
|
||||||
|
|
||||||
|
|
||||||
// Reading
|
// Reading
|
||||||
|
|
||||||
//- Read header
|
//- Read header
|
||||||
bool readHeader(Istream&);
|
bool readHeader(Istream& is);
|
||||||
|
|
||||||
//- Read header (uses typeFilePath to find file) and check its info.
|
//- Read header (uses typeFilePath to find file) and check its info.
|
||||||
// Optionally checks headerClassName against the type-name.
|
// Optionally checks headerClassName against the type-name.
|
||||||
// When search is false, simply use the current instance,
|
// When search is false, simply use the current instance,
|
||||||
// otherwise search previous instances.
|
// otherwise search previous instances.
|
||||||
template<class Type>
|
template<class Type>
|
||||||
bool typeHeaderOk
|
bool typeHeaderOk
|
||||||
(
|
(
|
||||||
const bool checkType = true,
|
const bool checkType = true,
|
||||||
const bool search = true
|
const bool search = true
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Helper: warn that type does not support re-reading
|
//- Helper: warn that type does not support re-reading
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void warnNoRereading() const;
|
void warnNoRereading() const;
|
||||||
|
|
||||||
// Writing
|
|
||||||
|
|
||||||
//- Write the standard OpenFOAM file/dictionary banner
|
|
||||||
// Optionally without -*- C++ -*- editor hint (eg, for logs)
|
|
||||||
template<class Stream>
|
|
||||||
static inline Stream& writeBanner(Stream& os, bool noHint=false);
|
|
||||||
|
|
||||||
//- Write the standard file section divider
|
|
||||||
template<class Stream>
|
|
||||||
static inline Stream& writeDivider(Stream& os);
|
|
||||||
|
|
||||||
//- Write the standard end file divider
|
|
||||||
template<class Stream>
|
|
||||||
static inline Stream& writeEndDivider(Stream& os);
|
|
||||||
|
|
||||||
//- Write header
|
|
||||||
bool writeHeader(Ostream&) const;
|
|
||||||
|
|
||||||
//- Write header. Allow override of type
|
|
||||||
bool writeHeader(Ostream&, const word& objectType) const;
|
|
||||||
|
|
||||||
|
|
||||||
// Error Handling
|
// Writing
|
||||||
|
|
||||||
bool good() const
|
//- Write the standard OpenFOAM file/dictionary banner
|
||||||
{
|
// Optionally without -*- C++ -*- editor hint (eg, for logs)
|
||||||
return objState_ == GOOD;
|
static Ostream& writeBanner(Ostream& os, bool noHint=false);
|
||||||
}
|
|
||||||
|
|
||||||
bool bad() const
|
//- Write the standard file section divider
|
||||||
{
|
static Ostream& writeDivider(Ostream& os);
|
||||||
return objState_ == BAD;
|
|
||||||
}
|
//- Write the standard end file divider
|
||||||
|
static Ostream& writeEndDivider(Ostream& os);
|
||||||
|
|
||||||
|
//- Write header
|
||||||
|
bool writeHeader(Ostream& os) const;
|
||||||
|
|
||||||
|
//- Write header. Allow override of type
|
||||||
|
bool writeHeader(Ostream& os, const word& objectType) const;
|
||||||
|
|
||||||
|
|
||||||
// Info
|
// Error Handling
|
||||||
|
|
||||||
//- Return info proxy.
|
inline bool good() const;
|
||||||
// Used to print token information to a stream
|
|
||||||
InfoProxy<IOobject> info() const
|
inline bool bad() const;
|
||||||
{
|
|
||||||
return *this;
|
|
||||||
}
|
// Info
|
||||||
|
|
||||||
|
//- Return info proxy.
|
||||||
|
// Used to print token information to a stream
|
||||||
|
InfoProxy<IOobject> info() const
|
||||||
|
{
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Member operators
|
// Member operators
|
||||||
|
|
||||||
void operator=(const IOobject&);
|
void operator=(const IOobject& io);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -23,95 +23,137 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "foamVersion.H"
|
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
template<class StringType>
|
||||||
|
inline Foam::word Foam::IOobject::groupName(StringType name, const word& group)
|
||||||
template<class Name>
|
|
||||||
inline Foam::word Foam::IOobject::groupName(Name name, const word& group)
|
|
||||||
{
|
{
|
||||||
if (group != word::null)
|
if (group.empty())
|
||||||
{
|
|
||||||
return name + ('.' + group);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Stream>
|
|
||||||
inline Stream& Foam::IOobject::writeBanner(Stream& os, bool noHint)
|
|
||||||
{
|
|
||||||
static bool spacesSet(false);
|
|
||||||
static char spaces[40];
|
|
||||||
|
|
||||||
if (!spacesSet)
|
|
||||||
{
|
|
||||||
memset(spaces, ' ', 40);
|
|
||||||
|
|
||||||
size_t len = strlen(Foam::FOAMversion);
|
|
||||||
if (len < 38)
|
|
||||||
{
|
|
||||||
spaces[38 - len] = '\0';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
spaces[0] = '\0';
|
|
||||||
}
|
|
||||||
spacesSet = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (noHint)
|
|
||||||
{
|
|
||||||
os <<
|
|
||||||
"/*--------------------------------------"
|
|
||||||
"-------------------------------------*\\\n";
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
os <<
|
return name + ('.' + group);
|
||||||
"/*--------------------------------*- C++ "
|
|
||||||
"-*----------------------------------*\\\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
os <<
|
|
||||||
"| ========= |"
|
|
||||||
" |\n"
|
|
||||||
"| \\\\ / F ield |"
|
|
||||||
" OpenFOAM: The Open Source CFD Toolbox |\n"
|
|
||||||
"| \\\\ / O peration |"
|
|
||||||
" Version: " << FOAMversion << spaces << "|\n"
|
|
||||||
"| \\\\ / A nd |"
|
|
||||||
" Web: www.OpenFOAM.com |\n"
|
|
||||||
"| \\\\/ M anipulation |"
|
|
||||||
" |\n"
|
|
||||||
"\\*-----------------------------------------"
|
|
||||||
"----------------------------------*/\n";
|
|
||||||
|
|
||||||
return os;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Stream>
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
inline Stream& Foam::IOobject::writeDivider(Stream& os)
|
|
||||||
{
|
|
||||||
os <<
|
|
||||||
"// * * * * * * * * * * * * * * * * * "
|
|
||||||
"* * * * * * * * * * * * * * * * * * * * //\n";
|
|
||||||
|
|
||||||
return os;
|
// General access
|
||||||
|
|
||||||
|
inline const Foam::word& Foam::IOobject::name() const
|
||||||
|
{
|
||||||
|
return name_;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class Stream>
|
|
||||||
inline Stream& Foam::IOobject::writeEndDivider(Stream& os)
|
|
||||||
{
|
|
||||||
os << "\n\n"
|
|
||||||
"// *****************************************"
|
|
||||||
"******************************** //\n";
|
|
||||||
|
|
||||||
return os;
|
inline const Foam::word& Foam::IOobject::headerClassName() const
|
||||||
|
{
|
||||||
|
return headerClassName_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline const Foam::string& Foam::IOobject::note() const
|
||||||
|
{
|
||||||
|
return note_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::string& Foam::IOobject::note()
|
||||||
|
{
|
||||||
|
return note_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline bool Foam::IOobject::registerObject() const
|
||||||
|
{
|
||||||
|
return registerObject_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline bool& Foam::IOobject::registerObject()
|
||||||
|
{
|
||||||
|
return registerObject_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline bool Foam::IOobject::globalObject() const
|
||||||
|
{
|
||||||
|
return globalObject_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline bool& Foam::IOobject::globalObject()
|
||||||
|
{
|
||||||
|
return globalObject_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Read/write options
|
||||||
|
|
||||||
|
inline Foam::IOobject::readOption Foam::IOobject::readOpt() const
|
||||||
|
{
|
||||||
|
return rOpt_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::IOobject::readOption& Foam::IOobject::readOpt()
|
||||||
|
{
|
||||||
|
return rOpt_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::IOobject::writeOption Foam::IOobject::writeOpt() const
|
||||||
|
{
|
||||||
|
return wOpt_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::IOobject::writeOption& Foam::IOobject::writeOpt()
|
||||||
|
{
|
||||||
|
return wOpt_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Path components
|
||||||
|
|
||||||
|
inline const Foam::fileName& Foam::IOobject::instance() const
|
||||||
|
{
|
||||||
|
return instance_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::fileName& Foam::IOobject::instance()
|
||||||
|
{
|
||||||
|
return instance_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline const Foam::fileName& Foam::IOobject::local() const
|
||||||
|
{
|
||||||
|
return local_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::fileName Foam::IOobject::objectPath() const
|
||||||
|
{
|
||||||
|
return path()/name();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Error Handling
|
||||||
|
|
||||||
|
inline bool Foam::IOobject::good() const
|
||||||
|
{
|
||||||
|
return objState_ == GOOD;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline bool Foam::IOobject::bad() const
|
||||||
|
{
|
||||||
|
return objState_ == BAD;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -116,9 +116,8 @@ void Foam::IOobject::warnNoRereading() const
|
|||||||
{
|
{
|
||||||
WarningInFunction
|
WarningInFunction
|
||||||
<< Type::typeName << ' ' << name()
|
<< Type::typeName << ' ' << name()
|
||||||
<< " constructed with IOobject::MUST_READ_IF_MODIFIED"
|
<< " constructed with IOobject::MUST_READ_IF_MODIFIED but "
|
||||||
" but " << Type::typeName
|
<< Type::typeName << " does not support automatic rereading."
|
||||||
<< " does not support automatic rereading."
|
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -29,29 +29,91 @@ Description
|
|||||||
|
|
||||||
#include "IOobject.H"
|
#include "IOobject.H"
|
||||||
#include "objectRegistry.H"
|
#include "objectRegistry.H"
|
||||||
#include "endian.H"
|
#include "foamVersion.H"
|
||||||
#include "label.H"
|
|
||||||
#include "scalar.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
// file-scope
|
// A banner corresponding to this:
|
||||||
// Hint about machine endian, OpenFOAM label and scalar sizes
|
//
|
||||||
static const std::string archHint =
|
/*--------------------------------*- C++ -*----------------------------------*\
|
||||||
(
|
| ========= | |
|
||||||
#ifdef WM_LITTLE_ENDIAN
|
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||||
"LSB"
|
| \\ / O peration | Version: VERSION |
|
||||||
#elif defined (WM_BIG_ENDIAN)
|
| \\ / A nd | Web: www.OpenFOAM.com |
|
||||||
"MSB"
|
| \\/ M anipulation | |
|
||||||
#else
|
\*---------------------------------------------------------------------------*/
|
||||||
"???"
|
|
||||||
#endif
|
Foam::Ostream& Foam::IOobject::writeBanner(Ostream& os, bool noHint)
|
||||||
";label=" + std::to_string(8*sizeof(Foam::label))
|
{
|
||||||
+ ";scalar=" + std::to_string(8*sizeof(Foam::scalar))
|
// The version padded with spaces to fit after "Version: "
|
||||||
);
|
// - initialized with zero-length string to detect if it has been populated
|
||||||
|
static char paddedVersion[39] = "";
|
||||||
|
|
||||||
|
if (!*paddedVersion)
|
||||||
|
{
|
||||||
|
// Populate: like strncpy but without trailing '\0'
|
||||||
|
const char *p = Foam::FOAMversion;
|
||||||
|
|
||||||
|
memset(paddedVersion, ' ', 38);
|
||||||
|
for (int i = 0; *p && i < 38; ++i)
|
||||||
|
{
|
||||||
|
paddedVersion[i] = *p++;
|
||||||
|
}
|
||||||
|
paddedVersion[38] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
os <<
|
||||||
|
"/*--------------------------------";
|
||||||
|
|
||||||
|
if (noHint)
|
||||||
|
{
|
||||||
|
// Without syntax hint
|
||||||
|
os << "---------";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// With syntax hint
|
||||||
|
os << "*- C++ -*";
|
||||||
|
}
|
||||||
|
|
||||||
|
os <<
|
||||||
|
"----------------------------------*\\\n"
|
||||||
|
"| ========= |"
|
||||||
|
" |\n"
|
||||||
|
"| \\\\ / F ield |"
|
||||||
|
" OpenFOAM: The Open Source CFD Toolbox |\n"
|
||||||
|
"| \\\\ / O peration |"
|
||||||
|
" Version: " << paddedVersion << "|\n"
|
||||||
|
"| \\\\ / A nd |"
|
||||||
|
" Web: www.OpenFOAM.com |\n"
|
||||||
|
"| \\\\/ M anipulation |"
|
||||||
|
" |\n"
|
||||||
|
"\\*-----------------------------------------"
|
||||||
|
"----------------------------------*/\n";
|
||||||
|
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
Foam::Ostream& Foam::IOobject::writeDivider(Ostream& os)
|
||||||
|
{
|
||||||
|
os <<
|
||||||
|
"// * * * * * * * * * * * * * * * * * "
|
||||||
|
"* * * * * * * * * * * * * * * * * * * * //\n";
|
||||||
|
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::Ostream& Foam::IOobject::writeEndDivider(Ostream& os)
|
||||||
|
{
|
||||||
|
os << "\n\n"
|
||||||
|
"// *****************************************"
|
||||||
|
"******************************** //\n";
|
||||||
|
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Foam::IOobject::writeHeader(Ostream& os, const word& type) const
|
bool Foam::IOobject::writeHeader(Ostream& os, const word& type) const
|
||||||
{
|
{
|
||||||
@ -72,7 +134,7 @@ bool Foam::IOobject::writeHeader(Ostream& os, const word& type) const
|
|||||||
|
|
||||||
if (os.format() == IOstream::BINARY)
|
if (os.format() == IOstream::BINARY)
|
||||||
{
|
{
|
||||||
os << " arch " << archHint << ";\n";
|
os << " arch " << Foam::FOAMbuildArch << ";\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!note().empty())
|
if (!note().empty())
|
||||||
|
|||||||
@ -37,7 +37,7 @@ License
|
|||||||
#include "sigInt.H"
|
#include "sigInt.H"
|
||||||
#include "sigQuit.H"
|
#include "sigQuit.H"
|
||||||
#include "sigSegv.H"
|
#include "sigSegv.H"
|
||||||
#include "endian.H"
|
#include "foamVersion.H"
|
||||||
|
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
|
|
||||||
@ -54,22 +54,6 @@ Foam::string::size_type Foam::argList::usageMin = 20;
|
|||||||
Foam::string::size_type Foam::argList::usageMax = 80;
|
Foam::string::size_type Foam::argList::usageMax = 80;
|
||||||
Foam::word Foam::argList::postProcessOptionName("postProcess");
|
Foam::word Foam::argList::postProcessOptionName("postProcess");
|
||||||
|
|
||||||
// file-scope
|
|
||||||
// Hint about machine endian, OpenFOAM label and scalar sizes
|
|
||||||
static const std::string archHint =
|
|
||||||
(
|
|
||||||
#ifdef WM_LITTLE_ENDIAN
|
|
||||||
"LSB"
|
|
||||||
#elif defined (WM_BIG_ENDIAN)
|
|
||||||
"MSB"
|
|
||||||
#else
|
|
||||||
"???"
|
|
||||||
#endif
|
|
||||||
";label=" + std::to_string(8*sizeof(Foam::label))
|
|
||||||
+ ";scalar=" + std::to_string(8*sizeof(Foam::scalar))
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
Foam::argList::initValidTables::initValidTables()
|
Foam::argList::initValidTables::initValidTables()
|
||||||
{
|
{
|
||||||
argList::addOption
|
argList::addOption
|
||||||
@ -639,7 +623,7 @@ void Foam::argList::parse
|
|||||||
{
|
{
|
||||||
IOobject::writeBanner(Info, true)
|
IOobject::writeBanner(Info, true)
|
||||||
<< "Build : " << Foam::FOAMbuild << nl
|
<< "Build : " << Foam::FOAMbuild << nl
|
||||||
<< "Arch : " << archHint << nl
|
<< "Arch : " << Foam::FOAMbuildArch << nl
|
||||||
<< "Exec : " << argListStr_.c_str() << nl
|
<< "Exec : " << argListStr_.c_str() << nl
|
||||||
<< "Date : " << dateString.c_str() << nl
|
<< "Date : " << dateString.c_str() << nl
|
||||||
<< "Time : " << timeString.c_str() << nl
|
<< "Time : " << timeString.c_str() << nl
|
||||||
@ -650,7 +634,7 @@ void Foam::argList::parse
|
|||||||
jobInfo.add("startDate", dateString);
|
jobInfo.add("startDate", dateString);
|
||||||
jobInfo.add("startTime", timeString);
|
jobInfo.add("startTime", timeString);
|
||||||
jobInfo.add("userName", userName());
|
jobInfo.add("userName", userName());
|
||||||
jobInfo.add("foamVersion", word(FOAMversion));
|
jobInfo.add("foamVersion", word(Foam::FOAMversion));
|
||||||
jobInfo.add("code", executable_);
|
jobInfo.add("code", executable_);
|
||||||
jobInfo.add("argList", argListStr_);
|
jobInfo.add("argList", argListStr_);
|
||||||
jobInfo.add("currentDir", cwd());
|
jobInfo.add("currentDir", cwd());
|
||||||
@ -660,10 +644,10 @@ void Foam::argList::parse
|
|||||||
// Add build information - only use the first word
|
// Add build information - only use the first word
|
||||||
{
|
{
|
||||||
std::string build(Foam::FOAMbuild);
|
std::string build(Foam::FOAMbuild);
|
||||||
std::string::size_type found = build.find(' ');
|
std::string::size_type space = build.find(' ');
|
||||||
if (found != std::string::npos)
|
if (space != std::string::npos)
|
||||||
{
|
{
|
||||||
build.resize(found);
|
build.resize(space);
|
||||||
}
|
}
|
||||||
jobInfo.add("foamBuild", build);
|
jobInfo.add("foamBuild", build);
|
||||||
}
|
}
|
||||||
@ -1247,7 +1231,7 @@ void Foam::argList::printUsage() const
|
|||||||
<<"Using: OpenFOAM-" << Foam::FOAMversion
|
<<"Using: OpenFOAM-" << Foam::FOAMversion
|
||||||
<< " (see www.OpenFOAM.com)" << nl
|
<< " (see www.OpenFOAM.com)" << nl
|
||||||
<< "Build: " << Foam::FOAMbuild << nl
|
<< "Build: " << Foam::FOAMbuild << nl
|
||||||
<< "Arch: " << archHint << nl
|
<< "Arch: " << Foam::FOAMbuildArch << nl
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -32,13 +32,20 @@ Global
|
|||||||
Foam::FOAMversion
|
Foam::FOAMversion
|
||||||
|
|
||||||
Description
|
Description
|
||||||
OpenFOAM version number static string.
|
OpenFOAM version number as a static string.
|
||||||
|
|
||||||
Global
|
Global
|
||||||
Foam::FOAMbuild
|
Foam::FOAMbuild
|
||||||
|
|
||||||
Description
|
Description
|
||||||
OpenFOAM version number static string with build information
|
OpenFOAM build information as a static string
|
||||||
|
|
||||||
|
Global
|
||||||
|
Foam::FOAMbuildArch
|
||||||
|
|
||||||
|
Description
|
||||||
|
OpenFOAM build architecture information (endian, label/scalar sizes)
|
||||||
|
as a static string
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
global.Cver
|
global.Cver
|
||||||
@ -48,6 +55,8 @@ SourceFiles
|
|||||||
#ifndef foamVersion_H
|
#ifndef foamVersion_H
|
||||||
#define foamVersion_H
|
#define foamVersion_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
// The directory name for user-resources (located in the HOME directory)
|
// The directory name for user-resources (located in the HOME directory)
|
||||||
#define WM_USER_RESOURCE_DIRNAME ".OpenFOAM"
|
#define WM_USER_RESOURCE_DIRNAME ".OpenFOAM"
|
||||||
|
|
||||||
@ -57,6 +66,7 @@ namespace Foam
|
|||||||
{
|
{
|
||||||
extern const char* const FOAMversion;
|
extern const char* const FOAMversion;
|
||||||
extern const char* const FOAMbuild;
|
extern const char* const FOAMbuild;
|
||||||
|
extern const std::string FOAMbuildArch;
|
||||||
}
|
}
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -33,10 +33,30 @@ Description
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
#include "foamVersion.H"
|
#include "foamVersion.H"
|
||||||
|
#include "endian.H"
|
||||||
|
#include "label.H"
|
||||||
|
#include "scalar.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
const char* const Foam::FOAMversion = "VERSION_STRING";
|
const char* const Foam::FOAMversion = "VERSION_STRING";
|
||||||
const char* const Foam::FOAMbuild = "BUILD_STRING";
|
const char* const Foam::FOAMbuild = "BUILD_STRING";
|
||||||
|
|
||||||
|
// Information about machine endian, label and scalar sizes
|
||||||
|
const std::string Foam::FOAMbuildArch =
|
||||||
|
(
|
||||||
|
#ifdef WM_LITTLE_ENDIAN
|
||||||
|
"LSB"
|
||||||
|
#elif defined (WM_BIG_ENDIAN)
|
||||||
|
"MSB"
|
||||||
|
#else
|
||||||
|
"???"
|
||||||
|
#endif
|
||||||
|
";label=" + std::to_string(8*sizeof(Foam::label))
|
||||||
|
+ ";scalar=" + std::to_string(8*sizeof(Foam::scalar))
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
// Setup an error handler for the global new operator
|
// Setup an error handler for the global new operator
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user