Computational electromagnetics for nanophotonic design and discovery