Conditions for coincidence in grain boundaries in hexagonal materials