Optimization for deuterium ion acceleration in foam targets by ultra-intense lasers