ENH: subModelBase - return bool from getModelProperty to identify read success

This commit is contained in:
Andrew Heather
2022-06-13 14:05:33 +01:00
parent 10d08c28e5
commit b0b9aa6def
2 changed files with 7 additions and 4 deletions

View File

@ -193,8 +193,9 @@ public:
) const; ) const;
//- Retrieve generic property from the sub-model //- Retrieve generic property from the sub-model
// Return true if found
template<class Type> template<class Type>
void getModelProperty(const word& entryName, Type& value) const; bool getModelProperty(const word& entryName, Type& value) const;
//- Retrieve generic property from the sub-model //- Retrieve generic property from the sub-model
template<class Type> template<class Type>

View File

@ -82,7 +82,7 @@ void Foam::subModelBase::setBaseProperty
template<class Type> template<class Type>
void Foam::subModelBase::getModelProperty bool Foam::subModelBase::getModelProperty
( (
const word& entryName, const word& entryName,
Type& value Type& value
@ -94,13 +94,15 @@ void Foam::subModelBase::getModelProperty
if (inLine() && baseDict.found(modelName_)) if (inLine() && baseDict.found(modelName_))
{ {
baseDict.subDict(modelName_).readIfPresent(entryName, value); return baseDict.subDict(modelName_).readIfPresent(entryName, value);
} }
else if (baseDict.found(modelType_)) else if (baseDict.found(modelType_))
{ {
baseDict.subDict(modelType_).readIfPresent(entryName, value); return baseDict.subDict(modelType_).readIfPresent(entryName, value);
} }
} }
return false;
} }