:py:mod:`tlm_adjoint.firedrake.assignment` ========================================== .. py:module:: tlm_adjoint.firedrake.assignment .. autoapi-nested-parse:: Assignment operations with Firedrake. .. !! processed by numpydoc !! Module Contents --------------- .. py:class:: ExprAssignment(x, rhs, *, subset=None) Represents an evaluation of `rhs`, storing the result in `x`. Uses :meth:`firedrake.function.Function.assign` or :meth:`firedrake.cofunction.Cofunction.assign` to perform the evaluation. The forward residual :math:`\mathcal{F}` is defined so that :math:`\partial \mathcal{F} / \partial x` is the identity. :arg x: A :class:`firedrake.function.Function` or :class:`firedrake.cofunction.Cofunction` defining the forward solution. :arg rhs: A :class:`ufl.core.expr.Expr` defining the expression to evaluate. Should not depend on `x`. :arg subset: A :class:`pyop2.types.set.Subset`. If provided then defines a subset of degrees of freedom at which to evaluate `rhs`. Other degrees of freedom are set to zero. .. !! processed by numpydoc !! .. py:method:: drop_references() Drop references to variables which store values. .. !! processed by numpydoc !! .. py:method:: forward_solve(x, deps=None) Compute the forward solution. Can assume that the currently active :class:`.EquationManager` is paused. :arg X: A variable or a :class:`Sequence` of variables storing the solution. May define an initial guess, and should be set by this method. :arg deps: A :class:`tuple` of variables, defining values for dependencies. Only the elements corresponding to `X` may be modified. `self.dependencies()` should be used if not supplied. .. !! processed by numpydoc !! .. py:method:: adjoint_derivative_action(nl_deps, dep_index, adj_x) Return the action of the adjoint of a derivative of the forward residual on the adjoint solution. This is the *negative* of an adjoint right-hand-side term. :arg nl_deps: A :class:`Sequence` of variables defining values for non-linear dependencies. Should not be modified. :arg dep_index: An :class:`int`. The derivative is defined by differentiation of the forward residual with respect to `self.dependencies()[dep_index]`. :arg adj_X: The adjoint solution. A variable or a :class:`Sequence` of variables. Should not be modified. :returns: The action of the adjoint of a derivative on the adjoint solution. Will be passed to :func:`.subtract_adjoint_derivative_action`, and valid types depend upon the adjoint variable type. Typically this will be a variable, or a two element :class:`tuple` `(alpha, F)`, where `alpha` is a :class:`numbers.Complex` and `F` a variable, with the value defined by the product of `alpha` and `F`. .. !! processed by numpydoc !! .. py:method:: adjoint_jacobian_solve(adj_x, nl_deps, b) Compute an adjoint solution. :arg adj_X: Either `None`, or a variable or :class:`Sequence` of variables defining the initial guess for an iterative solve. May be modified or returned. :arg nl_deps: A :class:`Sequence` of variables defining values for non-linear dependencies. Should not be modified. :arg B: The right-hand-side. A variable or :class:`Sequence` of variables storing the value of the right-hand-side. May be modified or returned. :returns: A variable or :class:`Sequence` of variables storing the value of the adjoint solution. May return `None` to indicate a value of zero. .. !! processed by numpydoc !! .. py:method:: tangent_linear(tlm_map) Derive an :class:`.Equation` corresponding to a tangent-linear operation. :arg tlm_map: A :class:`.TangentLinearMap` storing values for tangent-linear variables. :returns: An :class:`.Equation`, corresponding to the tangent-linear operation. .. !! processed by numpydoc !!