  We have developed finite difference codes based on the Yin-Yang grid for the
geodynamo simulation and the mantle convection simulation. The Yin-Yang grid is
a kind of spherical overset grid that is composed of two identical component
grids. The intrinsic simplicity of the mesh configuration of the Yin-Yang grid
enables us to develop highly optimized simulation codes on massively parallel
supercomputers. The Yin-Yang geodynamo code has achieved 15.2 Tflops with 4096
processors on the Earth Simulator. This represents 46% of the theoretical peak
performance. The Yin-Yang mantle code has enabled us to carry out mantle
convection simulations in realistic regimes with a Rayleigh number of $10^7$
including strongly temperature-dependent viscosity with spatial contrast up to
$10^6$.
