Swirling flow states in finite-length diverging or contracting circular pipes