ENH: function objects - apply scoped name when registering objects
This commit is contained in:
committed by
Mark Olesen
parent
9194cd5203
commit
c233961d45
@ -48,15 +48,25 @@ Foam::word Foam::functionObject::outputPrefix("postProcessing");
|
||||
|
||||
Foam::word Foam::functionObject::scopedName(const word& name) const
|
||||
{
|
||||
return name_ + ":" + name;
|
||||
if (scopedNames_)
|
||||
{
|
||||
return IOobject::scopedName(name_, name);
|
||||
}
|
||||
|
||||
return name_;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObject::functionObject(const word& name)
|
||||
Foam::functionObject::functionObject
|
||||
(
|
||||
const word& name,
|
||||
const bool scopedNames
|
||||
)
|
||||
:
|
||||
name_(name),
|
||||
scopedNames_(scopedNames),
|
||||
log(postProcess)
|
||||
{}
|
||||
|
||||
@ -128,16 +138,23 @@ Foam::autoPtr<Foam::functionObject> Foam::functionObject::New
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::word& Foam::functionObject::name() const
|
||||
const Foam::word& Foam::functionObject::name() const noexcept
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObject::scopedNames() const noexcept
|
||||
{
|
||||
return scopedNames_;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObject::read(const dictionary& dict)
|
||||
{
|
||||
if (!postProcess)
|
||||
{
|
||||
scopedNames_ = dict.getOrDefault("scopedNames", true);
|
||||
log = dict.getOrDefault("log", true);
|
||||
}
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -221,6 +221,9 @@ class functionObject
|
||||
//- Name
|
||||
const word name_;
|
||||
|
||||
//- Flag to indicate that names should be scoped
|
||||
bool scopedNames_;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
@ -266,7 +269,11 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
functionObject(const word& name);
|
||||
explicit functionObject
|
||||
(
|
||||
const word& name,
|
||||
const bool scopedNames = true
|
||||
);
|
||||
|
||||
//- Return clone
|
||||
autoPtr<functionObject> clone() const
|
||||
@ -294,7 +301,10 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- Return the name of this functionObject
|
||||
const word& name() const;
|
||||
const word& name() const noexcept;
|
||||
|
||||
//- Return the scoped names flag
|
||||
bool scopedNames() const noexcept;
|
||||
|
||||
//- Read and set the function object if its data have changed
|
||||
virtual bool read(const dictionary& dict);
|
||||
@ -347,7 +357,7 @@ class functionObject::unavailableFunctionObject
|
||||
protected:
|
||||
|
||||
//- Construct with name
|
||||
unavailableFunctionObject(const word& name);
|
||||
explicit unavailableFunctionObject(const word& name);
|
||||
|
||||
//- Report it is unavailable, emitting a FatalError for try/catch
|
||||
//- in the caller
|
||||
|
||||
Reference in New Issue
Block a user