ENH: enable the execution of functions objects in optimisation mode

This commit is contained in:
Vaggelis Papoutsis 2023-11-15 16:47:21 +02:00 committed by Andrew Heather
parent 2ad6c9f5d2
commit 8947735b1d
3 changed files with 10 additions and 3 deletions

View File

@ -612,7 +612,7 @@ bool Foam::functionObjectList::start()
}
bool Foam::functionObjectList::execute()
bool Foam::functionObjectList::execute(bool writeProperties)
{
bool ok = true;
@ -774,7 +774,7 @@ bool Foam::functionObjectList::execute()
}
// Force writing of properties dictionary after function object execution
if (time_.writeTime())
if (time_.writeTime() && writeProperties)
{
const auto oldPrecision = IOstream::precision_;
IOstream::precision_ = 16;

View File

@ -335,7 +335,7 @@ public:
//- Called at each ++ or += of the time-loop.
// postProcess overrides the usual executeControl behaviour and
// forces execution (used in post-processing mode)
bool execute();
bool execute(bool writeProperties = true);
//- Execute function objects using the specified subIndex.
// \param subIndex an execution sub-index corresponding to a

View File

@ -244,6 +244,13 @@ void Foam::simple::mainIter()
void Foam::simple::postIter()
{
// Execute function objects in optimisation cases
// Disabled in Time since we are subsycling
if (managerType_ == "steadyOptimisation")
{
const_cast<Time&>(mesh_.time()).functionObjects().execute(false);
}
solverControl_().write();
// Print objective values to screen and compute mean value