Minimisation problem without integral form

Hi Netgen/NGSolve community, I encoutered some difficulties for solving a minimisation problem. There is a simpler form of my problem which has the same difficulty I’m facing to.
Just imagine, I have this equation : Δ φ = - ρ define on a ring with φ=1 on the interior circle and φ=0 on the exterior circle. I want to minimise the function J(ρ) = 1/2 |φ|². Then, for doing that, I need to calculate the gradient of J so I have this formula
(∇J | z) = (φ| ∂ φ[z] )
where (⋅ | ⋅ ) is the scalar product in H¹ and ∂ is the derivative with respect to ρ in the direction z.
I know how to calculate the bilinearform on the left hand of this equation but I have a problem with the linearform for the right hand. Indeed, for now, when I solved an equation in NGSolve, I was using “LinearForm().Assemble()” but I can’t do that with this equation because we cannot write it in an integral form. So is there a way to solve that kind of equation without writing the right side in an integral form in NGSolve?

I hope this message is enough clear for understanding my problem.

Thank you in advance for your answers.