Hello
In my application, I need an expression to have a function as a class variable, which is used in the calculations in the eval
function. This function will be set from the outside in my python code, which worked fine when I wrote the code for my Expression in Python.
However, I need to increase the speed of the evaluation and has tried to do the same with an expression in C++ code. However, I get error messages of the form:
error: no match for call to ‘(dolfin::Function) (const dolfin::Array<double>
, when running the simplified version of the code that is found below. What can I do to make it work?
from dolfin import *
my_expression ='''
class test : public Expression
{
public:
test() : Expression(1) {}
void eval(Array<double>& values, const Array<double>& x)
{
values[0] = f(x);
}
Function& f;
};
'''
mesh = UnitSquareMesh(8, 8)
V = FunctionSpace(mesh, "Lagrange", 1)
u=interpolate(Constant(1.0),V)
c=Expression(cppcode=my_expression)
c.f=u