def assign(self, expr, subset=None): """Set the :class:`Function` value to the pointwise value of expr. expr may only contain :class:`Function`\s on the same :class:`.FunctionSpace` as the :class:`Function` being assigned to. Similar functionality is available for the augmented assignment operators `+=`, `-=`, `*=` and `/=`. For example, if `f` and `g` are both Functions on the same :class:`FunctionSpace` then:: f += 2 * g will add twice `g` to `f`. If present, subset must be an :class:`pyop2.Subset` of :attr:`node_set`. The expression will then only be assigned to the nodes on that subset. """ if isinstance(expr, Function) and \ expr._function_space == self._function_space: expr.dat.copy(self.dat, subset=subset) return self assemble_expressions.evaluate_expression( assemble_expressions.Assign(self, expr), subset) return self
def __idiv__(self, expr): if np.isscalar(expr): self.dat /= expr return self if isinstance(expr, Function) and \ expr._function_space == self._function_space: self.dat /= expr.dat return self assemble_expressions.evaluate_expression( assemble_expressions.IDiv(self, expr)) return self