|
[Sponsors] |
Change solver tolerance depending on solution |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
May 30, 2021, 23:34 |
Change solver tolerance depending on solution
|
#1 |
Member
Martin
Join Date: Dec 2011
Posts: 40
Rep Power: 14 |
Hello everyone.
I need to change the solver tolerances while running. More specifically, I need to change the absolute tolerance of the solver after a certain number of iterations. I know the fvMatrix class has a solver object; but neither of them has a getter implemented to return a reference to the tolerance parameter (which is read from fvSolution). Do you have any idea about how I can achieve this? Thanks in advance. |
|
May 31, 2021, 01:51 |
|
#2 |
Member
Join Date: Jun 2011
Location: Germany
Posts: 59
Rep Power: 14 |
A little hint.
Not tested until yet, but adding runTimeModifiable to fvSolution? doc: runTimeModifiable Switch for whether dictionaries, e.g. controlDict, are re-read during a simulation at the beginning of each time step, allowing the user to modify parameters during a simulation. |
|
May 31, 2021, 10:08 |
|
#3 | |
Member
Martin
Join Date: Dec 2011
Posts: 40
Rep Power: 14 |
Quote:
Apparently I can access the linear solver controls through the mesh as mesh.solverDict(fieldName). fvMesh is derived from fvSolution so that all fields have access to the fvSolution from the mesh reference they hold. I will keep you posted |
||
June 1, 2021, 11:55 |
|
#4 |
Member
Martin
Join Date: Dec 2011
Posts: 40
Rep Power: 14 |
Well, after trying several things. I managed to change the solver settings at runtime without needing to write the dictionary to file.
For anyone needing to do it, here it is my solution. a) Create a dictionary reading the original solver settings. Code:
IOdictionary solDict ( IOobject ( "fvSolution", runTime.caseSystem(), runTime, IOobject::MUST_READ, IOobject::AUTO_WRITE ) ); dictionary& solverControl = solDict.subDict("solvers").subDict("A"); Code:
solverControl.set("tolerance", 1E-10); Code:
AEqn.solve(solverControl); However, I still need to change the number of non-orthogonal correctors on the fly, which apparently has not a simple solution. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Foam::error::printStack(Foam::Ostream&) with simpleFoam -parallel | U.Golling | OpenFOAM Running, Solving & CFD | 52 | September 23, 2023 03:35 |
icoFoam Courant number growth problem | tdof | OpenFOAM Running, Solving & CFD | 12 | May 24, 2023 14:00 |
[ANSYS Meshing] Help with element size | sandri_92 | ANSYS Meshing & Geometry | 14 | November 14, 2018 07:54 |
alpha value negative | silviliril | OpenFOAM Programming & Development | 1 | June 1, 2018 14:57 |
2D isothermal cylinder not converging | UPengineer | OpenFOAM Running, Solving & CFD | 7 | March 13, 2014 05:17 |