Error 'Exp' object has no attribute '_cpp_object'


I am solving a coupled flow and temperature problem, where the viscosity ‘mu’ depends on the temperature, thus forming the coupling.

I want to be able to extract the viscosity as a .pvd file, but it’s proven tricky, as viscosity is defined as

mu = exp(-Gamma*T),

where T is temperature (part of the solution) and Gamma is a constant.

I want to do something like
File(“Viscosity,pvd”) << mu

but the error I get is
File “/usr/local/lib/python3.6/dist-packages/dolfin/io/”, line 21, in lshift
AttributeError: ‘Exp’ object has no attribute ‘_cpp_object’

I realise that I need to interpolate or do something else to mu before just exporting it, but I haven’t been able to find out exactly what that is.

Any help would be greatly appreciated!

You need to project mu into an appropriate function space. There are plenty of examples in:,36

Thank you! I was trying different versions of ‘interpolate’ but I see now that that’s for Expressions. ‘project’ worked like a charm ! (once I figured the appropriate function space).