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/)
-   -   Compilation error when using boost Bessel function in OpenFOAM (https://www.cfd-online.com/Forums/openfoam-programming-development/249010-compilation-error-when-using-boost-bessel-function-openfoam.html)

streamLiner April 14, 2023 10:54

Compilation error when using boost Bessel function in OpenFOAM
 
Hi,

I am trying to make a custom solver based on pimpleFoam, which includes a Bessel function in an equation which I added in the PIMPLE-loop. In the beginning of the solver, I have an include-statement which I believe I need to use the Bessel-function from boost:

Code:

#include <boost/math/special_functions/bessel.hpp>
However, I get a compilation error when I run "wmake" (here quoting selected parts of a long error message):

Code:

usr/include/boost/math/special_functions/detail/bernoulli_details.hpp: In function ‘std::size_t boost::math::detail::find_bernoulli_overflow_limit(const false_type&)’:
/usr/include/boost/math/special_functions/detail/bernoulli_details.hpp:104:63: error: call of overloaded ‘sqrt(double)’ is ambiguous
  104 |    double result = boost::math::tools::toms748_solve(fun, sqrt(double(t)), double(t), tol, max_iter).first / 2;

Code:

/opt/openfoam10/src/OpenFOAM/lnInclude/dimensionedScalar.H:65:19: note: candidate: ‘Foam::dimensionedScalar Foam::sqrt(const dimensionedScalar&)’
  65 | dimensionedScalar sqrt(const dimensionedScalar&);
      |                  ^~~~
make: *** [/opt/openfoam10/wmake/rules/General/transform:26: Make/linux64GccDPInt32Opt/cEHDfoam.o] Error 1

The solver compiles (and simulates) fine if I exclude the bessel-related "#include" statement and replace the bessel function with something else. Thus the error seems to be caused by the include-statement itself.

What could I do to solve this problem? If I include other boost library functions, for example "elliptic integral" from the "special functions" directory, then it compiles without error. So the error seems localized to bessel. And it seems the compiler is complaining about "sqrt( )" somehow (which I didn't type in or add anywhere, must come from boost).

Very strange! I'm thankful for any tips/suggestions you may have.


All times are GMT -4. The time now is 18:48.