Magnetomechanical effect in nickel and cobalt