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