mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Function objects - updated logic to determine whether or not to instantiate a time-based function object. Fixes #439
This commit is contained in:
@ -755,11 +755,7 @@ bool Foam::functionObjectList::read()
|
|||||||
fo2,
|
fo2,
|
||||||
"functionObject::" + key + "::new"
|
"functionObject::" + key + "::new"
|
||||||
);
|
);
|
||||||
if
|
if (functionObjects::timeControl::entriesPresent(dict))
|
||||||
(
|
|
||||||
dict.found("writeControl")
|
|
||||||
|| dict.found("outputControl")
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
foPtr.set
|
foPtr.set
|
||||||
(
|
(
|
||||||
|
|||||||
@ -50,6 +50,7 @@ const Foam::NamedEnum<Foam::timeControl::timeControls, 9>
|
|||||||
Foam::timeControl::timeControlNames_;
|
Foam::timeControl::timeControlNames_;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::timeControl::timeControl
|
Foam::timeControl::timeControl
|
||||||
@ -78,6 +79,23 @@ Foam::timeControl::~timeControl()
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
bool Foam::timeControl::entriesPresent
|
||||||
|
(
|
||||||
|
const dictionary& dict,
|
||||||
|
const word& prefix
|
||||||
|
)
|
||||||
|
{
|
||||||
|
const word controlName(prefix + "Control");
|
||||||
|
|
||||||
|
if (dict.found(controlName))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::timeControl::read(const dictionary& dict)
|
void Foam::timeControl::read(const dictionary& dict)
|
||||||
{
|
{
|
||||||
word controlName(prefix_ + "Control");
|
word controlName(prefix_ + "Control");
|
||||||
|
|||||||
@ -121,6 +121,10 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
|
//- Helper function to identify if a timeControl object is present
|
||||||
|
// in the dictionary
|
||||||
|
static bool entriesPresent(const dictionary& dict, const word& prefix);
|
||||||
|
|
||||||
//- Read from dictionary
|
//- Read from dictionary
|
||||||
void read(const dictionary&);
|
void read(const dictionary&);
|
||||||
|
|
||||||
|
|||||||
@ -93,6 +93,24 @@ Foam::functionObjects::timeControl::timeControl
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
bool Foam::functionObjects::timeControl::entriesPresent(const dictionary& dict)
|
||||||
|
{
|
||||||
|
if
|
||||||
|
(
|
||||||
|
Foam::timeControl::entriesPresent(dict, "write")
|
||||||
|
|| Foam::timeControl::entriesPresent(dict, "output") // backwards compat
|
||||||
|
|| Foam::timeControl::entriesPresent(dict, "execute")
|
||||||
|
|| dict.found("timeStart")
|
||||||
|
|| dict.found("timeEnd")
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Foam::functionObjects::timeControl::execute()
|
bool Foam::functionObjects::timeControl::execute()
|
||||||
{
|
{
|
||||||
if (active() && (postProcess || executeControl_.execute()))
|
if (active() && (postProcess || executeControl_.execute()))
|
||||||
|
|||||||
@ -157,6 +157,10 @@ public:
|
|||||||
|
|
||||||
// Function object control
|
// Function object control
|
||||||
|
|
||||||
|
//- Helper function to identify if a timeControl object is present
|
||||||
|
// in the dictionary
|
||||||
|
static bool entriesPresent(const dictionary& dict);
|
||||||
|
|
||||||
//- Called at each ++ or += of the time-loop.
|
//- Called at each ++ or += of the time-loop.
|
||||||
// postProcess overrides the usual executeControl behaviour and
|
// postProcess overrides the usual executeControl behaviour and
|
||||||
// forces execution (used in post-processing mode)
|
// forces execution (used in post-processing mode)
|
||||||
|
|||||||
Reference in New Issue
Block a user