From 8947735b1dcd81a54b57cf9d968c4c60786e6239 Mon Sep 17 00:00:00 2001 From: Vaggelis Papoutsis Date: Wed, 15 Nov 2023 16:47:21 +0200 Subject: [PATCH] ENH: enable the execution of functions objects in optimisation mode --- .../functionObjectList/functionObjectList.C | 4 ++-- .../functionObjectList/functionObjectList.H | 2 +- .../solvers/primalSolvers/incompressible/simple/simple.C | 7 +++++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C index 990614894a..ae8aed9e05 100644 --- a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C +++ b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C @@ -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; diff --git a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.H b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.H index da9df07527..16ca478ff7 100644 --- a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.H +++ b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.H @@ -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 diff --git a/src/optimisation/adjointOptimisation/adjoint/solvers/primalSolvers/incompressible/simple/simple.C b/src/optimisation/adjointOptimisation/adjoint/solvers/primalSolvers/incompressible/simple/simple.C index 8745f3dd76..d7bab37b8e 100644 --- a/src/optimisation/adjointOptimisation/adjoint/solvers/primalSolvers/incompressible/simple/simple.C +++ b/src/optimisation/adjointOptimisation/adjoint/solvers/primalSolvers/incompressible/simple/simple.C @@ -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(mesh_.time()).functionObjects().execute(false); + } + solverControl_().write(); // Print objective values to screen and compute mean value