Consider a Poisson equation u’’ = f with its assembled load vector (the right-hand side) L:

domain = mesh.create_unit_square(MPI.COMM_WORLD, 10, 10)
Vh = fem.FunctionSpace(domain, ("CG", 1))
v = ufl.TestFunction(Vh)
u = ufl.TrialFunction(Vh)
a = ufl.dot(ufl.grad(u), ufl.grad(v)) * v
L = fem.assemble_vector(fem.form(f * v * ufl.dx))

This vector L has N lines, where N is the number of nodes in the mesh. I want to implement DEIM using dolfinx. I won’t go into details of DEIM, but it requires computing only some lines of the load vector L (to speed up the computation) rather than assembling for all N nodes. Is there any way I can assemble only for some nodes?

Of course, I can construct L and then select some of its rows, but it kills the performance gain the DEIM method is about. I really appreciate your help/ideas.

Thank you! That was so helpful to understand the dolfinx possibilities. I tried to build upon this one that you suggested but I have " incompatible constructor arguments" error for fem.form. Do you have any idea?

Great! Thanks a lot. It is working well now. My only surprise is that the assembling even got slower using this marker (and dz(3) rather than dz), and I am wondering why.

I take back what I said, I was not precise. The issue is not about assembling time, I used it inside a nonlinear solver and the timing I have is not directly related to this dz measure, but lots of other stuff in convergence for example. Anyway, thank you, my code is at least working

Hi, I have a following question here: how to define L and solver in this case? I followed your steps and it reports the error by petsc-solver: object is in wrong state/Matrix is missing diagonal entry

Thanks. I’ll look through it. I would like to ask one more question if it’s relevant: I now have a 3D beam mesh and I want to give it a torsion. What may be the most efficient way to do this in fenicsx?

Much Thanks. I think it will also help other people. C++ is for now too hard for me to understand. But firslty I will try to implement the old code from Fenics.