When InP is grown by chemical beam epitaxy on substrates patterned with ridges oriented along [110] with (111)B sidewall planes, the migration of In species on the surface changes direction with growth temperature. The movement is from the ridge to the valley through the sidewall above 505 degrees C, and from the sidewall to the ridge below 495 degrees C. By using this specific growth behavior, we have obtained a triangular prism-shaped buried heterostructure with a narrow active region. We also present an estimation of the growth temperature dependence of the diffusion length on each plane and propose a model explaining the above migrations.