mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: allow top-level definition of function object name scoping
- this refines commit c233961d45, which added prefix scoping.
Default is now off (v2106 behaviour).
The 'useNamePrefix' keyword can be specified on a per function basis
or at the top-level of "functions".
```
functions
{
errors warn;
useNamePrefix true;
func1
{
type ...;
useNamePrefix false;
}
func2
{
type ...;
// Uses current default for useNamePrefix
}
}
```
This commit is contained in:
@ -41,6 +41,8 @@ namespace Foam
|
||||
|
||||
bool Foam::functionObject::postProcess(false);
|
||||
|
||||
bool Foam::functionObject::defaultUseNamePrefix(false);
|
||||
|
||||
Foam::word Foam::functionObject::outputPrefix("postProcessing");
|
||||
|
||||
|
||||
@ -48,7 +50,7 @@ Foam::word Foam::functionObject::outputPrefix("postProcessing");
|
||||
|
||||
Foam::word Foam::functionObject::scopedName(const word& name) const
|
||||
{
|
||||
if (scopedNames_)
|
||||
if (useNamePrefix_)
|
||||
{
|
||||
return IOobject::scopedName(name_, name);
|
||||
}
|
||||
@ -62,11 +64,11 @@ Foam::word Foam::functionObject::scopedName(const word& name) const
|
||||
Foam::functionObject::functionObject
|
||||
(
|
||||
const word& name,
|
||||
const bool scopedNames
|
||||
const bool withNamePrefix
|
||||
)
|
||||
:
|
||||
name_(name),
|
||||
scopedNames_(scopedNames),
|
||||
useNamePrefix_(withNamePrefix),
|
||||
log(postProcess)
|
||||
{}
|
||||
|
||||
@ -144,17 +146,36 @@ const Foam::word& Foam::functionObject::name() const noexcept
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObject::scopedNames() const noexcept
|
||||
bool Foam::functionObject::useNamePrefix() const noexcept
|
||||
{
|
||||
return scopedNames_;
|
||||
return useNamePrefix_;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObject::useNamePrefix(bool on) noexcept
|
||||
{
|
||||
bool old(useNamePrefix_);
|
||||
useNamePrefix_ = on;
|
||||
return old;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObject::read(const dictionary& dict)
|
||||
{
|
||||
// OR
|
||||
// useNamePrefix_ = Switch("useNamePrefix", dict, defaultUseNamePrefix);
|
||||
|
||||
useNamePrefix_ =
|
||||
dict.getOrDefault
|
||||
(
|
||||
"useNamePrefix",
|
||||
defaultUseNamePrefix,
|
||||
keyType::LITERAL
|
||||
);
|
||||
|
||||
|
||||
if (!postProcess)
|
||||
{
|
||||
scopedNames_ = dict.getOrDefault("scopedNames", true);
|
||||
log = dict.getOrDefault("log", true);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user