An Improved Foam Modeling Technique and Its Application to Petroleum Drilling and Production Practice