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

A tiny error in linear PCG solver

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By Zeppo
  • 1 Post By Zeppo

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 7, 2017, 12:22
Default A tiny error in linear PCG solver
  #1
Senior Member
 
Zeppo's Avatar
 
Sergei
Join Date: Dec 2009
Posts: 261
Rep Power: 21
Zeppo will become famous soon enough
A tiny error in linear PCG solver.
https://cpp.openfoam.org/v5/PCG_8C_source.html#l00066
It does one more iteration than specified in variable maxIter_ (which is read from system/fvSolution dictionary):
Code:
// “PCG.C”
Foam::solverPerformance Foam::PCG::solve
(
    ...
) const
{
    ...
    // --- Solver iteration
    do
    {
        ...
    } while
    (
        (
            solverPerf.nIterations()++ < maxIter_
            ...
        )
        ...
    );
    ...
}
Here the loop condition is evaluated first, then number of iterations is incremented. The sequence of operations must be in the reverse order:
Code:
// “PCG.C”
Foam::solverPerformance Foam::PCG::solve
(
    ...
) const
{
    ...
    // --- Solver iteration
    do
    {
        ...
    } while
    (
        (
            ++solverPerf.nIterations() < maxIter_
            ...
        )
        ...
    );
    ...
}
Tobi likes this.
Zeppo is offline   Reply With Quote

Old   October 9, 2017, 05:37
Default
  #2
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Hi Sergei,

I came across of that problems several times but never thought about that However, based on your post, I thought it is worth to mention in the bug-tracking system:

https://bugs.openfoam.org/view.php?id=2716
__________________
Keep foaming,
Tobias Holzmann

Last edited by Tobi; October 14, 2017 at 07:54.
Tobi is offline   Reply With Quote

Old   October 9, 2017, 08:26
Default
  #3
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
It is already resolved by the commit: https://github.com/OpenFOAM/OpenFOAM...7f0fa442d4ac56

In addition henry changed it in two other gradient based solvers
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   October 14, 2017, 07:32
Default
  #4
Senior Member
 
Zeppo's Avatar
 
Sergei
Join Date: Dec 2009
Posts: 261
Rep Power: 21
Zeppo will become famous soon enough
Hi, Tobias. Thanks for taking a burden of posting a bug report from me. The error was found a while ago but was left where it sat till recent moment. Sometimes searching for a bug in the code can be fun.
Tobi likes this.
Zeppo 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
Steady-State and Transient Solvers 70m1 OpenFOAM Running, Solving & CFD 21 May 8, 2021 08:09
PEMFC model with FLUENT brahimchoice FLUENT 22 April 19, 2020 16:44
fluent divergence for no reason sufjanst FLUENT 2 March 23, 2016 17:08
Heat flux BC lfrigeri3 OpenFOAM 9 February 22, 2014 12:59
suitable boundary condition for scavenging process? immortality OpenFOAM Running, Solving & CFD 3 January 25, 2013 20:10


All times are GMT -4. The time now is 11:57.