We have the continuity equation
$$ \partial_t \, P(\mathbf{x},t) = -\nabla \cdot[ \, P(\mathbf{x},t) \, \mathbf{v}(\mathbf{x},t) \, ] $$
where the positive scalar function $P$ is advected by the smooth field $\mathbf{v}$ (everything can be considered continuous and with continuous derivatives).
Imagine that the field $\mathbf{v}(\mathbf{x})$ is prescribed and constant in time. How do we get the steady (i.e. time independent) solution $P(\mathbf{x})$? Namely, we want to solve
$$ \nabla \cdot[ \, P(\mathbf{x}) \, \mathbf{v}(\mathbf{x}) \, ] = 0 \, . $$
Note: this means that the field $P \mathbf{v}$ is solenoidal and there should be a vector potential $P \mathbf{v} = \nabla \times \mathbf{A}$. Therefore, the function $P$ is a sort of "integrating factor" but for the existence of the vector potential (instead of the more usual notion of integrating factor for non-exact 1-forms that involves a scalar potential). Maybe the language of differential forms can help understanding the problem (i.e. looking at $q$ as a 0-form and $\mathbf{w}$ as a 1-form.. or a 2-form, since the divergence should be the external derivative for 2-forms in three-dimensional space). Partial answers and insights of any kind are well accepted.