# Reconciling vector and scalar notation

I am trying to derive Galerkin type weak formulation for the Stokes equations. I'm having a bit of a problem reconciling the notation in the integration by parts. I know that the answer I'm looking for is: $\int_\Omega \Delta\mathbf{u}\cdot\mathbf{v}d\Omega = \int_\Gamma (\mathbf{n}\cdot\nabla\mathbf{u})\cdot\mathbf{v}d\Gamma - \int_\Omega \nabla\mathbf{u}:\nabla\mathbf{v}d\Omega$

When I integrate by parts myself I get: $\int_\Omega \nabla u\cdot\mathbf{v}d\Omega = \int_\Gamma u(\mathbf{v}\cdot\mathbf{n})d\Gamma - \int_\Omega u \nabla\cdot\mathbf{v}d\Omega\\\ \quad\quad\quad \Rightarrow \int_\Omega\Delta\mathbf{u}\cdot\mathbf{v}d\Omega = \int_\Omega (\nabla\cdot (\nabla\mathbf{u}))\cdot\mathbf{v}d\Omega = \int_\Gamma \nabla\mathbf{u} (\mathbf{v}\cdot\mathbf{n})d\Gamma - \int_\Omega\nabla\mathbf{u}\nabla\cdot\mathbf{v}d\Omega$

I assume I should be using a dot product for the vector/matrix multiplication, but even so I can't reconcile my answer with what I know the correct answer to be. For instance the line integral should be a scalar, but with my answer $\nabla\mathbf{u}$ is a matrix and $\mathbf{v}\cdot\mathbf{n}$ is a scalar so I fail to see how their product could be a scalar.

I did notice that the formula I used applies for scalar $u$'s. Is there another identity I should be using when $u$ is a vector?

The formula still applies for vectors - I find it helpful to use index notation. If

$$(\nabla u) = u_{,i}$$,

where $$i$$ implicitly refers to the $$i$$th entry of the gradient (i.e. $$\frac{\partial u}{\partial x_i}$$), and we assume Einstein notation (i.e. repeated indices sum over that index), then we can rewrite

$$\nabla \cdot \nabla {\bf u} = (u_j)_{,i,i} = \sum_i \frac{\partial}{\partial x_i}\frac{\partial}{\partial x_i}u_j$$.

For scalar integration by parts, we have

$$\int_K\nabla \cdot \nabla u v = \int_Ku_{,i,i} v = \int_{\partial K}u_{,i}n_i v - \int_K u_{,i}v_{,i} = \int_{\partial K} \nabla u\cdot n v - \int_K \nabla u \nabla v$$

An advantage of using index notation is that integration by parts of gradients of vectors and tensors is more straightforward, since it breaks everything down into the scalar case. Using this for a vector means you throw in an extra index for the vector:

$$\int_K \nabla \cdot \nabla {\bf u v} = \int (u_j)_{,i,i} v_j = \int_{\partial K} (u_j)_{,i}{n_i} v_j - \int_K (u_j)_{,i} (v_j)_{,i} = \int_{\partial K} (\nabla {\bf u}\cdot n) \cdot {\bf v} - \int_K \nabla {\bf u} : \nabla {\bf v}$$

where the last part is from the definition of tensor contraction.