  We develop a dynamical theory for the origin of nuclear rings in barred
galaxies. In analogy with the standard theory of accretion discs, our theory is
based on shear viscous forces among nested annuli of gas. However, the fact
that gas follows non circular orbits in an external barred potential has
profound consequences: it creates a region of reverse shear in which it is
energetically favourable to form a stable ring which does not spread despite
dissipation. Our theory allows us to approximately predict the size of the ring
given the underlying gravitational potential. The size of the ring is loosely
related to the location of the Inner Lindblad Resonance in the epicyclic
approximation, but the predicted location is more accurate and is also valid
for strongly barred potentials. By comparing analytical predictions with the
results of hydrodynamical simulations, we find that our theory provides a
viable mechanism for ring formation if the effective sound speed of the gas is
low ($\cs\lesssim1\kms$), but that nuclear spirals/shocks created by pressure
destroy the ring when the sound speed is high ($\cs\simeq10\kms$). We conclude
that whether this mechanism for ring formation is relevant for real galaxies
ultimately depends on the effective equation of state of the ISM. Promising
confirmation comes from simulations in which the ISM is modelled using
state-of-the-art cooling functions coupled to live chemical networks, but more
tests are needed regarding the role of turbulence driven by stellar feedback.
If the mechanism is relevant in real galaxies, it could provide a powerful tool
to constrain the gravitational potential, in particular the bar pattern speed.
