The problem dealt with in this paper consists in coupling two boundaries with different number and location of nodes, while ensuring the natural continuity conditions of the physical quantities. To this end, a general purpose tool for restoring inter-element continuity is proposed, based on the alteration of the functional minimized. The new functional is expressed in terms of magnetic scalar or vector potentials. Practical difficulties, lying in the numerical integration and resolution methods are tackled. Numerical examples are included showing the ability of the method proposed as well as its limits.