diff --git a/etc/controlDict b/etc/controlDict index 352541fa75..bbecffaaa3 100644 --- a/etc/controlDict +++ b/etc/controlDict @@ -37,6 +37,7 @@ InfoSwitches { writePrecision 6; writeJobInfo 0; + writeDictionaries 0; // Allow case-supplied C++ code (#codeStream, codedFixedValue) allowSystemOperations 0; diff --git a/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionary.C b/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionary.C index 2c5087c120..92991459a3 100644 --- a/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionary.C +++ b/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionary.C @@ -21,12 +21,6 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . -Description - IOdictionary is derived from dictionary and IOobject to give the - dictionary automatic IO functionality via the objectRegistry. To facilitate - IO, IOdictioanry is provided with a constructor from IOobject and writeData - and write functions. - \*---------------------------------------------------------------------------*/ #include "IOdictionary.H" @@ -37,84 +31,10 @@ Description defineTypeNameAndDebug(Foam::IOdictionary, 0); - -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -// Parallel aware reading, using non-virtual type information (typeName instead -// of type()) because of use in constructor. -void Foam::IOdictionary::readFile(const bool masterOnly) -{ - if (Pstream::master() || !masterOnly) - { - if (debug) - { - Pout<< "IOdictionary : Reading " << objectPath() - << " from file " << endl; - } - readStream(typeName) >> *this; - close(); - } - - if (masterOnly && Pstream::parRun()) - { - // Scatter master data using communication scheme - - const List& comms = - ( - (Pstream::nProcs() < Pstream::nProcsSimpleSum) - ? Pstream::linearCommunication() - : Pstream::treeCommunication() - ); - - // Master reads headerclassname from file. Make sure this gets - // transfered as well as contents. - Pstream::scatter(comms, const_cast(headerClassName())); - Pstream::scatter(comms, note()); - - // Get my communication order - const Pstream::commsStruct& myComm = comms[Pstream::myProcNo()]; - - // Reveive from up - if (myComm.above() != -1) - { - if (debug) - { - Pout<< "IOdictionary : Reading " << objectPath() - << " from processor " << myComm.above() << endl; - } - - // Note: use ASCII for now - binary IO of dictionaries is - // not currently supported - IPstream fromAbove - ( - Pstream::scheduled, - myComm.above(), - 0, - IOstream::ASCII - ); - IOdictionary::readData(fromAbove); - } - - // Send to my downstairs neighbours - forAll(myComm.below(), belowI) - { - if (debug) - { - Pout<< "IOdictionary : Sending " << objectPath() - << " to processor " << myComm.below()[belowI] << endl; - } - OPstream toBelow - ( - Pstream::scheduled, - myComm.below()[belowI], - 0, - Pstream::msgType(), - IOstream::ASCII - ); - IOdictionary::writeData(toBelow); - } - } -} +bool Foam::IOdictionary::writeDictionaries +( + Foam::debug::infoSwitch("writeDictionaries", 0) +); // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionary.H b/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionary.H index 581d9bec72..e7fecbce91 100644 --- a/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionary.H +++ b/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionary.H @@ -25,10 +25,10 @@ Class Foam::IOdictionary Description - IOdictionary is derived from dictionary and IOobject to give the - dictionary automatic IO functionality via the objectRegistry. To facilitate - IO, IOdictioanry is provided with a constructor from IOobject and writeData - and write functions. + IOdictionary is derived from dictionary and IOobject to give the dictionary + automatic IO functionality via the objectRegistry. To facilitate IO, + IOdictioanry is provided with a constructor from IOobject and writeData and + write functions. SourceFiles IOdictionary.C @@ -56,12 +56,17 @@ class IOdictionary public regIOobject, public dictionary { + // Private data + + static bool writeDictionaries; + // Private Member Functions - //- read dictionary from file + //- Read dictionary from file void readFile(const bool); + public: TypeName("dictionary"); diff --git a/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionaryIO.C b/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionaryIO.C index 288056f63b..b1e90be300 100644 --- a/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionaryIO.C +++ b/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionaryIO.C @@ -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 @@ -21,21 +21,116 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . -Description - IOdictionary is derived from dictionary and IOobject to give the - dictionary automatic IO functionality via the objectRegistry. To facilitate - IO, IOdictioanry is provided with a constructor from IOobject and writeData - and write functions. - \*---------------------------------------------------------------------------*/ #include "IOdictionary.H" +#include "Pstream.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +// Parallel aware reading, using non-virtual type information (typeName instead +// of type()) because of use in constructor. +void Foam::IOdictionary::readFile(const bool masterOnly) +{ + if (Pstream::master() || !masterOnly) + { + if (debug) + { + Pout<< "IOdictionary : Reading " << objectPath() + << " from file " << endl; + } + readStream(typeName) >> *this; + close(); + + if (writeDictionaries && Pstream::master()) + { + Sout<< nl + << "--- IOdictionary " << name() + << ' ' << objectPath() << ":" << nl; + writeHeader(Sout); + writeData(Sout); + Sout<< "--- End of IOdictionary " << name() << nl << endl; + } + } + + if (masterOnly && Pstream::parRun()) + { + // Scatter master data using communication scheme + + const List& comms = + ( + (Pstream::nProcs() < Pstream::nProcsSimpleSum) + ? Pstream::linearCommunication() + : Pstream::treeCommunication() + ); + + // Master reads headerclassname from file. Make sure this gets + // transfered as well as contents. + Pstream::scatter(comms, const_cast(headerClassName())); + Pstream::scatter(comms, note()); + + // Get my communication order + const Pstream::commsStruct& myComm = comms[Pstream::myProcNo()]; + + // Reveive from up + if (myComm.above() != -1) + { + if (debug) + { + Pout<< "IOdictionary : Reading " << objectPath() + << " from processor " << myComm.above() << endl; + } + + // Note: use ASCII for now - binary IO of dictionaries is + // not currently supported + IPstream fromAbove + ( + Pstream::scheduled, + myComm.above(), + 0, + IOstream::ASCII + ); + IOdictionary::readData(fromAbove); + } + + // Send to my downstairs neighbours + forAll(myComm.below(), belowI) + { + if (debug) + { + Pout<< "IOdictionary : Sending " << objectPath() + << " to processor " << myComm.below()[belowI] << endl; + } + OPstream toBelow + ( + Pstream::scheduled, + myComm.below()[belowI], + 0, + Pstream::msgType(), + IOstream::ASCII + ); + IOdictionary::writeData(toBelow); + } + } +} + + +// * * * * * * * * * * * * * * * Members Functions * * * * * * * * * * * * * // bool Foam::IOdictionary::readData(Istream& is) { is >> *this; + + if (writeDictionaries && Pstream::master() && !is.bad()) + { + Sout<< nl + << "--- IOdictionary " << name() + << ' ' << objectPath() << ":" << nl; + writeHeader(Sout); + writeData(Sout); + Sout<< "--- End of IOdictionary " << name() << nl << endl; + } + return !is.bad(); } @@ -46,4 +141,5 @@ bool Foam::IOdictionary::writeData(Ostream& os) const return os.good(); } + // ************************************************************************* // diff --git a/src/OpenFOAM/db/regIOobject/regIOobjectRead.C b/src/OpenFOAM/db/regIOobject/regIOobjectRead.C index e2ed73d474..b578744888 100644 --- a/src/OpenFOAM/db/regIOobject/regIOobjectRead.C +++ b/src/OpenFOAM/db/regIOobject/regIOobjectRead.C @@ -98,7 +98,7 @@ Foam::Istream& Foam::regIOobject::readStream() } } - // Mark as uptodate if read succesfully + // Mark as uptodate if read successfully if (watchIndex_ != -1) { time().setUnmodified(watchIndex_); @@ -173,7 +173,7 @@ bool Foam::regIOobject::read() // Note: cannot do anything in readStream itself since this is used by // e.g. GeometricField. - bool masterOnly = + bool masterOnly = regIOobject::fileModificationChecking == timeStampMaster || regIOobject::fileModificationChecking == inotifyMaster;