mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: add Function1 wrapping for functionObject trigger
Returns a 0/1 value corresponding to function object trigger levels.
Usage:
\verbatim
<entryName> functionObjectTrigger;
<entryName>Coeffs
{
triggers (1 3 5);
defaultValue false; // Default when no triggers activated
}
\endverbatim
ENH: add reset() method for Constant Function1
ENH: allow forced change of trigger index
- the triggers are normally increase only,
but can now override this optionally
This commit is contained in:
@ -79,26 +79,38 @@ Foam::dictionary& Foam::functionObjects::properties::getObjectDict
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::properties::setTrigger
|
||||
(
|
||||
const label triggeri
|
||||
)
|
||||
void Foam::functionObjects::properties::clearTrigger()
|
||||
{
|
||||
label oldTriggeri = getOrDefault<label>("triggerIndex", labelMin);
|
||||
|
||||
if (triggeri > oldTriggeri)
|
||||
{
|
||||
set("triggerIndex", triggeri);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
remove("triggerIndex");
|
||||
}
|
||||
|
||||
|
||||
Foam::label Foam::functionObjects::properties::getTrigger() const
|
||||
{
|
||||
return getOrDefault<label>("triggerIndex", labelMin);
|
||||
// Like getOrDefault, but without reporting missing entry (noisy)
|
||||
label idx = labelMin;
|
||||
readIfPresent("triggerIndex", idx);
|
||||
return idx;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::properties::setTrigger
|
||||
(
|
||||
const label triggeri,
|
||||
bool increaseOnly
|
||||
)
|
||||
{
|
||||
const label currTriggeri = getTrigger();
|
||||
|
||||
if (increaseOnly ? (triggeri > currTriggeri) : (triggeri != currTriggeri))
|
||||
{
|
||||
set("triggerIndex", triggeri);
|
||||
return true;
|
||||
}
|
||||
|
||||
// TBD: any special handling for triggeri == labelMin - eg, clearTrigger()
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user