The Discrete Variational Method in Density Functional Theory and its Applications to Large Molecules and Solid-State Systems