Topology optimization in electromagnetic casting via quadratic programming