Problems with paraview

Hi everyone!
I have some problems to plot in paraview.

sensi_g_algorimt=File("Plots/sensi_s.pvd")
sensi_g_algorimt_h=XDMFFile('Plots/sensig_h.xdmf')
sensi_g_algorimt_h.parameters["flush_output"]=True

ug=Function(V)
pg=Function(Q)
vec_auxa=[]
vec_auxp=[]
for i in range(nsnap-1):
    vec_auxa[:]=uad_steps[:,i]
    vec_auxp[:]=pad_steps[:,i]
    ug.vector()[:]=vec_auxa[:]
    pg.vector()[:]=vec_auxp[:]
    theo_sensi=dot(sigma(ug,-pg),nh)
    theo_sensi_p=project(theo_sensi,V)
    sensi_g_algorimt << theo_sensi_p
    sensi_g_algorimt_h.write(theo_sensi_p, i)

uad_steps and pad_steps are matrices where I save a solution of a time-dependent equation and nh is the normal vector arround the object.


The problem is, when I play the animation, I obtain

in each steps, this changes and loses the colour palette.

I dont know if the problem is in paraview or the way like I save the solutions.
Does anyone have any ideas?
Thanks!

The projection is creating a new Function with a new name each step. You could either do:

theo_sensi_p=project(theo_sensi,V)
theo_sensi_p.rename("theo", "theo")

or assign a function beforehand, e.g.

theo_sensi_p = Function(V)
....
for i in range(nsnap-1):
    ...
    project(theo_sensi,V, function=theo_sensi_p)
    ...
1 Like

Thnak you so much, @nate ! This works!