import sympy


def DfjDxi(DN,f):
    """
    This method defines a gradient. Returns a matrix D such that D(i,j) = D(fj)/D(xi)

    This is the standard in fluid dynamics, that is:
        D(f1)/D(x1) D(f2)/D(x1) D(f3)/D(x1)
        D(f1)/D(x2) D(f2)/D(x2) D(f3)/D(x2)
        D(f1)/D(x3) D(f2)/D(x3) D(f3)/D(x3)

    Keyword arguments:
    - DN -- The shape function derivatives
    - f-- The variable to compute the gradient
    """
    return sympy.simplify(DN.transpose()*f)