Hi guys,
Currently I am modelling heat flow in a 3D system and I want to output the heat flux vector into a .pvd file so it can be represented in Paraview with both a magnitude and direction to view the direction of heat flow as a function of time in 3D space. However, this heat flow, q, is defined as:
i = Index()
G = as_tensor(T.dx(i), (i))
k_space = FunctionSpace(mesh, 'CG',1)
k = project(120), kappa_space) #project k into tensor
q = - k*G
And if I try to write this information to a file using:
t = 0 # time in seconds
file_q = File('test.pvd')
file_q << (q,t)
I obtain the error below:
File "test.py", line 234, in <module>
file_Q << (q,t)
File "/usr/lib/petsc/lib/python3/dist-packages/dolfin/io/__init__.py", line 19, in __lshift__
self.write(u[0], u[1])
AttributeError: 'ComponentTensor' object has no attribute '_cpp_object'
So my question is, how can this tensor object be output into paraview in order for the heat flow to be visualised?
My simplified example code is shown below:
from dolfin import *
from ufl import as_tensor
mesh = UnitSquareMesh(10,10)
Space = FunctionSpace(mesh, 'P', 1)
T = project(Expression("x[0]+0.1*x[1]", degree=2), Space)
k_space = FunctionSpace(mesh, "DG", 0)
i = Index()
G = as_tensor(T.dx(i), (i))
k = project(120), k_space) #project k into tensor
q = - k*G
t = 0 # time in seconds
file_q = File('test.pvd')
file_q << (q,t)