CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Floating Point Exception -after adding a filter (https://www.cfd-online.com/Forums/openfoam-programming-development/136461-floating-point-exception-after-adding-filter.html)

Thamali May 29, 2014 02:21

Floating Point Exception -after adding a filter
 
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??

ngj May 29, 2014 03:50

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

ngj May 29, 2014 03:51

P.S. You can also use
Code:

VSMALL
as call name.

Thamali May 29, 2014 05:17

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??:confused: (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??

ngj May 29, 2014 09:05

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

Thamali May 30, 2014 02:36

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??:mad:

Thanks in advance.
Regards,
Thamali

Thamali May 30, 2014 04:57

ok.I added the following just after the filter in the solver and it worked.

Code:

YO2.correctBoundaryConditions();
Thank you very much Neils.
Thamali

ngj May 30, 2014 05:04

You are welcome. Good that it worked.

Kind regards,

Niels


All times are GMT -4. The time now is 10:43.