def _gradient_extrapolation(extrapolation):
    """
Given the extrapolation of a field, returns the extrapolation mode of the corresponding gradient field.
    :param extrapolation: string or struct of strings
    :return: same type as extrapolation
    """
    return {'periodic': 'periodic',
            'boundary': 'constant',
            'constant': 'constant'}[extrapolation]