I am facing a coding error in FEniCS when I run the heat equation code it’s fail with,
error = np.abs(u_e.vector().array() - u.vector().array())
AttributeError: 'dolfin.cpp.la.PETScVector' object has no attribute 'array’
I believe the idea is to calculate the difference between u and the exact solution for each time level and put them in array then we going to take the maxium value.(if not, correct me please!)
the Original code for computing the error is
u_e = interpolate(u_D, V)
error = np.abs(u_e.vector().array() - u.vector().array()).max()
print('t = %.2f: error = %.3g' % (t, error))
Where u_D is the boundary condition.
I am not sure how I can make it works so any advice from you would appreciated.
Thanks in advance
I suggest to employ the conversion from the
numpy
module, in case you desire a lighter notation:Or if you prefer to mantain the structure of the original variable
I prefer the first one since I am more confortable with a MatLab-style usage of vectors.