ENH: runTimeControl - enable resetting the trigger to an earlier instant

The runTimeControl function object can activate further function objects using
triggers. Previously the trigger index could only advance; this change set
allows users to set smaller values to enable function object recycling, e.g.

Repeat for N cycles:
1. average the pressure at a point in space
2. when the average stabilises, run for a further 100 iterations
3. set a new patch inlet velocity
  - back to (1)

- Removes old default behaviour that only permitted an increase in the
  trigger level. This type of 'ratcheting' mechanism (if required) is
  now the responsibility of the derived function object.
This commit is contained in:
Andrew Heather
2022-01-13 16:15:12 +00:00
committed by Mark Olesen
parent 53c2eae543
commit bb04f5759d
21 changed files with 153 additions and 64 deletions

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation
Copyright (C) 2015-2021 OpenCFD Ltd.
Copyright (C) 2015-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -74,7 +74,8 @@ Foam::functionObjects::runTimeControls::runTimeControl::runTimeControl
writeStepI_(0),
satisfiedAction_(satisfiedAction::END),
triggerIndex_(labelMin),
active_(getObjectProperty(name, "active", true))
active_(getProperty("active", true)),
canRestart_(getProperty("canRestart", false))
{
read(dict);
}
@ -177,6 +178,12 @@ bool Foam::functionObjects::runTimeControls::runTimeControl::read
bool Foam::functionObjects::runTimeControls::runTimeControl::execute()
{
if (canRestart_)
{
active_ = true;
canRestart_ = false;
}
if (!active_)
{
return true;
@ -199,7 +206,7 @@ bool Foam::functionObjects::runTimeControls::runTimeControl::execute()
{
bool conditionSatisfied = condition.apply();
label groupi = condition.groupID();
const label groupi = condition.groupID();
auto conditionIter = groupMap_.cfind(groupi);
@ -271,14 +278,10 @@ bool Foam::functionObjects::runTimeControls::runTimeControl::execute()
if (nWriteStep_ != 0)
{
Info<< " - final step" << nl;
}
else
{
Info<< nl;
Info<< " - final step";
}
Info<< endl;
Info<< nl << endl;
active_ = false;
// Write any registered objects and set the end-time
@ -299,11 +302,25 @@ bool Foam::functionObjects::runTimeControls::runTimeControl::execute()
case satisfiedAction::SET_TRIGGER:
{
Info<< " Setting trigger " << triggerIndex_ << nl;
setTrigger(triggerIndex_);
// Deactivate the model
active_ = false;
setProperty("active", active_);
// Can be restarted
canRestart_ = true;
setProperty("canRestart", canRestart_);
// Reset all conditions in case the control is recycled/trigger
// index is set to a smaller value
forAll(conditions_, conditioni)
{
runTimeCondition& condition = conditions_[conditioni];
condition.reset();
}
break;
}
}