- **OpenFOAM Programming & Development**
(*https://www.cfd-online.com/Forums/openfoam-programming-development/*)

- - **Problem while getting the initial residual**
(*https://www.cfd-online.com/Forums/openfoam-programming-development/106183-problem-while-getting-initial-residual.html*)

Problem while getting the initial residualDear Foamers,
I am working on a solver (with OF-2.0.1) with an internal correction loop to deal with a non-linear equation. I try to use the initial residual of the resolution of each iteration of my internal loop to make the exit test of this loop (namely initialResidual<0.1), but : 1) When I use .solve().initialResidual() only, my initial residual is always 1 so that I cannot reach convergence (see Resolutions 1 and 1' and logs 1 or 1' below). 2) When I make successivly a .solve() and a .solve().initialResidual(), everything is fine in transient regime but if a steady state appears, the second resolution implied by .solve().initialResidual() makes the initial residual increasing, and thus impairs convergence (see Resolutions 2 and 2' and logs 2 or 2' below).. So my question is : in which way can I get acces to the initial residual without make a resolution, or alternatively use only .solve().initialResidual() without fixing the initial residual to one ? Thank you by advance for your help. Resolutions 1 and 1':1 : psiIR=psiEqn.solve().initialResidual(); Info<< "psiIR = " << psiIR << endl; 1': lduMatrix::solverPerformance sp = psiEqn.solve(); psiIR=sp.initialResidual(); Info<< "psiIR = " << psiIR << endl; logs 1 or 1':DICPCG: Solving for psi, Initial residual = 1, Final residual = 3.38224e-17, No Iterations 1 psiIR = 1 DICPCG: Solving for psi, Initial residual = 1, Final residual = 1.60809e-19, No Iterations 1 psiIR = 1 DICPCG: Solving for psi, Initial residual = 1, Final residual = 9.66389e-17, No Iterations 1 psiIR = 1 and so on, the initial residual is fixed to one so that the convergence criterium can't be reached. Resolutions 2 and 2' :2: psiEqn.solve(); lduMatrix::solverPerformance sp = psiEqn.solve(); psiIR=sp.initialResidual(); Info<< "psiIR = " << psiIR << endl; 2': psiEqn.solve(); psiIR=psiEqn.solve().initialResidual(); Info<< "psiIR = " << psiIR << endl; Logs 2 or 2':before steady state, no problem : DICPCG: Solving for psi, Initial residual = 0.0582326, Final residual = 4.93904e-20, No Iterations 1 DICPCG: Solving for psi, Initial residual = 3.70557e-16, Final residual = 3.70557e-16, No Iterations 0 psiIR = 3.70557e-16 and that's it, the residual is under the convergence criterium and the computation moves to the next time step. but as soon as the steady state is reached, the resolution made by the line to get the initial residual (e.g.: psiIR=psiEqn.solve().initialResidual();) makes the initial residual increases and thus impairs convergence : DICPCG: Solving for psi, Initial residual = 0.0436467, Final residual = 2.58946e-15, No Iterations 1 DICPCG: Solving for psi, Initial residual = 0.166518, Final residual = 1.86296e-14, No Iterations 1 psiIR = 0.166518 DICPCG: Solving for psi, Initial residual = 0.0436467, Final residual = 2.58946e-15, No Iterations 1 DICPCG: Solving for psi, Initial residual = 0.166518, Final residual = 1.86296e-14, No Iterations 1 psiIR = 0.166518 DICPCG: Solving for psi, Initial residual = 0.0436467, Final residual = 2.58946e-15, No Iterations 1 DICPCG: Solving for psi, Initial residual = 0.166518, Final residual = 1.86296e-14, No Iterations 1 psiIR = 0.166518 and so on, so that the convergence criteria (initial residual less than 0.1 here) can't be reached and the computation diverge. |

Did you figured out how to fix your problem with initial residual?
I am trying to solve equation fvScalarMatrix CEqn ( fvm::ddt(C) + fvm::div(phi, C) ); CeqnResidual = CEqn.solve().initialResidual(); In case where phi is zero (i.e. no flow), my initial residuals are always high (~ 0.3). When I am forcing the solver to exit without satisfying the convergence criterion (by setting a maximum for the iterations), I see that phi is zero everywhere and C is constant, as I expect. But, I don't know why CeqnResidual is high! |

All times are GMT -4. The time now is 03:15. |