CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   control reaches end of non-void function (http://www.cfd-online.com/Forums/openfoam-programming-development/119827-control-reaches-end-non-void-function.html)

sharonyue June 25, 2013 20:28

control reaches end of non-void function
 
Hi,

I want to modify the "muf" and "nuf"'s function in twoPhaseMixture.C. The function is this:
Code:

"muf",
            rho2_*fvc::interpolate(nuModel2_->nu())
            + (rho1_*fvc::interpolate(nuModel1_->nu())
              -
              rho2_*fvc::interpolate(nuModel2_->nu()))
            *(exp(128*alpha1f)-1)
            /exp(2)

When I wmake libso, it said:

Code:

cfd@cfd:~/myCase/mylib/incompressibleTwoPhaseMixture/incompressible$ wmake libso
Making dependency list for source file incompressibleTwoPhaseMixture/twoPhaseMixture.C
SOURCE=incompressibleTwoPhaseMixture/twoPhaseMixture.C ;  g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3  -DNoRepository -ftemplate-depth-100 -I.. -I/opt/openfoam220/src/finiteVolume/lnInclude -IlnInclude -I. -I/opt/openfoam220/src/OpenFOAM/lnInclude -I/opt/openfoam220/src/OSspecific/POSIX/lnInclude  -fPIC -c $SOURCE -o Make/linux64GccDPOpt/twoPhaseMixture.o
incompressibleTwoPhaseMixture/twoPhaseMixture.C: In member function ‘Foam::tmp<Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> > Foam::twoPhaseMixture::muf() const’:
incompressibleTwoPhaseMixture/twoPhaseMixture.C:160:19: error: call of overloaded ‘exp(int)’ is ambiguous
incompressibleTwoPhaseMixture/twoPhaseMixture.C:160:19: note: candidates are:
In file included from /opt/openfoam220/src/OpenFOAM/lnInclude/floatScalar.H:78:0,
                from /opt/openfoam220/src/OpenFOAM/lnInclude/scalar.H:39,
                from /opt/openfoam220/src/OpenFOAM/lnInclude/IOstream.H:49,
                from /opt/openfoam220/src/OpenFOAM/lnInclude/Ostream.H:39,
                from /opt/openfoam220/src/OpenFOAM/lnInclude/UILListIO.C:27,
                from /opt/openfoam220/src/OpenFOAM/lnInclude/UILList.C:92,
                from /opt/openfoam220/src/OpenFOAM/lnInclude/UILList.H:285,
                from /opt/openfoam220/src/OpenFOAM/lnInclude/ILList.H:39,
                from /opt/openfoam220/src/OpenFOAM/lnInclude/IDLList.H:35,
                from /opt/openfoam220/src/OpenFOAM/lnInclude/entry.H:45,
                from /opt/openfoam220/src/OpenFOAM/lnInclude/dictionary.H:53,
                from /opt/openfoam220/src/OpenFOAM/lnInclude/IOdictionary.H:42,
                from incompressibleTwoPhaseMixture/transportModel.H:39,
                from incompressibleTwoPhaseMixture/twoPhaseMixture.H:38,
                from incompressibleTwoPhaseMixture/twoPhaseMixture.C:26:
/opt/openfoam220/src/OpenFOAM/lnInclude/Scalar.H:260:1: note: Foam::floatScalar Foam::exp(Foam::floatScalar)
In file included from /opt/openfoam220/src/OpenFOAM/lnInclude/doubleScalar.H:78:0,
                from /opt/openfoam220/src/OpenFOAM/lnInclude/scalar.H:40,
                from /opt/openfoam220/src/OpenFOAM/lnInclude/IOstream.H:49,
                from /opt/openfoam220/src/OpenFOAM/lnInclude/Ostream.H:39,
                from /opt/openfoam220/src/OpenFOAM/lnInclude/UILListIO.C:27,
                from /opt/openfoam220/src/OpenFOAM/lnInclude/UILList.C:92,
                from /opt/openfoam220/src/OpenFOAM/lnInclude/UILList.H:285,
                from /opt/openfoam220/src/OpenFOAM/lnInclude/ILList.H:39,
                from /opt/openfoam220/src/OpenFOAM/lnInclude/IDLList.H:35,
                from /opt/openfoam220/src/OpenFOAM/lnInclude/entry.H:45,
                from /opt/openfoam220/src/OpenFOAM/lnInclude/dictionary.H:53,
                from /opt/openfoam220/src/OpenFOAM/lnInclude/IOdictionary.H:42,
                from incompressibleTwoPhaseMixture/transportModel.H:39,
                from incompressibleTwoPhaseMixture/twoPhaseMixture.H:38,
                from incompressibleTwoPhaseMixture/twoPhaseMixture.C:26:
/opt/openfoam220/src/OpenFOAM/lnInclude/Scalar.H:260:1: note: Foam::doubleScalar Foam::exp(Foam::doubleScalar)
In file included from incompressibleTwoPhaseMixture/viscosityModel.H:55:0,
                from incompressibleTwoPhaseMixture/twoPhaseMixture.H:39,
                from incompressibleTwoPhaseMixture/twoPhaseMixture.C:26:
/opt/openfoam220/src/OpenFOAM/lnInclude/dimensionedScalar.H:73:19: note: Foam::dimensionedScalar Foam::exp(const dimensionedScalar&)
incompressibleTwoPhaseMixture/twoPhaseMixture.C:163:1: warning: control reaches end of non-void function [-Wreturn-type]
make: *** [Make/linux64GccDPOpt/twoPhaseMixture.o] Error 1

cfd@cfd:~/myCase/mylib/incompressibleTwoPhaseMixture/incompressible$

If I delete the last exp(2), it succeed, does anyone know why? Thanks in advance.

BTW,if I want to over exp(128), how to make it?

marupio June 26, 2013 10:36

exp() is defined for all types, and you are giving it a literal constant. The compiler can't tell which exp() function to call. Try giving it more scope:

scalar::exp(2.0)

or

exp(scalar(2.0))

Share and enjoy!

sharonyue June 26, 2013 19:54

Quote:

Originally Posted by marupio (Post 436122)
exp() is defined for all types, and you are giving it a literal constant. The compiler can't tell which exp() function to call. Try giving it more scope:

scalar::exp(2.0)

or

exp(scalar(2.0))

Share and enjoy!

That's cool! exp(scalar(2.0)) works, thanks!!


All times are GMT -4. The time now is 05:03.