My lecture notes contain the idea below, but I'm finding it difficult to understand one aspect.
Consider a finite volume $V$, bounded by a surface $S$ and outward pointing normal $\hat{\bf{n}}$.
A fluid occupies the space of which $V$ is a subset.
The fluid has velocity $u(\boldsymbol{r},t)$ and denisty $\rho(\boldsymbol{r},t)$.
By the principle of conservation of mass, we have that $$ \frac{d}{dt}\int_V \rho(\boldsymbol{r},t) \, dV=-\int_S \rho\boldsymbol{u}\cdot\hat{\boldsymbol{n}}\, dS $$
I understand that the left-hand side represents the rate of change of mass in $V$, and the right-hand side represents the rate at which mass flows into $V$ through $S$.
I don't understand why these two quantities are equal though.
Surely the rate of change of mass (i.e., the LHS) should be equal to the rate in minus the rate out? Rather than just the rate out.
Perhaps I have a fundamental misunderstanding of something here?