So essentially my example is more complicated but I have an example - I take a function, make it a petsc4py vector, manipulate it a bit, and then I want to put it back into the function. But it seems that it isn’t trivial, anyone know how to do this easily?
from petsc4py import PETSc
from dolfin import *
size=128
p1 = Point(-1.0,-1.0)
p2 = Point(1.0,1.0)
mesh = RectangleMesh(p1,p2,size,size)
singlespace = FunctionSpace(mesh,'CG',1)
w=Function(singlespace)
w=w.vector()
lb=w.vec()
vec_size = lb.size
for i in range(0,vec_size):
lb.setValue(i,20.0)
w_new = Function(singlespace)
#how to put lb back into w_new- this doesn't work?
#ValueError: allocator<T>::allocate(size_t n) 'n' exceeds maximum supported size
w_new.vector().set_local(lb)