mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
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:
committed by
Mark Olesen
parent
53c2eae543
commit
bb04f5759d
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2015 OpenFOAM Foundation
|
||||
Copyright (C) 2015-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2015-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -83,17 +83,18 @@ Foam::functionObjects::runTimeControls::averageCondition::averageCondition
|
||||
iter_(-1)
|
||||
{
|
||||
dictionary& conditionDict = this->conditionDict();
|
||||
conditionDict.readIfPresent("iter", iter_);
|
||||
|
||||
forAll(fieldNames_, fieldi)
|
||||
if (resetOnRestart_)
|
||||
{
|
||||
const word& fieldName = fieldNames_[fieldi];
|
||||
reset();
|
||||
}
|
||||
else
|
||||
{
|
||||
forAll(fieldNames_, fieldi)
|
||||
{
|
||||
const word& fieldName = fieldNames_[fieldi];
|
||||
|
||||
if (resetOnRestart_)
|
||||
{
|
||||
conditionDict.set(fieldName, dictionary());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (conditionDict.found(fieldName))
|
||||
{
|
||||
const dictionary& valueDict = conditionDict.subDict(fieldName);
|
||||
@ -105,8 +106,6 @@ Foam::functionObjects::runTimeControls::averageCondition::averageCondition
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
conditionDict.readIfPresent("iter", iter_);
|
||||
}
|
||||
|
||||
|
||||
@ -194,4 +193,21 @@ void Foam::functionObjects::runTimeControls::averageCondition::write()
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::runTimeControls::averageCondition::reset()
|
||||
{
|
||||
dictionary& conditionDict = this->conditionDict();
|
||||
|
||||
forAll(fieldNames_, fieldi)
|
||||
{
|
||||
const word& fieldName = fieldNames_[fieldi];
|
||||
|
||||
conditionDict.set(fieldName, dictionary());
|
||||
totalTime_[fieldi] = 0;
|
||||
}
|
||||
|
||||
iter_ = -1;
|
||||
conditionDict.set("iter", iter_);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2015 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -77,7 +77,7 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
// Protected Data
|
||||
|
||||
//- Name of function object to retrieve data from
|
||||
word functionObjectName_;
|
||||
@ -143,6 +143,9 @@ public:
|
||||
|
||||
//- Write
|
||||
virtual void write();
|
||||
|
||||
//- Reset
|
||||
virtual void reset();
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -230,4 +230,11 @@ equationInitialResidualCondition::write()
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::runTimeControls::
|
||||
equationInitialResidualCondition::reset()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2015 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2019 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -130,6 +130,9 @@ public:
|
||||
|
||||
//- Write
|
||||
virtual void write();
|
||||
|
||||
//- Reset
|
||||
virtual void reset();
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2015 OpenFOAM Foundation
|
||||
Copyright (C) 2015-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2015-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -168,4 +168,11 @@ void Foam::functionObjects::runTimeControls::equationMaxIterCondition::write()
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Foam::functionObjects::runTimeControls::equationMaxIterCondition::reset()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2015 OpenFOAM Foundation
|
||||
Copyright (C) 2016 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -97,6 +97,9 @@ public:
|
||||
|
||||
//- Write
|
||||
virtual void write();
|
||||
|
||||
//- Reset
|
||||
virtual void reset();
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2018-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -110,4 +110,10 @@ void Foam::functionObjects::runTimeControls::maxDurationCondition::write()
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::runTimeControls::maxDurationCondition::reset()
|
||||
{
|
||||
initialised_ = false;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2018 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -99,6 +99,9 @@ public:
|
||||
|
||||
//- Write
|
||||
virtual void write();
|
||||
|
||||
//- Reset
|
||||
virtual void reset();
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2015 OpenFOAM Foundation
|
||||
Copyright (C) 2015-2016 OpenCFD Ltd.
|
||||
Copyright (C) 2015-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -166,4 +166,10 @@ void Foam::functionObjects::runTimeControls::minMaxCondition::write()
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::runTimeControls::minMaxCondition::reset()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2015 OpenFOAM Foundation
|
||||
Copyright (C) 2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -124,6 +125,9 @@ public:
|
||||
|
||||
//- Write
|
||||
virtual void write();
|
||||
|
||||
//- Reset
|
||||
virtual void reset();
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2015 OpenFOAM Foundation
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -94,4 +94,10 @@ void Foam::functionObjects::runTimeControls::minTimeStepCondition::write()
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::runTimeControls::minTimeStepCondition::reset()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2015 OpenFOAM Foundation
|
||||
Copyright (C) 2016 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -91,6 +91,9 @@ public:
|
||||
|
||||
//- Write
|
||||
virtual void write();
|
||||
|
||||
//- Reset
|
||||
virtual void reset();
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2015 OpenFOAM Foundation
|
||||
Copyright (C) 2016 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -162,6 +162,9 @@ public:
|
||||
|
||||
//- Write
|
||||
virtual void write() = 0;
|
||||
|
||||
//- Reset
|
||||
virtual void reset() = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2015-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -111,6 +111,11 @@ private:
|
||||
// trigger has been set
|
||||
bool active_;
|
||||
|
||||
//- Can be restarted flag
|
||||
// Used in the trigger case after the trigger has been set to allow
|
||||
// this object to be restarted/reset the active flag
|
||||
bool canRestart_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
|
||||
Reference in New Issue
Block a user