mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
INT: objectRegistry: optionally caching temporary objects (#2723)
- functionality introduced by openfoam.org to support selective
caching of temporary fields. The purpose is two-fold: to enable
diagnostics and to allow more places to use unregistered fields by
default.
For example to cache the grad(k) field in
cacheTemporaryObjects
(
grad(k)
);
If the name of a field which in never constructed is added to the
cacheTemporaryObjects list a waning message is generated which
includes a useful list of ALL the temporary fields constructed
during the time step
Multiple regions are also supported by specifying individual region
names in a cacheTemporaryObjects dictionary.
cacheTemporaryObjects
{
porous
(
porosityBlockage:UNbr
);
}
functions
{
writePorousObjects
{
type writeObjects;
libs (utilityFunctionObjects);
region porous;
writeControl writeTime;
writeOption anyWrite;
objects (porosityBlockage:UNbr);
}
}
This commit is contained in:
@ -361,6 +361,7 @@ $(regIOobject)/regIOobjectWrite.C
|
|||||||
|
|
||||||
db/IOobjectList/IOobjectList.C
|
db/IOobjectList/IOobjectList.C
|
||||||
db/objectRegistry/objectRegistry.C
|
db/objectRegistry/objectRegistry.C
|
||||||
|
db/objectRegistry/objectRegistryCache.C
|
||||||
db/CallbackRegistry/CallbackRegistryName.C
|
db/CallbackRegistry/CallbackRegistryName.C
|
||||||
|
|
||||||
dll = db/dynamicLibrary
|
dll = db/dynamicLibrary
|
||||||
|
|||||||
@ -459,6 +459,7 @@ Foam::Time::Time
|
|||||||
writeStreamOption_(IOstreamOption::ASCII),
|
writeStreamOption_(IOstreamOption::ASCII),
|
||||||
graphFormat_("raw"),
|
graphFormat_("raw"),
|
||||||
runTimeModifiable_(false),
|
runTimeModifiable_(false),
|
||||||
|
cacheTemporaryObjects_(true),
|
||||||
functionObjects_(*this, false)
|
functionObjects_(*this, false)
|
||||||
{
|
{
|
||||||
if (enableFunctionObjects)
|
if (enableFunctionObjects)
|
||||||
@ -525,6 +526,7 @@ Foam::Time::Time
|
|||||||
writeStreamOption_(IOstreamOption::ASCII),
|
writeStreamOption_(IOstreamOption::ASCII),
|
||||||
graphFormat_("raw"),
|
graphFormat_("raw"),
|
||||||
runTimeModifiable_(false),
|
runTimeModifiable_(false),
|
||||||
|
cacheTemporaryObjects_(true),
|
||||||
functionObjects_(*this, false)
|
functionObjects_(*this, false)
|
||||||
{
|
{
|
||||||
// Functions
|
// Functions
|
||||||
@ -609,6 +611,7 @@ Foam::Time::Time
|
|||||||
writeStreamOption_(IOstreamOption::ASCII),
|
writeStreamOption_(IOstreamOption::ASCII),
|
||||||
graphFormat_("raw"),
|
graphFormat_("raw"),
|
||||||
runTimeModifiable_(false),
|
runTimeModifiable_(false),
|
||||||
|
cacheTemporaryObjects_(true),
|
||||||
functionObjects_(*this, false)
|
functionObjects_(*this, false)
|
||||||
{
|
{
|
||||||
if (enableFunctionObjects)
|
if (enableFunctionObjects)
|
||||||
@ -683,6 +686,7 @@ Foam::Time::Time
|
|||||||
writeStreamOption_(IOstreamOption::ASCII),
|
writeStreamOption_(IOstreamOption::ASCII),
|
||||||
graphFormat_("raw"),
|
graphFormat_("raw"),
|
||||||
runTimeModifiable_(false),
|
runTimeModifiable_(false),
|
||||||
|
cacheTemporaryObjects_(true),
|
||||||
functionObjects_(*this, false)
|
functionObjects_(*this, false)
|
||||||
{
|
{
|
||||||
if (enableFunctionObjects)
|
if (enableFunctionObjects)
|
||||||
@ -885,6 +889,11 @@ bool Foam::Time::run() const
|
|||||||
addProfiling(fo, "functionObjects.end()");
|
addProfiling(fo, "functionObjects.end()");
|
||||||
functionObjects_.end();
|
functionObjects_.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cacheTemporaryObjects_)
|
||||||
|
{
|
||||||
|
cacheTemporaryObjects_ = checkCacheTemporaryObjects();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -915,6 +924,11 @@ bool Foam::Time::run() const
|
|||||||
{
|
{
|
||||||
const_cast<Time&>(*this).readModifiedObjects();
|
const_cast<Time&>(*this).readModifiedObjects();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cacheTemporaryObjects_)
|
||||||
|
{
|
||||||
|
cacheTemporaryObjects_ = checkCacheTemporaryObjects();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the "is-running" status following the
|
// Update the "is-running" status following the
|
||||||
|
|||||||
@ -5,8 +5,8 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||||
Copyright (C) 2016-2020 OpenCFD Ltd.
|
Copyright (C) 2016-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -215,6 +215,9 @@ private:
|
|||||||
//- Is runtime modification of dictionaries allowed?
|
//- Is runtime modification of dictionaries allowed?
|
||||||
Switch runTimeModifiable_;
|
Switch runTimeModifiable_;
|
||||||
|
|
||||||
|
//- Is temporary object cache enabled?
|
||||||
|
mutable bool cacheTemporaryObjects_;
|
||||||
|
|
||||||
//- Function objects executed at start and on ++, +=
|
//- Function objects executed at start and on ++, +=
|
||||||
mutable functionObjectList functionObjects_;
|
mutable functionObjectList functionObjects_;
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||||
Copyright (C) 2015-2023 OpenCFD Ltd.
|
Copyright (C) 2015-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -98,7 +98,10 @@ Foam::objectRegistry::objectRegistry(const Time& t, const label nObjects)
|
|||||||
time_(t),
|
time_(t),
|
||||||
parent_(t),
|
parent_(t),
|
||||||
dbDir_(name()),
|
dbDir_(name()),
|
||||||
event_(1)
|
event_(1),
|
||||||
|
cacheTemporaryObjectsActive_(false),
|
||||||
|
cacheTemporaryObjects_(0),
|
||||||
|
temporaryObjects_(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
@ -109,7 +112,10 @@ Foam::objectRegistry::objectRegistry(const IOobject& io, const label nObjects)
|
|||||||
time_(io.time()),
|
time_(io.time()),
|
||||||
parent_(io.db()),
|
parent_(io.db()),
|
||||||
dbDir_(parent_.dbDir()/local()/name()),
|
dbDir_(parent_.dbDir()/local()/name()),
|
||||||
event_(1)
|
event_(1),
|
||||||
|
cacheTemporaryObjectsActive_(false),
|
||||||
|
cacheTemporaryObjects_(0),
|
||||||
|
temporaryObjects_(0)
|
||||||
{
|
{
|
||||||
writeOpt(IOobject::AUTO_WRITE);
|
writeOpt(IOobject::AUTO_WRITE);
|
||||||
}
|
}
|
||||||
@ -249,6 +255,8 @@ bool Foam::objectRegistry::checkIn(regIOobject* io) const
|
|||||||
{
|
{
|
||||||
if (!io) return false;
|
if (!io) return false;
|
||||||
|
|
||||||
|
objectRegistry& obr = const_cast<objectRegistry&>(*this);
|
||||||
|
|
||||||
if (objectRegistry::debug)
|
if (objectRegistry::debug)
|
||||||
{
|
{
|
||||||
Pout<< "objectRegistry::checkIn : "
|
Pout<< "objectRegistry::checkIn : "
|
||||||
@ -257,7 +265,36 @@ bool Foam::objectRegistry::checkIn(regIOobject* io) const
|
|||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
objectRegistry& obr = const_cast<objectRegistry&>(*this);
|
// Delete cached object if it has the same name as io, and in the
|
||||||
|
// cacheTemporaryObjects list
|
||||||
|
if (!cacheTemporaryObjects_.empty())
|
||||||
|
{
|
||||||
|
auto cacheIter = cacheTemporaryObjects_.find(io->name());
|
||||||
|
|
||||||
|
if (cacheIter.good())
|
||||||
|
{
|
||||||
|
iterator iter = obr.find(io->name());
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
iter.good()
|
||||||
|
&& iter.val() != io
|
||||||
|
&& iter.val()->ownedByRegistry()
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (objectRegistry::debug)
|
||||||
|
{
|
||||||
|
Pout<< "objectRegistry::checkIn : "
|
||||||
|
<< name() << " : deleting cached object "
|
||||||
|
<< io->name() << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
cacheIter.val().first() = false;
|
||||||
|
deleteCachedObject(iter.val());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool ok = obr.insert(io->name(), io);
|
bool ok = obr.insert(io->name(), io);
|
||||||
|
|
||||||
|
|||||||
@ -5,8 +5,8 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
Copyright (C) 2016-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -44,6 +44,7 @@ SourceFiles
|
|||||||
#include "UPtrList.H"
|
#include "UPtrList.H"
|
||||||
#include "regIOobject.H"
|
#include "regIOobject.H"
|
||||||
#include "wordRes.H"
|
#include "wordRes.H"
|
||||||
|
#include "Pair.H"
|
||||||
|
|
||||||
// Historically included by objectRegistryTemplates (until NOV-2018),
|
// Historically included by objectRegistryTemplates (until NOV-2018),
|
||||||
// but not used by objectRegistry directly.
|
// but not used by objectRegistry directly.
|
||||||
@ -78,6 +79,17 @@ class objectRegistry
|
|||||||
//- Current event
|
//- Current event
|
||||||
mutable label event_;
|
mutable label event_;
|
||||||
|
|
||||||
|
//- State of cacheTemporaryObjects_, set true after reading
|
||||||
|
mutable bool cacheTemporaryObjectsActive_;
|
||||||
|
|
||||||
|
//- Names of temporary object with current state
|
||||||
|
mutable HashTable<Pair<bool>> cacheTemporaryObjects_;
|
||||||
|
|
||||||
|
//- Accumulated list of temporary objects available to cache
|
||||||
|
// Used to provide diagnostics in case the requested object is not
|
||||||
|
// available
|
||||||
|
mutable wordHashSet temporaryObjects_;
|
||||||
|
|
||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
@ -85,6 +97,13 @@ class objectRegistry
|
|||||||
// Used to terminate searching within the ancestors
|
// Used to terminate searching within the ancestors
|
||||||
bool parentNotTime() const noexcept;
|
bool parentNotTime() const noexcept;
|
||||||
|
|
||||||
|
//- Read the cacheTemporaryObjects list from Time controlDict
|
||||||
|
void readCacheTemporaryObjects() const;
|
||||||
|
|
||||||
|
//- Delete the cached object. Eg, before caching a new object
|
||||||
|
//- A nullptr is ignored.
|
||||||
|
void deleteCachedObject(regIOobject* io) const;
|
||||||
|
|
||||||
//- Templated implementation for count()
|
//- Templated implementation for count()
|
||||||
// The number of items with a matching class
|
// The number of items with a matching class
|
||||||
template<class MatchPredicate1, class MatchPredicate2>
|
template<class MatchPredicate1, class MatchPredicate2>
|
||||||
@ -559,6 +578,30 @@ public:
|
|||||||
virtual void rename(const word& newName);
|
virtual void rename(const word& newName);
|
||||||
|
|
||||||
|
|
||||||
|
// Temporaries
|
||||||
|
|
||||||
|
//FUTURE //- Add given name to the set of temporary objects to cache
|
||||||
|
//FUTURE void addTemporaryObject(const word& name) const;
|
||||||
|
|
||||||
|
//- True if given name is in the cacheTemporaryObjects set
|
||||||
|
bool cacheTemporaryObject(const word& name) const;
|
||||||
|
|
||||||
|
//- Cache the given object. Moves content and stores
|
||||||
|
template<class Type>
|
||||||
|
bool cacheTemporaryObject(Type& obj) const;
|
||||||
|
|
||||||
|
//- Reset the cache state of the given object (nullptr is ignored)
|
||||||
|
void resetCacheTemporaryObject(const regIOobject* io) const;
|
||||||
|
|
||||||
|
//- Reset the cache state of the given object
|
||||||
|
// in the cacheTemporaryObjects set
|
||||||
|
void resetCacheTemporaryObject(const regIOobject& io) const;
|
||||||
|
|
||||||
|
//- Check that all objects specified in the cacheTemporaryObjects
|
||||||
|
//- were also cached
|
||||||
|
bool checkCacheTemporaryObjects() const;
|
||||||
|
|
||||||
|
|
||||||
// Reading
|
// Reading
|
||||||
|
|
||||||
//- Return true if any of the object's files have been modified
|
//- Return true if any of the object's files have been modified
|
||||||
@ -573,7 +616,7 @@ public:
|
|||||||
|
|
||||||
// Writing
|
// Writing
|
||||||
|
|
||||||
//- writeData function required by regIOobject but not used.
|
//- The writeData function is required by regIOobject but not used.
|
||||||
// For this class, write is used instead
|
// For this class, write is used instead
|
||||||
virtual bool writeData(Ostream&) const
|
virtual bool writeData(Ostream&) const
|
||||||
{
|
{
|
||||||
|
|||||||
183
src/OpenFOAM/db/objectRegistry/objectRegistryCache.C
Normal file
183
src/OpenFOAM/db/objectRegistry/objectRegistryCache.C
Normal file
@ -0,0 +1,183 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | www.openfoam.com
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Copyright (C) 2019 OpenFOAM Foundation
|
||||||
|
Copyright (C) 2023 OpenCFD Ltd.
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "objectRegistry.H"
|
||||||
|
#include "Time.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::objectRegistry::readCacheTemporaryObjects() const
|
||||||
|
{
|
||||||
|
if (cacheTemporaryObjectsActive_) return;
|
||||||
|
|
||||||
|
const auto* eptr = time_.controlDict().findEntry
|
||||||
|
(
|
||||||
|
"cacheTemporaryObjects",
|
||||||
|
keyType::LITERAL
|
||||||
|
);
|
||||||
|
|
||||||
|
if (eptr)
|
||||||
|
{
|
||||||
|
cacheTemporaryObjectsActive_ = true;
|
||||||
|
|
||||||
|
// Clear old cache?
|
||||||
|
// cacheTemporaryObjects_.clear();
|
||||||
|
|
||||||
|
wordList objectNames;
|
||||||
|
|
||||||
|
if (eptr->isDict())
|
||||||
|
{
|
||||||
|
// Per region (sub-dictionary syntax)
|
||||||
|
eptr->dict().readIfPresent(name(), objectNames);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// All regions
|
||||||
|
eptr->readEntry(objectNames);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const word& objName : objectNames)
|
||||||
|
{
|
||||||
|
cacheTemporaryObjects_.emplace(objName, false, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::objectRegistry::deleteCachedObject(regIOobject* io) const
|
||||||
|
{
|
||||||
|
if (io)
|
||||||
|
{
|
||||||
|
io->release(); // Relinquish any ownership by registry
|
||||||
|
io->checkOut();
|
||||||
|
delete io;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// FUTURE: (currently not needed)
|
||||||
|
// void Foam::objectRegistry::addTemporaryObject
|
||||||
|
// (
|
||||||
|
// const word& name
|
||||||
|
// ) const
|
||||||
|
// {
|
||||||
|
// cacheTemporaryObjects_.emplace(name, false, false);
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::objectRegistry::cacheTemporaryObject
|
||||||
|
(
|
||||||
|
const word& name
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
return cacheTemporaryObjects_.found(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::objectRegistry::resetCacheTemporaryObject
|
||||||
|
(
|
||||||
|
const regIOobject* io
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
if (io && !cacheTemporaryObjects_.empty())
|
||||||
|
{
|
||||||
|
auto iter = cacheTemporaryObjects_.find(io->name());
|
||||||
|
|
||||||
|
// Reset the cached flag
|
||||||
|
if (iter.good())
|
||||||
|
{
|
||||||
|
iter.val().first() = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::objectRegistry::resetCacheTemporaryObject
|
||||||
|
(
|
||||||
|
const regIOobject& io
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
resetCacheTemporaryObject(&io);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::objectRegistry::checkCacheTemporaryObjects() const
|
||||||
|
{
|
||||||
|
bool enabled = cacheTemporaryObjects_.size();
|
||||||
|
|
||||||
|
forAllConstIters(*this, iter)
|
||||||
|
{
|
||||||
|
const auto* subObr = dynamic_cast<const objectRegistry*>(iter.val());
|
||||||
|
|
||||||
|
// Protect against re-searching the top-level registry
|
||||||
|
if (subObr && subObr != this)
|
||||||
|
{
|
||||||
|
enabled = subObr->checkCacheTemporaryObjects() || enabled;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (enabled)
|
||||||
|
{
|
||||||
|
OSstream* emitWarning = nullptr;
|
||||||
|
|
||||||
|
forAllIters(cacheTemporaryObjects_, iter)
|
||||||
|
{
|
||||||
|
if (!iter.val().second())
|
||||||
|
{
|
||||||
|
if (!emitWarning)
|
||||||
|
{
|
||||||
|
emitWarning = &(Foam::Warning.stream());
|
||||||
|
|
||||||
|
*emitWarning
|
||||||
|
<< "objectRegistry '"
|
||||||
|
<< name() << "' has missing temporary objects:" << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
*emitWarning<< " " << iter.key() << nl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
iter.val().second() = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (emitWarning)
|
||||||
|
{
|
||||||
|
*emitWarning
|
||||||
|
<< "Available temporary objects: "
|
||||||
|
<< temporaryObjects_.sortedToc() << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
temporaryObjects_.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -5,8 +5,8 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2015 OpenFOAM Foundation
|
Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
Copyright (C) 2016-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -595,4 +595,50 @@ Type& Foam::objectRegistry::lookupObjectRef
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
bool Foam::objectRegistry::cacheTemporaryObject(Type& obj) const
|
||||||
|
{
|
||||||
|
bool ok = false;
|
||||||
|
|
||||||
|
readCacheTemporaryObjects();
|
||||||
|
|
||||||
|
if (cacheTemporaryObjects_.size())
|
||||||
|
{
|
||||||
|
temporaryObjects_.insert(obj.name());
|
||||||
|
|
||||||
|
auto iter = cacheTemporaryObjects_.find(obj.name());
|
||||||
|
|
||||||
|
// Cache object if is in the cacheTemporaryObjects list
|
||||||
|
// and hasn't been cached yet
|
||||||
|
if (iter.good() && iter.val().first() == false)
|
||||||
|
{
|
||||||
|
iter.val().first() = true;
|
||||||
|
iter.val().second() = true;
|
||||||
|
|
||||||
|
Type* cachedPtr = obj.db().template getObjectPtr<Type>(obj.name());
|
||||||
|
|
||||||
|
// Remove any name collisions from the cache
|
||||||
|
if (cachedPtr && cachedPtr != &obj && cachedPtr->ownedByRegistry())
|
||||||
|
{
|
||||||
|
deleteCachedObject(cachedPtr);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Info<< "Caching " << obj.name()
|
||||||
|
<< " of type " << obj.type() << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
obj.release();
|
||||||
|
obj.checkOut();
|
||||||
|
regIOobject::store(new Type(std::move(obj)));
|
||||||
|
|
||||||
|
ok = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -178,6 +178,9 @@ Foam::regIOobject::~regIOobject()
|
|||||||
// checkOut(). By being 'unowned', the registry will not attempt a
|
// checkOut(). By being 'unowned', the registry will not attempt a
|
||||||
// second deletion when the object name is removed from the registry.
|
// second deletion when the object name is removed from the registry.
|
||||||
|
|
||||||
|
// Reset the cache state (if any)
|
||||||
|
db().resetCacheTemporaryObject(this);
|
||||||
|
|
||||||
// Revoke any registry ownership: we are already deleting
|
// Revoke any registry ownership: we are already deleting
|
||||||
ownedByRegistry_ = false;
|
ownedByRegistry_ = false;
|
||||||
|
|
||||||
|
|||||||
@ -37,8 +37,11 @@ Foam::DimensionedField<Type, GeoMesh>::New
|
|||||||
const Field<Type>& iField
|
const Field<Type>& iField
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return tmp<DimensionedField<Type, GeoMesh>>::New
|
const bool caching = mesh.thisDb().cacheTemporaryObject(name);
|
||||||
|
|
||||||
|
return tmp<DimensionedField<Type, GeoMesh>>::NewImmovable
|
||||||
(
|
(
|
||||||
|
caching, // (true: immovable, false: movable)
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
name,
|
name,
|
||||||
@ -46,7 +49,7 @@ Foam::DimensionedField<Type, GeoMesh>::New
|
|||||||
mesh.thisDb(),
|
mesh.thisDb(),
|
||||||
IOobjectOption::NO_READ,
|
IOobjectOption::NO_READ,
|
||||||
IOobjectOption::NO_WRITE,
|
IOobjectOption::NO_WRITE,
|
||||||
IOobjectOption::NO_REGISTER
|
caching // (true: REGISTER, false: NO_REGISTER)
|
||||||
),
|
),
|
||||||
mesh,
|
mesh,
|
||||||
dims,
|
dims,
|
||||||
@ -65,8 +68,11 @@ Foam::DimensionedField<Type, GeoMesh>::New
|
|||||||
Field<Type>&& iField
|
Field<Type>&& iField
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return tmp<DimensionedField<Type, GeoMesh>>::New
|
const bool caching = mesh.thisDb().cacheTemporaryObject(name);
|
||||||
|
|
||||||
|
return tmp<DimensionedField<Type, GeoMesh>>::NewImmovable
|
||||||
(
|
(
|
||||||
|
caching, // (true: immovable, false: movable)
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
name,
|
name,
|
||||||
@ -74,7 +80,7 @@ Foam::DimensionedField<Type, GeoMesh>::New
|
|||||||
mesh.thisDb(),
|
mesh.thisDb(),
|
||||||
IOobjectOption::NO_READ,
|
IOobjectOption::NO_READ,
|
||||||
IOobjectOption::NO_WRITE,
|
IOobjectOption::NO_WRITE,
|
||||||
IOobjectOption::NO_REGISTER
|
caching // (true: REGISTER, false: NO_REGISTER)
|
||||||
),
|
),
|
||||||
mesh,
|
mesh,
|
||||||
dims,
|
dims,
|
||||||
@ -92,8 +98,11 @@ Foam::DimensionedField<Type, GeoMesh>::New
|
|||||||
const dimensionSet& dims
|
const dimensionSet& dims
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return tmp<DimensionedField<Type, GeoMesh>>::New
|
const bool caching = mesh.thisDb().cacheTemporaryObject(name);
|
||||||
|
|
||||||
|
return tmp<DimensionedField<Type, GeoMesh>>::NewImmovable
|
||||||
(
|
(
|
||||||
|
caching, // (true: immovable, false: movable)
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
name,
|
name,
|
||||||
@ -101,7 +110,7 @@ Foam::DimensionedField<Type, GeoMesh>::New
|
|||||||
mesh.thisDb(),
|
mesh.thisDb(),
|
||||||
IOobjectOption::NO_READ,
|
IOobjectOption::NO_READ,
|
||||||
IOobjectOption::NO_WRITE,
|
IOobjectOption::NO_WRITE,
|
||||||
IOobjectOption::NO_REGISTER
|
caching // (true: REGISTER, false: NO_REGISTER)
|
||||||
),
|
),
|
||||||
mesh,
|
mesh,
|
||||||
dims,
|
dims,
|
||||||
@ -120,8 +129,11 @@ Foam::DimensionedField<Type, GeoMesh>::New
|
|||||||
const dimensionSet& dims
|
const dimensionSet& dims
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return tmp<DimensionedField<Type, GeoMesh>>::New
|
const bool caching = mesh.thisDb().cacheTemporaryObject(name);
|
||||||
|
|
||||||
|
return tmp<DimensionedField<Type, GeoMesh>>::NewImmovable
|
||||||
(
|
(
|
||||||
|
caching, // (true: immovable, false: movable)
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
name,
|
name,
|
||||||
@ -129,7 +141,7 @@ Foam::DimensionedField<Type, GeoMesh>::New
|
|||||||
mesh.thisDb(),
|
mesh.thisDb(),
|
||||||
IOobjectOption::NO_READ,
|
IOobjectOption::NO_READ,
|
||||||
IOobjectOption::NO_WRITE,
|
IOobjectOption::NO_WRITE,
|
||||||
IOobjectOption::NO_REGISTER
|
caching // (true: REGISTER, false: NO_REGISTER)
|
||||||
),
|
),
|
||||||
mesh,
|
mesh,
|
||||||
value,
|
value,
|
||||||
@ -166,8 +178,11 @@ Foam::DimensionedField<Type, GeoMesh>::New
|
|||||||
const tmp<DimensionedField<Type, GeoMesh>>& tfld
|
const tmp<DimensionedField<Type, GeoMesh>>& tfld
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return tmp<DimensionedField<Type, GeoMesh>>::New
|
const bool caching = tfld().db().cacheTemporaryObject(name);
|
||||||
|
|
||||||
|
return tmp<DimensionedField<Type, GeoMesh>>::NewImmovable
|
||||||
(
|
(
|
||||||
|
caching, // (true: immovable, false: movable)
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
name,
|
name,
|
||||||
@ -176,7 +191,7 @@ Foam::DimensionedField<Type, GeoMesh>::New
|
|||||||
tfld().db(),
|
tfld().db(),
|
||||||
IOobjectOption::NO_READ,
|
IOobjectOption::NO_READ,
|
||||||
IOobjectOption::NO_WRITE,
|
IOobjectOption::NO_WRITE,
|
||||||
IOobjectOption::NO_REGISTER
|
caching // (true: REGISTER, false: NO_REGISTER)
|
||||||
),
|
),
|
||||||
tfld
|
tfld
|
||||||
);
|
);
|
||||||
@ -193,8 +208,11 @@ Foam::DimensionedField<Type, GeoMesh>::New
|
|||||||
const dimensionSet& dims
|
const dimensionSet& dims
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return tmp<DimensionedField<Type, GeoMesh>>::New
|
const bool caching = fld.db().cacheTemporaryObject(name);
|
||||||
|
|
||||||
|
return tmp<DimensionedField<Type, GeoMesh>>::NewImmovable
|
||||||
(
|
(
|
||||||
|
caching, // (true: immovable, false: movable)
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
name,
|
name,
|
||||||
@ -202,7 +220,7 @@ Foam::DimensionedField<Type, GeoMesh>::New
|
|||||||
fld.db(),
|
fld.db(),
|
||||||
IOobjectOption::NO_READ,
|
IOobjectOption::NO_READ,
|
||||||
IOobjectOption::NO_WRITE,
|
IOobjectOption::NO_WRITE,
|
||||||
IOobjectOption::NO_REGISTER
|
caching // (true: REGISTER, false: NO_REGISTER)
|
||||||
),
|
),
|
||||||
fld.mesh(),
|
fld.mesh(),
|
||||||
dims
|
dims
|
||||||
@ -220,8 +238,11 @@ Foam::DimensionedField<Type, GeoMesh>::New
|
|||||||
const dimensioned<Type>& dt
|
const dimensioned<Type>& dt
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return tmp<DimensionedField<Type, GeoMesh>>::New
|
const bool caching = fld.db().cacheTemporaryObject(name);
|
||||||
|
|
||||||
|
return tmp<DimensionedField<Type, GeoMesh>>::NewImmovable
|
||||||
(
|
(
|
||||||
|
caching, // (true: immovable, false: movable)
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
name,
|
name,
|
||||||
@ -229,7 +250,7 @@ Foam::DimensionedField<Type, GeoMesh>::New
|
|||||||
fld.db(),
|
fld.db(),
|
||||||
IOobjectOption::NO_READ,
|
IOobjectOption::NO_READ,
|
||||||
IOobjectOption::NO_WRITE,
|
IOobjectOption::NO_WRITE,
|
||||||
IOobjectOption::NO_REGISTER
|
caching // (true: REGISTER, false: NO_REGISTER)
|
||||||
),
|
),
|
||||||
fld.mesh(),
|
fld.mesh(),
|
||||||
dt.value(),
|
dt.value(),
|
||||||
|
|||||||
@ -38,8 +38,11 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
|||||||
const word& patchFieldType
|
const word& patchFieldType
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return tmp<GeometricField<Type, PatchField, GeoMesh>>::New
|
const bool caching = mesh.thisDb().cacheTemporaryObject(name);
|
||||||
|
|
||||||
|
return tmp<GeometricField<Type, PatchField, GeoMesh>>::NewImmovable
|
||||||
(
|
(
|
||||||
|
caching, // (true: immovable, false: movable)
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
name,
|
name,
|
||||||
@ -47,7 +50,7 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
|||||||
mesh.thisDb(),
|
mesh.thisDb(),
|
||||||
IOobjectOption::NO_READ,
|
IOobjectOption::NO_READ,
|
||||||
IOobjectOption::NO_WRITE,
|
IOobjectOption::NO_WRITE,
|
||||||
IOobjectOption::NO_REGISTER
|
caching // (true: REGISTER, false: NO_REGISTER)
|
||||||
),
|
),
|
||||||
mesh,
|
mesh,
|
||||||
dims,
|
dims,
|
||||||
@ -67,8 +70,11 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
|||||||
const word& patchFieldType
|
const word& patchFieldType
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return tmp<GeometricField<Type, PatchField, GeoMesh>>::New
|
const bool caching = mesh.thisDb().cacheTemporaryObject(name);
|
||||||
|
|
||||||
|
return tmp<GeometricField<Type, PatchField, GeoMesh>>::NewImmovable
|
||||||
(
|
(
|
||||||
|
caching, // (true: immovable, false: movable)
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
name,
|
name,
|
||||||
@ -76,7 +82,7 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
|||||||
mesh.thisDb(),
|
mesh.thisDb(),
|
||||||
IOobjectOption::NO_READ,
|
IOobjectOption::NO_READ,
|
||||||
IOobjectOption::NO_WRITE,
|
IOobjectOption::NO_WRITE,
|
||||||
IOobjectOption::NO_REGISTER
|
caching // (true: REGISTER, false: NO_REGISTER)
|
||||||
),
|
),
|
||||||
mesh,
|
mesh,
|
||||||
dims,
|
dims,
|
||||||
@ -97,8 +103,11 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
|||||||
const word& patchFieldType
|
const word& patchFieldType
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return tmp<GeometricField<Type, PatchField, GeoMesh>>::New
|
const bool caching = mesh.thisDb().cacheTemporaryObject(name);
|
||||||
|
|
||||||
|
return tmp<GeometricField<Type, PatchField, GeoMesh>>::NewImmovable
|
||||||
(
|
(
|
||||||
|
caching, // (true: immovable, false: movable)
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
name,
|
name,
|
||||||
@ -106,7 +115,7 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
|||||||
mesh.thisDb(),
|
mesh.thisDb(),
|
||||||
IOobjectOption::NO_READ,
|
IOobjectOption::NO_READ,
|
||||||
IOobjectOption::NO_WRITE,
|
IOobjectOption::NO_WRITE,
|
||||||
IOobjectOption::NO_REGISTER
|
caching // (true: REGISTER, false: NO_REGISTER)
|
||||||
),
|
),
|
||||||
mesh,
|
mesh,
|
||||||
dims,
|
dims,
|
||||||
@ -127,8 +136,11 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
|||||||
const word& patchFieldType
|
const word& patchFieldType
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return tmp<GeometricField<Type, PatchField, GeoMesh>>::New
|
const bool caching = mesh.thisDb().cacheTemporaryObject(name);
|
||||||
|
|
||||||
|
return tmp<GeometricField<Type, PatchField, GeoMesh>>::NewImmovable
|
||||||
(
|
(
|
||||||
|
caching, // (true: immovable, false: movable)
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
name,
|
name,
|
||||||
@ -136,7 +148,7 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
|||||||
mesh.thisDb(),
|
mesh.thisDb(),
|
||||||
IOobjectOption::NO_READ,
|
IOobjectOption::NO_READ,
|
||||||
IOobjectOption::NO_WRITE,
|
IOobjectOption::NO_WRITE,
|
||||||
IOobjectOption::NO_REGISTER
|
caching // (true: REGISTER, false: NO_REGISTER)
|
||||||
),
|
),
|
||||||
mesh,
|
mesh,
|
||||||
value,
|
value,
|
||||||
@ -158,8 +170,11 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
|||||||
const wordList& actualPatchTypes
|
const wordList& actualPatchTypes
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return tmp<GeometricField<Type, PatchField, GeoMesh>>::New
|
const bool caching = mesh.thisDb().cacheTemporaryObject(name);
|
||||||
|
|
||||||
|
return tmp<GeometricField<Type, PatchField, GeoMesh>>::NewImmovable
|
||||||
(
|
(
|
||||||
|
caching, // (true: immovable, false: movable)
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
name,
|
name,
|
||||||
@ -167,7 +182,7 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
|||||||
mesh.thisDb(),
|
mesh.thisDb(),
|
||||||
IOobjectOption::NO_READ,
|
IOobjectOption::NO_READ,
|
||||||
IOobjectOption::NO_WRITE,
|
IOobjectOption::NO_WRITE,
|
||||||
IOobjectOption::NO_REGISTER
|
caching // (true: REGISTER, false: NO_REGISTER)
|
||||||
),
|
),
|
||||||
mesh,
|
mesh,
|
||||||
value,
|
value,
|
||||||
@ -231,8 +246,11 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
|||||||
const word& patchFieldType
|
const word& patchFieldType
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return tmp<GeometricField<Type, PatchField, GeoMesh>>::New
|
const bool caching = tgf().db().cacheTemporaryObject(name);
|
||||||
|
|
||||||
|
return tmp<GeometricField<Type, PatchField, GeoMesh>>::NewImmovable
|
||||||
(
|
(
|
||||||
|
caching, // (true: immovable, false: movable)
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
name,
|
name,
|
||||||
@ -241,7 +259,7 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
|||||||
tgf().db(),
|
tgf().db(),
|
||||||
IOobjectOption::NO_READ,
|
IOobjectOption::NO_READ,
|
||||||
IOobjectOption::NO_WRITE,
|
IOobjectOption::NO_WRITE,
|
||||||
IOobjectOption::NO_REGISTER
|
caching // (true: REGISTER, false: NO_REGISTER)
|
||||||
),
|
),
|
||||||
tgf,
|
tgf,
|
||||||
patchFieldType
|
patchFieldType
|
||||||
@ -257,8 +275,11 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
|||||||
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf
|
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return tmp<GeometricField<Type, PatchField, GeoMesh>>::New
|
const bool caching = tgf().db().cacheTemporaryObject(name);
|
||||||
|
|
||||||
|
return tmp<GeometricField<Type, PatchField, GeoMesh>>::NewImmovable
|
||||||
(
|
(
|
||||||
|
caching, // (true: immovable, false: movable)
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
name,
|
name,
|
||||||
@ -267,7 +288,7 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
|||||||
tgf().db(),
|
tgf().db(),
|
||||||
IOobjectOption::NO_READ,
|
IOobjectOption::NO_READ,
|
||||||
IOobjectOption::NO_WRITE,
|
IOobjectOption::NO_WRITE,
|
||||||
IOobjectOption::NO_REGISTER
|
caching // (true: REGISTER, false: NO_REGISTER)
|
||||||
),
|
),
|
||||||
tgf
|
tgf
|
||||||
);
|
);
|
||||||
@ -284,8 +305,11 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
|||||||
const wordList& actualPatchTypes
|
const wordList& actualPatchTypes
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return tmp<GeometricField<Type, PatchField, GeoMesh>>::New
|
const bool caching = tgf().db().cacheTemporaryObject(name);
|
||||||
|
|
||||||
|
return tmp<GeometricField<Type, PatchField, GeoMesh>>::NewImmovable
|
||||||
(
|
(
|
||||||
|
caching, // (true: immovable, false: movable)
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
name,
|
name,
|
||||||
@ -294,7 +318,7 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
|||||||
tgf().db(),
|
tgf().db(),
|
||||||
IOobjectOption::NO_READ,
|
IOobjectOption::NO_READ,
|
||||||
IOobjectOption::NO_WRITE,
|
IOobjectOption::NO_WRITE,
|
||||||
IOobjectOption::NO_REGISTER
|
caching // (true: REGISTER, false: NO_REGISTER)
|
||||||
),
|
),
|
||||||
tgf,
|
tgf,
|
||||||
patchFieldTypes,
|
patchFieldTypes,
|
||||||
@ -314,8 +338,11 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
|||||||
const word& patchFieldType
|
const word& patchFieldType
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return tmp<GeometricField<Type, PatchField, GeoMesh>>::New
|
const bool caching = fld.db().cacheTemporaryObject(name);
|
||||||
|
|
||||||
|
return tmp<GeometricField<Type, PatchField, GeoMesh>>::NewImmovable
|
||||||
(
|
(
|
||||||
|
caching, // (true: immovable, false: movable)
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
name,
|
name,
|
||||||
@ -323,7 +350,7 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
|||||||
fld.db(),
|
fld.db(),
|
||||||
IOobjectOption::NO_READ,
|
IOobjectOption::NO_READ,
|
||||||
IOobjectOption::NO_WRITE,
|
IOobjectOption::NO_WRITE,
|
||||||
IOobjectOption::NO_REGISTER
|
caching // (true: REGISTER, false: NO_REGISTER)
|
||||||
),
|
),
|
||||||
fld.mesh(),
|
fld.mesh(),
|
||||||
dims,
|
dims,
|
||||||
@ -343,8 +370,11 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
|||||||
const word& patchFieldType
|
const word& patchFieldType
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return tmp<GeometricField<Type, PatchField, GeoMesh>>::New
|
const bool caching = fld.db().cacheTemporaryObject(name);
|
||||||
|
|
||||||
|
return tmp<GeometricField<Type, PatchField, GeoMesh>>::NewImmovable
|
||||||
(
|
(
|
||||||
|
caching, // (true: immovable, false: movable)
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
name,
|
name,
|
||||||
@ -352,7 +382,7 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
|||||||
fld.db(),
|
fld.db(),
|
||||||
IOobjectOption::NO_READ,
|
IOobjectOption::NO_READ,
|
||||||
IOobjectOption::NO_WRITE,
|
IOobjectOption::NO_WRITE,
|
||||||
IOobjectOption::NO_REGISTER
|
caching // (true: REGISTER, false: NO_REGISTER)
|
||||||
),
|
),
|
||||||
fld.mesh(),
|
fld.mesh(),
|
||||||
dt.value(),
|
dt.value(),
|
||||||
|
|||||||
@ -219,11 +219,24 @@ bool Foam::functionObjects::writeObjects::write()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log << " writing object " << obj.name() << endl;
|
// TBD:
|
||||||
|
// If the object is a temporary field expression wrap with tmp<...>
|
||||||
|
|
||||||
|
// if (obj.db().cacheTemporaryObject(objName))
|
||||||
|
// {
|
||||||
|
// obj.IOobject::rename("tmp<" + objName + ">");
|
||||||
|
//
|
||||||
|
// Log << " writing object " << obj.name() << endl;
|
||||||
|
// obj.write();
|
||||||
|
// obj.IOobject::rename(objName);
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
{
|
||||||
|
Log << " writing object " << obj.name() << endl;
|
||||||
obj.write();
|
obj.write();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user