fem.function
- class dolfinx_graph_ad.fem.function.Constant(*args, **kwargs)
Bases:
ConstantOVERLOADS:
dolfinx.fem.ConstantInitialize a constant function.The overloaded class modifies the initialization of the Constant to keep track of the dependencies in the computational graph and the adjoint equations. The original functionality is kept.
- class dolfinx_graph_ad.fem.function.ConstantNode(object: Any, **kwargs)
Bases:
NodeA Constant version with its saved value.
- save()
Copy this version’s value once, before a later recorded call overwrites it.
The copy is local to the calling rank.
- class dolfinx_graph_ad.fem.function.Function(*args, **kw)
Bases:
FunctionOVERLOADS:
dolfinx.fem.FunctionInitialize a finite element Function.The overloaded class modifies the initialization of the Function to keep track of the dependencies in the computational graph and the adjoint equations. The original functionality is kept. Two additional methods are added to the class: copy and assign. The copy method creates a new function and adds the corresponding node to the graph. The assign method assign values to the function and adds the corresponding operation to the graph.
- assign(function: Function, **kwargs)
Assign values of a different dolfinx.fem.Function to the function and adds the corresponding operation to the graph.
- Parameters:
function (dolfinx.fem.Function) – The function to assign values from.
graph (graph, optional) – An additional keyword argument to specify whether the operation should be added to the graph. If not present, the original functionality of dolfinx is used without any additional functionalities.
version (int, optional) – The recorded version of the target. Defaults to the version after its latest recorded one, or 0 if it is unrecorded.
Note
The node is added in any case, since it is the version of this function the subsequent operations depend on.
- copy(**kwargs)
Creates a new dolfinx.fem.Function with the same function space and a copy of the PETsc vector.
- Parameters:
name (str, optional) – Keyword arguments to specify the name of the function.
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:
A new dolfinx.fem.Function with the same function space and a copy of the PETsc vector.
- Return type:
- class dolfinx_graph_ad.fem.function.FunctionNode(object: Any, **kwargs)
Bases:
NodeA Function version, with derivatives in its distributed vector layout.
- save()
Copy this version’s values once, before a later recorded call overwrites them.
The copy includes the ghost entries and shares the scatterer of the original, so creating it does not communicate.