Poincaré inequality for a subspace of $H^1(\Omega)$

The following is the well known Poincaré inequality for $H_0^1(\Omega)$:

Suppose that $\Omega$ is an open set in $\mathbb{R}^n$ that is bounded. Then there is a constant $C$ such that $$ \int_\Omega u^2\ dx\leq C\int_\Omega|Du|^2\ dx\quad \textrm{ for all }\ \ \color{red}{u\in H_0^1(\Omega)}. $$

Here is my questions:

Can the condition $u\in H_0^1(\Omega)$ be relaxed so that the inequality is still true? More precisely, suppose $H$ is a subspace of $H^1(\Omega)$ such that for any $u\in H$, $u|_\Gamma=0$, where $\Gamma$ is a ([Added:]nonempty) closed proper subset of the boundary $\partial\Omega$ and the idenity is in the sense of trace. In other words, $u$ is only zero on a part of the boundary. Do we still have the Poincaré ineqaulity in $H$?


[Added:] This question is motivated by the following exercise

enter image description here enter image description here


I'm going to augment your statement with three assumptions in order to make the proof work. First, I'm going to assume that $\partial \Omega$ is Lipschitz. We're going to need that to invoke the usual trace theory in $H^1(\Omega)$. Second, I'm going to assume that $\Gamma \subseteq \partial \Omega$ is such that $\mathcal{H}^{n-1}(\Gamma) >0$, i.e. $\Gamma$ has nonzero Hausdorff measure on the boundary. Third, I'm going to assume that $\Omega$ is connected.

Now we modify one of the standard proofs of the Poincaré inequality, namely the proof by contradiction. Suppose, by way of contradiction, that the inequality fails. Then for each $n \ge 1$ we can find $u_n \in H^1$ such that $u_n =0$ on $\Gamma$ and $$ \Vert u_n \Vert_{L^2} \ge n \Vert D u_n \Vert_{L^2}. $$ Exploiting the homogeneity of the norm, we can assume WLOG that $\Vert u_n \Vert_{L^2} = 1$ for all $n$. Then $$ \Vert D u_n \Vert_{L^2} \le \frac{1}{n} \text{ and } \Vert u_n \Vert_{L^2} =1, $$ from which we deduce that $\{u_n\}_{n=1}^\infty$ is uniformly bounded in $H^1(\Omega)$. Using weak compactness and Rellich's theorem we can extract a subsequence $u_{n_k} \rightharpoonup u$ weakly in $H^1$ such that $u_{n_k} \to u$ strongly in $L^2$.

It's clear that the limit satisfies $$ \Vert D u \Vert_{L^2} =0, \Vert u \Vert_{L^2} =1, \text{ and } u = 0 \text{ on } \Gamma. $$ The last equality can be verified using convexity and its relation to weak convergence, for instance. The first and third conditions, together with the fact that $\Gamma$ has positive measure and $\Omega$ is connected, tell us that $u=0$, which contradicts the fact that $\Vert u \Vert_{L^2}=1$.

Thus there exists $C >0$ such that $$ \Vert u \Vert_{L^2} \le C \Vert D u \Vert_{L^2} \text{ for all } u \in H^1 \text{ s.t. } u\vert_{\Gamma}=0. $$

Note that we really need connectedness here, as otherwise we can take two disconnected open sets and look at $\Gamma$ only in the boundary of one of them. The inequality clearly fails in this case because it fails in the set that $\Gamma$ doesn't touch.

EDIT: Requested extra details.

Trace theory shows that there exists $C>0$ such that $$ \Vert u\Vert_{L^2(\partial \Omega)} \le C \Vert u \Vert_{H^1(\Omega)} $$ for all $u \in H^1(\Omega)$. Note that this uses the fact that the boundary is Lipschitz. In particular we can further bound $$ \Vert u\Vert_{L^2(\Gamma)} \le C \Vert u \Vert_{H^1(\Omega)}. $$ This bound shows that the set $\{u \in H^1(\Omega) : u=0 \text{ on }\Gamma\}$ is strongly closed in $H^1(\Omega)$. However, it's also clearly a convex set. We know from functional analysis (ultimately due to Hahn-Banach) that strongly closed convex sets are also weakly closed, so the fact that $\{u_{n_k}\}_k$ converges weakly to $u$ shows that $u$ belongs to this same set, i.e. $u=0$ on $\Gamma$. Note, though, that this is not the only way to prove this result.