Skip to content
Snippets Groups Projects
Commit eed3b770 authored by Andrew Heather's avatar Andrew Heather
Browse files

ENH: Function objects - updated logic to determine whether or not to...

ENH: Function objects - updated logic to determine whether or not to instantiate a time-based function object.  Fixes #439
parent 694a03df
Branches
Tags
No related merge requests found
......@@ -755,11 +755,7 @@ bool Foam::functionObjectList::read()
fo2,
"functionObject::" + key + "::new"
);
if
(
dict.found("writeControl")
|| dict.found("outputControl")
)
if (functionObjects::timeControl::entriesPresent(dict))
{
foPtr.set
(
......
......@@ -50,6 +50,7 @@ const Foam::NamedEnum<Foam::timeControl::timeControls, 9>
Foam::timeControl::timeControlNames_;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::timeControl::timeControl
......@@ -78,6 +79,23 @@ Foam::timeControl::~timeControl()
// * * * * * * * * * * * * * * * 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)
{
word controlName(prefix_ + "Control");
......
......@@ -121,6 +121,10 @@ public:
// 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
void read(const dictionary&);
......
......@@ -93,6 +93,24 @@ Foam::functionObjects::timeControl::timeControl
// * * * * * * * * * * * * * * * 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()
{
if (active() && (postProcess || executeControl_.execute()))
......
......@@ -157,6 +157,10 @@ public:
// 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.
// postProcess overrides the usual executeControl behaviour and
// forces execution (used in post-processing mode)
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment