diff --git a/dafoam/pyDAFoam.py b/dafoam/pyDAFoam.py index 75f65b12..b1d93227 100755 --- a/dafoam/pyDAFoam.py +++ b/dafoam/pyDAFoam.py @@ -704,8 +704,8 @@ def __init__(self): } ## number of minimal primal iterations. The primal has to run this many iterations, even the primal residual - ## has reduced below the tolerance. The default is a negative value (always satisfied). - self.primalMinIters = -1 + ## has reduced below the tolerance. The default is 1: the primal has to run for at least one iteration + self.primalMinIters = 1 ## tensorflow related functions self.tensorflow = { diff --git a/src/adjoint/DAModel/DATurbulenceModel/DASpalartAllmaras.C b/src/adjoint/DAModel/DATurbulenceModel/DASpalartAllmaras.C index 7ac2d0eb..8b0782c3 100755 --- a/src/adjoint/DAModel/DATurbulenceModel/DASpalartAllmaras.C +++ b/src/adjoint/DAModel/DATurbulenceModel/DASpalartAllmaras.C @@ -454,11 +454,8 @@ void DASpalartAllmaras::calcResiduals(const dictionary& options) // get the solver performance info such as initial // and final residuals SolverPerformance solverNuTilda = solve(nuTildaEqn); - if (printToScreen) - { - Info << "nuTilda Initial residual: " << solverNuTilda.initialResidual() << endl - << " Final residual: " << solverNuTilda.finalResidual() << endl; - } + + DAUtility::primalResidualControl(solverNuTilda, printToScreen, "nuTilda"); DAUtility::boundVar(allOptions_, nuTilda_, printToScreen); nuTilda_.correctBoundaryConditions(); diff --git a/src/adjoint/DAModel/DATurbulenceModel/DASpalartAllmarasFv3.C b/src/adjoint/DAModel/DATurbulenceModel/DASpalartAllmarasFv3.C index 4c819f9f..afe68f68 100755 --- a/src/adjoint/DAModel/DATurbulenceModel/DASpalartAllmarasFv3.C +++ b/src/adjoint/DAModel/DATurbulenceModel/DASpalartAllmarasFv3.C @@ -479,11 +479,7 @@ void DASpalartAllmarasFv3::calcResiduals(const dictionary& options) // get the solver performance info such as initial // and final residuals SolverPerformance solverNuTilda = solve(nuTildaEqn); - if (printToScreen) - { - Info << "nuTilda Initial residual: " << solverNuTilda.initialResidual() << endl - << " Final residual: " << solverNuTilda.finalResidual() << endl; - } + DAUtility::primalResidualControl(solverNuTilda, printToScreen, "nuTilda"); DAUtility::boundVar(allOptions_, nuTilda_, printToScreen); nuTilda_.correctBoundaryConditions(); diff --git a/src/adjoint/DAModel/DATurbulenceModel/DASpalartAllmarasFv3FieldInversion.C b/src/adjoint/DAModel/DATurbulenceModel/DASpalartAllmarasFv3FieldInversion.C index 5e2f545e..0bd65416 100755 --- a/src/adjoint/DAModel/DATurbulenceModel/DASpalartAllmarasFv3FieldInversion.C +++ b/src/adjoint/DAModel/DATurbulenceModel/DASpalartAllmarasFv3FieldInversion.C @@ -465,11 +465,7 @@ void DASpalartAllmarasFv3FieldInversion::calcResiduals(const dictionary& options // get the solver performance info such as initial // and final residuals SolverPerformance solverNuTilda = solve(nuTildaEqn); - if (printToScreen) - { - Info << "nuTilda Initial residual: " << solverNuTilda.initialResidual() << endl - << " Final residual: " << solverNuTilda.finalResidual() << endl; - } + DAUtility::primalResidualControl(solverNuTilda, printToScreen, "nuTilda"); DAUtility::boundVar(allOptions_, nuTilda_, printToScreen); nuTilda_.correctBoundaryConditions(); diff --git a/src/adjoint/DAModel/DATurbulenceModel/DAkEpsilon.C b/src/adjoint/DAModel/DATurbulenceModel/DAkEpsilon.C index 7731d30f..3e9d7994 100755 --- a/src/adjoint/DAModel/DATurbulenceModel/DAkEpsilon.C +++ b/src/adjoint/DAModel/DATurbulenceModel/DAkEpsilon.C @@ -572,11 +572,7 @@ void DAkEpsilon::calcResiduals(const dictionary& options) // get the solver performance info such as initial // and final residuals SolverPerformance solverEpsilon = solve(epsEqn); - if (printToScreen) - { - Info << "epsilon Initial residual: " << solverEpsilon.initialResidual() << endl - << " Final residual: " << solverEpsilon.finalResidual() << endl; - } + DAUtility::primalResidualControl(solverEpsilon, printToScreen, "epsilon"); DAUtility::boundVar(allOptions_, epsilon_, printToScreen); } @@ -610,11 +606,7 @@ void DAkEpsilon::calcResiduals(const dictionary& options) // get the solver performance info such as initial // and final residuals SolverPerformance solverK = solve(kEqn); - if (printToScreen) - { - Info << "k Initial residual: " << solverK.initialResidual() << endl - << " Final residual: " << solverK.finalResidual() << endl; - } + DAUtility::primalResidualControl(solverK, printToScreen, "k"); DAUtility::boundVar(allOptions_, k_, printToScreen); diff --git a/src/adjoint/DAModel/DATurbulenceModel/DAkOmega.C b/src/adjoint/DAModel/DATurbulenceModel/DAkOmega.C index 272b5f30..ffeeef65 100755 --- a/src/adjoint/DAModel/DATurbulenceModel/DAkOmega.C +++ b/src/adjoint/DAModel/DATurbulenceModel/DAkOmega.C @@ -577,11 +577,7 @@ void DAkOmega::calcResiduals(const dictionary& options) // get the solver performance info such as initial // and final residuals SolverPerformance solverOmega = solve(omegaEqn); - if (printToScreen) - { - Info << "omega Initial residual: " << solverOmega.initialResidual() << endl - << " Final residual: " << solverOmega.finalResidual() << endl; - } + DAUtility::primalResidualControl(solverOmega, printToScreen, "omega"); DAUtility::boundVar(allOptions_, omega_, printToScreen); } @@ -614,11 +610,7 @@ void DAkOmega::calcResiduals(const dictionary& options) // get the solver performance info such as initial // and final residuals SolverPerformance solverK = solve(kEqn); - if (printToScreen) - { - Info << "k Initial residual: " << solverK.initialResidual() << endl - << " Final residual: " << solverK.finalResidual() << endl; - } + DAUtility::primalResidualControl(solverK, printToScreen, "k"); DAUtility::boundVar(allOptions_, k_, printToScreen); diff --git a/src/adjoint/DAModel/DATurbulenceModel/DAkOmegaFieldInversionOmega.C b/src/adjoint/DAModel/DATurbulenceModel/DAkOmegaFieldInversionOmega.C index b9d1cb9c..acfa006e 100755 --- a/src/adjoint/DAModel/DATurbulenceModel/DAkOmegaFieldInversionOmega.C +++ b/src/adjoint/DAModel/DATurbulenceModel/DAkOmegaFieldInversionOmega.C @@ -581,11 +581,7 @@ void DAkOmegaFieldInversionOmega::calcResiduals(const dictionary& options) // get the solver performance info such as initial // and final residuals SolverPerformance solverOmega = solve(omegaEqn); - if (printToScreen) - { - Info << "omega Initial residual: " << solverOmega.initialResidual() << endl - << " Final residual: " << solverOmega.finalResidual() << endl; - } + DAUtility::primalResidualControl(solverOmega, printToScreen, "omega"); DAUtility::boundVar(allOptions_, omega_, printToScreen); } @@ -618,11 +614,7 @@ void DAkOmegaFieldInversionOmega::calcResiduals(const dictionary& options) // get the solver performance info such as initial // and final residuals SolverPerformance solverK = solve(kEqn); - if (printToScreen) - { - Info << "k Initial residual: " << solverK.initialResidual() << endl - << " Final residual: " << solverK.finalResidual() << endl; - } + DAUtility::primalResidualControl(solverK, printToScreen, "k"); DAUtility::boundVar(allOptions_, k_, printToScreen); diff --git a/src/adjoint/DAModel/DATurbulenceModel/DAkOmegaSST.C b/src/adjoint/DAModel/DATurbulenceModel/DAkOmegaSST.C index 330ad573..ee9651fb 100755 --- a/src/adjoint/DAModel/DATurbulenceModel/DAkOmegaSST.C +++ b/src/adjoint/DAModel/DATurbulenceModel/DAkOmegaSST.C @@ -741,11 +741,7 @@ void DAkOmegaSST::calcResiduals(const dictionary& options) // get the solver performance info such as initial // and final residuals SolverPerformance solverOmega = solve(omegaEqn); - if (printToScreen) - { - Info << "omega Initial residual: " << solverOmega.initialResidual() << endl - << " Final residual: " << solverOmega.finalResidual() << endl; - } + DAUtility::primalResidualControl(solverOmega, printToScreen, "omega"); DAUtility::boundVar(allOptions_, omega_, printToScreen); } @@ -782,11 +778,7 @@ void DAkOmegaSST::calcResiduals(const dictionary& options) // get the solver performance info such as initial // and final residuals SolverPerformance solverK = solve(kEqn); - if (printToScreen) - { - Info << "k Initial residual: " << solverK.initialResidual() << endl - << " Final residual: " << solverK.finalResidual() << endl; - } + DAUtility::primalResidualControl(solverK, printToScreen, "k"); DAUtility::boundVar(allOptions_, k_, printToScreen); diff --git a/src/adjoint/DAModel/DATurbulenceModel/DAkOmegaSSTFIML.C b/src/adjoint/DAModel/DATurbulenceModel/DAkOmegaSSTFIML.C index 949c82d8..dc47e2d2 100755 --- a/src/adjoint/DAModel/DATurbulenceModel/DAkOmegaSSTFIML.C +++ b/src/adjoint/DAModel/DATurbulenceModel/DAkOmegaSSTFIML.C @@ -1047,11 +1047,7 @@ void DAkOmegaSSTFIML::calcResiduals(const dictionary& options) // get the solver performance info such as initial // and final residuals SolverPerformance solverOmega = solve(omegaEqn); - if (printToScreen) - { - Info << "omega Initial residual: " << solverOmega.initialResidual() << endl - << " Final residual: " << solverOmega.finalResidual() << endl; - } + DAUtility::primalResidualControl(solverOmega, printToScreen, "omega"); DAUtility::boundVar(allOptions_, omega_, printToScreen); } @@ -1088,11 +1084,7 @@ void DAkOmegaSSTFIML::calcResiduals(const dictionary& options) // get the solver performance info such as initial // and final residuals SolverPerformance solverK = solve(kEqn); - if (printToScreen) - { - Info << "k Initial residual: " << solverK.initialResidual() << endl - << " Final residual: " << solverK.finalResidual() << endl; - } + DAUtility::primalResidualControl(solverK, printToScreen, "k"); DAUtility::boundVar(allOptions_, k_, printToScreen); diff --git a/src/adjoint/DAModel/DATurbulenceModel/DAkOmegaSSTFieldInversion.C b/src/adjoint/DAModel/DATurbulenceModel/DAkOmegaSSTFieldInversion.C index bc7a9177..1e92966a 100755 --- a/src/adjoint/DAModel/DATurbulenceModel/DAkOmegaSSTFieldInversion.C +++ b/src/adjoint/DAModel/DATurbulenceModel/DAkOmegaSSTFieldInversion.C @@ -792,11 +792,7 @@ void DAkOmegaSSTFieldInversion::calcResiduals(const dictionary& options) // get the solver performance info such as initial // and final residuals SolverPerformance solverOmega = solve(omegaEqn); - if (printToScreen) - { - Info << "omega Initial residual: " << solverOmega.initialResidual() << endl - << " Final residual: " << solverOmega.finalResidual() << endl; - } + DAUtility::primalResidualControl(solverOmega, printToScreen, "omega"); DAUtility::boundVar(allOptions_, omega_, printToScreen); } @@ -833,11 +829,7 @@ void DAkOmegaSSTFieldInversion::calcResiduals(const dictionary& options) // get the solver performance info such as initial // and final residuals SolverPerformance solverK = solve(kEqn); - if (printToScreen) - { - Info << "k Initial residual: " << solverK.initialResidual() << endl - << " Final residual: " << solverK.finalResidual() << endl; - } + DAUtility::primalResidualControl(solverK, printToScreen, "k"); DAUtility::boundVar(allOptions_, k_, printToScreen); diff --git a/src/adjoint/DAModel/DATurbulenceModel/DAkOmegaSSTLM.C b/src/adjoint/DAModel/DATurbulenceModel/DAkOmegaSSTLM.C index 21ac75e4..43c8b87a 100755 --- a/src/adjoint/DAModel/DATurbulenceModel/DAkOmegaSSTLM.C +++ b/src/adjoint/DAModel/DATurbulenceModel/DAkOmegaSSTLM.C @@ -1105,11 +1105,7 @@ void DAkOmegaSSTLM::calcResiduals(const dictionary& options) // get the solver performance info such as initial // and final residuals SolverPerformance solverOmega = solve(omegaEqn); - if (printToScreen) - { - Info << "omega Initial residual: " << solverOmega.initialResidual() << endl - << " Final residual: " << solverOmega.finalResidual() << endl; - } + DAUtility::primalResidualControl(solverOmega, printToScreen, "omega"); DAUtility::boundVar(allOptions_, omega_, printToScreen); } @@ -1146,11 +1142,7 @@ void DAkOmegaSSTLM::calcResiduals(const dictionary& options) // get the solver performance info such as initial // and final residuals SolverPerformance solverK = solve(kEqn); - if (printToScreen) - { - Info << "k Initial residual: " << solverK.initialResidual() << endl - << " Final residual: " << solverK.finalResidual() << endl; - } + DAUtility::primalResidualControl(solverK, printToScreen, "k"); DAUtility::boundVar(allOptions_, k_, printToScreen); @@ -1207,11 +1199,7 @@ void DAkOmegaSSTLM::calcResiduals(const dictionary& options) // get the solver performance info such as initial // and final residuals SolverPerformance solverReThetat = solve(ReThetatEqn); - if (printToScreen) - { - Info << "ReThetat Initial residual: " << solverReThetat.initialResidual() << endl - << " Final residual: " << solverReThetat.finalResidual() << endl; - } + DAUtility::primalResidualControl(solverReThetat, printToScreen, "ReThetat"); DAUtility::boundVar(allOptions_, ReThetat_, printToScreen); } @@ -1259,11 +1247,7 @@ void DAkOmegaSSTLM::calcResiduals(const dictionary& options) // get the solver performance info such as initial // and final residuals SolverPerformance solverGammaInt = solve(gammaIntEqn); - if (printToScreen) - { - Info << "gammaInt Initial residual: " << solverGammaInt.initialResidual() << endl - << " Final residual: " << solverGammaInt.finalResidual() << endl; - } + DAUtility::primalResidualControl(solverGammaInt, printToScreen, "gammaInt"); DAUtility::boundVar(allOptions_, gammaInt_, printToScreen); diff --git a/src/adjoint/DASolver/DAHeatTransferFoam/DAHeatTransferFoam.C b/src/adjoint/DASolver/DAHeatTransferFoam/DAHeatTransferFoam.C index 3658c349..bd6595d6 100755 --- a/src/adjoint/DASolver/DAHeatTransferFoam/DAHeatTransferFoam.C +++ b/src/adjoint/DASolver/DAHeatTransferFoam/DAHeatTransferFoam.C @@ -82,12 +82,13 @@ label DAHeatTransferFoam::solvePrimal( return 1; } - primalMinRes_ = 1e10; label printInterval = daOptionPtr_->getOption