mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: stateFunctionObject - separated dictionary access and updated api to return result status for retrieving properties
This commit is contained in:
@ -95,6 +95,39 @@ bool Foam::functionObjects::stateFunctionObject::foundProperty
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::functionObjects::stateFunctionObject::getDict
|
||||||
|
(
|
||||||
|
const word& entryName,
|
||||||
|
dictionary& dict
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
return getObjectDict(name(), entryName, dict);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::functionObjects::stateFunctionObject::getObjectDict
|
||||||
|
(
|
||||||
|
const word& objectName,
|
||||||
|
const word& entryName,
|
||||||
|
dictionary& dict
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
const IOdictionary& stateDict = this->stateDict();
|
||||||
|
|
||||||
|
if (stateDict.found(objectName))
|
||||||
|
{
|
||||||
|
const dictionary& baseDict = stateDict.subDict(objectName);
|
||||||
|
if (baseDict.found(entryName) && baseDict.isDict(entryName))
|
||||||
|
{
|
||||||
|
dict = baseDict.subDict(entryName);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::word Foam::functionObjects::stateFunctionObject::resultType
|
Foam::word Foam::functionObjects::stateFunctionObject::resultType
|
||||||
(
|
(
|
||||||
const word& entryName
|
const word& entryName
|
||||||
|
|||||||
@ -125,6 +125,21 @@ public:
|
|||||||
//- Return true if the property exists
|
//- Return true if the property exists
|
||||||
bool foundProperty(const word& entryName) const;
|
bool foundProperty(const word& entryName) const;
|
||||||
|
|
||||||
|
//- Set dictionary, return true if set
|
||||||
|
bool getDict
|
||||||
|
(
|
||||||
|
const word& entryName,
|
||||||
|
dictionary& dict
|
||||||
|
) const;
|
||||||
|
|
||||||
|
//- Set dictionary from named object, return true if set
|
||||||
|
bool getObjectDict
|
||||||
|
(
|
||||||
|
const word& objectName,
|
||||||
|
const word& entryName,
|
||||||
|
dictionary& dict
|
||||||
|
) const;
|
||||||
|
|
||||||
//- Retrieve generic property
|
//- Retrieve generic property
|
||||||
template<class Type>
|
template<class Type>
|
||||||
Type getProperty
|
Type getProperty
|
||||||
@ -133,9 +148,9 @@ public:
|
|||||||
const Type& defaultValue = Type(Zero)
|
const Type& defaultValue = Type(Zero)
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Retrieve generic property
|
//- Set generic property, return true if set
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void getProperty(const word& entryName, Type& value) const;
|
bool getProperty(const word& entryName, Type& value) const;
|
||||||
|
|
||||||
//- Add generic property
|
//- Add generic property
|
||||||
template<class Type>
|
template<class Type>
|
||||||
@ -150,9 +165,9 @@ public:
|
|||||||
const Type& defaultValue = Type(Zero)
|
const Type& defaultValue = Type(Zero)
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Retrieve generic property from named object
|
//- Set generic property from named object, return true if set
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void getObjectProperty
|
bool getObjectProperty
|
||||||
(
|
(
|
||||||
const word& objectName,
|
const word& objectName,
|
||||||
const word& entryName,
|
const word& entryName,
|
||||||
@ -205,9 +220,9 @@ public:
|
|||||||
const Type& defaultValue = Type(Zero)
|
const Type& defaultValue = Type(Zero)
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Retrieve result from named object
|
//- Set result from named object, return true if set
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void getObjectResult
|
bool getObjectResult
|
||||||
(
|
(
|
||||||
const word& objectName,
|
const word& objectName,
|
||||||
const word& entryName,
|
const word& entryName,
|
||||||
|
|||||||
@ -41,13 +41,13 @@ Type Foam::functionObjects::stateFunctionObject::getProperty
|
|||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::functionObjects::stateFunctionObject::getProperty
|
bool Foam::functionObjects::stateFunctionObject::getProperty
|
||||||
(
|
(
|
||||||
const word& entryName,
|
const word& entryName,
|
||||||
Type& value
|
Type& value
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
getObjectProperty(name(), entryName, value);
|
return getObjectProperty(name(), entryName, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ Type Foam::functionObjects::stateFunctionObject::getObjectProperty
|
|||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::functionObjects::stateFunctionObject::getObjectProperty
|
bool Foam::functionObjects::stateFunctionObject::getObjectProperty
|
||||||
(
|
(
|
||||||
const word& objectName,
|
const word& objectName,
|
||||||
const word& entryName,
|
const word& entryName,
|
||||||
@ -89,18 +89,10 @@ void Foam::functionObjects::stateFunctionObject::getObjectProperty
|
|||||||
if (stateDict.found(objectName))
|
if (stateDict.found(objectName))
|
||||||
{
|
{
|
||||||
const dictionary& baseDict = stateDict.subDict(objectName);
|
const dictionary& baseDict = stateDict.subDict(objectName);
|
||||||
if (baseDict.found(entryName))
|
return baseDict.readIfPresent(entryName, value);
|
||||||
{
|
|
||||||
if (baseDict.isDict(entryName))
|
|
||||||
{
|
|
||||||
value = baseDict.subDict(entryName);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
baseDict.lookup(entryName) >> value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -192,13 +184,13 @@ Type Foam::functionObjects::stateFunctionObject::getObjectResult
|
|||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
Type result = defaultValue;
|
Type result = defaultValue;
|
||||||
getObjectResult(objectName, entryName, result);
|
(void)getObjectResult(objectName, entryName, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::functionObjects::stateFunctionObject::getObjectResult
|
bool Foam::functionObjects::stateFunctionObject::getObjectResult
|
||||||
(
|
(
|
||||||
const word& objectName,
|
const word& objectName,
|
||||||
const word& entryName,
|
const word& entryName,
|
||||||
@ -222,10 +214,12 @@ void Foam::functionObjects::stateFunctionObject::getObjectResult
|
|||||||
const dictionary& resultTypeDict =
|
const dictionary& resultTypeDict =
|
||||||
objectDict.subDict(dictTypeName);
|
objectDict.subDict(dictTypeName);
|
||||||
|
|
||||||
resultTypeDict.readIfPresent<Type>(entryName, value);
|
return resultTypeDict.readIfPresent<Type>(entryName, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user