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 EXE_LIBS = -lODE

View File

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

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd. \\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2015 OpenFOAM Foundation | Copyright (C) 2011-2015 OpenFOAM Foundation
@ -85,15 +85,6 @@ inline Scalar atan2(const Scalar y, const Scalar x)
return ::atan2(y, 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 // Normal (double-precision) transcendental functions
#define transFunc(func) \ #define transFunc(func) \
@ -102,14 +93,34 @@ inline Scalar func(const Scalar s) \
return ::func(s); \ return ::func(s); \
} }
// Normal (double-precision) bessel functions.
// Double-precision bessel functions // May not be available on all systems
#define besselFunc(func) \ #ifdef Foam_no_besselFunc
inline Scalar func(const Scalar s) \ // 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); \ 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 ScalarRead
#undef transFunc #undef transFunc
#undef besselFunc #undef besselFunc
#undef besselFunc2
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd. \\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2015 OpenFOAM Foundation | Copyright (C) 2011-2015 OpenFOAM Foundation
@ -93,43 +93,47 @@ inline Scalar func(const Scalar s) \
} }
#ifdef darwin // Single-precision bessel functions.
// Single-precision bessel functions. (No float version for darwin). // May not be available on all systems
#define besselFunc(func) \ #ifdef Foam_no_besselFunc
inline Scalar func(const Scalar s) \ // 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); \ return ::func(s); \
} }
#define besselFunc2(func) \
inline Scalar jn(const int n, const Scalar s) inline Scalar func(const int n, const Scalar s) \
{ { \
return Scalar(::jn(n, double(s))); return Scalar(::func(n, double(s))); \
} }
inline Scalar yn(const int n, const Scalar s)
{
return Scalar(::yn(n, double(s)));
}
#else #else
// With 'f' (float) appended to the name
// Single-precision bessel functions (with 'f' appended to the name) #define besselFunc(func) \
#define besselFunc(func) \ inline Scalar func(const Scalar s) \
inline Scalar func(const Scalar s) \ { \
{ \
return ::func##f(s); \ return ::func##f(s); \
} }
#define besselFunc2(func) \
inline Scalar jn(const int n, const Scalar s) inline Scalar func(const int n, const Scalar s) \
{ { \
return ::jnf(n, s); return ::func##f(n, s); \
} }
inline Scalar yn(const int n, const Scalar s)
{
return ::ynf(n, s);
}
#endif #endif
@ -149,6 +153,7 @@ inline Scalar yn(const int n, const Scalar s)
#undef ScalarRead #undef ScalarRead
#undef transFunc #undef transFunc
#undef besselFunc #undef besselFunc
#undef besselFunc2
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //