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

Floating Point Exception -after adding a filter

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By ngj

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 29, 2014, 03:21
Default Floating Point Exception -after adding a filter
  #1
Member
 
Thamali
Join Date: Jul 2013
Posts: 67
Rep Power: 12
Thamali is on a distinguished road
Dear Foamers,
I am running a case with a solver developed by me for packed bed wood chip combustion.My problem is when the input radiation temperature is increased to about 1100K the iterations stop around 2600 with a floating point exception.According to the error it is in the following equation;

Code:
volScalarField rCH4=AG*exp(-AF/tg)*pow(YCH4*rho/(16*pow(scalar(10),-3)),0.7)*pow(YO2*rho/(32*pow(scalar(10),-3)),0.8);
  • as i figured out "YO2" values become (-)ve in the last iteration.
  • But i have added following filter before the equation.
Code:
forAll(YO2,cellI)
            {if (YO2[cellI]<0.0)
                YO2[cellI]=1.0e-60;
                           }
still the floating point exception occurs at same iteration.
  • "YCH4" and "rho" has not become zero.
the error shown is
Code:
#0  Foam::error::printStack(Foam::Ostream&) at ~/OpenFOAM/OpenFOAM-2.2.2/src/OSspecific/POSIX/printStack.C:221
#1  Foam::sigFpe::sigHandler(int) at ~/OpenFOAM/OpenFOAM-2.2.2/src/OSspecific/POSIX/signals/sigFpe.C:117
#2   in "/lib/x86_64-linux-gnu/libc.so.6"
#3   in "/lib/x86_64-linux-gnu/libm.so.6"
#4  Foam::pow(double, double) at ~/OpenFOAM/OpenFOAM-2.2.2/src/OpenFOAM/lnInclude/doubleFloat.H:78
#5  Foam::pow(Foam::Field<double>&, Foam::UList<double> const&, double const&) at ~/OpenFOAM/OpenFOAM-2.2.2/src/OpenFOAM/fields/Fields/scalarField/scalarField.C:118 (discriminator 2)
#6  void Foam::pow<Foam::fvPatchField>(Foam::FieldField<Foam::fvPatchField, double>&, Foam::FieldField<Foam::fvPatchField, double> const&, double const&) at ~/OpenFOAM/OpenFOAM-2.2.2/src/OpenFOAM/lnInclude/scalarFieldField.C:94 (discriminator 2)
#7  void Foam::pow<Foam::fvPatchField, Foam::volMesh>(Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>&, Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&, Foam::dimensioned<double> const&) at ~/OpenFOAM/OpenFOAM-2.2.2/src/OpenFOAM/lnInclude/GeometricScalarField.C:275
#8  
 at ~/OpenFOAM/OpenFOAM-2.2.2/src/OpenFOAM/lnInclude/GeometricScalarField.C:328
#9  
 at ~/OpenFOAM/OpenFOAM-2.2.2/src/OpenFOAM/lnInclude/GeometricScalarField.C:350
#10  
 at ~/OpenFOAM/thamali-2.2.2/applications/solvers/my_fireFoam14dryDiffwithPfilterschanged/UEqn.H:145 (discriminator 3)
#11  __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6"
#12  
 at ??:?
Floating point exception (core dumped)

can someone tell me any thing wrong in the filter or what my problem would be??

Last edited by Thamali; May 29, 2014 at 03:31. Reason: adding error
Thamali is offline   Reply With Quote

Old   May 29, 2014, 04:50
Default
  #2
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37
ngj will become famous soon enoughngj will become famous soon enough
Hi Thamali,

The only thing I see is that Y02 can be allowed to be 0, which should not be a problem. However, whenever I have this type of problem, I always go for a little bit more conservative solution:

Code:
if (Y02[cellI] < SMALL)
{
    Y02[cellI] = SMALL;
}
Furthermore, I have noticed the computation of static values, e.g.:

Code:
16.0*Foam::pow(scalar(10), -3)
I would suggest simply to either recompute this value before hand and insert a variable or simply hard-code 0.016. This will safe you a little bit of computations.

Finally, I would recommend that you always add

Code:
Foam::
in front of e.g. pow, sin, cos, exp, etc, to make sure that the compiler knows that you want to use the OF-overloaded functions and not those from the std:: namespace.

Kind regards,

Niels
Kummi likes this.
__________________
Please note that I do not use the Friend-feature, so do not be offended, if I do not accept a request.
ngj is offline   Reply With Quote

Old   May 29, 2014, 04:51
Default
  #3
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37
ngj will become famous soon enoughngj will become famous soon enough
P.S. You can also use
Code:
 VSMALL
as call name.
__________________
Please note that I do not use the Friend-feature, so do not be offended, if I do not accept a request.
ngj is offline   Reply With Quote

Old   May 29, 2014, 06:17
Default
  #4
Member
 
Thamali
Join Date: Jul 2013
Posts: 67
Rep Power: 12
Thamali is on a distinguished road
First of all,thank you very much for your reply.

Yeah I edited the code as you mentioned,but it still my problem remains.
I don't get why this "Floating Point Exception" error still occurring,after the filter is added.
When I check the values of "YO2" using "write()" function,it shows the VSMALL(1e-300) value,but why that value is not taking in to account of calculating rCH4 in the next step?? (This problem occurs at only one point)

Code:
volScalarField rCH4=AG*exp(-AF/tg)*Foam::pow(YCH4*rho/0.016,0.7)*Foam::pow(YO2*rho/0.032,0.8)
or this is not the real error,although it shows like;
Code:
#0  Foam::error::printStack(Foam::Ostream&) at ~/OpenFOAM/OpenFOAM-2.2.2/src/OSspecific/POSIX/printStack.C:221
#1  Foam::sigFpe::sigHandler(int) at ~/OpenFOAM/OpenFOAM-2.2.2/src/OSspecific/POSIX/signals/sigFpe.C:117
#2   in "/lib/x86_64-linux-gnu/libc.so.6"
#3   in "/lib/x86_64-linux-gnu/libm.so.6"
#4  Foam::pow(double, double) at ~/OpenFOAM/OpenFOAM-2.2.2/src/OpenFOAM/lnInclude/doubleFloat.H:78
#5  Foam::pow(Foam::Field<double>&, Foam::UList<double> const&, double const&) at ~/OpenFOAM/OpenFOAM-2.2.2/src/OpenFOAM/fields/Fields/scalarField/scalarField.C:118 (discriminator 2)
#6  void Foam::pow<Foam::fvPatchField>(Foam::FieldField<Foam::fvPatchField, double>&, Foam::FieldField<Foam::fvPatchField, double> const&, double const&) at ~/OpenFOAM/OpenFOAM-2.2.2/src/OpenFOAM/lnInclude/scalarFieldField.C:94 (discriminator 2)
#7  void Foam::pow<Foam::fvPatchField, Foam::volMesh>(Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>&, Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&, Foam::dimensioned<double> const&) at ~/OpenFOAM/OpenFOAM-2.2.2/src/OpenFOAM/lnInclude/GeometricScalarField.C:275
#8  
 at ~/OpenFOAM/OpenFOAM-2.2.2/src/OpenFOAM/lnInclude/GeometricScalarField.C:328
#9  
 at ~/OpenFOAM/OpenFOAM-2.2.2/src/OpenFOAM/lnInclude/GeometricScalarField.C:350
#10  
 at ~/OpenFOAM/thamali-2.2.2/applications/solvers/my_fireFoam14dryDiffwithPfilterschanged/UEqn.H:135 (discriminator 3)
#11  __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6"
#12  
 at ??:?
Floating point exception (core dumped)
I am stuck,please help??

Last edited by Thamali; May 29, 2014 at 06:18. Reason: error
Thamali is offline   Reply With Quote

Old   May 29, 2014, 10:05
Default
  #5
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37
ngj will become famous soon enoughngj will become famous soon enough
You could try to evaluate each term with an Info statement in between. This will narrow it down to which of the two pow, which cause the problem.

Thereafter, you can look at the values of the fields, which go wrong and the whole argument, e.g. by use of the write() method of volField<Type>.

Could it be that your values at thw boundaries become negative? If you do not use correctBoundaryConditions() method after the filter, then zeroGradient type boundary conditions will still hold the original value of the internal field.

Good luck,

Niels
__________________
Please note that I do not use the Friend-feature, so do not be offended, if I do not accept a request.
ngj is offline   Reply With Quote

Old   May 30, 2014, 03:36
Default
  #6
Member
 
Thamali
Join Date: Jul 2013
Posts: 67
Rep Power: 12
Thamali is on a distinguished road
Dear Niels,

HTML Code:
Could it be that your values at thw boundaries become negative? If you  do not use correctBoundaryConditions() method after the filter, then  zeroGradient type boundary conditions will still hold the original value  of the internal field.
You were right.It is (-)ve in the boundary condition.So,i tried to solve the problem using a groovyBC as one of the following methods;

Code:
interFace
    {
       
    type        groovyBC;
    valueExpression        "1e-25";
    gradientExpression    "0";
    fractionExpression    "(internalField(YO2) == 1e-25) ? 1 : 0";
    value        0.2314;
    }
Code:
interFace
    {
        
    type        groovyBC;
    valueExpression        "1e-25";
    gradientExpression    "0";
    fractionExpression    "(internalField(YO2) <0) ? 1 : 0";
    value        0.2314;
    }
Code:
interFace
    {
         
    type        groovyBC;
    valueExpression        "1e-25";
    gradientExpression    "0";
    fractionExpression    "(YO2 <0) ? 1 : 0";
    value        0.2314;
    }
But nothing worked.Still the value is (-)ve.
Do you see anything wrong??

Thanks in advance.
Regards,
Thamali
Thamali is offline   Reply With Quote

Old   May 30, 2014, 05:57
Default
  #7
Member
 
Thamali
Join Date: Jul 2013
Posts: 67
Rep Power: 12
Thamali is on a distinguished road
ok.I added the following just after the filter in the solver and it worked.

Code:
YO2.correctBoundaryConditions();
Thank you very much Neils.
Thamali
Thamali is offline   Reply With Quote

Old   May 30, 2014, 06:04
Default
  #8
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37
ngj will become famous soon enoughngj will become famous soon enough
You are welcome. Good that it worked.

Kind regards,

Niels
__________________
Please note that I do not use the Friend-feature, so do not be offended, if I do not accept a request.
ngj is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Floating point exception with pimpleDyMFoam ebah6 OpenFOAM Running, Solving & CFD 9 November 1, 2017 06:58
Inlet Velocity Profile BC - Floating Point exception during solution initialization Janshi STAR-CCM+ 4 March 14, 2012 11:21
simpleFoam Floating point exception error -help sudhasran OpenFOAM Running, Solving & CFD 3 March 12, 2012 17:23
Pipe flow in settlingFoam floating point exception jochemvandenbosch OpenFOAM Running, Solving & CFD 4 February 16, 2012 04:24
block-structured mesh for t-junction Robert@cfd ANSYS Meshing & Geometry 20 November 11, 2011 05:59


All times are GMT -4. The time now is 16:40.