A general theory of thixotropy and viscosity