Nonlinear equations used for the analysis of the contact problem between thestructures and their foundations are established. The iteration method, variable incrementsearching method, is adopted to solve the interaction problem among the lock walls, boltsand their rock foundation. A complicated nonlinear three dimensional contact problemcaused by temperature, water pressure and seepage pressure during or after construction isdivided into two parts for study. The first part is to solve the opening problem betweenthe structures and their foundations caused by temperature. In the second part, theopenings are regarded as initial joint spacings and the laws of the variations and thestresses of the whole system under external loads are studied. And the fact that the freelengthes of the bolts affect the distribution of their internal forces is discussed in detail.The results obtained have been used in practice.