Mathematical And Numerical Frameworks For Metamaterials And Metasurfaces