A novel numerical algorithm based on the solution of the two-dimensional effective mass equation for current-carrying scattering states in mesoscopic devices is developed. Using this while allowing for an energy dependent transmission matrix, the total charge density distribution based on all electrons injected into the device is calculated through integration over energy. By coupling this energy-resolved calculation of charge density distribution iteratively with a potential calculation a fully self-consistent calculation, which allows for accurate simulations of mesoscopic devices with arbitrary complex device geometries operating under a finite bias, is achieved. Thus it is possible to self-consistently study space charge effects in mesoscopic devices. The developed method is described and tested on a number of sample geometries.