dolfinx_adjoint.node module
- class dolfinx_adjoint.node.AbstractNode(object: Any, version=0, **kwargs)
Bases:
objectThe base class for nodes in the graph.
AbstractNodes provide the functionality to represent the object and operations in the graph. To create a new node, the user should inherit from this class and implement the __call__ method or use the this AbstractNode class to directly create a new node without any additional functionalities.
The AbstractNode class is used to represent objects without any numerical value.
- id
The python id of the object
- Type:
int
- version
The version of the object, indicates if an object is an updated version of an already existing object. Defaults to 0.
- Type:
int, optional
- object
The object that the node represents
- Type:
Any
- gradFuncs
A list of the gradient functions that are connected to the node
- Type:
list
- _name
The name of the node
- Type:
str
- append_gradFuncs(Funcs: list | Any)
Appends a gradient function to the list of gradient functions.
- Parameters:
_list (list or Any) – A list of the gradient functions that are connected to the node. If a single function is given, it is appended to the list.
- get_gradFuncs()
Returns the gradient functions of the node.
- Returns:
A list of the gradient functions that are connected to the node
- Return type:
list
- property name
Returns the name of the node.
- Returns:
The name of the node
- Return type:
str
- set_gradFuncs(list: list)
Sets the gradient functions of the node.
- Parameters:
list (list) – A list of the gradient functions that are connected to the node
- set_object(object: Any)
Sets the object of the node.
- Parameters:
object (Any) – The object that the node represents
- class dolfinx_adjoint.node.Node(object: Any, **kwargs)
Bases:
AbstractNodeThe Node class is used to represent objects with a numerical value.
The Node class inherits from the AbstractNode class and provides the functionality to represent the object and operations in the graph.
- data
The object that the node represents
- Type:
Any
- grad
The gradient of the object
- Type:
float or PETSc.Vec
- accumulate_grad(value: float)
- get_grad()
- get_object()
- reset_grad()
- set_grad(value: float)