I want to prove this equality used in out lecture notes:
Let $D=(0,r)^2 \subset \mathbb{R}^2, r\geqslant 0$. Then, for any $u \in H^1(D)$, there holds
$$\lVert u\rVert \leqslant \frac 1 r \left|\int_D u(x)dx\right| + \sqrt{2}r \lVert\nabla u\rVert$$
where $\lVert\cdot\rVert$ is the $L^2$-norm on $D$.
I have no clue how to prove this estimate on $D$. Can somebody help me?