Why Density Matters in a Flow
A velocity field describes how fluid moves, but it does not by itself describe how much mass moves. If density varies from place to place, equal volumes of fluid can carry different amounts of mass. The appropriate field for measuring mass transport combines density with velocity.
In a steady flow, the density and velocity at each fixed point do not change with time. That does not mean they are spatially constant. Mass conservation asks whether the mass flowing out of a region balances the mass flowing in. A signed flux calculation answers that question: outward flow counts positively, and inward flow counts negatively.
The Steady Mass-Balance Law
Let \(V\) be a bounded region with a piecewise smooth closed boundary \(\partial V\), oriented by the outward unit normal \(\mathbf{n}\). Assume that \(\rho\) and \(\mathbf{v}\) are sufficiently smooth on a neighbourhood of \(V\), with \(\rho\geq 0\). The total outward mass-flow rate across the boundary is the flux integral of \(\rho\mathbf{v}\).
A positive result means more mass leaves \(V\) than enters it. A negative result means net mass enters. In a steady flow with no mass sources or sinks inside \(V\), the mass contained in a fixed control volume does not change, so the net outward mass-flow rate must be zero.
The divergence theorem applies here because the mass-flux field is continuously differentiable and the boundary is piecewise smooth. The statement that the volume integral vanishes for every control volume is important: a zero integral over just one particular region would not, by itself, show that the integrand is zero everywhere.
Why the Local Equation Follows
The physical balance first gives a statement about the boundary of a region. The divergence theorem converts that boundary flux into an integral over the region itself. To get a pointwise equation, consider any small control volume around a point. If the continuous function \(\nabla\cdot(\rho\mathbf{v})\) were positive at that point, it would remain positive in some sufficiently small surrounding region. Its integral over that region would then be positive, contradicting the zero balance. A negative value leads to the same contradiction with signs reversed.
In a steady, source-free flow, the signed outward mass flux across its closed boundary is zero.
The boundary flux equals the volume integral of \(\nabla\cdot(\rho\mathbf{v})\).
If every sufficiently small region has zero integral and the divergence is continuous, the divergence must vanish pointwise.
This argument also explains why the pointwise law is a local version of mass conservation, not an unrelated extra condition. The integral and differential forms express the same balance under the stated smoothness assumptions.
Expanding the Divergence
The product rule for divergence makes explicit how spatial changes in density and velocity both affect mass transport. For differentiable scalar field \(\rho\) and vector field \(\mathbf{v}\),
Thus steady, source-free mass conservation can also be written as
The first term accounts for density changing in the direction of motion. The second accounts for the velocity field spreading out or converging, weighted by the local density. Neither term must vanish separately; it is their sum that must be zero.
Worked Example: A Variable Density with Balanced Flow
Let a box have \(0\leq x\leq 2\,\mathrm{m}\) and \(0\leq y,z\leq 1\,\mathrm{m}\). Set \(\rho=(1+x/(1\,\mathrm{m}))\,\mathrm{kg/m^3}\) and \(\mathbf{v}=\big((1\,\mathrm{m/s})/(1+x/(1\,\mathrm{m})),0,0\big)\). Calculate the mass-flux field and the net boundary flux.
Multiplying density by velocity gives \(\rho\mathbf{v}=(1\,\mathrm{kg/(m^2s)},0,0)\), since the factors \(1+x/(1\,\mathrm{m})\) cancel. Therefore \(\nabla\cdot(\rho\mathbf{v})=0\).
Only the faces perpendicular to the \(x\)-axis contribute. On the right face, \(x=2\,\mathrm{m}\), the outward normal is \((1,0,0)\), and the face area is \(1\,\mathrm{m^2}\). Its outward mass-flow rate is \((1\,\mathrm{kg/(m^2s)})(1\,\mathrm{m^2})=1\,\mathrm{kg/s}\). On the left face, \(x=0\), the outward normal is \((-1,0,0)\), so its outward flux is \(-(1\,\mathrm{kg/(m^2s)})(1\,\mathrm{m^2})=-1\,\mathrm{kg/s}\). The other four faces have zero flux because the mass-flux field has no \(y\)- or \(z\)-component.
The net boundary flux is \(1-1=0\,\mathrm{kg/s}\), agreeing with the volume calculation \(\iiint_V 0\,dV=0\,\mathrm{kg/s}\). Substitution into the local equation also checks the result: the mass-flux field is constant, so its divergence is indeed zero.
Checking Inflow and Outflow on a Box
For a box, the outward normal on each face points away from the interior. A face with negative flux is an inflow face; a face with positive flux is an outflow face. The total is a signed sum, so inflow and outflow can cancel even when there is substantial flow through individual faces.
Worked Example: Comparing Inflow and Outflow
Use the box \(0\leq x\leq 2\,\mathrm{m}\), \(0\leq y,z\leq 1\,\mathrm{m}\), with \(\rho=(1+x/(1\,\mathrm{m}))\,\mathrm{kg/m^3}\) and \(\mathbf{v}=(1\,\mathrm{m/s},0,0)\). Find the flux through the two faces that contribute, and compare it with the volume integral.
The mass-flux field is \(\rho\mathbf{v}=((1+x/(1\,\mathrm{m}))\,\mathrm{kg/(m^2s)},0,0)\). Its divergence is \(\nabla\cdot(\rho\mathbf{v})=1\,\mathrm{kg/(m^3s)}\), because differentiating \(x/(1\,\mathrm{m})\) with respect to \(x\) gives \(1/(1\,\mathrm{m})\), and the velocity factor is \(1\,\mathrm{m/s}\).
At the right face \(x=2\,\mathrm{m}\), the density is \(3\,\mathrm{kg/m^3}\), so the outward flux is \((3\,\mathrm{kg/m^3})(1\,\mathrm{m/s})(1\,\mathrm{m^2})=3\,\mathrm{kg/s}\). At the left face \(x=0\), the density is \(1\,\mathrm{kg/m^3}\). The outward normal points in the negative \(x\)-direction, so the flux is \(-(1\,\mathrm{kg/m^3})(1\,\mathrm{m/s})(1\,\mathrm{m^2})=-1\,\mathrm{kg/s}\). The other faces contribute zero.
Hence the right face carries \(3\,\mathrm{kg/s}\) outward and the left face carries \(1\,\mathrm{kg/s}\) inward. The net outward flux is \(3-1=2\,\mathrm{kg/s}\). The box volume is \(2\,\mathrm{m^3}\), so the volume integral is \((1\,\mathrm{kg/(m^3s)})(2\,\mathrm{m^3})=2\,\mathrm{kg/s}\), as required by the divergence theorem.
This nonzero net flux means the stated fields do not describe a steady, source-free flow in this box. The calculation is a test of the mass-balance condition, not evidence that the fields satisfy it.
A Full Three-Dimensional Flux Check
Worked Example: Flux Through All Faces of a Box
On the box \(0\leq x\leq1\,\mathrm{m}\), \(0\leq y\leq2\,\mathrm{m}\), \(0\leq z\leq1\,\mathrm{m}\), take \(\rho=(2+x/(1\,\mathrm{m}))\,\mathrm{kg/m^3}\) and \(\mathbf{v}=(y/(1\,\mathrm{m})\,\mathrm{m/s},x/(1\,\mathrm{m})\,\mathrm{m/s},0)\). Calculate the divergence integral and independently add the face fluxes.
The mass-flux components are \(F_x=(2+x/(1\,\mathrm{m}))(y/(1\,\mathrm{m}))\,\mathrm{kg/(m^2s)}\) and \(F_y=(2+x/(1\,\mathrm{m}))(x/(1\,\mathrm{m}))\,\mathrm{kg/(m^2s)}\), with \(F_z=0\). Differentiating gives \(\nabla\cdot(\rho\mathbf{v})=(y/(1\,\mathrm{m}))\,\mathrm{kg/(m^3s)}\): the \(x\)-derivative of \(F_x\) gives this term, while \(F_y\) is independent of \(y\).
For the volume integral, integrate \(y/(1\,\mathrm{m})\) from \(0\) to \(2\,\mathrm{m}\), obtaining \(2\,\mathrm{m}\). The \(x\)- and \(z\)-intervals each have length \(1\,\mathrm{m}\). Thus \(\iiint_V\nabla\cdot(\rho\mathbf{v})\,dV=2\,\mathrm{kg/s}\).
Now add the face contributions. At \(x=1\,\mathrm{m}\), \(F_x=3(y/(1\,\mathrm{m}))\,\mathrm{kg/(m^2s)}\). Integrating over \(0\leq y\leq2\,\mathrm{m}\) and \(0\leq z\leq1\,\mathrm{m}\) gives \(3(2\,\mathrm{m})(1\,\mathrm{m})\,\mathrm{kg/(m^2s)}=6\,\mathrm{kg/s}\). At \(x=0\), the outward normal reverses the sign; the corresponding flux is \(-2(2\,\mathrm{m})(1\,\mathrm{m})\,\mathrm{kg/(m^2s)}=-4\,\mathrm{kg/s}\). The two \(x\)-faces therefore contribute \(6-4=2\,\mathrm{kg/s}\).
On the \(y\)-faces, \(F_y\) is independent of \(y\). The face at \(y=2\,\mathrm{m}\) contributes \(\int_0^{1\,\mathrm{m}}(2+x/(1\,\mathrm{m}))(x/(1\,\mathrm{m}))\,dx\,\mathrm{kg/(m^2s)}\,(1\,\mathrm{m})=4/3\,\mathrm{kg/s}\). The face at \(y=0\) has the opposite normal and contributes \(-4/3\,\mathrm{kg/s}\). The \(z\)-faces contribute zero because \(F_z=0\). The total is \(2+4/3-4/3=2\,\mathrm{kg/s}\), matching the volume integral.
A Common Mistake: Using Velocity Divergence Alone
A frequent error is to assume that \(\nabla\cdot\mathbf{v}=0\) automatically means mass is conserved. That conclusion is valid when density is constant, but not in general. For example, take \(\rho=(1+x/(1\,\mathrm{m}))\,\mathrm{kg/m^3}\) and \(\mathbf{v}=(1\,\mathrm{m/s},0,0)\). Then \(\nabla\cdot\mathbf{v}=0\), but
The correction is to test the divergence of the entire mass-flux field \(\rho\mathbf{v}\), not the velocity field alone. A spatially varying density can change the mass transported through successive cross-sections even when the velocity field has zero divergence.
Interpreting the Balance
The local equation \(\nabla\cdot(\rho\mathbf{v})=0\) says that every sufficiently small region has balanced inward and outward mass flow. It does not say that the flow is motionless, that the density is uniform, or that the flux through each face is zero. As the worked examples show, substantial inflow and outflow can cancel exactly.
If mass is added or removed within the region, the source-free equation must be modified. With a signed source rate \(s(\mathbf{x})\), measured as mass per unit volume per unit time and positive for addition, the steady balance becomes \(\nabla\cdot(\rho\mathbf{v})=s\). In the absence of sources or sinks, \(s=0\), giving the equation derived above.
These checks matter whenever a proposed steady flow is specified by density and velocity fields. Computing \(\nabla\cdot(\rho\mathbf{v})\) tests the local balance; integrating it over a bounded volume and comparing with outward boundary flux checks the same balance globally. Both viewpoints are useful, and the divergence theorem guarantees they agree when its regularity conditions hold.
Check Your Understanding
Use the signed outward-flux convention and the steady mass-balance law in answering these questions.
- What field represents mass transported per unit area per unit time by a density \(\rho\) and velocity \(\mathbf{v}\)?
- Why does the divergence theorem connect a volume integral of \(\nabla\cdot(\rho\mathbf{v})\) to net boundary mass flow?
- If \(\nabla\cdot\mathbf{v}=0\), what additional information is needed to conclude that \(\nabla\cdot(\rho\mathbf{v})=0\)?
- A bounded control volume has \(5\,\mathrm{kg/s}\) outward flow on one face and \(2\,\mathrm{kg/s}\) inward flow on another, with zero flux on the remaining boundary. Is its net outward mass flux zero?
- What does a positive value of \(\nabla\cdot(\rho\mathbf{v})\) at a point indicate about local outward mass flow?