Many problems in mining and civil engineering require using numerical stress analysis methods to repeatedly solve large models. Widespread acceptance of tunneling methods, such as New Austrian Tunneling Method, which depend heavily on numerical stress analysis tools and the fact that the effects of excavation at the face of a tunnel are distinctively three–dimensional (3D), necessitates the use of 3D numerical analysis for these problems. Stress analysis of a practical mining problem can be very lengthy, and the processing time can be measured in days or weeks at times. A framework is developed to facilitate efficient modeling of underground excavations and to create an optimal 3D mesh by reducing the number of surface and volume elements while keeping the result of stress analysis accurate enough at the region of interest, where a solution is sought. Fewer surface and volume elements mean fewer degrees of freedom in the numerical model, which directly translates into savings in computational time and resources. The mesh refinement algorithm is driven by a set of criteria that are functions of distance and visibility of points from the region of interest, and the framework can be easily extended by adding new types of criteria. This paper defines the framework, whereas a second companion paper will investigate its efficiency, accuracy and application to a number of practical mining problems. Copyright © 2012 John Wiley & Sons, Ltd.