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()
280 if (cacheTemporaryObjects_.size())
284 cacheTemporaryObjects_.find(io.
name())
287 if (cacheIter != cacheTemporaryObjects_.
end())
291 if (iter != end() && iter() != &io && iter()->ownedByRegistry())
293 if (objectRegistry::debug)
295 Pout<<
"objectRegistry::checkIn(regIOobject&) : "
296 <<
name() <<
" : deleting cached object " << iter.key()
300 cacheIter().first() =
false;
301 deleteCachedObject(*iter());
316 if (objectRegistry::debug)
318 Pout<<
"objectRegistry::checkOut(regIOobject&) : "
319 <<
name() <<
" : checking out " << iter.key()
325 if (objectRegistry::debug)
328 <<
name() <<
" : attempt to checkOut copy of "
351 if (objectRegistry::debug)
353 Pout<<
"objectRegistry::checkOut(regIOobject&) : "
354 <<
name() <<
" : could not find " << io.
name()
355 <<
" in registry " <<
name()
367 label nMyObjects = 0;
369 for (iterator iter = begin(); iter != end(); ++iter)
371 if (iter()->ownedByRegistry())
373 myObjects[nMyObjects++] = iter();
377 for (
label i=0; i < nMyObjects; i++)
379 checkOut(*myObjects[i]);
391 return root.cacheTemporaryObjects_.found(
name);
400 if (cacheTemporaryObjects_.size())
404 cacheTemporaryObjects_.find(ob.
name())
409 if (iter != cacheTemporaryObjects_.
end())
411 iter().first() =
false;
418 time_.resetCacheTemporaryObject(ob);
431 if (orPtr_ && orPtr_ !=
this)
439 if (root.cacheTemporaryObjects_.empty())
449 root.cacheTemporaryObjects_,
456 <<
"Could not find temporary object " << iter.key()
457 <<
" in registry " <<
name() <<
nl
458 <<
"Available temporary objects "
464 cacheTemporaryObjects_.clear();
471 root.cacheTemporaryObjects_,
475 iter().second() =
false;
479 temporaryObjects_.clear();
492 if (i == string::npos)
498 dbDir_.
replace(i+1, string::npos, newName);
507 if (iter()->modified())
519 dependents_.setSize(size());
524 if (iter()->dependenciesModified())
526 dependents_[
count++] = iter();
529 dependents_.setSize(
count);
537 bool modified =
false;
539 for (iterator iter = begin(); iter != end(); ++iter)
541 if (objectRegistry::debug)
543 Pout<<
"objectRegistry::readModifiedObjects() : "
544 <<
name() <<
" : Considering reading object "
545 << iter.key() <<
endl;
548 modified = modified || iter()->readIfModified();
561 dependents_[i]->read();
570 dependenciesModified();
572 const bool modified = readIfModified();
591 os <<
" " <<
setf(ios_base::left)
592 <<
setw(39) << sortedObjects[i].key()
593 <<
' ' << sortedObjects[i]()->
type()
611 if (objectRegistry::debug)
613 Pout<<
"objectRegistry::write() : "
614 <<
name() <<
" : Considering writing object "
616 <<
" of type " << iter()->type()
617 <<
" with writeOpt " << iter()->writeOpt()
618 <<
" to file " << iter()->objectPath()
622 if (iter()->writeOpt() != NO_WRITE)
624 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