How to implement the penalty contact condition

I would like to implement a boundary condition for overlapping meshes in the initial state such that their surfaces touch using the penalty method. Please let me know. Or, if there is another implementation other than the penalty method, please let me know.