Given a mixed function space, how to manipulate the “coefficient array views” that underly the components of a function? I would like to do something like
a,b = u.split()
a.vector().set_local(...) # only set the data that belongs to a
b.vector().get_local(...) # only get the data that belongs to b
But a.vector(), b.vector(), u.vector() all point to the same object:
from fenics import *
mesh = UnitIntervalMesh(10)
cell = mesh.ufl_cell()
el = MixedElement(
FiniteElement("P", cell, 2),
FiniteElement("P", cell, 1),
)
V = FunctionSpace(mesh, el)
u = Function(V)
a,b = u.split()
# these are the same vector:
assert id(a.vector()) == id(b.vector())
print(u.vector()) # <dolfin.cpp.la.PETScVector object at 0x7f6713c96f10>
print(a.vector()) # <dolfin.cpp.la.PETScVector object at 0x7f6713c96f10>
Is that the way to go or is there something more convenient? I would prefer to have a “view” on u[dm0.dofs()] instead of passing u and dm0.dofs() around.