Modified version of KAM to allow calculation across grain boundaries