39 bool Foam::objectRegistry::parentNotTime()
const
45 void Foam::objectRegistry::readCacheTemporaryObjects()
const
49 !cacheTemporaryObjectsSet_
50 && time_.controlDict().found(
"cacheTemporaryObjects")
53 cacheTemporaryObjectsSet_ =
true;
55 const dictionary&
controlDict = time_.controlDict();
64 >> cacheTemporaryObjects;
70 >> cacheTemporaryObjects;
73 forAll(cacheTemporaryObjects, i)
75 cacheTemporaryObjects_.insert
77 cacheTemporaryObjects[i],
85 void Foam::objectRegistry::deleteCachedObject(regIOobject& cachedOb)
const
89 cachedOb.rename(cachedOb.name() +
"Cached");
99 const label nIoObjects
120 cacheTemporaryObjectsSet_(false)
127 const label nIoObjects
134 dbDir_(parent_.dbDir()/local()/
name()),
136 cacheTemporaryObjectsSet_(false)
146 cacheTemporaryObjects_.clear();
155 const word& instance,
160 return rootPath()/caseName()/instance/dbDir()/local;
180 for (const_iterator iter = cbegin(); iter != cend(); ++iter)
184 objectNames[
count++] = iter.key();
206 const bool forceCreate
209 if (forceCreate && !foundObject<objectRegistry>(
name))
222 fieldsCachePtr->
store();
224 return lookupObject<objectRegistry>(
name);
230 label curEvent = event_++;
234 if (objectRegistry::debug)
237 <<
"Event counter has overflowed. "
238 <<
"Resetting counter on all dependent objects." <<
nl
239 <<
"This might cause extra evaluations." <<
endl;
246 for (const_iterator iter = begin(); iter != end(); ++iter)
250 if (objectRegistry::debug)
252 Pout<<
"objectRegistry::getEvent() : "
253 <<
"resetting count on " << iter.key() <<
endl;
269 if (objectRegistry::debug)
271 Pout<<
"objectRegistry::checkIn(regIOobject&) : "
272 <<
name() <<
" : checking in " << io.
name()
273 <<
" of type " << io.type()
279 if (cacheTemporaryObjects_.size())
283 cacheTemporaryObjects_.find(io.
name())
286 if (cacheIter != 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());
315 if (objectRegistry::debug)
317 Pout<<
"objectRegistry::checkOut(regIOobject&) : "
318 <<
name() <<
" : checking out " << iter.key()
324 if (objectRegistry::debug)
327 <<
name() <<
" : attempt to checkOut copy of "
350 if (objectRegistry::debug)
352 Pout<<
"objectRegistry::checkOut(regIOobject&) : "
353 <<
name() <<
" : could not find " << io.
name()
354 <<
" in registry " <<
name()
366 label nMyObjects = 0;
368 for (iterator iter = begin(); iter != end(); ++iter)
370 if (iter()->ownedByRegistry())
372 myObjects[nMyObjects++] = iter();
376 for (
label i=0; i < nMyObjects; i++)
378 checkOut(*myObjects[i]);
388 if (!cacheTemporaryObjects_.found(
name))
390 cacheTemporaryObjects_.insert(
name, {
false,
false});
400 return cacheTemporaryObjects_.found(
name);
409 if (cacheTemporaryObjects_.size())
413 cacheTemporaryObjects_.find(ob.
name())
418 if (iter != cacheTemporaryObjects_.
end())
420 iter().first() =
false;
428 bool enabled = cacheTemporaryObjects_.size();
436 if (orPtr_ && orPtr_ !=
this)
447 cacheTemporaryObjects_,
454 <<
"Could not find temporary object " << iter.key()
455 <<
" in registry " <<
name() <<
nl
456 <<
"Available temporary objects "
462 iter().second() =
false;
466 temporaryObjects_.clear();
480 if (i == string::npos)
486 dbDir_.
replace(i+1, string::npos, newName);
495 if (iter()->modified())
507 for (iterator iter = begin(); iter != end(); ++iter)
509 if (objectRegistry::debug)
511 Pout<<
"objectRegistry::readModifiedObjects() : "
512 <<
name() <<
" : Considering reading object "
513 << iter.key() <<
endl;
516 iter()->readIfModified();
523 readModifiedObjects();
540 if (objectRegistry::debug)
542 Pout<<
"objectRegistry::write() : "
543 <<
name() <<
" : Considering writing object "
545 <<
" of type " << iter()->type()
546 <<
" with writeOpt " << iter()->writeOpt()
547 <<
" to file " << iter()->objectPath()
551 if (iter()->writeOpt() != NO_WRITE)
553 ok = iter()->writeObject(fmt, ver, cmp,
write) && ok;
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< Key > sortedToc() const
Return the table of contents as a sorted list.
bool erase(const iterator &)
Erase a hashedEntry specified by given iterator.
List< Key > toc() const
Return the table of contents.
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 ordered pair of two objects of type <T> with first() and second() elements.
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 sortedNames() const
Return the sorted list of names of the IOobjects.
const objectRegistry & subRegistry(const word &name, const bool forceCreate=false) const
Lookup and return a const sub-objectRegistry. Optionally create.
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 ~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.
wordList names() const
Return the list of names of the IOobjects.
void addTemporaryObject(const word &name) const
Add the given name to the set of temporary objects to cache.
virtual void rename(const word &newName)
Rename.
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.
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.
word name(const bool)
Return a word representation of a bool.
labelList second(const UList< labelPair > &p)
defineTypeNameAndDebug(combustionModel, 0)
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
runTime controlDict().lookup("adjustTimeStep") >> adjustTimeStep
thermo validate(args.executable(), "h")
static iteratorEnd end()
iteratorEnd set to beyond the end of any HashTable