Solution (source code)

= Solution

Write $\rho$ for the <mass density>. A material <volume> contains the same <fluid elements> at all times, so <conservation of mass> requires
$$
0=\frac d{dt}\int_{V(t)}\rho\,dV=\int_{V(t)}\left(\partial_t\rho+\nabla\cdot(\rho\mathbf u)\right)dV,
$$
by the <Reynolds transport theorem>. Since the initial material <volume> can be chosen arbitrarily, continuity of the integrand forces it to vanish pointwise. Thus the <continuity equation> is
$$
\boxed{\partial_t\rho+\nabla\cdot(\rho\mathbf u)=0,\qquad\frac{D\rho}{Dt}+\rho\nabla\cdot\mathbf u=0.}
$$
For positive <mass density>, the <incompressibility condition> $D\rho/Dt=0$ reduces this to $\nabla\cdot\mathbf u=0$. <Mass conservation> itself does not require <incompressible flow>.