CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Running, Solving & CFD (
-   -   Iteration control (

kdarc September 20, 2007 16:50

Is there a way to force solver
Is there a way to force solvers to perform just ONE iteration at a time??

I am trying to work with a highly coupled system of equations and want to use the "solve" structures since they handle all the boundary conditions and can apply relaxation factors. I would have to set up my own kind of convergence control, but would be happy to get on with doing that if I could solve each equation one at a time.


kdarc September 21, 2007 09:48

Come on people, this is critic
Come on people, this is critical!!

I see that in the file lduMatrix.H, there is some code:

00206 //- Abstract base-class for lduMatrix solvers
00207 class solver
00208 {
00209 protected:
00211 // Protected data
00213 word fieldName_;
00214 const lduMatrix& matrix_;
00215 const FieldField<field,>& interfaceBouCoeffs_;
00216 const FieldField<field,>& interfaceIntCoeffs_;
00217 lduInterfaceFieldPtrsList interfaces_;
00219 //- dictionary of controls
00220 dictionary controlDict_;
00222 //- Maximum number of iterations in the solver
00223 label maxIter_;
00225 //- Final convergence tolerance
00226 scalar tolerance_;
00228 //- Convergence tolerance relative to the initial
00229 scalar relTol_;

there is a label maxIter_ referred to.

Does anyone know how/what/where to use this to chnage the maximum number of solver iterations from what seems to be 5001, to just 1.


olesen September 21, 2007 10:14

Okay Ken, you now have our att
Okay Ken, you now have our attention.

I can't see where the '5001' is coming from either. The constructor in lduMatrix/lduMatrixSolver.C is using 1000.

From your demand for help, I assume that the maxIter in the fvSolution isn't being respected?
I guess this is critical - ie, a bug or a problem with your installation.

k smoothSolver
smoother GaussSeidel;
nSweeps 2;
tolerance 1e-7;
relTol 0.1;
maxIter 1;


kdarc September 21, 2007 13:05

thanks for the reply Mark.
thanks for the reply Mark.

I still can't figure out how to implement what you're suggesting.

what I want, is to solve for variable phi_SR1 with solver ICCG to tol of 1e-6 relTol 0 (really tol and relTol are irrelevant for 1 iteration...) with iterMax = 1. your example showed:

k smoothSolver
smoother GaussSeidel;
nSweeps 2;
tolerance 1e-7;
relTol 0.1;
maxIter 1;

presumably this is in fvSolution?
in your case, is k the variable to be solved?

if I imitate with

phi_SR1 solver or smoothSolver, I get an error.

putting maxIter 1; anywhere seems to have no effect.

how/where would you code what I'm trying to accomplish?


olesen September 24, 2007 05:10

Hi Ken, Yes, you should be
Hi Ken,

Yes, you should be adding your solver parameters into system/fvSolution. If you get an error with using phi_SRI smoothSolver { .... };
There is something else wrong (eg, you are not using a fv method, etc.).
If this is not working properly, you can't place maxIter within the braces.

After you get this sorted out, you might even try just using relTol=1 (or 0.999). I would think that this should give a similar result as limiting the maxIter explicitly.

kdarc September 24, 2007 12:27

Ok thanks! it's working as
Ok thanks!

it's working as required, one hitch was that I am using subdomains and in our recently implemented v1.4, it wasn't obvious that additional fvSolution files are now required subdomain system directories...

blood pressure now returning to normal level....

All times are GMT -4. The time now is 21:00.