objectRegistry: Corrected caching of registered temporary objects
For example the generation term in the k-epsilon turbulence kEpsilon:G is a
temporary field that is specifically named and registered so that it can be
looked-up be the wall-function boundary conditions and requires slightly
different handling compared to normal temporary fields which are not registered.
The tutorials/incompressible/simpleFoam/pitzDaily case now demostrates this
functionality with the addition of
cacheTemporaryObjects
(
kEpsilon:G
);
functions
{
#includeFunc writeObjects(objects = (kEpsilon:G))
}
in controlDict which caches kEpsilon:G and writes it at every write time.
This commit is contained in:
@ -82,6 +82,15 @@ void Foam::objectRegistry::readCacheTemporaryObjects() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::objectRegistry::deleteCachedObject(regIOobject& cachedOb) const
|
||||||
|
{
|
||||||
|
cachedOb.release();
|
||||||
|
cachedOb.checkOut();
|
||||||
|
cachedOb.rename(cachedOb.name() + "Cached");
|
||||||
|
delete &cachedOb;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::objectRegistry::objectRegistry
|
Foam::objectRegistry::objectRegistry
|
||||||
@ -255,6 +264,34 @@ bool Foam::objectRegistry::checkIn(regIOobject& io) const
|
|||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Delete cached object with the same name as io and if it is in the
|
||||||
|
// cacheTemporaryObjects list
|
||||||
|
if (cacheTemporaryObjects_.size())
|
||||||
|
{
|
||||||
|
HashTable<Pair<bool>>::iterator cacheIter
|
||||||
|
(
|
||||||
|
cacheTemporaryObjects_.find(io.name())
|
||||||
|
);
|
||||||
|
|
||||||
|
if (cacheIter != cacheTemporaryObjects_.end())
|
||||||
|
{
|
||||||
|
iterator iter = const_cast<objectRegistry&>(*this).find(io.name());
|
||||||
|
|
||||||
|
if (iter != end() && iter() != &io && iter()->ownedByRegistry())
|
||||||
|
{
|
||||||
|
if (objectRegistry::debug)
|
||||||
|
{
|
||||||
|
Pout<< "objectRegistry::checkIn(regIOobject&) : "
|
||||||
|
<< name() << " : deleting cached object " << iter.key()
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
cacheIter().first() = false;
|
||||||
|
deleteCachedObject(*iter());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return const_cast<objectRegistry&>(*this).insert(io.name(), &io);
|
return const_cast<objectRegistry&>(*this).insert(io.name(), &io);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -87,8 +87,12 @@ class objectRegistry
|
|||||||
// Used to terminate searching within the ancestors
|
// Used to terminate searching within the ancestors
|
||||||
bool parentNotTime() const;
|
bool parentNotTime() const;
|
||||||
|
|
||||||
|
//- Read the cacheTemporaryObjects list from controlDict
|
||||||
void readCacheTemporaryObjects() const;
|
void readCacheTemporaryObjects() const;
|
||||||
|
|
||||||
|
//- Delete the current cached object before caching a new object
|
||||||
|
void deleteCachedObject(regIOobject& cachedOb) const;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|||||||
@ -240,10 +240,7 @@ bool Foam::objectRegistry::cacheTemporaryObject(Object& ob) const
|
|||||||
// If the object is already cached in the database delete it
|
// If the object is already cached in the database delete it
|
||||||
if (&cachedOb != &ob && cachedOb.ownedByRegistry())
|
if (&cachedOb != &ob && cachedOb.ownedByRegistry())
|
||||||
{
|
{
|
||||||
cachedOb.release();
|
deleteCachedObject(cachedOb);
|
||||||
cachedOb.checkOut();
|
|
||||||
cachedOb.rename(cachedOb.name() + "Cached");
|
|
||||||
delete &cachedOb;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -50,4 +50,14 @@ functions
|
|||||||
#includeFunc streamlines
|
#includeFunc streamlines
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cacheTemporaryObjects
|
||||||
|
(
|
||||||
|
kEpsilon:G
|
||||||
|
);
|
||||||
|
|
||||||
|
functions
|
||||||
|
{
|
||||||
|
#includeFunc writeObjects(objects = (kEpsilon:G))
|
||||||
|
}
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
Reference in New Issue
Block a user