Skip to content

Commit 30ef1a9

Browse files
committed
Improve derivative_block's docstring to make clear the type of return values in each case that it supports.
1 parent 0141b99 commit 30ef1a9

1 file changed

Lines changed: 27 additions & 15 deletions

File tree

python/dolfinx/fem/forms.py

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -757,22 +757,34 @@ def derivative_block(
757757
This is commonly used to derive a block residual from a functional, or to
758758
derive a block Jacobian from a block residual.
759759
760-
If ``F`` is a univariate rank zero form, returns the residual computed as
761-
:math:`R = \\frac{\\partial F}{\\partial u}[\\delta u]`.
760+
Four cases are supported:
761+
762+
1. ``F`` is a rank-zero ``ufl.Form``, and ``u`` is a ``ufl.Function``.
763+
Returns a ``ufl.Form`` representing the residual :math:`R =
764+
\\frac{\\partial F}{\\partial u}[\\delta u]`. This is equivalent to
765+
calling {py:func}`ufl.derivative` directly.
766+
767+
2. ``F`` is a rank-zero `ufl.Form``, and ``u`` is a list of ``ufl.Function``.
768+
Returns a list of ``ufl.Form`` representing the block residual :math:`R`,
769+
with :math:`R_i = \\frac{\\partial F}{\\partial u_i}[\\delta u_i]`, where
770+
:math:`\\delta u_i` is a test subfunction of the mixed space defined by
771+
``u``. This is equivalent to calling {py:func}`ufl.extract_blocks` on the
772+
result from {py:func}`ufl.derivative`.
773+
774+
3. ``F`` is a rank-one `ufl.Form``, and ``u`` is a ``ufl.Function``.
775+
Returns a ``ufl.Form`` representing the Jacobian :math:`J =
776+
\\frac{\\partial F}{\\partial u}[\\delta u]`. This is equivalent to
777+
calling {py:func}`ufl.derivative` directly.
778+
779+
4. ``F`` is a list of rank-one `ufl.Form``, and ``u`` is a list of
780+
``ufl.Function``. Returns a list of lists representing the block Jacobian
781+
:math:`J`, with :math:`J_{ij} = \\frac{\\partial F_i}{u_j}[\\delta u_j]`
782+
using {py:func}`ufl.derivative` called component-wise.
762783
763-
If ``F`` is a rank one form, returns the Jacobian computed as :math:`J =
764-
\\frac{\\partial F}{\\partial u}[\\delta u]`.
765-
766-
The two operations above are identical to calling {py:func}`ufl.derivative` directly.
767-
768-
If ``F`` is a multivariate rank zero form, returns the block residual as a list with
769-
:math:`R_i = \\frac{\\partial F}{\\partial u_i}[\\delta u_i]`, where
770-
:math:`\\delta u_i` is a test subfunction of the mixed space defined by u. This is
771-
equivalent to calling {py:func}`ufl.extract_blocks` on the result from {py:func}`ufl.derivative`.
772-
773-
If ``F`` is a list of rank one forms, returns the block Jacobian as a list of lists with
774-
:math:`J_{ij} = \\frac{\\partial F_i}{u_j}[\\delta u_j]` using {py:func}`ufl.derivative`
775-
called component-wise.
784+
Args:
785+
F: UFL form(s) to be derived.
786+
u: Function(s) with respect to the derivative is computed.
787+
du: UFL argument(s) representing the direction of the derivative.
776788
""" # noqa: D301
777789

778790
if isinstance(F, ufl.Form) and not F.arguments():

0 commit comments

Comments
 (0)