|
[Sponsors] |
April 29, 2015, 12:10 |
adapting tolerance of matrix solver
|
#1 |
Senior Member
Daniel Witte
Join Date: Nov 2011
Posts: 148
Rep Power: 15 |
Hello,
the tolerance of the matrix solver is set in fVsolution. This is ok for me, but under certain circumstances, I want to adapt the value, or minIter that is specified. Is there somebody who knows, how to do that? I know how to get solverperformance, but not how to change convergence criteria within the application solver code. Regards, Daniel |
|
May 4, 2015, 09:13 |
|
#2 |
Senior Member
Daniel Witte
Join Date: Nov 2011
Posts: 148
Rep Power: 15 |
I have made some progress, but I am still missing some information on the issue. The information is defined as a dictionary. I can get the information within the dictionary. I added the following code:
Code:
const dictionary& solverControls_p = mesh.solver(p_rgh.select(pimple.finalInnerIter())); Info<< " before changing solverControls_p = " << solverControls_p << endl; HTML Code:
solverControls_p = { solver PCG_norm; preconditioner DIC; tolerance 1e-05; relTol 0.001; maxIter 20000; Regards, Daniel |
|
May 4, 2015, 10:25 |
|
#3 |
Senior Member
|
Hi,
If you take a look at fvMesh::solver [1] documentation (which was in fact inherited from solution class), you can learn that it returns dictionary with solver settings. So the call Code:
pEqn.solve(mesh.solver(p.select(pimple.finalInnerIter()))); So, you either construct dictionary yourself, set desired value of tolerance (along with other linear solver parameters), and then pass this dictionary to solve method. Or you create a copy of fvMesh::solver, set desired value of the tolerance, and the pass the dictionary to solve method. The second variant is more convenient as it takes other settings from fvSolution (you just overwrite tolerance entry of the dictionary), while using the first variant, you have to set all solver settings yourself. 1. http://foam.sourceforge.net/docs/cpp...f7779f1b8870e2 2. http://foam.sourceforge.net/docs/cpp...161fe7f7e6b9c8 3. http://foam.sourceforge.net/docs/cpp...5731ffe067b39f |
|
May 4, 2015, 11:34 |
|
#4 |
Senior Member
Daniel Witte
Join Date: Nov 2011
Posts: 148
Rep Power: 15 |
Hi Alexey,
Thanks again for your help. Your suggestion seems logical to me, however i do not get to work. If I use the set method (method 2), I guess I will get what I want. I tried: Code:
solverControls_p.set(tolerance,1e-06); Code:
void Foam::dictionary::set(entry* entryPtr) Regards, Daniel |
|
May 4, 2015, 13:19 |
|
#5 |
Senior Member
|
Hi,
As you have used tolerance without quotes, compiler thinks it is a variable named tolerance. Do you have this variable? In general, you would use just a string "tolerance". And you should use method [1] instead of [2]. The method is template, so you also supply type of the "tolerance" key (scalar). So the whole thing should be something like: Code:
dictionary t(mesh.solver("field")); t.set<scalar>("tolerance", 1e-20); fieldEqn.solve(t); 2. http://foam.sourceforge.net/docs/cpp...c8b1ac9e18460b |
|
May 5, 2015, 04:53 |
|
#6 |
Senior Member
Daniel Witte
Join Date: Nov 2011
Posts: 148
Rep Power: 15 |
Hi Alexey,
Thanks, this works perfectly. Regards, Daniel |
|
Tags |
tolerance change |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
solver tolerance in fvSolution | fisch | OpenFOAM Running, Solving & CFD | 7 | July 28, 2020 12:57 |
Getting iterations number of matrix solver | danny123 | OpenFOAM Programming & Development | 4 | March 3, 2015 09:00 |
IcoFoam stationary solution STRONGLY dependent on the tolerance of the linear solver | Mehrez | OpenFOAM Running, Solving & CFD | 1 | February 16, 2015 07:59 |
compressible two phase flow in CFX4.4 | youngan | CFX | 0 | July 2, 2003 00:32 |
solver for linear system with large sparse matrix | Yangang Bao | Main CFD Forum | 1 | October 25, 1999 05:22 |