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
This commit is contained in:
Henry 2015-01-03 16:54:07 +00:00
parent 5cf6680021
commit cc21bb9a87
4 changed files with 40 additions and 6 deletions

View File

@ -38,6 +38,7 @@ InfoSwitches
writePrecision 6; writePrecision 6;
writeJobInfo 0; writeJobInfo 0;
writeDictionaries 0; writeDictionaries 0;
writeOptionalEntries 0;
// Allow case-supplied C++ code (#codeStream, codedFixedValue) // Allow case-supplied C++ code (#codeStream, codedFixedValue)
allowSystemOperations 1; allowSystemOperations 1;

View File

@ -34,8 +34,13 @@ License
namespace Foam namespace Foam
{ {
defineTypeNameAndDebug(dictionary, 0); defineTypeNameAndDebug(dictionary, 0);
const dictionary dictionary::null; const dictionary dictionary::null;
bool dictionary::writeOptionalEntries
(
debug::infoSwitch("writeOptionalEntries", 0)
);
} }

View File

@ -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-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -142,6 +142,10 @@ class dictionary
{ {
// Private data // 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 of the entries held on the DL-list for quick lookup
HashTable<entry*> hashedEntries_; HashTable<entry*> hashedEntries_;

View File

@ -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) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -45,6 +45,14 @@ T Foam::dictionary::lookupOrDefault
} }
else else
{ {
if (writeOptionalEntries)
{
IOInfoIn("dictionary::lookupOrDefault", *this)
<< "Optional entry '" << keyword << "' is not present,"
<< " returning the default value '" << deflt
<< endl;
}
return deflt; return deflt;
} }
} }
@ -67,6 +75,14 @@ T Foam::dictionary::lookupOrAddDefault
} }
else 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)); add(new primitiveEntry(keyword, deflt));
return deflt; return deflt;
} }
@ -76,13 +92,13 @@ T Foam::dictionary::lookupOrAddDefault
template<class T> template<class T>
bool Foam::dictionary::readIfPresent bool Foam::dictionary::readIfPresent
( (
const word& k, const word& keyword,
T& val, T& val,
bool recursive, bool recursive,
bool patternMatch bool patternMatch
) const ) const
{ {
const entry* entryPtr = lookupEntryPtr(k, recursive, patternMatch); const entry* entryPtr = lookupEntryPtr(keyword, recursive, patternMatch);
if (entryPtr) if (entryPtr)
{ {
@ -91,6 +107,14 @@ bool Foam::dictionary::readIfPresent
} }
else else
{ {
if (writeOptionalEntries)
{
IOInfoIn("dictionary::readIfPresent", *this)
<< "Optional entry '" << keyword << "' is not present,"
<< " the default value '" << val << "' will be used."
<< endl;
}
return false; return false;
} }
} }