Rigorous computation of time-dependent electromagnetic fields in gyrotron cavities excited by internal sources