From 94bacb8c1889130c5176fdb1da9e56efd88bb9d5 Mon Sep 17 00:00:00 2001 From: andy <andy> Date: Tue, 13 Mar 2012 09:33:02 +0000 Subject: [PATCH] BUG: Corrected pimpleControl behaviour for final iteration --- .../pimpleControl/pimpleControl.C | 30 ++++++++++++++----- .../pimpleControl/pimpleControl.H | 5 +++- .../pimpleControl/pimpleControlI.H | 6 ++-- 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleControl.C b/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleControl.C index 7ff31db0eca..4cd984f0ccc 100644 --- a/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleControl.C +++ b/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleControl.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -126,7 +126,8 @@ Foam::pimpleControl::pimpleControl(fvMesh& mesh) nCorrPIMPLE_(0), nCorrPISO_(0), corrPISO_(0), - turbOnFinalIterOnly_(true) + turbOnFinalIterOnly_(true), + converged_(false) { read(); @@ -194,12 +195,27 @@ bool Foam::pimpleControl::loop() } bool completed = false; - if (criteriaSatisfied()) + if (converged_ || criteriaSatisfied()) { - Info<< algorithmName_ << ": converged in " << corr_ - 1 << " iterations" - << endl; - completed = true; - corr_ = 0; + if (converged_) + { + Info<< algorithmName_ << ": converged in " << corr_ - 1 + << " iterations" << endl; + + mesh_.data::remove("finalIteration"); + corr_ = 0; + converged_ = false; + + completed = true; + } + else + { + Info<< algorithmName_ << ": iteration " << corr_ << endl; + storePrevIterFields(); + + mesh_.data::add("finalIteration", true); + converged_ = true; + } } else { diff --git a/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleControl.H b/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleControl.H index 9a5912e4fb7..6cb9d3a21f6 100644 --- a/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleControl.H +++ b/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleControl.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -66,6 +66,9 @@ protected: //- Flag to indicate whether to only solve turbulence on final iter bool turbOnFinalIterOnly_; + //- Converged flag + bool converged_; + // Protected Member Functions diff --git a/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleControlI.H b/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleControlI.H index 1fe60987317..1d8917de89b 100644 --- a/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleControlI.H +++ b/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleControlI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -73,14 +73,14 @@ inline bool Foam::pimpleControl::storeInitialResiduals() const inline bool Foam::pimpleControl::finalIter() const { - return corr_ == nCorrPIMPLE_; + return converged_ || (corr_ == nCorrPIMPLE_); } inline bool Foam::pimpleControl::finalInnerIter() const { return - corr_ == nCorrPIMPLE_ + finalIter() && corrPISO_ == nCorrPISO_ && corrNonOrtho_ == nNonOrthCorr_ + 1; } -- GitLab