def _make_identity(self, sh): "Create a higher order identity tensor to represent dv/dv." res = None if sh == (): # Scalar dv/dv is scalar return FloatValue(1.0) elif len(sh) == 1: # Vector v makes dv/dv the identity matrix return Identity(sh[0]) else: # TODO: Add a type for this higher order identity? # II[i0,i1,i2,j0,j1,j2] = 1 if all((i0==j0, i1==j1, i2==j2)) else 0 # Tensor v makes dv/dv some kind of higher rank identity tensor ind1 = () ind2 = () for d in sh: i, j = indices(2) dij = Identity(d)[i, j] if res is None: res = dij else: res *= dij ind1 += (i, ) ind2 += (j, ) fp = as_tensor(res, ind1 + ind2) return fp
def __init__(self, topological_dimension): GenericDerivativeRuleset.__init__(self, var_shape=(topological_dimension, )) self._Id = Identity(topological_dimension)
def __init__(self, geometric_dimension): GenericDerivativeRuleset.__init__(self, var_shape=(geometric_dimension, )) self._Id = Identity(geometric_dimension)