If $u\in H^1_0(\Omega)\cap C(\Omega)$ is it true that $u\in H^1_0(\{u>0\})$? Let $\Omega$ be a non-empty open subset of $\mathbb{R}^N$.
Let $H^1_0(\Omega)$ be the closure in the $H^1(\Omega)$ norm of the subspace $C^\infty_c(\Omega)$.
Let $u\in C(\Omega)\cap H^1_0(\Omega)$ such that $D:=\{x\in\Omega\ |\ u(x)>0\}\neq\emptyset$.
Then $D$ is a non-empty open subset of $\mathbb{R}^N$ and so it makes sense to talk about $H^1(D)$ and $H^1_0(D)$.

Is it true that $u|_D\in H^1_0(D)$? I.e.: does there exist a sequence $(\varphi_n)_{n\in\mathbb{N}}\subset C^\infty_c(D)$ such that $\|u|_D-\varphi_n\|_{H^1(D)}\to0,n\rightarrow\infty$? If not, what about if $\partial\Omega$ is smooth or maybe if we require further regularity on $u$?

 A: Yes, this is true in general. The idea is to consider the sequence of functions,
$$u_{\varepsilon} = (u-\varepsilon)_+ = \max\{u-\varepsilon,0\} \in H^1_0(\Omega)$$
and approximate these by functions in $C^{\infty}_c(D).$ If $\Omega$ is bounded, the support of each $\operatorname{supp} v_{\varepsilon}$ is compactly contained in $\Omega,$ so we can mollify each to obtain elements in $C^{\infty}_c(D).$ The general case will require an additional cutoff argument.
Let $\chi_{1/\varepsilon} \in C^{\infty}_c(B_{1+1/\varepsilon})$ be a cutoff such that $\chi_{1/\varepsilon} \equiv 1$ in $B_{1/\varepsilon}$ and $|\nabla\chi_{1/\varepsilon}| \leq 2$ everywhere. Put $v_{\varepsilon} = u_{\varepsilon}\chi_{1/\varepsilon},$ so one can check that $v_{\varepsilon} \rightarrow u$ in $H^1(D)$ as $\varepsilon \rightarrow 0.$ Now $K_{\varepsilon} = \operatorname{supp} v_{\varepsilon} \subset \Omega$ is compact, by continuity of each $v_{\varepsilon}$ and as $K_{\varepsilon} \cap \partial\Omega = \emptyset.$ Hence the mollification $v_{\varepsilon} \ast \eta_{\delta}$ lies in $C^{\infty}_c(\Omega)$ provided $\delta < \delta_0(\varepsilon).$ Taking $\delta = \delta_0(\varepsilon)/2$ and letting $\varepsilon \rightarrow 0$ gives a sequence of $C^{\infty}_c(D)$ functions converging to $u.$ Hence $u \in H^1_0(D).$
A: If the set $D$ is not too exotic then yes, we have $u\lvert_D \in H^1_0(D).$
Assuming that $\partial D$ is regular enough (says, of Lipschitz boundary), since $\partial D$ is contained in the set $u^{-1}(\{0\})$, we have $\text{Tr}(u)=0$, where $\text{Tr}:H^1(D)\to L^2(\partial D)$ is the trace operator.
The set $\partial D$ can be very irregular, however. This question on Mathoverflow discusses how bad can the zero set of a continuous (or even smooth) function can be. In this case I believe the space $H^1(D)$ itself would be pretty hard to describe.
