Theory of Ostwald ripening for open systems