Error 'Exp' object has no attribute '_cpp_object'

Hello,

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/init.py”, line 21, in lshift
self.write(u)
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: https://bitbucket.org/fenics-project/dolfin/src/946dbd3e268dc20c64778eb5b734941ca5c343e5/python/demo/undocumented/projection-interpolation/demo_projection-interpolation.py?at=master#demo_projection-interpolation.py-1,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).