def _ad_convert_type(self, value, options={}): if value is None: # TODO: Should the default be 0 constant here or return just None? return Constant(numpy.zeros(self.ufl_shape)) value = gather(value) value = compat.constant_function_firedrake_compat(value) return constant_from_values(self, value)
def _applyBinary(self, f, y): npdata = self.values() npdatacopy = self.values().copy() npdatay = y.values() for i in range(len(npdata)): npdatacopy[i] = f(npdata[i], npdatay[i]) self.assign(constant_from_values(self, npdatacopy))
def _ad_iadd(self, other): self.assign(constant_from_values(self, self.values() + other.values()))
def _ad_imul(self, other): self.assign(constant_from_values(self, self.values() * other))
def _ad_copy(self): return constant_from_values(self)
def _ad_add(self, other): return constant_from_values(self, self.values() + other.values())
def _ad_mul(self, other): return constant_from_values(self, self.values() * other)
def _ad_create_checkpoint(self): return constant_from_values(self)
def __deepcopy__(self, memodict={}): return constant_from_values(self)
def _applyUnary(self, f): npdata = self.values() npdatacopy = npdata.copy() for i in range(len(npdata)): npdatacopy[i] = f(npdata[i]) self.assign(constant_from_values(self, npdatacopy))