From d58cd15176d3b5572c8cbda193fde2b52c853122 Mon Sep 17 00:00:00 2001 From: Ping He Date: Wed, 10 Apr 2024 08:28:37 -0500 Subject: [PATCH] Enabled using objFunc std as convergence criterion. (#624) * Enabled using objFunc std as convergence criterion. * Enables using objFuncStd as convergence criterion. --- dafoam/pyDAFoam.py | 4 + src/adjoint/DASolver/DASolver.C | 139 +++++++++++++++++- src/adjoint/DASolver/DASolver.H | 21 ++- .../DAFoam_Test_DARhoSimpleFoamUBendRef.txt | 28 ++-- tests/runTests_DARhoSimpleFoamUBend.py | 3 +- 5 files changed, 173 insertions(+), 22 deletions(-) diff --git a/dafoam/pyDAFoam.py b/dafoam/pyDAFoam.py index aab119d1..8be65864 100755 --- a/dafoam/pyDAFoam.py +++ b/dafoam/pyDAFoam.py @@ -74,6 +74,10 @@ def __init__(self): ## of magnitude (default) higher than this tolerance, the primal solution will return fail=True self.primalMinResTol = 1.0e-8 + ## The convergence tolerance based on the selected objective function's standard deviation + ## The standard deviation is calculated based on the last N (default 200) steps of the objective function series + self.primalObjStdTol = {"active": False, "objFuncName": "None", "steps": 200, "tol": 1e-5, "tolDiff": 1e2} + ## The boundary condition for primal solution. The keys should include "variable", "patch", ## and "value". For turbulence variable, one can also set "useWallFunction" [bool]. ## Note that setting "primalBC" will overwrite any values defined in the "0" folder. diff --git a/src/adjoint/DASolver/DASolver.C b/src/adjoint/DASolver/DASolver.C index b4322bc8..6bff5954 100644 --- a/src/adjoint/DASolver/DASolver.C +++ b/src/adjoint/DASolver/DASolver.C @@ -64,6 +64,9 @@ DASolver::DASolver( primalMinResTol_ = daOptionPtr_->getOption("primalMinResTol"); primalMinIters_ = daOptionPtr_->getOption