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)
128 const label nIoObjects
135 dbDir_(parent_.dbDir()/local()/
name()),
137 cacheTemporaryObjectsSet_(false)
147 cacheTemporaryObjects_.clear();
156 const word& instance,
161 return rootPath()/caseName()/instance/dbDir()/local;
170 for (const_iterator iter = cbegin(); iter != cend(); ++iter)
174 objectNames[
count++] = iter.key();
196 const bool forceCreate
199 if (forceCreate && !foundObject<objectRegistry>(
name))
212 fieldsCachePtr->
store();
214 return lookupObject<objectRegistry>(
name);
220 label curEvent = event_++;
224 if (objectRegistry::debug)
227 <<
"Event counter has overflowed. "
228 <<
"Resetting counter on all dependent objects." <<
nl
229 <<
"This might cause extra evaluations." <<
endl;
236 for (const_iterator iter = begin(); iter != end(); ++iter)
240 if (objectRegistry::debug)
242 Pout<<
"objectRegistry::getEvent() : "
243 <<
"resetting count on " << iter.key() <<
endl;
259 if (objectRegistry::debug)
261 Pout<<
"objectRegistry::checkIn(regIOobject&) : "
262 <<
name() <<
" : checking in " << io.
name()
263 <<
" of type " << io.type()
269 if (cacheTemporaryObjects_.size())
273 cacheTemporaryObjects_.find(io.
name())
276 if (cacheIter != cacheTemporaryObjects_.
end())
280 if (iter != end() && iter() != &io && iter()->ownedByRegistry())
282 if (objectRegistry::debug)
284 Pout<<
"objectRegistry::checkIn(regIOobject&) : "
285 <<
name() <<
" : deleting cached object " << iter.key()
289 cacheIter().first() =
false;
290 deleteCachedObject(*iter());
305 if (objectRegistry::debug)
307 Pout<<
"objectRegistry::checkOut(regIOobject&) : "
308 <<
name() <<
" : checking out " << iter.key()
314 if (objectRegistry::debug)
317 <<
name() <<
" : attempt to checkOut copy of "
340 if (objectRegistry::debug)
342 Pout<<
"objectRegistry::checkOut(regIOobject&) : "
343 <<
name() <<
" : could not find " << io.
name()
344 <<
" in registry " <<
name()
356 label nMyObjects = 0;
358 for (iterator iter = begin(); iter != end(); ++iter)
360 if (iter()->ownedByRegistry())
362 myObjects[nMyObjects++] = iter();
366 for (
label i=0; i < nMyObjects; i++)
368 checkOut(*myObjects[i]);
378 if (!cacheTemporaryObjects_.found(
name))
380 cacheTemporaryObjects_.insert(
name, {
false,
false});
390 return cacheTemporaryObjects_.found(
name);
399 if (cacheTemporaryObjects_.size())
403 cacheTemporaryObjects_.find(ob.
name())
408 if (iter != cacheTemporaryObjects_.
end())
410 iter().first() =
false;
418 bool enabled = cacheTemporaryObjects_.size();
426 if (orPtr_ && orPtr_ !=
this)
437 cacheTemporaryObjects_,
444 <<
"Could not find temporary object " << iter.key()
445 <<
" in registry " <<
name() <<
nl
446 <<
"Available temporary objects "
452 iter().second() =
false;
456 temporaryObjects_.clear();
470 if (i == string::npos)
476 dbDir_.
replace(i+1, string::npos, newName);
485 if (iter()->modified())
497 dependents_.setSize(size());
502 if (iter()->dependenciesModified())
504 dependents_[
count++] = iter();
507 dependents_.setSize(
count);
515 bool modified =
false;
517 for (iterator iter = begin(); iter != end(); ++iter)
519 if (objectRegistry::debug)
521 Pout<<
"objectRegistry::readModifiedObjects() : "
522 <<
name() <<
" : Considering reading object "
523 << iter.key() <<
endl;
526 modified = modified || iter()->readIfModified();
539 dependents_[i]->read();
548 dependenciesModified();
550 const bool modified = readIfModified();
569 os <<
" " <<
setf(ios_base::left)
570 <<
setw(39) << sortedObjects[i].key()
571 <<
' ' << sortedObjects[i]()->
type()
589 if (objectRegistry::debug)
591 Pout<<
"objectRegistry::write() : "
592 <<
name() <<
" : Considering writing object "
594 <<
" of type " << iter()->type()
595 <<
" with writeOpt " << iter()->writeOpt()
596 <<
" to file " << iter()->objectPath()
600 if (iter()->writeOpt() != NO_WRITE)
602 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.
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.
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.
word name(const bool)
Return a word representation of a bool.
Omanip< int > setw(const int i)
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
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