This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Plotting Functions obtained by a scipy sparse solver

0 votes

Due to unavoidable reasons, I had to shift to scipy solver as the linear system is not derivable from a variational form. Now that I have computed a vector from scipy, I want to put it back to fenics function object for plotting.

I found this trick from an old code

ufun = Function(U)
ufun.vector()[:] = un
plot(ufun,title='control')

(un is a vector from scipy and initiated to the right hand size by a compatible vector from fenics) The interesting thing is that I have set U to ("DG", 0) type FunctionSpace and when I plot ufun, I get a flat plot, like as a 2D thing. I am not sure where this behaviour arises from. I have checked other codes that plot a function with the same FunctionSpace but are legitimate 3-D plots.

What am I doing wrong over here? Kindly let me know if this information is not sufficient.

EDIT: If I change my space from DG,0 to CG,1, the plot is accurate and in 3D. Although the shape of the plot seems to have no affect on what the solution is (what can be judged approximately), I am curious as to what is the right way to initiate plottable object with given values.

Cheers!
Aseem

asked Apr 28, 2016 by aseemdua FEniCS Novice (180 points)
edited May 3, 2016 by aseemdua
...