CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Running, Solving & CFD

tolerance in solver VS tolerance in residualControl

Register Blogs Community New Posts Updated Threads Search

Like Tree11Likes
  • 1 Post By s1291
  • 1 Post By s1291
  • 3 Post By s1291
  • 1 Post By s1291
  • 2 Post By dlahaye
  • 1 Post By FluidKo
  • 2 Post By dlahaye

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 8, 2022, 09:25
Question tolerance in solver VS tolerance in residualControl
  #1
Senior Member
 
-
Join Date: Oct 2021
Location: -
Posts: 139
Rep Power: 4
FluidKo is on a distinguished road
Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  v1812                                 |
|   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    location    "system";
    object      fvSolution;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

solvers
{
    p
    {
        solver          PCG;
        preconditioner  DIC;
        tolerance       1e-06;
        relTol          0.05;
    }

    pFinal
    {
        $p;
        relTol          0;
    }

    "(U|k|epsilon|omega|R|nuTilda)"
    {
        solver          smoothSolver;
        smoother        symGaussSeidel;
        tolerance       1e-05;
        relTol          0;
    }

    "(U|k|epsilon|omega|R|nuTilda)Final"
    {
        solver          smoothSolver;
        smoother        symGaussSeidel;
        tolerance       1e-05;
        relTol          0;
    }

}


PIMPLE
{
    nNonOrthogonalCorrectors 2;
    nCorrectors          3;
    nOuterCorrectors    1000;

    residualControl
    {
        U
        {
                tolerance  1e-5;
                relTol      0;
        }
        p
        {
                tolerance  5e-4;
                relTol      0;
        }
     }

}


relaxationFactors
{
    fields
    {
        p      0.4;
        pFinal   1;
    }
    equations
    {
        "(U|k|epsilon|omega|R|nuTilda)"     0.4;
        "(U|k|epsilon|omega|R|nuTilda)Final"   1;
    }
}







// ************************************************************************* //
Hello everyone~!
I have one question.
In this code there are 2 kinds of tolerance.
One is tolerance in solvers and another is tolerance in residualControl.
What is difference between them?
I've guessed one thing deals with residual in inner loop(Pressure correction) and another deals with residual in outer loop(Momentum prediction).
But I don't know which one deals with which residual exactly.
And also I've heard that "tolerance in residual control deals with change of the initial residuals from each time step to the next."
But I have no idea meaning of this sentence.
What is the meaning of tolerance between time step?
I think there must be change between time step because of unsteady state.
But why they want to decrease the tolerance between time steps?
Thank you~!
FluidKo is offline   Reply With Quote

Old   August 8, 2022, 18:02
Default
  #2
Member
 
s1291's Avatar
 
Join Date: Aug 2017
Location: Algeria
Posts: 98
Rep Power: 9
s1291 is on a distinguished road
Please refer to the user guide for more details:

https://doc.cfd.direct/openfoam/user...v10/fvsolution
FluidKo likes this.
__________________
"When in doubt, use brute force." -- Ken Thompson
s1291 is offline   Reply With Quote

Old   August 8, 2022, 20:02
Question
  #3
Senior Member
 
-
Join Date: Oct 2021
Location: -
Posts: 139
Rep Power: 4
FluidKo is on a distinguished road
Quote:
Originally Posted by s1291 View Post
Please refer to the user guide for more details:

https://doc.cfd.direct/openfoam/user...v10/fvsolution
In this link, they are dealing with tolerance in solvers only.
I want to know difference between tolerance in solver and tolerance in residualControl.
Thank you~
FluidKo is offline   Reply With Quote

Old   August 8, 2022, 20:27
Default
  #4
Member
 
s1291's Avatar
 
Join Date: Aug 2017
Location: Algeria
Posts: 98
Rep Power: 9
s1291 is on a distinguished road
the residualControl is used for case termination for steady-state solvers and to control the number of outer corrector loops for pimple-based solvers.

More details here: https://www.openfoam.com/documentati...rmination.html
FluidKo likes this.
__________________
"When in doubt, use brute force." -- Ken Thompson
s1291 is offline   Reply With Quote

Old   August 9, 2022, 01:54
Question
  #5
Senior Member
 
-
Join Date: Oct 2021
Location: -
Posts: 139
Rep Power: 4
FluidKo is on a distinguished road
Quote:
Originally Posted by s1291 View Post
the residualControl is used for case termination for steady-state solvers and to control the number of outer corrector loops for pimple-based solvers.

More details here: https://www.openfoam.com/documentati...rmination.html
Aha~!
So for the case of PIMPLE, tolerance in residualControl deals with outer loop(Pressure corrector) and tolerance in solvers deals with inner loop(Momentum predictor).
Thank you~!
FluidKo is offline   Reply With Quote

Old   August 9, 2022, 06:50
Default
  #6
Member
 
s1291's Avatar
 
Join Date: Aug 2017
Location: Algeria
Posts: 98
Rep Power: 9
s1291 is on a distinguished road
Quote:
Originally Posted by FluidKo View Post
Aha~!
So for the case of PIMPLE, tolerance in residualControl deals with outer loop(Pressure corrector) and tolerance in solvers deals with inner loop(Momentum predictor).
Thank you~!
I am afraid that's not correct.

don't let the word 'solver' confuse you here. solver refers to the 'linear solver' that solve the linear system AX = B. the tolerance in this context will control the number of iterations needed to solve it.

the number of pressure correction is controlled by 'nCorrectors' not 'nOuterCorrectors'.


'nOuterCorrectors' controls how many iterations of the PIMPLE algorithm. For example if you set nOuterCorrectors to 1 the algorithm will act as PISO algorithm.

Edit: You can check the following pages to learn more about the PIMPLE Algorithm:

1. PIMPLE Algorithm: https://www.simscale.com/forum/t/cfd...lgorithm/81418
2. OpenFOAM guide/The PIMPLE algorithm in OpenFOAM: https://openfoamwiki.net/index.php/O...hm_in_OpenFOAM
Santiago, Hughtong and FluidKo like this.
__________________
"When in doubt, use brute force." -- Ken Thompson
s1291 is offline   Reply With Quote

Old   August 12, 2022, 03:48
Question
  #7
Senior Member
 
-
Join Date: Oct 2021
Location: -
Posts: 139
Rep Power: 4
FluidKo is on a distinguished road
Quote:
Originally Posted by s1291 View Post
I am afraid that's not correct.

don't let the word 'solver' confuse you here. solver refers to the 'linear solver' that solve the linear system AX = B. the tolerance in this context will control the number of iterations needed to solve it.

the number of pressure correction is controlled by 'nCorrectors' not 'nOuterCorrectors'.


'nOuterCorrectors' controls how many iterations of the PIMPLE algorithm. For example if you set nOuterCorrectors to 1 the algorithm will act as PISO algorithm.

Edit: You can check the following pages to learn more about the PIMPLE Algorithm:

1. PIMPLE Algorithm: https://www.simscale.com/forum/t/cfd...lgorithm/81418
2. OpenFOAM guide/The PIMPLE algorithm in OpenFOAM: https://openfoamwiki.net/index.php/O...hm_in_OpenFOAM
I understand tolerance in 'solvers' is the criteria for stop of iteration.
So although we set nCorrectors to 50, if residual becomes smaller than tolerance that is written in 'solvers' at third iteration, then iteration stops.
I understand this point.
And this nCorrectors is related to pressure corrector part(Inner loop).

Then I'm wondering what are tolerance in 'residualControl' and criteria of nOutercorrectors?

I'm not sure but what I've guessed is relation between tolerance in 'residualControl' and nOutercorrectors is similar to relation between tolerance in 'solvers' and nCorrectors.
If my guess is wrong, then what is the criteria of stopping iteration(momentum predictor) of nOutercorrectors?
And what does tolerance in 'residualControl' work?

P.S
Tolerance in 'solvers' that I mean is below.
Code:
solvers
{
    p
    {
        solver          PCG;
        preconditioner  DIC;
        tolerance       1e-06;
        relTol          0.05;
    }
And tolerance in 'residualControl' that I mean is below
Code:
 residualControl
    {
        U
        {
                tolerance  1e-5;
                relTol      0;
        }
        p
        {
                tolerance  5e-4;
                relTol      0;
        }
     }
Thank you~!
FluidKo is offline   Reply With Quote

Old   August 12, 2022, 09:42
Default
  #8
Member
 
s1291's Avatar
 
Join Date: Aug 2017
Location: Algeria
Posts: 98
Rep Power: 9
s1291 is on a distinguished road
Again, your understanding is not correct. Be very careful with your assumptions.

Quote:
I understand tolerance in 'solvers' is the criteria for stop of iteration
tolerance in 'solvers' controls the number of iterations of the LINEAR SOLVER not the number of iterations for the SIMPLE/PISO/PIMPLE loops.


In case of PIMPLE, residualControl controls the number of outer correctors .
FluidKo likes this.
__________________
"When in doubt, use brute force." -- Ken Thompson
s1291 is offline   Reply With Quote

Old   August 12, 2022, 12:44
Question
  #9
Senior Member
 
-
Join Date: Oct 2021
Location: -
Posts: 139
Rep Power: 4
FluidKo is on a distinguished road
Quote:
Originally Posted by s1291 View Post
Again, your understanding is not correct. Be very careful with your assumptions.



tolerance in 'solvers' controls the number of iterations of the LINEAR SOLVER not the number of iterations for the SIMPLE/PISO/PIMPLE loops.


In case of PIMPLE, residualControl controls the number of outer correctors .
I think I am being confused iteration of 'linear solvers' and iteration of PIMPLE.

Actually I can't understand what is 'iteration of linear solvers' exactly.
There are only 2 types of iteration that I know.
One thing is momentum predictor(outer loop) and another is pressure corrector(inner loop).
But it was the first time that I've heard there is one more type of iteration which is called 'iteration of linear solver'.

What is iteration of linear solver? Is it different to iteration of momentum-pressure coupling predictor and iteration of pressure corrector?

Thank you~!

P.S.
I'm not sure but I think linear solver means momentum predictor.
https://www.openfoam.com/documentati...e-solvers.html
Because in this link, linear solver means Ax=B.
And what I know is in CFD, Ax=B represents momentum equation.
A is coefficient matrix that is determined by mesh, time step and relaxation factor.
x and B are velocity field and pressure gradient field respectively.
But I think I am being confused.
What is wrong?

Last edited by FluidKo; August 12, 2022 at 14:54.
FluidKo is offline   Reply With Quote

Old   August 12, 2022, 15:10
Default
  #10
Senior Member
 
Domenico Lahaye
Join Date: Dec 2013
Posts: 770
Blog Entries: 1
Rep Power: 17
dlahaye is on a distinguished road
Possibly (maybe) it helps to reason as follows:

The finite volume discretization of the mass and momentum equation leads to (results in) a system of non-linear equations. This non-linear system is solved using a outer-inner iteration. The outer iteration is the PIMPLE iteration. At each iteration of PIMPLE, a sequence of linear systems (for velocity and pressure need to be solved).

Let us now focus on the inner (linear) iteration.

A linear system of the form A x = b can be solved using either a direct or an iterative solution method. A direct method computes an LU factorization of the coefficient matrix (in some form). An iterative method computes a sequence of interlands converge to the solution of the linear system.

Suppose now that the inner iteration is solved by a direct method (not implemented in OpenFoam). Then you would see only the residual of the outer iteration (because a direct method for a linear system does not require a residual).

In reality OpenFoam employs an iterative method for each linear system. This implies that at each iteration of the outer iteration, a sequence of iterations at the inner iteration is required. Each iteration has its corresponding non-linear (outer) iteration and linear (inner) iteration.

Possibly one can try to illustrate this by plotting the non-linear and linear residual.

Does this help?
granzer and FluidKo like this.
dlahaye is offline   Reply With Quote

Old   August 13, 2022, 00:52
Default
  #11
Senior Member
 
-
Join Date: Oct 2021
Location: -
Posts: 139
Rep Power: 4
FluidKo is on a distinguished road
Quote:
Originally Posted by dlahaye View Post
Possibly (maybe) it helps to reason as follows:

The finite volume discretization of the mass and momentum equation leads to (results in) a system of non-linear equations. This non-linear system is solved using a outer-inner iteration. The outer iteration is the PIMPLE iteration. At each iteration of PIMPLE, a sequence of linear systems (for velocity and pressure need to be solved).

Let us now focus on the inner (linear) iteration.

A linear system of the form A x = b can be solved using either a direct or an iterative solution method. A direct method computes an LU factorization of the coefficient matrix (in some form). An iterative method computes a sequence of interlands converge to the solution of the linear system.

Suppose now that the inner iteration is solved by a direct method (not implemented in OpenFoam). Then you would see only the residual of the outer iteration (because a direct method for a linear system does not require a residual).

In reality OpenFoam employs an iterative method for each linear system. This implies that at each iteration of the outer iteration, a sequence of iterations at the inner iteration is required. Each iteration has its corresponding non-linear (outer) iteration and linear (inner) iteration.

Possibly one can try to illustrate this by plotting the non-linear and linear residual.

Does this help?
I'm not sure whether I understand what you have said properly or not.
What I understand is momentum equation is non-linear and it is solved by outer iteration.
And linear system is for velocity and pressure and that is solved by inner iteration.

1. I think outer iteration what are you meaning is momentum predictor and inner iteration what are you meaning is pressure corrector.
Is it right?
I've uploaded schematic of momentum predictor and pressure corrector that I know.

2. If it is right, then why do we solve inner solver(pressure corrector) like Ax=b?
Form of pressure corrector that I know is following.
\bigtriangledown \cdot (A^{-1}\bigtriangledown p)=\bigtriangledown \cdot (A^{-1}H)
But this is different to Ax=b.

3. As you can see from code, there are 2 types of tolerance. One is tolerance in 'solvers' part and another is tolerance in 'residualControl" part.
As far as I know, tolerance is criteria for stop of iteration and there are many types of iteration.
I want to know which tolerance is criteria for which iteration.

Thank you~!
Attached Images
File Type: jpg PIMPLE1.jpg (63.0 KB, 44 views)
File Type: png PIMPLE2.png (107.5 KB, 46 views)
Hughtong likes this.

Last edited by FluidKo; August 13, 2022 at 02:36.
FluidKo is offline   Reply With Quote

Old   August 15, 2022, 06:09
Default
  #12
Senior Member
 
Domenico Lahaye
Join Date: Dec 2013
Posts: 770
Blog Entries: 1
Rep Power: 17
dlahaye is on a distinguished road
1. Yes. correct;

2. The equation you write down becomes a linear system after finite volume discretisation;

3. tolerance for linear system (or inner iteration). residualControl for non-linear system (or outer iteration). This is easy to verify on a small example.

Good luck.
Hughtong and FluidKo like this.
dlahaye is offline   Reply With Quote

Old   August 17, 2022, 02:53
Thumbs up
  #13
Senior Member
 
-
Join Date: Oct 2021
Location: -
Posts: 139
Rep Power: 4
FluidKo is on a distinguished road
Quote:
Originally Posted by dlahaye View Post
1. Yes. correct;

2. The equation you write down becomes a linear system after finite volume discretisation;

3. tolerance for linear system (or inner iteration). residualControl for non-linear system (or outer iteration). This is easy to verify on a small example.

Good luck.
Ok I got it.
Thanks for your sincere answer~!
FluidKo is offline   Reply With Quote

Old   January 30, 2024, 10:59
Default
  #14
Member
 
Hüseyin Can Önel
Join Date: Sep 2018
Location: Ankara, Turkey
Posts: 47
Rep Power: 7
hconel is on a distinguished road
Essentially, you are solving some physical conservation equations, and since these equations are non-linear, you are casting them into linear systems and solving them iteratively.

For example, you solve the mass and momentum conservation equations for the incompressible flow. Due to the pressure-velocity decoupling, you perform additional solution steps such as momentum predictor, pressure equation, flux corrector etc. The individual solution of any of these equations may be iterative, and every iterative process requires some tolerance to stop. Lastly, solving any of these equations individually does not mean that you are conserving the physical quantities (mass, momentum, etc.) simultaneously, i.e. satisfying the overall physics of the problem.

So I always visualize it this way:
With the solver tolerance, you set the allowed error for the iterative solution of, say, the momentum equation Ax+e=b, where e is the error.
With the residual, you set the allowed error which causes the computed pressure and velocity fields to disagree in terms of how they satisfy the governing conservation equations.

I guess tolerance and residual concepts boil down to the same thing when you are solving a single conservation equation (i.e. Laplace equation for heat conduction), thus the confusion arises in a multi-variable & multi-equation system: the solution processes of A) every single equation AND B) the overall system of equations are both iterative, and each iterative process has its own tolerance definition.

I hope I didn't make some mistakes in my explanation and this makes sense.
hconel is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
alpha value is negative silviliril OpenFOAM Running, Solving & CFD 1 May 18, 2018 08:44
rhoSimplecFoam - multiple linear solvers? tdog OpenFOAM Running, Solving & CFD 2 January 2, 2017 09:55
adapting tolerance of matrix solver danny123 OpenFOAM Running, Solving & CFD 5 May 5, 2015 03:53
IcoFoam stationary solution STRONGLY dependent on the tolerance of the linear solver Mehrez OpenFOAM Running, Solving & CFD 1 February 16, 2015 06:59
Working directory via command line Luiz CFX 4 March 6, 2011 20:02


All times are GMT -4. The time now is 21:40.