Hypervirial analysis of enclosed quantum mechanical systems. I. Dirichlet boundary conditions