def grid_indices_gen(nx, ny):
    """A generator for grid vertex indices.
    """
    for x in range(nx - 1):
        for y in range(ny - 1):
            root = x + y * ny
            yield root, root + 1, root + nx
            yield root + nx, root + 1, root + nx + 1
