Problem with Expression since 2017.2

Hi everyone,

I just noticed that the “old” way of creating a full cpp string and using it to instantiate an Expression no longer works. In fact, I tracked down the chain of methods in JIT and found that for every string you insert to the Expression constructor, it just appends it to value[0]. The consequence of this is that previous codes which used a cpp object as
cpp_code = “”"
class Foo: public Expression
{…};
f = Expression(cpp_code, degree = N)

now results in the following code:
value[0] =
class MyExpr: public Expression
{…};;
which obviously doesn’t compile. I am currently working on a quick workaround, but if there is another solution, I would appreciate the information infinitely.

Best regards,
Nico

The way to use cpp expressions has changed since 2017.2.0.
See for instance: https://bitbucket.org/fenics-project/dolfin/src/master/python/demo/documented/tensor-weighted-poisson/demo_tensor-weighted-poisson.py for an example on how to use cpp_code in expressions.

1 Like

Cant believe that literally the only example I didnt read had the answer. Exactly what I was looking for, thank you very much!

Could you mark this as resolved?:slight_smile:

I tried when you answered but I cant find how to do it. Maybe the phone interface doesnt support it?? I will as soon as I get to a computer. Sorry!

Ok, cant find it. How do I do it??

You should now be able to do it, go to the answer that solved the problem above and mark as

1 Like

Yep, now it appeared. What happened? (thanks)

@jackhale added the extension.