40 bool Foam::objectRegistry::parentNotTime()
const
46 void Foam::objectRegistry::readCacheTemporaryObjects()
const
50 !cacheTemporaryObjectsSet_
51 && time_.controlDict().found(
"cacheTemporaryObjects")
54 cacheTemporaryObjectsSet_ =
true;
56 const dictionary&
controlDict = time_.controlDict();
65 >> cacheTemporaryObjects;
71 >> cacheTemporaryObjects;
74 forAll(cacheTemporaryObjects, i)
76 cacheTemporaryObjects_.insert
78 cacheTemporaryObjects[i],
86 void Foam::objectRegistry::deleteCachedObject(regIOobject& cachedOb)
const
90 cachedOb.rename(cachedOb.name() +
"Cached");
100 const label nIoObjects
121 cacheTemporaryObjectsSet_(false)
129 const label nIoObjects
138 cacheTemporaryObjectsSet_(false)
147 const label nIoObjects
158 cacheTemporaryObjects_.clear();
167 const word& instance,
172 return rootPath()/caseName()/instance/dbDir()/local;
181 for (const_iterator iter = cbegin(); iter != cend(); ++iter)
185 objectNames[
count++] = iter.key();
207 const bool forceCreate
210 if (forceCreate && !foundObject<objectRegistry>(
name))
223 fieldsCachePtr->
store();
225 return lookupObject<objectRegistry>(
name);
231 label curEvent = event_++;
235 if (objectRegistry::debug)
238 <<
"Event counter has overflowed. "
239 <<
"Resetting counter on all dependent objects." <<
nl
240 <<
"This might cause extra evaluations." <<
endl;
247 for (const_iterator iter = begin(); iter != end(); ++iter)
251 if (objectRegistry::debug)
253 Pout<<
"objectRegistry::getEvent() : "
254 <<
"resetting count on " << iter.key() <<
endl;
270 if (objectRegistry::debug)
272 Pout<<
"objectRegistry::checkIn(regIOobject&) : "
273 <<
name() <<
" : checking in " << io.
name()
274 <<
" of type " << io.type()
284 root.cacheTemporaryObjects_.find(io.
name())
286 if (cacheIter != root.cacheTemporaryObjects_.end())
290 if (iter != end() && iter() != &io && iter()->ownedByRegistry())
292 if (objectRegistry::debug)
294 Pout<<
"objectRegistry::checkIn(regIOobject&) : "
295 <<
name() <<
" : deleting cached object " << iter.key()
299 cacheIter().first() =
false;
300 deleteCachedObject(*iter());
314 if (objectRegistry::debug)
316 Pout<<
"objectRegistry::checkOut(regIOobject&) : "
317 <<
name() <<
" : checking out " << iter.key()
323 if (objectRegistry::debug)
326 <<
name() <<
" : attempt to checkOut copy of "
349 if (objectRegistry::debug)
351 Pout<<
"objectRegistry::checkOut(regIOobject&) : "
352 <<
name() <<
" : could not find " << io.
name()
353 <<
" in registry " <<
name()
365 label nMyObjects = 0;
367 for (iterator iter = begin(); iter != end(); ++iter)
369 if (iter()->ownedByRegistry())
371 myObjects[nMyObjects++] = iter();
375 for (
label i=0; i < nMyObjects; i++)
377 checkOut(*myObjects[i]);
389 return root.cacheTemporaryObjects_.found(
name);
402 cacheTemporaryObjects_.find(ob.
name())
404 if (iter != cacheTemporaryObjects_.
end())
406 iter().first() =
false;
412 time_.resetCacheTemporaryObject(ob);
425 if (orPtr_ && orPtr_ !=
this)
433 if (root.cacheTemporaryObjects_.empty())
443 root.cacheTemporaryObjects_,
450 <<
"Could not find temporary object " << iter.key()
451 <<
" in registry " <<
name() <<
nl
452 <<
"Available temporary objects "
458 cacheTemporaryObjects_.clear();
465 root.cacheTemporaryObjects_,
469 iter().second() =
false;
473 temporaryObjects_.clear();
486 if (i == string::npos)
492 dbDir_.
replace(i+1, string::npos, newName);
501 if (iter()->modified())
513 dependents_.setSize(size());
518 if (iter()->dependenciesModified())
520 dependents_[
count++] = iter();
523 dependents_.setSize(
count);
531 bool modified =
false;
533 for (iterator iter = begin(); iter != end(); ++iter)
535 if (objectRegistry::debug)
537 Pout<<
"objectRegistry::readModifiedObjects() : "
538 <<
name() <<
" : Considering reading object "
539 << iter.key() <<
endl;
542 modified = modified || iter()->readIfModified();
555 dependents_[i]->read();
564 dependenciesModified();
566 const bool modified = readIfModified();
585 os <<
" " <<
setf(ios_base::left)
586 <<
setw(39) << sortedObjects[i].key()
587 <<
' ' << sortedObjects[i]()->
type()
605 if (objectRegistry::debug)
607 Pout<<
"objectRegistry::write() : "
608 <<
name() <<
" : Considering writing object "
610 <<
" of type " << iter()->type()
611 <<
" with writeOpt " << iter()->writeOpt()
612 <<
" to file " << iter()->objectPath()
616 if (iter()->writeOpt() != NO_WRITE)
618 ok = iter()->writeObject(fmt, ver, cmp,
write) && ok;
Istream and Ostream manipulators taking arguments.
graph_traits< Graph >::vertices_size_type size_type
#define forAll(list, i)
Loop across all elements in list.
#define forAllIter(Container, container, iter)
Iterate across all elements in the container object of type.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
An STL-conforming hash table.
List< word > sortedToc() const
Return the table of contents as a sorted list.
bool erase(const iterator &)
Erase a hashedEntry specified by given iterator.
bool insert(const Key &, const T &newElmt)
Insert a new hashedEntry.
iterator find(const Key &)
Find and return an iterator set at the hashedEntry.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
writeOption writeOpt() const
const word & name() const
Return name.
streamFormat
Enumeration for the format of data in the stream.
compressionType
Enumeration for the format of data in the stream.
void setSize(const label)
Reset size of List.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
A class for handling file names.
Registry of regIOobjects.
virtual bool writeObject(IOstream::streamFormat fmt, IOstream::versionNumber ver, IOstream::compressionType cmp, const bool write) const
Write the objects.
wordList toc() const
Return the list of names of the IOobjects of given type.
const objectRegistry & subRegistry(const word &name, const bool forceCreate=false) const
Lookup and return a const sub-objectRegistry. Optionally create.
void printToc(Ostream &os) const
Print the list of object names and their type.
virtual bool modified() const
Return true if any of the object's files have been modified.
objectRegistry(const Time &db, const label nIoObjects=128)
Construct the time objectRegistry given an initial estimate.
virtual bool dependenciesModified() const
Cache pointers to objects who's dependencies have been modified.
virtual ~objectRegistry()
Destructor.
bool checkCacheTemporaryObjects() const
Check that all objects in the cacheTemporaryObjects set.
bool cacheTemporaryObject(const word &name) const
Return true if given name is in the cacheTemporaryObjects set.
virtual bool readIfModified()
Read object if modified.
fileName path() const
Return complete path.
void clear()
Remove all regIOobject owned by the registry.
void resetCacheTemporaryObject(const regIOobject &ob) const
Reset the cache state of the given object.
void readModifiedObjects()
Read the objects that have been modified.
virtual void rename(const word &newName)
Rename.
virtual bool read()
Read dependent objects.
label getEvent() const
Return new event number.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
bool ownedByRegistry() const
Is this object owned by the registry?
label eventNo() const
Event number at last update.
bool checkOut()
Remove object from registry.
virtual void rename(const word &newName)
Rename.
void store()
Transfer ownership of this object to its registry.
bool checkIn()
Add object to registry.
A class for handling character strings derived from std::string.
string & replace(const string &oldStr, const string &newStr, size_type start=0)
In this string replace first occurrence of sub-string oldStr.
A class for handling words, derived from string.
#define ClassName(TypeNameString)
Add typeName information from argument TypeNameString to a class.
#define WarningInFunction
Report a warning using Foam::Warning.
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
List< word > wordList
A List of words.
Smanip< ios_base::fmtflags > setf(const ios_base::fmtflags flags)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Omanip< int > setw(const int i)
labelList second(const UList< labelPair > &p)
defineTypeNameAndDebug(combustionModel, 0)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
prefixOSstream Pout(cout, "Pout")
label count(const ListType &l, typename ListType::const_reference x)
Count the number of occurrences of a value in a list.
static const label labelMax
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
runTime controlDict().lookup("adjustTimeStep") >> adjustTimeStep
thermo validate(args.executable(), "h")
static iteratorEnd end()
iteratorEnd set to beyond the end of any HashTable