ENH: avoid raw dictionary lookup in functionObjects (issue #762)

Style changes:
    - use lookupObjectRef instead of using const_cast
    - use tmp::New factory
This commit is contained in:
Mark Olesen
2018-08-04 00:23:18 +02:00
parent 1c354e0906
commit 1036cf9612
81 changed files with 492 additions and 639 deletions

View File

@ -305,13 +305,13 @@ bool Foam::functionObjects::fieldAverage::read(const dictionary& dict)
dict.readIfPresent("restartOnRestart", restartOnRestart_);
dict.readIfPresent("restartOnOutput", restartOnOutput_);
dict.readIfPresent("periodicRestart", periodicRestart_);
dict.lookup("fields") >> faItems_;
dict.readEntry("fields", faItems_);
const scalar currentTime = obr().time().value();
if (periodicRestart_)
{
scalar userRestartPeriod = readScalar(dict.lookup("restartPeriod"));
scalar userRestartPeriod = dict.get<scalar>("restartPeriod");
restartPeriod_ = obr().time().userTimeToTime(userRestartPeriod);
if (restartPeriod_ > 0)

View File

@ -192,13 +192,13 @@ void Foam::functionObjects::fieldAverageItem::clear
bool Foam::functionObjects::fieldAverageItem::readState(const dictionary& dict)
{
dict.lookup("totalIter") >> totalIter_;
dict.lookup("totalTime") >> totalTime_;
dict.readEntry("totalIter", totalIter_);
dict.readEntry("totalTime", totalTime_);
if (window_ > 0)
{
dict.lookup("windowTimes") >> windowTimes_;
dict.lookup("windowFieldNames") >> windowFieldNames_;
dict.readEntry("windowTimes", windowTimes_);
dict.readEntry("windowFieldNames", windowFieldNames_);
}
return true;

View File

@ -66,8 +66,8 @@ Foam::Istream& Foam::functionObjects::operator>>
faItem.active_ = false;
faItem.fieldName_ = entry.keyword();
faItem.mean_ = readBool(entry.lookup("mean"));
faItem.prime2Mean_ = readBool(entry.lookup("prime2Mean"));
faItem.mean_ = entry.get<bool>("mean");
faItem.prime2Mean_ = entry.get<bool>("prime2Mean");
faItem.base_ = faItem.baseTypeNames_.lookup("base", entry);
faItem.window_ = entry.lookupOrDefault<scalar>("window", -1.0);
@ -94,7 +94,7 @@ Foam::Istream& Foam::functionObjects::operator>>
if (faItem.windowType_ == fieldAverageItem::windowType::EXACT)
{
faItem.allowRestart_ = readBool(entry.lookup("allowRestart"));
faItem.allowRestart_ = entry.get<bool>("allowRestart");
if (!faItem.allowRestart_)
{