Multiscale homogenization of multilayered structures