What is the safe way to initialize a dolfin.Vector
which is compatible with a given dolfin.FunctionSpace
?
More specifically, let Vh
be an instance of dolfin.FuctionSpace
.
Then if I want to create a new dolfin.Vector
u
which is compatible with Vh
I can simply do
u = dolfin.Function(Vh).vector()
However what if I want to initialize an already existing dolfin.Vector
v
to be compatible with Vh
?
Is the following code safe, or am I missing something?
v = dl.Vector()
v.init(Vh.mesh().mpi_comm(), Vh.dofmap().ownership_range() )
Thanks in advance.
Best regards,
Umberto