View Issue Details

IDProjectCategoryView StatusLast Update
0000253OpenFOAMBugpublic2011-07-20 16:07
Reporterjherb Assigned Tohenry  
PrioritynormalSeverityfeatureReproducibilityhave not tried
Status resolvedResolutionfixed 
PlatformLinuxOSRHESOS Version5.4
Summary0000253: Add feature to log content of dictionary files
DescriptionEspecially if the content of dictionary files is changed during the run it is not always reproducible what the settings were.

So a feature would be nice to log the content of the dictionary files at startup of a simulation run and if a file is changed and reloaded.

The attached patch adds this feature.

If you would recommend a different way to get such a feature please give advice.
TagsNo tags attached.

Activities

jherb

2011-07-18 14:53

reporter  

writeDictionaryLog-v01.patch (2,218 bytes)   
diff --git a/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionary.C b/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionary.C
index 2c5087c..0137c89 100644
--- a/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionary.C
+++ b/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionary.C
@@ -36,6 +36,7 @@ Description
 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
 
 defineTypeNameAndDebug(Foam::IOdictionary, 0);
+bool Foam::IOdictionary::writeDictionaryLog(Foam::debug::infoSwitch("writeDictionaryLog", 0));
 
 
 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
@@ -53,6 +54,14 @@ void Foam::IOdictionary::readFile(const bool masterOnly)
         }
         readStream(typeName) >> *this;
         close();
+
+        if (writeDictionaryLog)
+        {
+            Info<<"Settings for " << name() << " from " << objectPath() << ":" <<nl;
+            writeHeader(Info);
+            Info<<*this;
+            Info<<"End of " << name() << " from " << objectPath() <<nl;
+        }
     }
 
     if (masterOnly && Pstream::parRun())
diff --git a/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionary.H b/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionary.H
index 581d9be..df9c0cd 100644
--- a/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionary.H
+++ b/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionary.H
@@ -57,6 +57,9 @@ class IOdictionary
     public dictionary
 {
 
+    // Private data
+        static bool writeDictionaryLog;
+
     // Private Member Functions
 
         //- read dictionary from file
diff --git a/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionaryIO.C b/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionaryIO.C
index 288056f..80e1001 100644
--- a/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionaryIO.C
+++ b/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionaryIO.C
@@ -36,6 +36,15 @@ Description
 bool Foam::IOdictionary::readData(Istream& is)
 {
     is >> *this;
+
+    if (writeDictionaryLog)
+    {
+        Info<<"Settings for " << name() << " from " << objectPath() << ":" <<nl;
+        writeHeader(Info);
+        Info<<*this;
+        Info<<"End of " << name() << " from " << objectPath() <<nl;
+    }
+
     return !is.bad();
 }
 
writeDictionaryLog-v01.patch (2,218 bytes)   

henry

2011-07-20 16:07

manager   ~0000576

Thanks for the patch. We have implemented the equivalent feature based on your request resolving a few issues in particular the inconsistent output formatting:
commit 9ce8e309bc02d9b858aa4e28807bea71a45d679a

Please let us know if there are any issues with this new feature.

Issue History

Date Modified Username Field Change
2011-07-18 14:53 jherb New Issue
2011-07-18 14:53 jherb File Added: writeDictionaryLog-v01.patch
2011-07-20 16:07 henry Note Added: 0000576
2011-07-20 16:07 henry Status new => resolved
2011-07-20 16:07 henry Resolution open => fixed
2011-07-20 16:07 henry Assigned To => henry