Commit 9988e549 authored by Andrew Heather's avatar Andrew Heather
Browse files

STYLE: writeDictionary - updated output messages

parent 1523160c
......@@ -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-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2013-2017 OpenFOAM Foundation
......@@ -51,10 +51,43 @@ namespace functionObjects
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::functionObjects::writeDictionary::writeHeader()
{
if (firstChange_)
{
Info<< type() << " " << name() << " write:" << nl << endl;
IOobject::writeDivider(Info);
Info<< endl;
firstChange_ = false;
}
}
void Foam::functionObjects::writeDictionary::checkDictionary
(
const dictionary& dict,
const label dicti
)
{
if (dict.digest() != digests_[dicti])
{
writeHeader();
digests_[dicti] = dict.digest();
Info<< dict.dictName() << dict << nl;
IOobject::writeDivider(Info);
Info<< endl;
}
}
bool Foam::functionObjects::writeDictionary::tryDirectory
(
const label dicti,
const word& location
const word& location,
const label dicti
)
{
IOobject dictIO
......@@ -69,17 +102,7 @@ bool Foam::functionObjects::writeDictionary::tryDirectory
if (dictIO.typeHeaderOk<IOdictionary>(true))
{
IOdictionary dict(dictIO);
if (dict.digest() != digests_[dicti])
{
Info<< dict.dictName() << dict << nl;
IOobject::writeDivider(Info);
Info<< endl;
digests_[dicti] = dict.digest();
}
checkDictionary(IOdictionary(dictIO), dicti);
return true;
}
......@@ -99,19 +122,14 @@ Foam::functionObjects::writeDictionary::writeDictionary
:
regionFunctionObject(name, runTime, dict),
dictNames_(),
digests_()
digests_(),
firstChange_(true)
{
read(dict);
execute();
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::functionObjects::writeDictionary::~writeDictionary()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::functionObjects::writeDictionary::read(const dictionary& dict)
......@@ -150,47 +168,36 @@ bool Foam::functionObjects::writeDictionary::execute()
bool Foam::functionObjects::writeDictionary::write()
{
Info<< type() << " " << name() << " write:" << nl << endl;
IOobject::writeDivider(Info);
Info<< endl;
firstChange_ = true;
forAll(dictNames_, i)
forAll(dictNames_, dicti)
{
const IOdictionary* dictptr =
obr_.lookupObjectPtr<IOdictionary>(dictNames_[i]);
obr_.lookupObjectPtr<IOdictionary>(dictNames_[dicti]);
if (dictptr)
{
const dictionary& dict = *dictptr;
if (dict.digest() != digests_[i])
{
digests_[i] = dict.digest();
Info<< dict.dictName() << dict << nl;
IOobject::writeDivider(Info);
Info<< endl;
}
checkDictionary(*dictptr, dicti);
}
else
{
bool processed = tryDirectory(i, obr_.time().timeName());
bool processed = tryDirectory(obr_.time().timeName(), dicti);
if (!processed)
{
processed = tryDirectory(i, obr_.time().constant());
processed = tryDirectory(obr_.time().constant(), dicti);
}
if (!processed)
{
processed = tryDirectory(i, obr_.time().system());
processed = tryDirectory(obr_.time().system(), dicti);
}
if (!processed)
{
Info<< " Unable to locate dictionary " << dictNames_[i]
writeHeader();
Info<< " Unable to locate dictionary " << dictNames_[dicti]
<< nl << endl;
IOobject::writeDivider(Info);
......
......@@ -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-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2013-2016 OpenFOAM Foundation
......@@ -67,20 +67,21 @@ class writeDictionary
//- List of changed dictionaries (only those registered to database)
List<SHA1Digest> digests_;
//- Flag to indicate the first time that a dictionary is been changed
//- (per call to execute)
bool firstChange_;
// Private Member Functions
//- Helper function to write the dictionary if found at location
bool tryDirectory
(
const label dicti,
const word& location
);
// Private Member Functions
//- Write the output header
void writeHeader();
private:
//- Helper to check and write the dictionary if its sha1 has changed
void checkDictionary(const dictionary& dict, const label dicti);
// Private member functions
//- Helper to write the dictionary if found at location
bool tryDirectory(const word& location, const label dicti);
//- No copy construct
writeDictionary(const writeDictionary&) = delete;
......@@ -107,7 +108,7 @@ public:
//- Destructor
virtual ~writeDictionary();
virtual ~writeDictionary() = default;
// Member Functions
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment