Model of Internal Boundary Layer Formation over Inhomogeneous Terrain