Finite element method for the solution of Maxwell's equations in multiple media