  Using a 3-D parallelepiped model of intrinsic Josephson junctions, we
calculate the cavity resonance modes of Josephson plasma waves excited by
external electric currents. The electromagnetic (EM) wave of the excited
Josephson plasma is converted to a THz EM wave at the sample surfaces. The
cavity modes accompanied by static phase kinks of the superconducting order
parameter have been intensively investigated. The phase kinks induce a spatial
modulation of the amplitude of the order parameter around the kinks and
decrease the superconducting condensation energy. The Josephson plasma produces
a magnetic field in the vacuum in addition to the emitted EM wave. This
magnetic energy detemines the orientation of the cavity mode. Taking account of
the facts mentioned above, we obtained sharp resonance peaks in the I-V curves
and sizable powers of continuous and coherent terahertz wave emission at the
cavity resonance. The emission frequencies are inversely proportional to the
length of the shorter side of the samples in agreement with experiments.
