fem.bcs
- class dolfinx_graph_ad.fem.bcs.DirichletBCNode(object, arguments, version=0)
Bases:
AbstractNodeNode of a boundary condition, with the version of the value it applies.
A boundary condition is created once and applies whatever its value holds when a problem is solved. Every solve therefore depends on the version of the value that is the latest at the solve, which a node created with the boundary condition cannot know.
- Variables:
arguments (dict) – The arguments of the
dolfinx.fem.dirichletbc()call.
- bind(_graph) DirichletBCNode
Record a fresh boundary-condition version with the value this solve reads.
- Parameters:
_graph (Graph) – The graph the solve is recorded in.
- Returns:
A new version with an edge from the latest recorded version of the boundary value.
- Return type:
- release()
Releases the boundary condition and the arguments it was created with.
- class dolfinx_graph_ad.fem.bcs.DirichletBC_Constant_Edge(predecessor: Node, successor: Node, ctx=None)
Bases:
EdgeEdge providing the adjoint equation for the derivative of the DirichletBC to the constant defining the value of the BC.
- Variables:
ctx (list) – The owned dofs of the boundary condition, the constant and the space the boundary condition constrains.
- calculate_adjoint(value: Vec)
The method provides the adjoint equation for the derivative of the DirichletBC to the constant defining the value of the BC.
The cached DOLFINx interpolation matrix supplies the component mapping. Its PETSc transpose product accumulates contributions across mesh ranks; masking only owned entries avoids counting ghost sensitivities twice.
- Returns:
The accumulated gradient up to this point in the computational graph, which the contributions of the same constant from the forms it appears in are accumulated with.
- Return type:
float or complex or PETSc.Vec
- release()
Releases the values saved in the edge and its interpolation matrix.
- class dolfinx_graph_ad.fem.bcs.DirichletBC_Function_Edge(predecessor: Node, successor: Node, ctx=None)
Bases:
EdgeEdge providing the adjoint equation for the derivative of the DirichletBC to the function defining the value of the BC.
- calculate_adjoint(value: Vec)
The method provides the adjoint equation for the derivative of the DirichletBC to the function defining the value of the BC.
Since the boundary condition is only applied to a part of the domain, the derivative of the boundary condition applies the accumulated gradient to the function only defined on the relevant boundary.
- Returns:
The accumulated gradient up to this point in the computational graph. It has the layout of the vector of the function defining the value of the boundary condition, but only its entries owned by the calling rank are valid.
- Return type:
(PETSc.Vec)
- dolfinx_graph_ad.fem.bcs.dirichletbc(*args, **kwargs)
OVERLOADS:
dolfinx.fem.dirichletbc(). Creates a representation of a Dirichlet boundary condition inThe overloaded function adds the functionality to keep track of the dependencies in the computational graph. The original functionality is kept.
The boundary condition carries the gradient of the value defining it, so a value that is not part of the graph leaves nothing to record and the boundary condition behaves like the one of DOLFINx.
- Parameters:
args – Arguments to
dolfinx.fem.dirichletbc().kwargs – Keyword arguments to
dolfinx.fem.dirichletbc().graph – An additional keyword argument to specify whether the boundary condition should be added to the graph. If not present, the original functionality of dolfinx is used without any additional functionalities.