dolfinx_adjoint.fem.assemble module

class dolfinx_adjoint.fem.assemble.AssembleScalarNode(object: Any, M: Form)

Bases: Node

Node for the operation dolfinx.fem.assemble_scalar().

In order to assemble the scalar value from the form in the forward pass, the form needs to be saved in the node.

object

The object that is being represented by the node

Type:

Any

M

The form that is being assembled

Type:

dolfinx.fem.Form

dolfinx_adjoint.fem.assemble.assemble_scalar(*args, **kwargs)

OVERLOADS: dolfinx.fem.assemble_scalar(). Assemble functional. The returned value is local and not accumulated across processes.

The overloaded function adds the functionality to keep track of the dependencies in the computational graph. The original functionality is kept.

Parameters:
  • args – Arguments to dolfinx.fem.assemble_scalar().

  • kwargs – Keyword arguments to dolfinx.fem.assemble_scalar().

  • graph (graph, optional) – An additional keyword argument to specifier whether the assemble operation should be added to the graph. If not present, the original functionality of dolfinx is used without any additional functionalities.

Returns:

The computed scalar on the calling rank

Return type:

float

Note

When a form is assembled into a scalar value, the information about its dependencies is lost, and the resulting scalar does not support automatic differentiation. To this end the graph is used to keep track of the dependencies between the resulting scalar value and the used form to obtain the scalar value.