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

[Solved] Passive Scalar Source Term "Bug"

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes
  • 1 Post By taalf
  • 2 Post By blais.bruno

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 13, 2016, 05:15
Default [Solved] Passive Scalar Source Term "Bug"
  #1
Member
 
William Tougeron
Join Date: Jan 2011
Location: Czech Republic
Posts: 70
Rep Power: 15
taalf is on a distinguished road
Hi everyone,

I would like to share the solution of a problem that have stuck me for numerous days...

I actually wanted to add a passive scalar to the pimpleFoam solver and to continuously inject this scalar into a cellSet, but the scalar value was stuck inside the cellSet after few iterations without logical reason.

I used OpenFOAM 3.0.1.

Case:

I first added a very simple passive scalar transport equation (without diffusivity) into pimpleFoam.

I inspired myself from this well known tutorial:
http://openfoamwiki.net/index.php/How_to_add_temperature_to_icoFoam


Then I created a custom pimpleFoam solver in which I just copy-pasted the transport equation of the basic/scalarTransportFoam solver.

Something like this (a is the scalar field):

Code:
             solve
             (
                 fvm::ddt(a)
               + fvm::div(phi, a)
//               - fvm::laplacian(Da, a)
              ==
                 fvOptions(a)
             );
inside the:

Code:
        while (pimple.loop())
I then added a source term in the fvOption file to "inject" the scalar in a given cellSet (obtained thanks to topoSet):

Code:
scalarSemiImplicitSource
{
    type            scalarSemiImplicitSource;
    active          true;
    
    scalarSemiImplicitSourceCoeffs
    {
        selectionMode   cellSet;
        cellSet         the_cell_set;
        
        volumeMode      specific; //absolute //specific
        injectionRateSuSp
        {
            a              (1 0);
        }
    }
}
On a small test case like the pitzDaily, everything was correct.

Problem:

But then, on a more complex case, the scalar increased as expected into the cellSet... before being stuck after few iterations. Something like this:

Code:
# Probe 0 (-22.08 0 1.79212)
#       Probe             0
#        Time
       0.0001        0.0001  # Growing...
       0.0002   0.000199415  # Growing...
       0.0003   0.000298911  # Growing...
       0.0004   0.00039848   # Growing...
       0.0005   0.000498117  # Growing...
       0.0006   0.000498117  # Stuck!
       0.0007   0.000498117
       0.0008   0.000498117
The most surprising thing was that the number of iterations before being stuck was depending on... things like the fineness of the mesh (outside the cellSet) and the dimensions of the cellSet. So it was very strange...

Solution:

Now, here it the reason.

After switching to OpenFOAM 2.4 and 4.0 (same results), after trying the same with pisoFoam (without any improvement), after trying numerous modifications in my solver and checking one hundred times the fvSolution and fvScheme files, I finally had a look at... the log file of my computation.

The Initial residual for my scalar transport equation was under its tolerance, leading to a number of iterations equaling zero. This is why the scalar was stuck.

Code:
DILUPBiCG:  Solving for a, Initial residual = 7.45438e-06, Final residual = 7.45438e-06, No Iterations 0
To solve this, I simply moved the line "tolerance" from the "a" to the "aFinal" dictionary in the fvSolution file and ... it works like a charm

Code:
    a
    {
        solver          PBiCG;
        preconditioner  DILU;
        relTol          0.1;
    }
    
    aFinal
    {
        $a;
        tolerance       1e-5;
        relTol          0;
    }
Conclusion:

When one doesn't know where to find the error, look first around your feet before looking at the horizon...

... Hope this will help people crossing the same issue.

Best regards,
blais.bruno likes this.
taalf is offline   Reply With Quote

Old   July 13, 2016, 09:29
Default
  #2
Member
 
Bruno Blais
Join Date: Sep 2013
Location: Canada
Posts: 64
Rep Power: 13
blais.bruno is on a distinguished road
Thanks for sharing!
I had a similar problem before. I think that when debugging or looking at a very specific thing, setting all residual to drastically low value is a good habit just to make sure the issue isnt there. Then you can increase them progressively for the large simulations !
taalf and Christian86 like this.
blais.bruno 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
[swak4Foam] funkyDoCalc with OF2.3 massflow NiFl OpenFOAM Community Contributions 14 November 25, 2020 04:30
implicit - scalar product source term in momentum equation vinch OpenFOAM Running, Solving & CFD 0 October 28, 2014 15:57
OpenFOAM without MPI kokizzu OpenFOAM Installation 4 May 26, 2014 10:17
centOS 5.6 : paraFoam not working yossi OpenFOAM Installation 2 October 9, 2013 02:41
OpenFOAM on MinGW crosscompiler hosted on Linux allenzhao OpenFOAM Installation 127 January 30, 2009 20:08


All times are GMT -4. The time now is 20:29.