# OpenFOAM floating point Error

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

 June 13, 2016, 06:57 #2 Member   Join Date: Jul 2011 Posts: 54 Rep Power: 11 Look for any division by "0" in your whole code. What is the value of your Prandtl number Pr, for example? Code: `Pout<< "Pr = " << Pr << endl;` Put "Info<<" or "Pout<<" statements at the positions of your code, where it aborts. Really look for any possible division by zero. Hard to give an answer without knowing what's in the code.

 June 14, 2016, 10:26 #3 Senior Member   Hassan Kassem Join Date: May 2010 Location: Germany Posts: 239 Rep Power: 14 Generally speaking, in any division operation add a VSMALL to the denominator. It is a good practice. Code: ```volScalarField Nu ( "Nu", 0.3+(0.62*pow(Re,0.5)*pow(Pr,0.33)*pow(1+pow(Re/282000,0.625),0.8) /pow(1+pow(0.4/(Pr+VSMALL),0.66),0.25)) );``` Try this to check if Pr is causing this problem or not. Bw, Hassan

 June 15, 2016, 22:45 #4 Member   Upuli Join Date: Feb 2016 Posts: 68 Rep Power: 7 Dear all Thank you for the answers. I added small value to the denominator . But it still give the error in the same way volScalarField Nu ( "Nu", 0.3+(0.62*pow(Re,0.5)*pow(Pr,0.33)*pow(1+pow(Re/282000,0.625),0.8)/pow(1+pow(0.4/(Pr+Prsmall),0.66),0.25)) );

 June 16, 2016, 07:52 #5 Senior Member   Hassan Kassem Join Date: May 2010 Location: Germany Posts: 239 Rep Power: 14 Hello, I created a small program to test your formula. It works fine with VSMALL and doesn't work without it as expected. Also, I noticed that, this formula is really sensitive to Pr value and independent of Re value. Here is the code you can use it to try different values for Pr and Re. Regarding the error, it could be due to something else. Bet wishes, Hassan Code: ```\*---------------------------------------------------------------------------*/ #include "fvCFD.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // int main(int argc, char *argv[]) { label size = 10; scalarField Pr(size, 0.0); scalarField Re(size, 0.0); scalarField Nu(size, 0.0); Nu = 0.3+(0.62*Foam::pow(Re,0.5)*Foam::pow(Pr,0.33) * Foam::pow(1.0+Foam::pow(Re/282000,0.625),0.8) / Foam::pow(1+Foam::pow(0.4/(Pr+VSMALL),0.66),0.25)); Info << Pr << endl; Info << Nu << endl; Info<< "End\n" << endl; return 0; } // ************************************************************************* //```

 June 20, 2016, 03:19 #6 Member   Upuli Join Date: Feb 2016 Posts: 68 Rep Power: 7 Dear All I was able to solve the error in Nu.But the following error appears #0 Foam::error:rintStack(Foam::Ostream&) at ~/OpenFOAM/OpenFOAM-2.3.0/src/OSspecific/POSIX/printStack.C:221 #1 Foam::sigFpe::sigHandler(int) at ~/OpenFOAM/OpenFOAM-2.3.0/src/OSspecific/POSIX/signals/sigFpe.C:108 #2 in "/lib/x86_64-linux-gnu/libc.so.6" #3 double Foam::sumProd(Foam::UList const&, Foam::UList const&) at ~/OpenFOAM/OpenFOAM-2.3.0/src/OpenFOAM/fields/Fields/scalarField/scalarField.C:98 (discriminator 2) #4 double Foam::gSumProd(Foam::UList const&, Foam::UList const&, int) at ~/OpenFOAM/OpenFOAM-2.3.0/src/OpenFOAM/lnInclude/FieldFunctions.C:560 #5 Foam::PCG::solve(Foam::Field&, Foam::Field const&, unsigned char) const at ~/OpenFOAM/OpenFOAM-2.3.0/src/OpenFOAM/matrices/lduMatrix/solvers/PCG/PCG.C:138 (discriminator 1) #6 Foam::fvMatrix::solveSegregated(Foam::dict ionary const&) at ~/OpenFOAM/OpenFOAM-2.3.0/src/finiteVolume/fvMatrices/fvScalarMatrix/fvScalarMatrix.C:169 (discriminator 3) #7 Foam::fvMatrix::solve(Foam::dictionary const&) at ~/OpenFOAM/OpenFOAM-2.3.0/src/finiteVolume/lnInclude/fvMatrixSolve.C:82 #8 at ~/mysolver/myreactingFoam/pEqn.H:76 (discriminator 1) #9 __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6" #10 at ??:? Floating point exception (core dumped) My pEqn is volScalarField rAU(1.0/UEqn.A()); surfaceScalarField rhorAUf("rhorAUf", fvc::interpolate(rhog*rAU)); volVectorField HbyA("HbyA", U); HbyA = rAU*UEqn.H(); if (pimple.transonic()) { surfaceScalarField phid ( "phid", fvc::interpolate(psi) *( (fvc::interpolate(rhog*HbyA) & mesh.Sf()) + rhorAUf*fvc::ddtCorr(rhog, U, phi) )/fvc::interpolate(rhog) ); surfaceScalarField phie ( "phie", fvc::interpolate(solidporosity)*phid ); while (pimple.correctNonOrthogonal()) { fvScalarMatrix pEqn ( fvm::ddt(solidporosity*psi, p) + fvm::div(phie, p) - fvm::laplacian(solidporosity*rhog*rAU, p) == gasgeneration ); pEqn.solve(mesh.solver(p.select(pimple.finalInnerI ter()))); if (pimple.finalNonOrthogonalIter()) { phi == pEqn.flux(); } } } else { surfaceScalarField phiHbyA ( "phiHbyA", ( (fvc::interpolate(rhog*HbyA) & mesh.Sf()) + rhorAUf*fvc::ddtCorr(rhog, U, phi) ) ); surfaceScalarField phiHbyB ( "phiHbyB", fvc::interpolate(solidporosity)*phiHbyA ); while (pimple.correctNonOrthogonal()) { fvScalarMatrix pEqn ( fvm::ddt(solidporosity*psi, p) + fvc::div(phiHbyB) - fvm::laplacian(solidporosity*rhog*rAU, p) == gasgeneration ); pEqn.solve(mesh.solver(p.select(pimple.finalInnerI ter()))); if (pimple.finalNonOrthogonalIter()) { phi = phiHbyB + pEqn.flux(); } } } #include "rhoEqn.H" #include "compressibleContinuityErrs.H" U = HbyA - rAU*fvc::grad(p); U.correctBoundaryConditions(); K = 0.5*magSqr(U);