Diffraction analysis of layered structures of photorefractive gratings