Why is $\delta\mathbf{u}\cdot \mathrm{div}(\mathbf{\sigma}) = -\mathrm{grad}(\delta\mathbf{u}) \mathbf{:} \mathbf{\sigma}$? Context is from this deal.ii tutorial. Screenshot of the relevant part is below.

I don't get the transformation from $\delta\mathbf{u}\cdot \mathrm{div}(\mathbf{\sigma})$ to $-\mathrm{grad}(\delta\mathbf{u}) \mathbf{:} \mathbf{\sigma}$, that seems to be happening as a part of the first line. $\mathbf{u}$ is the displacement field (vector field), $\sigma$ is the stress tensor (tensor field) and $\delta$ is the variational operator. When I try to break the problem down in index notation, I get
$$\delta\mathbf{u}\cdot \mathrm{div}(\mathbf{\sigma}) = \delta u_i\cdot\frac{\partial\sigma_{ij}}{\partial x_j}$$
and
$$-\mathrm{grad}(\delta\mathbf{u}) \mathbf{:} \mathbf{\sigma} = -\delta\left(\frac{\partial u_i}{\partial x_j}\right)\cdot \sigma_{ij}.$$
Which means that $$\delta u_i\cdot\frac{\partial\sigma_{ij}}{\partial x_j} = -\delta\left(\frac{\partial u_i}{\partial x_j}\right)\cdot \sigma_{ij}.$$
Can these two terms possibly be the same? There's a minus sign on one of them and not on the other, and in the left side the derivation is taken of $\sigma$ while on the right side it's taken of $u$. I can't see any transformations that would turn one into the other, and I also can't find a mistake in my chain of reasoning, what am I missing here?
 A: This is pretty much just a Green Theorem of the form
$$
\int_\Omega g_i \frac{\partial f_{ij}}{\partial x_j} dV= - \int_\Omega \frac{\partial g_i}{\partial x_j} f_{ij} dV+ \int_{\partial \Omega} g_i f_{ij} n_j dS
$$
where $n$ is the normal to the surface, applied on the term $\int_\Omega \delta\mathbf{u}\cdot \mathrm{div}(\mathbf{\sigma}) d v $.
The term $\sigma_{ij}n_j$ is then written out as $t$ which should be a force prescribed on the boundary.
A: The author is doing two things at once: integration by parts and invoking the divergence theorem. In coordinate form you have $\delta u \cdot \operatorname{div}\sigma$ being
$\delta u_i\, \partial\sigma_{ij}/\partial x_j$, and
\begin{align}
\delta u_i\, \frac{\partial\sigma_{ij}}{\partial x_j} &=
\frac{\partial}{\partial x_j}\left(\delta u_i\,\sigma_{ij}\right) - 
\frac{\partial \delta u_i}{\partial x_j}\sigma_{ij}.
\end{align}
The second term on the right appears within the integral over $\Omega$ and the first, after using the divergence theorem, in the integral over $\partial\Omega$.
