Zero-valued right-hand side of Linear Problem

Dear FEniCS community,
I implemented a Poisson equation in dolfinx, and I tried to set the right-hand side of the equation to zero, like this:

a = u.dx(0)*v.dx(0)*dx
L = ScalarType(0.)*v*dx
problem = fem.petsc.LinearProblem(a, L, bcs=[])

In that case, I get the error

ufl.log.UFLException: This integral is missing an integration domain.

When I replace ScalarType(0.) with some tiny finite value though, like ScalarType(1e-100), the solution works fine.
Is there a way to make the case with a zero-valued right-hand side work?

I would do

a = u.dx(0)*v.dx(0)*dx
L = fem.Constant(mesh, ScalarType(0.))*v*dx
problem = fem.petsc.LinearProblem(a, L, bcs=[])
1 Like

Thanks so much! That solves the problem.

Good morning,

I have a question regarding this aspect: how can I set to zero the right-hand side of the algebraic system Au = b?

Thanks for the help,


Create an empty vector/dolfinx.fem.Function and pass it to the rhs, i.e.

b_func = dolfinx.fem.Function(V)
b_func.x.array[:] = 0
b = b_func.vector
1 Like