Savings in computational resources have become a main subject of study in geomechanics due to the complexity of the problems analyzed. This thesis develops and evaluates the performance of a partial p-adaptive mesh optimization method for stress analysis of underground excavations. The method uses transition finite elements in order to connect a mesh of quadratic (triangular or quadrilateral) elements with a mesh of linear (triangular or quadrilateral) elements. The analysis is performed using SIMFEM, a computer program that solves plane strain problems and is able to handle this type of mixed meshes. After the formulation of 4 types of transition elements (5-node, 7-node quadrilateral, 4-node and 5-node triangle), which were incorporated into the code, 57 models (including the analysis of a pressurized cavity) were run, analyzed and for some of the models, the results obtained were compared to commercial software, as to ensure the correct behaviour of these elements in a finite element mesh. A final application was performed modeling a continuum with two circular excavations, surrounded by a linear elastic material in a biaxial stress field, obtaining favourable results. The global stiffness matrix size was reduced by 85.4% and by 74.1% for the models using triangles and quadrilaterals respectively, as a result, the calculation times were considerably reduced. The average percentage of error with respect to the models without optimization, measured at eight critical points, was 0.15% and 2.63% in the case of triangular and quadrilateral elements respectively.