At least, there are two ways to use Bessel functions in an dolfin expression with Python: (a) by subclassing and then using scipy.special
Bessel functions, and (b) by using UFL functions (for instance bessel_j). Both methods lead to inefficient procedures if the functions has to be evaluated or projected in a fine mesh.
As alternative, I'm considering to use a JIT-compiled expressions involving the c++ functions cyl_bessel_*
. However, I couldn’t compile it successfully (in Fenics 1.3.0). The minimal example to reproduce the compiling error is:
from dolfin import *
code = '''
class MyFun : public Expression
{
public:
MyFun(): Expression() {};
void eval(Array<double>& values, const Array<double>& x) const {
values[0] = cyl_bessel_j(0,x[0]);
}};'''
f=Expression(code)
f(1.0)
Is it possible to call Bessel functions in a JIT-compiled code? In that case, is it correct the use of cyl_bessel_*
functions in the code?