Analytical treatment of grain boundary sources for dislocations