From a5845c9aa33b7f04ee93567eef64271ca120d102 Mon Sep 17 00:00:00 2001
From: Vaggelis Papoutsis <vaggelisp@gmail.com>
Date: Fri, 16 Oct 2020 13:50:01 +0300
Subject: [PATCH] BUG: Wrong First extrapolated value of the merit function
 (fixes #1948)

Affected only the first optimisation cycle, if line search was enabled

If eta was not set explicitly, it was computed after evaluating the
directional derivative of the merit function, which was computed
wrongly, leading to an erroneous value of the extrapolated merit
function value.
---
 .../optimisationType/optimisationTypeIncompressible.C       | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/optimisation/adjointOptimisation/adjoint/optimisation/optimisationType/incompressible/optimisationType/optimisationTypeIncompressible.C b/src/optimisation/adjointOptimisation/adjoint/optimisation/optimisationType/incompressible/optimisationType/optimisationTypeIncompressible.C
index 06b2de5394b..6d0e54aa754 100644
--- a/src/optimisation/adjointOptimisation/adjoint/optimisation/optimisationType/incompressible/optimisationType/optimisationTypeIncompressible.C
+++ b/src/optimisation/adjointOptimisation/adjoint/optimisation/optimisationType/incompressible/optimisationType/optimisationTypeIncompressible.C
@@ -175,9 +175,6 @@ void optimisationType::update()
 
 void optimisationType::update(scalarField& direction)
 {
-    // Compute eta if needed
-    computeEta(direction);
-
     // Multiply with line search step, if necessary
     scalarField correction(direction);
     if (lineSearch_.valid())
@@ -218,6 +215,9 @@ tmp<scalarField> optimisationType::computeDirection()
     scalarField& correction = tcorrection.ref();
     correction = updateMethod_->returnCorrection();
 
+    // Compute eta if needed
+    computeEta(correction);
+
     return tcorrection;
 }
 
-- 
GitLab