From 70525fe75e962a38fdb0399527dfd00fdb8306b5 Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 27 Jan 2016 17:35:46 +0000 Subject: [PATCH] ENH: include file tracking: missed out adding files to list of files to check --- .../functionEntries/codeStream/codeStream.C | 58 ++++++++++++++++--- .../functionEntries/codeStream/codeStream.H | 6 +- .../includeEntry/includeEntry.C | 38 +++++++++++- .../includeIfPresentEntry.C | 27 ++++++++- 4 files changed, 119 insertions(+), 10 deletions(-) diff --git a/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.C b/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.C index f0e90284fb..85aa366cb2 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.C @@ -70,11 +70,52 @@ Foam::dlLibraryTable& Foam::functionEntries::codeStream::libs const dictionary& dict ) { - const IOdictionary& d = static_cast(dict.topDict()); + const baseIOdictionary& d = static_cast + ( + dict.topDict() + ); return const_cast(d.time()).libs(); } +bool Foam::functionEntries::codeStream::doingMasterOnlyReading +( + const dictionary& dict +) +{ + const dictionary& topDict = dict.topDict(); + + if (isA(topDict)) + { + const baseIOdictionary& d = static_cast + ( + topDict + ); + + if (debug) + { + Pout<< "codeStream : baseIOdictionary:" << dict.name() + << " master-only-reading:" << d.globalObject() + << endl; + } + + return d.globalObject(); + } + else + { + if (debug) + { + Pout<< "codeStream : not a baseIOdictionary:" << dict.name() + << " master-only-reading:" << regIOobject::masterOnlyReading + << endl; + } + + // Fall back to regIOobject::masterOnlyReading + return regIOobject::masterOnlyReading; + } +} + + Foam::functionEntries::codeStream::streamingFunctionType Foam::functionEntries::codeStream::getFunction ( @@ -96,7 +137,10 @@ Foam::functionEntries::codeStream::getFunction // see if library is loaded void* lib = NULL; - if (isA(parentDict.topDict())) + + const dictionary& topDict = parentDict.topDict(); + + if (isA(topDict)) { lib = libs(parentDict).findLibrary(libPath); } @@ -111,7 +155,7 @@ Foam::functionEntries::codeStream::getFunction // avoid compilation if possible by loading an existing library if (!lib) { - if (isA(parentDict.topDict())) + if (isA(topDict)) { // Cached access to dl libs. Guarantees clean up upon destruction // of Time. @@ -178,10 +222,10 @@ Foam::functionEntries::codeStream::getFunction } //- Only block if we're not doing master-only reading. (flag set by - // regIOobject::read, IOdictionary constructor) + // regIOobject::read, baseIOdictionary constructor) if ( - !regIOobject::masterOnlyReading + !doingMasterOnlyReading(topDict) && regIOobject::fileModificationSkew > 0 ) { @@ -246,7 +290,7 @@ Foam::functionEntries::codeStream::getFunction } } - if (isA(parentDict.topDict())) + if (isA(topDict)) { // Cached access to dl libs. Guarantees clean up upon destruction // of Time. @@ -282,7 +326,7 @@ Foam::functionEntries::codeStream::getFunction } bool haveLib = lib; - if (!regIOobject::masterOnlyReading) + if (!doingMasterOnlyReading(topDict)) { reduce(haveLib, andOp()); } diff --git a/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.H b/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.H index 1dc2b57c87..eeb8ce9b2e 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.H +++ b/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.H @@ -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-2014 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -123,6 +123,10 @@ class codeStream //- Helper function: parent (of parent etc.) of dictionary up to the top static const dictionary& topDict(const dictionary&); + //- Helper function: access IOobject for master-only-reading + // functionality + static bool doingMasterOnlyReading(const dictionary& dict); + //- Helper function: access to dlLibraryTable of Time static dlLibraryTable& libs(const dictionary& dict); diff --git a/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.C b/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.C index 8e836e50f6..29137f41b8 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.C @@ -24,10 +24,10 @@ License \*---------------------------------------------------------------------------*/ #include "includeEntry.H" -#include "dictionary.H" #include "IFstream.H" #include "addToMemberFunctionSelectionTable.H" #include "stringOps.H" +#include "Time.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -127,6 +127,9 @@ bool Foam::functionEntries::includeEntry::execute ( includeFileName(is.name().path(), rawFName, parentDict) ); + + + // Read contents of file into parentDict IFstream ifs(fName); if (ifs) @@ -135,6 +138,21 @@ bool Foam::functionEntries::includeEntry::execute { Info<< fName << endl; } + + // Add watch on included file + const dictionary& top = parentDict.topDict(); + if (isA(top)) + { + regIOobject& rio = const_cast + ( + dynamic_cast(top) + ); + //Info<< rio.name() << " : adding depenency on included file " + // << fName << endl; + + rio.addWatch(fName); + } + parentDict.read(ifs); return true; } @@ -165,6 +183,9 @@ bool Foam::functionEntries::includeEntry::execute ( includeFileName(is.name().path(), rawFName, parentDict) ); + + + // Read contents of file into parentDict IFstream ifs(fName); if (ifs) @@ -173,6 +194,21 @@ bool Foam::functionEntries::includeEntry::execute { Info<< fName << endl; } + + // Add watch on included file + const dictionary& top = parentDict.topDict(); + if (isA(top)) + { + regIOobject& rio = const_cast + ( + dynamic_cast(top) + ); + //Info<< rio.name() << " : adding depenency on included file " + // << fName << endl; + + rio.addWatch(fName); + } + entry.read(parentDict, ifs); return true; } diff --git a/src/OpenFOAM/db/dictionary/functionEntries/includeIfPresentEntry/includeIfPresentEntry.C b/src/OpenFOAM/db/dictionary/functionEntries/includeIfPresentEntry/includeIfPresentEntry.C index 2c0ccc9893..6c07f6a612 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/includeIfPresentEntry/includeIfPresentEntry.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/includeIfPresentEntry/includeIfPresentEntry.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -26,6 +26,7 @@ License #include "includeIfPresentEntry.H" #include "dictionary.H" #include "IFstream.H" +#include "regIOobject.H" #include "addToMemberFunctionSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -78,6 +79,18 @@ bool Foam::functionEntries::includeIfPresentEntry::execute { Info<< fName << endl; } + + // Add watch on included file + const dictionary& top = parentDict.topDict(); + if (isA(top)) + { + regIOobject& rio = const_cast + ( + dynamic_cast(top) + ); + rio.addWatch(fName); + } + parentDict.read(ifs); } @@ -101,6 +114,18 @@ bool Foam::functionEntries::includeIfPresentEntry::execute { Info<< fName << endl; } + + // Add watch on included file + const dictionary& top = parentDict.topDict(); + if (isA(top)) + { + regIOobject& rio = const_cast + ( + dynamic_cast(top) + ); + rio.addWatch(fName); + } + entry.read(parentDict, ifs); }