What is the best way to impose a "constant constraint" for a PDE? Specifically, I want to solve an eigenvalue problem $Au=\lambda u$ on the rectangle $(0,2\pi)\times(-\pi/2,\pi/2)$ with periodicity constraints horizontally and constant constraint on the lines $y=\pi/2, y=-\pi/2$. Here a constant constraint means that $u(x,\pi/2)$ is constant and the constant is not fixed. The same in $-\pi/2$ with possibly a different constant. I use a finite difference grid.
Is there any way to impose the constant constraint in the matrix $M$ which is the discretized of $A$?