C++ code for user-defined Expression
I have a problem in which I need to define an Expression using "complicated" C++ code. Before making the real code, I am trying to test it, with the following trivial code:
-------
from dolfin import *
code = '''
class SomeExpr : public Expression
{
public:
SomeExpr() : Expression(1) {}
void eval(Array<double>& values, const Data& data) const
{
values[0] = data.x[0];
}
};
'''
mesh = UnitInterval(10)
V = FunctionSpace(mesh, 'CG', 2)
u = TrialFunction(V)
v = TestFunction(V)
f = Expression(code)
a = f*inner(
L = Constant(0)*v*dx
-------
When running it, I get the error message:
Trying to integrate expression of rank 1 with free indices ().
On the other hand, if I just write
f = Expression('x[0]'),
which is what I try to do in the above code, no error messages are issued.
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- DOLFIN Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Øystein Sørensen
- Solved:
- Last query:
- Last reply: