Consider the scalar PDE for $u$ with Dirichlet boundary conditions:
$\mathrm{div}(\mathcal{K}\nabla u) = f\; \forall x\; \in \Omega \subset R^2$,
$u = 0 \; \forall \; x\;\in \partial\Omega$
where $\mathcal{K} \in R^{2\times 2}$ is positive definite symmetric.
For a start I assume $\Omega$ is the unit square with a uniform rectangular mesh.
EDIT: I edited the question following Jed's comment to make it more specific.
If $\mathcal{K}$ is diagonal, it is simple enough. When it is not, I see that there it will require a computation of the "secondary gradient" (gradient along the face). How is that usually done ? And what I should do when I am near the boundary in this case ?