  We present a generalized algorithm based on a spherical harmonics expansion
method for efficient computation of the three-dimensional gravitational
potential on a multi-patch grid in spherical geometry. Instead of solving for
the gravitational potential by superposition of separate contributions from the
mass density distribution on individual grid patch our new algorithm computes
directly the gravitational potential due to contributions from all grid patches
in one computation step, thereby reducing the computational cost of the gravity
solver. This is possible by considering a set of angular weights which are
derived from rotations of spherical harmonics functions defined in a global
coordinate system that is common for all grid patches. Additionally, our
algorithm minimizes data communication between parallel compute tasks by
eliminating its proportionality to the number of subdomains in the grid
configuration, making it suitable for parallelized computation on a multi-patch
grid configuration with any number of subdomains. Test calculations of the
gravitational potential of a tri-axial ellipsoidal body with constant mass
density on the Yin-Yang two-patch overset grid demonstrate that our method
delivers the same level of accuracy as a previous method developed for the
Yin-Yang grid, while offering improved computation efficiency and parallel
scaling behaviour.
