Change solver tolerance depending on solution
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. |
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. |
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 |
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 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. |
All times are GMT -4. The time now is 11:12. |