|
[Sponsors] |
tolerance in solver VS tolerance in residualControl |
![]() |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
![]() |
![]() |
#1 |
Senior Member
-
Join Date: Oct 2021
Location: -
Posts: 139
Rep Power: 4 ![]() |
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; } } // ************************************************************************* // 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~! ![]() |
|
![]() |
![]() |
![]() |
![]() |
#2 |
Member
Join Date: Aug 2017
Location: Algeria
Posts: 98
Rep Power: 9 ![]() |
Please refer to the user guide for more details:
https://doc.cfd.direct/openfoam/user...v10/fvsolution
__________________
"When in doubt, use brute force." -- Ken Thompson |
|
![]() |
![]() |
![]() |
![]() |
#3 | |
Senior Member
-
Join Date: Oct 2021
Location: -
Posts: 139
Rep Power: 4 ![]() |
Quote:
I want to know difference between tolerance in solver and tolerance in residualControl. Thank you~ ![]() |
||
![]() |
![]() |
![]() |
![]() |
#4 |
Member
Join Date: Aug 2017
Location: Algeria
Posts: 98
Rep Power: 9 ![]() |
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
__________________
"When in doubt, use brute force." -- Ken Thompson |
|
![]() |
![]() |
![]() |
![]() |
#5 | |
Senior Member
-
Join Date: Oct 2021
Location: -
Posts: 139
Rep Power: 4 ![]() |
Quote:
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~! |
||
![]() |
![]() |
![]() |
![]() |
#6 | |
Member
Join Date: Aug 2017
Location: Algeria
Posts: 98
Rep Power: 9 ![]() |
Quote:
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
__________________
"When in doubt, use brute force." -- Ken Thompson |
||
![]() |
![]() |
![]() |
![]() |
#7 | |
Senior Member
-
Join Date: Oct 2021
Location: -
Posts: 139
Rep Power: 4 ![]() |
Quote:
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; } Code:
residualControl { U { tolerance 1e-5; relTol 0; } p { tolerance 5e-4; relTol 0; } } ![]() |
||
![]() |
![]() |
![]() |
![]() |
#8 | |
Member
Join Date: Aug 2017
Location: Algeria
Posts: 98
Rep Power: 9 ![]() |
Again, your understanding is not correct. Be very careful with your assumptions.
Quote:
In case of PIMPLE, residualControl controls the number of outer correctors .
__________________
"When in doubt, use brute force." -- Ken Thompson |
||
![]() |
![]() |
![]() |
![]() |
#9 | |
Senior Member
-
Join Date: Oct 2021
Location: -
Posts: 139
Rep Power: 4 ![]() |
Quote:
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. |
||
![]() |
![]() |
![]() |
![]() |
#10 |
Senior Member
|
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? |
|
![]() |
![]() |
![]() |
![]() |
#11 | |
Senior Member
-
Join Date: Oct 2021
Location: -
Posts: 139
Rep Power: 4 ![]() |
Quote:
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. ![]() 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~! ![]() Last edited by FluidKo; August 13, 2022 at 02:36. |
||
![]() |
![]() |
![]() |
![]() |
#12 |
Senior Member
|
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. |
|
![]() |
![]() |
![]() |
![]() |
#13 | |
Senior Member
-
Join Date: Oct 2021
Location: -
Posts: 139
Rep Power: 4 ![]() |
Quote:
Thanks for your sincere answer~! ![]() |
||
![]() |
![]() |
![]() |
![]() |
#14 |
Member
Hüseyin Can Önel
Join Date: Sep 2018
Location: Ankara, Turkey
Posts: 47
Rep Power: 7 ![]() |
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. |
|
![]() |
![]() |
![]() |
|
|
![]() |
||||
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 |