Gluing two functions from Sobolev spaces.

I am studying Galdi's Introduction to the mathematical theory of Navier-Stokes equations and somewhere in a proof, he "glued" two functions in $$W^{1, 2}(\Omega_1)$$ and $$W^{1, 2}(\Omega_2)$$ to obtain a function in $$W^{1, 2}(\Omega_1 \cup \Omega_2)$$ and I don't really understand why it is true. Let me explain it in more details.

Let $$B_1$$ and $$B_2$$ be the open balls in $$\mathbb R^n$$ of radius $$1$$ and $$2$$ respectively. Let $$\Omega_1 = B_1$$ and $$\Omega_2 = B_2 \cap (\overline{B_1}^c)$$. We consider $$\boldsymbol{u}_1 \in W^{1, 2}(\Omega_1)$$ and $$\boldsymbol{u}_2 \in W^{1, 2}(\Omega_2)$$ (where $$\boldsymbol{u}= (u^1, \ldots, u^m)$$ and $$\boldsymbol{u}_i \in W^{1, 2}(\Omega_i)$$ actually means $$\boldsymbol{u}_i \in [W^{1, 2}(\Omega_i)]^m$$) verifying $$\nabla \cdot \boldsymbol{u}_i = 0 ~~\text{in }\Omega_i \quad \text{and} \quad \boldsymbol{u}_1 = \boldsymbol{u}_2 ~~~\text{at }\partial \Omega_1,$$ in the trace sens. My question is, if we consider $$\boldsymbol{u}: x \in \overline{\Omega_1} \cup \Omega_2 = \Omega \mapsto \begin{cases} \boldsymbol{u}_1(x) & \text{if } x \in \Omega_1\\ \boldsymbol{u}_2(x) & \text{if } x \in \Omega_2\\ \end{cases},$$ is that true that $$\boldsymbol{u} \in W^{1, 2}(\overline{\Omega_1} \cup \Omega_2)$$ and that $$\nabla \cdot \boldsymbol{u} = 0$$ in $$\overline{\Omega_1} \cup \Omega_2$$ ? I don't really see why this should be true because if we take $$\boldsymbol{\psi} \in C^\infty_0(\overline{\Omega_1} \cup \Omega_2)$$, we should be able to show that
$$\int_{\overline{\Omega_1} \cup \Omega_2} \boldsymbol{u} \cdot \partial_i\boldsymbol{\psi} = - \int_{\overline{\Omega_1} \cup \Omega_2} \partial_i\boldsymbol{u} \cdot \boldsymbol{\psi}$$ but $$\int_{\overline{\Omega_1} \cup \Omega_2} \boldsymbol{u} \cdot \partial_i\boldsymbol{\psi} = \int_{\Omega_1} \boldsymbol{u} \cdot \partial_i\boldsymbol{\psi} + \int_{\Omega_2} \boldsymbol{u} \cdot \partial_i\boldsymbol{\psi} \stackrel{?}{=}-\int_{\Omega_1} \partial_i\boldsymbol{u} \cdot \boldsymbol{\psi} - \int_{\Omega_2} \partial_i\boldsymbol{u} \cdot \boldsymbol{\psi} = -\int_{\overline{\Omega_1} \cup \Omega_2} \partial_i\boldsymbol{u} \cdot \boldsymbol{\psi}$$ where I don't see why the second equality could be satisfied as $$\boldsymbol{\psi}|_{\Omega_i} \notin C^\infty_0(\Omega_i)$$. Could someone help me with this ?

• You'll have to multiply $\psi$ by a sequence of suitable cutoff functions to get a function supported in $\Omega_1\cup\Omega_2$ and justify that everything converges to the right thing if you take the limit. May 26 at 18:01
• So the result is true ? May 27 at 6:13
• Yes, I think so. Alternatively you can also use the divergence theorem and check that the boundary terms coming from $\Omega_1$ and $\Omega_2$ cancel each other (because the normal vector fields point in opposite directions). But again you would need an approximation argument to justify the divergence theorem for Sobolev functions. May 27 at 6:46
• @MaoWao If I understand correctly, the first approach (with cutting off the boundary) doesn't take the trace assumption into account, so it couldn't work. May 28 at 7:32
• @Falcon, gluing would be much easier if we had $\Omega_2 = B_2$ (that is, if $\Omega_1$ and $\Omega_2$ overlapped). The statement you gave is also true, but it relies on the right understanding of trace. May 28 at 7:34

The identity follows from the divergence theorem on $$\Omega_i$$: $$\int_{\Omega_i} \text{div}(u) \psi \, dx = - \int_{\Omega_i} u\cdot \nabla \psi\, dx + \int_{\partial\Omega_i} u\cdot n\psi\, dx,$$ where $$n$$ is the outer normal to $$\Omega_i$$.
Now, since the support of $$\psi$$ is on the union, the last integral is really on $$\partial\Omega_1\cap \partial\Omega_2$$, but with opposite orientations depending on which domain we're on. Since both functions agree on the boundary, this means that the boundary integrals will cancel each other out and give your identity.