On the variational derivation of the kinematics for thin-walled closed section beams