Consider the steady heat equation $\nabla\cdot(k(x) \nabla u)=f$ in two dimensions on a periodic domain, say $[0,1]\times[0,1]$. My goal is to solve it numerically with standard central 5-points stencils. Due to the periodicity, the solutions are not unique and the corresponding linear system of equations, $AX=b$, is singular with rank-1 kernel (which contains constant grid functions). I know that the system is solvable since the data $f$ fulfills the solvability condition.
How should I find the solution of the system? In my previous work, I had constant $k$, so I could find the solution using discrete Fourier transform very efficiently, but it does not work here. I tried some iterative methods such as GMRES and Gauss-Seidel but they do not seem to work well.
Funny enough I just concluded a year-long project on a similar problem, for the unsteady case with the source term also specially varying. I used finite volume schemes in OpenFOAM to solve the problem, the frame-work in OpenFOAM is suitable for these sorts of computations, particularly if you want to play with the domain geometry as well. In any case id say give finite volume methods a try.