Discretization of unknown functions: A new method to solve partial differential equations with mixed boundary conditions