Van der Waals density functional for layered structures.