dolfinx_adjoint.fem.bcs module

class dolfinx_adjoint.fem.bcs.DirichletBC_Edge(predecessor: Node, successor: Node, ctx=None, input_value=None)

Bases: Edge

Edge providing the adjoint equation for the derivative of the DirichletBC to the function defining the value of the BC.

calculate_adjoint()

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.

Return type:

(PETSc.Vec)

dolfinx_adjoint.fem.bcs.dirichletbc(*args, map=None, **kwargs)

OVERLOADS: dolfinx.fem.dirichletbc(). Creates a representation of a Dirichlet boundary condition in

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.dirichletbc().

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

  • map – Defines the map between the function space of the boundary condition and the function space of the problem.

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

Note

The map is used to define the map between the function space of the boundary condition and the function space of the problem. This is useful when the function space of the boundary condition and the function space of the problem are different. The map is stored as an array where the index is equivalent to the index in the correct space and the value is the index in the wrong space.