I know differential work is $p dV$, since all standard Thermodynamics textbooks cover this. But, almost every case that they cover is about a gas (continuum-mechanics) that has low density, so its pressure does not vary with vertical coordinates. Since thermodyanimics deals with equilibrium states, all exercises are about constant-pressure gases or pressure in a $p = f(V)$ form. I'm talking about a pressure field $p = f(x, y, z)$, that could be obtained from a Navier-Stokes solution, for example. I thought it could be something like $W = \iiint\limits_{V_{2}} \, p dV - \iiint\limits_{V_{1}} \, p dV$
Being $V_{2}$ and $V_{1}$ the final volume frontier and the initial volume frontier, respectively. But I didn't find any references in standard books, and I don't know if $dW = p dV$ remains valid for non-equilibrium process.