add c function generator for periodic grids