This paper presents an efficient method to calculate the magnetic forces on bodies in contact. The forces are computed through the local application of the virtual work principle on degenerated air-gap elements. The results from this method are compared with those from other software and validated with measurements on a permanent magnet setup. Not only is this technique very accurate, but it also reduces the computational burden related to the problematic meshing of thin layers. The implementation of this method in an open source finite element software having facilities for higher order elements and parallel computation unlocks a cost effective and effectual platform for an electromechanical computation of electromechanical devices and magnetic materials.