Solution (source code)

= Solution

The <Navier-Stokes equation> for constant <mass density> $\rho$, <dynamic viscosity> $\mu$, and <body force> per unit mass $\mathbf f$ is
$$
\rho\left(\partial_t\mathbf u+\mathbf u\mathbin{\cdot}\nabla\mathbf u\right)
=\nabla\mathbin{\cdot}\boldsymbol\sigma+\rho\mathbf f,
\qquad
\nabla\mathbin{\cdot}\mathbf u=0,
$$
where the <Newtonian fluid stress tensor> is
$$
\boldsymbol\sigma=-p\mathbf I+2\mu\mathbf e,
\qquad
\mathbf e=\frac12\left(\nabla\mathbf u+(\nabla\mathbf u)^T\right).
$$
Taking the <inner product>[dot product] with $\mathbf u$ gives
$$
\rho\mathbf u\mathbin{\cdot}
\left(\partial_t\mathbf u+\mathbf u\mathbin{\cdot}\nabla\mathbf u\right)
=\nabla\mathbin{\cdot}(\boldsymbol\sigma\mathbf u)
-\boldsymbol\sigma:\nabla\mathbf u
+\rho\mathbf f\mathbin{\cdot}\mathbf u.
$$
Incompressibility implies
$$
\boldsymbol\sigma:\nabla\mathbf u=2\mu\mathbf e:\mathbf e,
$$
and converts the left side into a local time derivative plus the divergence of kinetic-energy flux. The <divergence theorem> therefore gives the <kinetic-energy balance for an incompressible Newtonian fluid>
$$
\boxed{
\begin{aligned}
\frac d{dt}\int_\Omega\frac12\rho|\mathbf u|^2\,dV
={}&-\int_{\partial\Omega}\frac12\rho|\mathbf u|^2
\mathbf u\mathbin{\cdot}\mathbf n\,dS\\
&+\int_{\partial\Omega}
\mathbf u\mathbin{\cdot}\boldsymbol\sigma\mathbf n\,dS
+\int_\Omega\rho\mathbf f\mathbin{\cdot}\mathbf u\,dV
-2\mu\int_\Omega\mathbf e:\mathbf e\,dV.
\end{aligned}}
$$
The four terms are respectively outward advective transport of kinetic energy, mechanical power supplied by surface traction, power supplied by the body force, and irreversible viscous dissipation into heat.