# How to solve a Poisson equation using the finite difference method when there is an object inside a domain?

I'm interested in solving an electrostatics problem in 2d case in some domain with a conductor placed inside the domain. From a mathematical point of view, I have to solve a Poisson equation with user-defined boundary conditions (let us consider a rectangular domain for simplicity) and a certain region in the domain with a constant user-defined potential (see the figure). I use a finite difference method to solve the Poisson equation numerically, which means I have to construct a grid in the domain and then attempt to find values of the potential at the nodes of the grid. Recall that in the finite difference method, we write an equation for the unknown potential at each node of the grid. Combined together, these equations form a system of linear equations. Solution of this system is an approximate solution to the Poisson equation in the domain.

I know how to construct and solve the system of linear equations for the unknow potential in a rectangular domain without any "inner objects". My question is: how should I approach the problem, when there are some "inner objects"?

My current idea is to record each node the object occupies (orange on the figure) and then cross out the corresponding equations from the linear system. I would also have to modify the equations corresponding to the nodes that happen to lie near the boundary of the object. Having done that, it should be possible solve the system. Then, using this solution and the user-defined value of the potential on the conductor, it is possible to restore the potential in the full domain.

Is it the only possible strategy or are there any simpler ways to do this? I'm interested in the approach, most reasonable from a programming point of view.

BTW: I use PETSc to solve linear system. Could it possibly have a certain feature for such case? 