  Consider the diffraction of an electromagnetic plane wave by a biperiodic
structure where the wave propagation is governed by the three-dimensional
Maxwell equations. Based on transparent boundary condition, the grating problem
is formulated into a boundary value problem in a bounded domain. Using a
duality argument technique, we derive an a posteriori error estimate for the
finite element method with the truncation of the nonlocal Dirichlet-to-Neumann
(DtN) boundary operator. The a posteriori error consists of both the finite
element approximation error and the truncation error of boundary operator which
decays exponentially with respect to the truncation parameter. An adaptive
finite element algorithm is developed with error controlled by the a posterior
error estimate, which determines the truncation parameter through the
truncation error and adjusts the mesh through the finite element approximation
error. Numerical experiments are presented to demonstrate the competitive
behavior of the proposed adaptive method.
