COMP: provision for non-existence of bessel functions

- These are not defined in the C++ standard for cmath, so allow for
  compilation without them. Will need to provide replacements in the
  future or rework.
This commit is contained in:
Mark Olesen
2019-03-15 11:19:15 +01:00
committed by Andrew Heather
parent 5f0714fe5b
commit cdb36e08e9
4 changed files with 84 additions and 64 deletions

View File

@ -1,2 +1,3 @@
EXE_INC = -I$(LIB_SRC)/ODE/lnInclude
EXE_INC = /* -DFoam_no_besselFunc */ -I$(LIB_SRC)/ODE/lnInclude
EXE_LIBS = -lODE

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation
@ -184,6 +184,8 @@ besselFunc(j0)
besselFunc(j1)
besselFunc(y0)
besselFunc(y1)
besselFunc2(jn)
besselFunc2(yn)
inline Scalar& setComponent(Scalar& s, const direction)

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2015 OpenFOAM Foundation
@ -85,31 +85,42 @@ inline Scalar atan2(const Scalar y, const Scalar x)
return ::atan2(y, x);
}
inline Scalar jn(const int n, const Scalar s)
{
return ::jn(n, s);
}
inline Scalar yn(const int n, const Scalar s)
{
return ::yn(n, s);
}
// Normal (double-precision) transcendental functions
#define transFunc(func) \
inline Scalar func(const Scalar s) \
{ \
return ::func(s); \
}
// Double-precision bessel functions
#define besselFunc(func) \
inline Scalar func(const Scalar s) \
{ \
return ::func(s); \
#define transFunc(func) \
inline Scalar func(const Scalar s) \
{ \
return ::func(s); \
}
// Normal (double-precision) bessel functions.
// May not be available on all systems
#ifdef Foam_no_besselFunc
// Not available
#define besselFunc(func) \
inline Scalar func(const Scalar s) \
{ \
std::cerr<< "No '" << #func << "' function\n"; \
return 0; \
}
#define besselFunc2(func) \
inline Scalar func(const int n, const Scalar s) \
{ \
std::cerr<< "No '" << #func << "' function\n"; \
return 0; \
}
#else
#define besselFunc(func) \
inline Scalar func(const Scalar s) \
{ \
return ::func(s); \
}
#define besselFunc2(func) \
inline Scalar func(const int n, const Scalar s) \
{ \
return ::func(n, s); \
}
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -127,6 +138,7 @@ inline Scalar func(const Scalar s) \
#undef ScalarRead
#undef transFunc
#undef besselFunc
#undef besselFunc2
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2015 OpenFOAM Foundation
@ -86,50 +86,54 @@ inline Scalar atan2(const Scalar y, const Scalar x)
}
// Single-precision transcendental functions (with 'f' appended to the name)
#define transFunc(func) \
inline Scalar func(const Scalar s) \
{ \
return ::func##f(s); \
#define transFunc(func) \
inline Scalar func(const Scalar s) \
{ \
return ::func##f(s); \
}
#ifdef darwin
// Single-precision bessel functions. (No float version for darwin).
#define besselFunc(func) \
inline Scalar func(const Scalar s) \
{ \
return ::func(s); \
}
inline Scalar jn(const int n, const Scalar s)
{
return Scalar(::jn(n, double(s)));
}
inline Scalar yn(const int n, const Scalar s)
{
return Scalar(::yn(n, double(s)));
}
// Single-precision bessel functions.
// May not be available on all systems
#ifdef Foam_no_besselFunc
// Not available
#define besselFunc(func) \
inline Scalar func(const Scalar s) \
{ \
std::cerr<< "No '" << #func << "' function\n"; \
return 0; \
}
#define besselFunc2(func) \
inline Scalar func(const int n, const Scalar s) \
{ \
std::cerr<< "No '" << #func << "' function\n"; \
return 0; \
}
#elif defined(darwin)
// No float version for darwin - use a cast.
#define besselFunc(func) \
inline Scalar func(const Scalar s) \
{ \
return ::func(s); \
}
#define besselFunc2(func) \
inline Scalar func(const int n, const Scalar s) \
{ \
return Scalar(::func(n, double(s))); \
}
#else
// Single-precision bessel functions (with 'f' appended to the name)
#define besselFunc(func) \
inline Scalar func(const Scalar s) \
{ \
return ::func##f(s); \
}
inline Scalar jn(const int n, const Scalar s)
{
return ::jnf(n, s);
}
inline Scalar yn(const int n, const Scalar s)
{
return ::ynf(n, s);
}
// With 'f' (float) appended to the name
#define besselFunc(func) \
inline Scalar func(const Scalar s) \
{ \
return ::func##f(s); \
}
#define besselFunc2(func) \
inline Scalar func(const int n, const Scalar s) \
{ \
return ::func##f(n, s); \
}
#endif
@ -149,6 +153,7 @@ inline Scalar yn(const int n, const Scalar s)
#undef ScalarRead
#undef transFunc
#undef besselFunc
#undef besselFunc2
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //