A Numerical Three-Dimensional Model for the Contact of Rough Surfaces by Variational Principle