Definition and detection of contact in atomistic simulations