I have a Tensor, and I want to replace the values for vertex 2 like this:
vert_2[0,0]=0
vert_2[0,0]=1
vert_2[0,0]=2
vert_2[0,0]=3
is this a correct way to do it?
from dolfin import *
M=UnitSquareMesh(4,4)
TS=TensorFunctionSpace(M, "CG", 1)
v_to_d=TS.dofmap().vertex_to_dof_map(M)
d_to_v=TS.dofmap().dof_to_vertex_map(M)
F=Function(TS)
F=interpolate(Expression((('2*x[0]','x[1]'),('1.0','2.0'))),TS)
ve=F.vector().array()[d_to_v]
n=2
ve[n*4]=0
ve[n*4+1]=1
ve[n*4+2]=2
ve[n*4+3]=3
F.vector().set_local(ve[v_to_d])
With this, I assume that when one does:
ve=F.vector().array()[d_to_v]
he gets back an array that's ordered like this:
vertex 0 component 0,0
vertex 0 component 0,1
vertex 0 component 1,0
vertex 0 component 1,1
...
vertex n component 0,0
vertex n component 0,1
vertex n component 1,0
vertex n component 1,1
...
is it correct?
Thanks.