Skip to content
Snippets Groups Projects
Commit cedd2159 authored by Henry's avatar Henry
Browse files

Added InfoSwitches::writeOptionalEntries which enables the writing of optional...

Added InfoSwitches::writeOptionalEntries which enables the writing of optional keywords and values which are not present in the dictionary
Warning: generates a VERY large number of messages from OpenFOAM applications
Resolves bug-report http://www.openfoam.org/mantisbt/view.php?id=1473
parent 4d415b0c
No related merge requests found
......@@ -38,6 +38,7 @@ InfoSwitches
writePrecision 6;
writeJobInfo 0;
writeDictionaries 0;
writeOptionalEntries 0;
// Allow case-supplied C++ code (#codeStream, codedFixedValue)
allowSystemOperations 1;
......
......@@ -34,8 +34,13 @@ License
namespace Foam
{
defineTypeNameAndDebug(dictionary, 0);
const dictionary dictionary::null;
defineTypeNameAndDebug(dictionary, 0);
const dictionary dictionary::null;
bool dictionary::writeOptionalEntries
(
debug::infoSwitch("writeOptionalEntries", 0)
);
}
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -142,6 +142,10 @@ class dictionary
{
// Private data
//- If true write optional keywords and values
// if not present in dictionary
static bool writeOptionalEntries;
//- HashTable of the entries held on the DL-list for quick lookup
HashTable<entry*> hashedEntries_;
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -45,6 +45,14 @@ T Foam::dictionary::lookupOrDefault
}
else
{
if (writeOptionalEntries)
{
IOInfoIn("dictionary::lookupOrDefault", *this)
<< "Optional entry '" << keyword << "' is not present,"
<< " returning the default value '" << deflt
<< endl;
}
return deflt;
}
}
......@@ -67,6 +75,14 @@ T Foam::dictionary::lookupOrAddDefault
}
else
{
if (writeOptionalEntries)
{
IOInfoIn("dictionary::lookupOrAddDefault", *this)
<< "Optional entry '" << keyword << "' is not present,"
<< " adding and returning the default value '" << deflt
<< endl;
}
add(new primitiveEntry(keyword, deflt));
return deflt;
}
......@@ -76,13 +92,13 @@ T Foam::dictionary::lookupOrAddDefault
template<class T>
bool Foam::dictionary::readIfPresent
(
const word& k,
const word& keyword,
T& val,
bool recursive,
bool patternMatch
) const
{
const entry* entryPtr = lookupEntryPtr(k, recursive, patternMatch);
const entry* entryPtr = lookupEntryPtr(keyword, recursive, patternMatch);
if (entryPtr)
{
......@@ -91,6 +107,14 @@ bool Foam::dictionary::readIfPresent
}
else
{
if (writeOptionalEntries)
{
IOInfoIn("dictionary::readIfPresent", *this)
<< "Optional entry '" << keyword << "' is not present,"
<< " the default value '" << val << "' will be used."
<< endl;
}
return false;
}
}
......
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