Commit cb8bf9f7 authored by mattijs's avatar mattijs
Browse files

ENH: codeStream: make it work with master-only reading (timeStampMaster)

parent 6d970f6c
...@@ -39,9 +39,17 @@ void Foam::IOdictionary::readFile(const bool masterOnly) ...@@ -39,9 +39,17 @@ void Foam::IOdictionary::readFile(const bool masterOnly)
Pout<< "IOdictionary : Reading " << objectPath() Pout<< "IOdictionary : Reading " << objectPath()
<< " from file " << endl; << " from file " << endl;
} }
// Set flag for e.g. codeStream
bool oldFlag = regIOobject::masterOnlyReading;
regIOobject::masterOnlyReading = masterOnly;
// Read file
readStream(typeName) >> *this; readStream(typeName) >> *this;
close(); close();
regIOobject::masterOnlyReading = oldFlag;
if (writeDictionaries && Pstream::master()) if (writeDictionaries && Pstream::master())
{ {
Sout<< nl Sout<< nl
......
...@@ -197,25 +197,12 @@ Foam::functionEntries::codeStream::getFunction ...@@ -197,25 +197,12 @@ Foam::functionEntries::codeStream::getFunction
} }
} }
//- We don't know whether this code was from IOdictionary //- Only block if we're not doing master-only reading. (flag set by
// (possibly read on master only) or from e.g. Field so cannot // regIOobject::read, IOdictionary constructor)
// decide here. if (!regIOobject::masterOnlyReading)
//// all processes must wait for compile to finish - except if this {
//// file is only read on the master
//bool masterOnly =
// (
// regIOobject::fileModificationChecking
// == regIOobject::timeStampMaster
// )
// || (
// regIOobject::fileModificationChecking
// == regIOobject::inotifyMaster
// );
//
//if (!masterOnly)
//{
reduce(create, orOp<bool>()); reduce(create, orOp<bool>());
//} }
if (isA<IOdictionary>(topDict(parentDict))) if (isA<IOdictionary>(topDict(parentDict)))
{ {
......
...@@ -2,7 +2,7 @@ ...@@ -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) 2004-2010 OpenCFD Ltd. \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
...@@ -69,6 +69,9 @@ Foam::regIOobject::fileCheckTypes Foam::regIOobject::fileModificationChecking ...@@ -69,6 +69,9 @@ Foam::regIOobject::fileCheckTypes Foam::regIOobject::fileModificationChecking
); );
bool Foam::regIOobject::masterOnlyReading = false;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from IOobject // Construct from IOobject
......
...@@ -2,7 +2,7 @@ ...@@ -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) 2004-2010 OpenCFD Ltd. \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
...@@ -49,6 +49,11 @@ SourceFiles ...@@ -49,6 +49,11 @@ SourceFiles
namespace Foam namespace Foam
{ {
namespace functionEntries
{
class codeStream;
}
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class regIOobject Declaration Class regIOobject Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
...@@ -72,6 +77,12 @@ public: ...@@ -72,6 +77,12 @@ public:
static const NamedEnum<fileCheckTypes, 4> fileCheckTypesNames; static const NamedEnum<fileCheckTypes, 4> fileCheckTypesNames;
protected:
//- To flag master-only reading of objects
static bool masterOnlyReading;
private: private:
// Private data // Private data
...@@ -103,6 +114,11 @@ private: ...@@ -103,6 +114,11 @@ private:
public: public:
//- Declare friendship with any classes that need access to
// masterOnlyReading
friend class functionEntries::codeStream;
// Static data // Static data
//- Runtime type information //- Runtime type information
......
...@@ -186,8 +186,16 @@ bool Foam::regIOobject::read() ...@@ -186,8 +186,16 @@ bool Foam::regIOobject::read()
<< "reading object " << name() << "reading object " << name()
<< " from file " << endl; << " from file " << endl;
} }
// Set flag for e.g. codeStream
bool oldFlag = regIOobject::masterOnlyReading;
regIOobject::masterOnlyReading = masterOnly;
// Read file
ok = readData(readStream(type())); ok = readData(readStream(type()));
close(); close();
regIOobject::masterOnlyReading = oldFlag;
} }
if (masterOnly && Pstream::parRun()) if (masterOnly && Pstream::parRun())
......
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