ENH: support objectRegistry::checkOut(const word& name)

- similar to what erase() does, but as a mutable operation (#1180)

- replace basicThermo lookupAndCheckout (commit 880c98757d) with
  the new objectRegistry::checkOut() method.
This commit is contained in:
Mark Olesen
2019-02-06 12:01:29 +01:00
parent 988e4cad7f
commit 0767409988
8 changed files with 27 additions and 56 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2011, 2017 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2009-2011, 2017-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation
@ -152,7 +152,7 @@ void Foam::functionObjects::fieldAverageItem::evolve(const objectRegistry& obr)
const word fieldName = windowFieldNames_.pop();
//Info<< "evolve: removing field: " << fieldName << endl;
obr.checkOut(*obr[fieldName]);
obr.checkOut(fieldName);
}
}
}
@ -164,22 +164,19 @@ void Foam::functionObjects::fieldAverageItem::clear
bool fullClean
)
{
if (mean_ && obr.found(meanFieldName_))
if (mean_)
{
obr.checkOut(*obr[meanFieldName_]);
obr.checkOut(meanFieldName_);
}
if (prime2Mean_ && obr.found(prime2MeanFieldName_))
if (prime2Mean_)
{
obr.checkOut(*obr[prime2MeanFieldName_]);
obr.checkOut(prime2MeanFieldName_);
}
for (const word& fieldName : windowFieldNames_)
{
if (obr.found(fieldName))
{
obr.checkOut(*obr[fieldName]);
}
obr.checkOut(fieldName);
}
if (totalTime_ < 0 || fullClean)

View File

@ -46,11 +46,9 @@ namespace functionObjects
void Foam::functionObjects::momentum::purgeFields()
{
objectRegistry& obr = const_cast<objectRegistry&>(obr_);
obr.erase(scopedName("momentum"));
obr.erase(scopedName("angularMomentum"));
obr.erase(scopedName("angularVelocity"));
obr_.checkOut(scopedName("momentum"));
obr_.checkOut(scopedName("angularMomentum"));
obr_.checkOut(scopedName("angularVelocity"));
}