Dynamic analysis of rigid and deformable multibody systems with penalty methods and energy–momentum schemes