mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Initial implementation for FO activation by trigger
This commit is contained in:
@ -458,6 +458,15 @@ Foam::autoPtr<Foam::functionObjectList> Foam::functionObjectList::New
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::label Foam::functionObjectList::triggerIndex() const
|
||||
{
|
||||
label triggeri = labelMin;
|
||||
stateDict().readIfPresent("triggerIndex", triggeri);
|
||||
|
||||
return triggeri;
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjectList::resetState()
|
||||
{
|
||||
// Reset (re-read) the state dictionary
|
||||
|
||||
@ -174,6 +174,9 @@ public:
|
||||
//- Access to the functionObjects
|
||||
using PtrList<functionObject>::operator[];
|
||||
|
||||
//- Return the current trigger index (read from the stateDict)
|
||||
label triggerIndex() const;
|
||||
|
||||
//- Reset/read state dictionary for current time
|
||||
void resetState();
|
||||
|
||||
|
||||
@ -78,6 +78,34 @@ Foam::dictionary& Foam::functionObjects::stateFunctionObject::propertyDict()
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::stateFunctionObject::setTrigger
|
||||
(
|
||||
const label triggeri
|
||||
)
|
||||
{
|
||||
IOdictionary& stateDict = this->stateDict();
|
||||
|
||||
label oldTriggeri =
|
||||
stateDict.lookupOrDefault<label>("triggerIndex", labelMin);
|
||||
|
||||
if (triggeri > oldTriggeri)
|
||||
{
|
||||
stateDict.set("triggerIndex", triggeri);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Foam::label Foam::functionObjects::stateFunctionObject::getTrigger() const
|
||||
{
|
||||
const IOdictionary& stateDict = this->stateDict();
|
||||
|
||||
return stateDict.lookupOrDefault<label>("triggerIndex", labelMin);
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::stateFunctionObject::foundProperty
|
||||
(
|
||||
const word& entryName
|
||||
|
||||
@ -125,6 +125,12 @@ public:
|
||||
//- Return true if the property exists
|
||||
bool foundProperty(const word& entryName) const;
|
||||
|
||||
//- Get the current trigger index
|
||||
label getTrigger() const;
|
||||
|
||||
//- Set the current trigger index
|
||||
bool setTrigger(const label triggeri);
|
||||
|
||||
//- Set dictionary, return true if set
|
||||
bool getDict
|
||||
(
|
||||
|
||||
@ -51,6 +51,10 @@ void Foam::functionObjects::timeControl::readControls()
|
||||
{
|
||||
timeEnd_ = time_.userTimeToTime(timeEnd_);
|
||||
}
|
||||
|
||||
dict_.readIfPresent("triggerStart", triggerStart_);
|
||||
dict_.readIfPresent("triggerEnd", triggerEnd_);
|
||||
|
||||
deltaTCoeff_ = GREAT;
|
||||
if (dict_.readIfPresent("deltaTCoeff", deltaTCoeff_))
|
||||
{
|
||||
@ -70,9 +74,14 @@ void Foam::functionObjects::timeControl::readControls()
|
||||
|
||||
bool Foam::functionObjects::timeControl::active() const
|
||||
{
|
||||
label triggeri = time_.functionObjects().triggerIndex();
|
||||
|
||||
return
|
||||
time_.value() >= (timeStart_ - 0.5*time_.deltaTValue())
|
||||
&& time_.value() <= (timeEnd_ + 0.5*time_.deltaTValue());
|
||||
(triggeri >= triggerStart_)
|
||||
|| (
|
||||
time_.value() >= (timeStart_ - 0.5*time_.deltaTValue())
|
||||
&& time_.value() <= (timeEnd_ + 0.5*time_.deltaTValue())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -403,6 +412,8 @@ Foam::functionObjects::timeControl::timeControl
|
||||
dict_(dict),
|
||||
timeStart_(-VGREAT),
|
||||
timeEnd_(VGREAT),
|
||||
triggerStart_(labelMin),
|
||||
triggerEnd_(labelMax),
|
||||
nStepsToStartTimeChange_(labelMax),
|
||||
executeControl_(t, dict, "execute"),
|
||||
writeControl_(t, dict, "write"),
|
||||
@ -426,6 +437,8 @@ bool Foam::functionObjects::timeControl::entriesPresent(const dictionary& dict)
|
||||
|| Foam::timeControl::entriesPresent(dict, "execute")
|
||||
|| dict.found("timeStart")
|
||||
|| dict.found("timeEnd")
|
||||
|| dict.found("triggerStart")
|
||||
|| dict.found("triggerEnd")
|
||||
)
|
||||
{
|
||||
return true;
|
||||
|
||||
@ -92,6 +92,12 @@ class timeControl
|
||||
//- De-activation time - defaults to VGREAT
|
||||
scalar timeEnd_;
|
||||
|
||||
//- Activation trigger index - defaults to labelMin
|
||||
label triggerStart_;
|
||||
|
||||
//- De-activation trigger index - defaults to labelMax
|
||||
label triggerEnd_;
|
||||
|
||||
//- Max time step change
|
||||
scalar deltaTCoeff_;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user