Dear Ray,
As you said, when calling thess functions from <cmath> in Func1.h, the code is written as follow:
virtual doublereal eval(doublereal t) const {
return sin(m_c*t);
}
however, in some header files of openfoam, member funciton named sin(*) is also defined.
So when I add #include "zerodim.h" which Func.h in openfoam header files, it goes wrong, the error out put looks like as follow ::
In file included from /usr/include/cantera/zeroD/Wall.h:10:0,
from /usr/include/cantera/zerodim.h:6,
from /opt/openfoam5/applications/solvers/combustion/RNreactingFoam/CanteraFoam/lnInclude/outputFoam.H:47,
from RNreactingFoam.C:41:
/usr/include/cantera/numerics/Func1.h: In member function ‘virtual doublereal Cantera::Sin1::eval(doublereal) const’:
/usr/include/cantera/numerics/Func1.h:162:25: error: call of overloaded ‘sin(doublereal)’ is ambiguous
return sin(m_c*t);
^
In file included from /usr/include/features.h:367:0,
from /usr/include/x86_64-linux-gnu/c++/5/bits/os_defines.h:39,
from /usr/include/x86_64-linux-gnu/c++/5/bits/c++config.h:482,
from /usr/include/c++/5/cstdint:38,
from /opt/openfoam5/src/OpenFOAM/lnInclude/int32.H:39,
from /opt/openfoam5/src/OpenFOAM/lnInclude/int.H:38,
from /opt/openfoam5/src/OpenFOAM/lnInclude/label.H:39,
from /opt/openfoam5/src/OpenFOAM/lnInclude/labelList.H:47,
from /opt/openfoam5/src/OpenFOAM/lnInclude/UPstream.H:42,
from /opt/openfoam5/src/OpenFOAM/lnInclude/Pstream.H:42,
from /opt/openfoam5/src/OpenFOAM/lnInclude/parRun.H:35,
from /opt/openfoam5/src/finiteVolume/lnInclude/fvCFD.H:4,
from RNreactingFoam.C:32:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:65:1: note: candidate: double sin(double)
__MATHCALL_VEC (sin,, (_Mdouble_ __x));
^
In file included from /opt/openfoam5/src/OpenFOAM/lnInclude/TimeState.H:38:0,
from /opt/openfoam5/src/OpenFOAM/lnInclude/Time.H:47,
from /opt/openfoam5/src/finiteVolume/lnInclude/fvCFD.H:6,
from RNreactingFoam.C:32:
/opt/openfoam5/src/OpenFOAM/lnInclude/dimensionedScalar.H:80:19: note: candidate: Foam::dimensionedScalar Foam::sin(const dimensionedScalar&)
dimensionedScalar sin(const dimensionedScalar&);
^
In file included from /opt/openfoam5/src/OpenFOAM/lnInclude/scalar.H:40:0,
from /opt/openfoam5/src/OpenFOAM/lnInclude/IOstream.H:49,
from /opt/openfoam5/src/OpenFOAM/lnInclude/Ostream.H:39,
from /opt/openfoam5/src/OpenFOAM/lnInclude/OSstream.H:39,
from /opt/openfoam5/src/OpenFOAM/lnInclude/messageStream.H:216,
from /opt/openfoam5/src/OpenFOAM/lnInclude/error.H:51,
from /opt/openfoam5/src/OpenFOAM/lnInclude/UListI.H:26,
from /opt/openfoam5/src/OpenFOAM/lnInclude/UList.H:416,
from /opt/openfoam5/src/OpenFOAM/lnInclude/List.H:43,
from /opt/openfoam5/src/OpenFOAM/lnInclude/labelList.H:48,
from /opt/openfoam5/src/OpenFOAM/lnInclude/UPstream.H:42,
from /opt/openfoam5/src/OpenFOAM/lnInclude/Pstream.H:42,
from /opt/openfoam5/src/OpenFOAM/lnInclude/parRun.H:35,
from /opt/openfoam5/src/finiteVolume/lnInclude/fvCFD.H:4,
from RNreactingFoam.C:32:
/opt/openfoam5/src/OpenFOAM/lnInclude/Scalar.H:119:11: note: candidate: Foam::doubleScalar Foam::sin(Foam::doubleScalar)
transFunc(sin)
^
/opt/openfoam5/src/OpenFOAM/lnInclude/doubleScalar.H:84:15: note: in definition of macro ‘transFunc’
inline Scalar func(const Scalar s) \
^
To solve this problem , you should add namespace std:: in front of sin(*) for avoiding ambiguous overloaded ‘sin(*)’ between <cmath> and openfoam :
virtual doublereal eval(doublereal t) const {
return std::sin(m_c*t);
}
Best
Bruce
在 2018年2月13日星期二 UTC-5下午2:50:07,Ray Speth写道: