CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Getting iterations number of matrix solver

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By alexeym

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 2, 2015, 12:56
Default Getting iterations number of matrix solver
  #1
Senior Member
 
Daniel Witte
Join Date: Nov 2011
Posts: 148
Rep Power: 15
danny123 is on a distinguished road
Hi,

I am trying to get the number of iterations of the matrix solver (e.g. PCG) back into the application solver, such as interFoam etc. I have looked at the code. In ldumatrix.H the iteration number is defined under solverPerformance.

There are other values that I can get. If I call prghEq.residual(), I get the residual vector of the ldumatrix calculation. Is there some simple trick to get the iteration number? The iteration number of the matrix solver is printed out on screen, but this is done within a seperated routine (while the matrix solver is called).

Regards,

Daniel
danny123 is offline   Reply With Quote

Old   March 2, 2015, 14:01
Default
  #2
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,938
Rep Power: 39
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Hi,

Solve method returns SolverPerformance object. Using this object you can learn initial residual, final residual and number of iterations.
alexeym is offline   Reply With Quote

Old   March 3, 2015, 04:14
Default
  #3
Senior Member
 
Daniel Witte
Join Date: Nov 2011
Posts: 148
Rep Power: 15
danny123 is on a distinguished road
Thanks alexeym,

I got to that page already. In InterDymFoam the pressure equation is called like this:

Code:
while (pimple.correctNonOrthogonal())
    {
        fvScalarMatrix p_rghEqn
        (
            fvm::laplacian(rAUf, p_rgh) == fvc::div(phiHbyA)
        );

        p_rghEqn.solve(mesh.solver(p_rgh.select(pimple.finalInnerIter())));

       ...
So solve is already called. I do not understand what "solve" calls in this case (I guess it ought to stop iteration when it exceeds the maximum number, but I am not sure.

p_rghEqn has a number of objects that can be called directly (e.g. A, residuals() etc.), but not the number of iterations. What you suggest is to change the solve call, I assume, but how?

I had already the idea to add a new object to fvMatrix, but it is not that easy to get the number of iterations of the matrix solver.

Regards,

Daniel
danny123 is offline   Reply With Quote

Old   March 3, 2015, 04:52
Default
  #4
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,938
Rep Power: 39
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Hi,

You can access nIterations with something like this:

Code:
        const solverPerformance& sp = 
            p_rghEqn.solve(mesh.solver(p_rgh.select(pimple.finalInnerIter())));

        Info<< sp.nIterations() << endl;
sharonyue likes this.
alexeym is offline   Reply With Quote

Old   March 3, 2015, 09:00
Default
  #5
Senior Member
 
Daniel Witte
Join Date: Nov 2011
Posts: 148
Rep Power: 15
danny123 is on a distinguished road
Thanks, works as a charme!

Regards Daniel
danny123 is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
High Courant Number @ icoFoam Artex85 OpenFOAM Running, Solving & CFD 11 February 16, 2017 14:40
Compressor Simulation using rhoPimpleDyMFoam Jetfire OpenFOAM Running, Solving & CFD 107 December 9, 2014 14:38
Simulation seems to converge but crashes suddenly xxxx OpenFOAM 16 September 12, 2014 09:07
Courant-number explodes after a lon while (icoFoam) Rody- OpenFOAM Running, Solving & CFD 6 January 29, 2014 05:27
How to write k and epsilon before the abnormal end xiuying OpenFOAM Running, Solving & CFD 8 August 27, 2013 16:33


All times are GMT -4. The time now is 18:56.