Equivalent of "dolfinx.cpp.la.create_vector" in latest Dolfinx release

I am trying to port to the last version of Dolfinx this notebook

I made some progress, not without effort.
I am now totally stuck on this line in the notebook

b = dolfinx.create_vector(V_alpha.dofmap.index_map, V_alpha.dofmap.index_map_bs)

So, V_alpha is a dolfinx.fem.function.FunctionSpace, and the methods dofmap.index_map anddofmap.index_map_bs yield a dolfinx.cpp.common.IndexMap and int objects respectively.

So the old function dolfinx.create_vector) gets two arguments of such types.

The dolfinx.fem.assemble.create_vector takes a L: FormMetaClass object, as per source.

They look totally different! I am not even sure I understand what the “old” function was doing, as I cannot find the sources.
Any hint please in the right direction? I am really eager to understand, thanks a lot

1 Like

You can use dolfinx.la.create_petsc_vector as done in dolfinx/test_newton.py at f39714c3cecc43f767169ea4381c8eeff39b5a7a · FEniCS/dolfinx · GitHub

Thanks a lot. This also helped me with dolfinx.fem.petsc.create_matrix and dolfinx.fem.assemble.create_matrix. I have hit another issue already but need also to study the example in detail. Thanks