tlm_adjoint.instructions

Module Contents

class tlm_adjoint.instructions.Instruction

An adjoint tape record which defines instructions to be performed during forward or adjoint calculations.

adjoint_jacobian_solve(adj_X, nl_deps, B)

Compute an adjoint solution.

Parameters:
  • adj_X – Either None, or a variable or Sequence of variables defining the initial guess for an iterative solve. May be modified or returned.

  • nl_deps – A Sequence of variables defining values for non-linear dependencies. Should not be modified.

  • B – The right-hand-side. A variable or Sequence of variables storing the value of the right-hand-side. May be modified or returned.

Returns:

A variable or Sequence of variables storing the value of the adjoint solution. May return None to indicate a value of zero.

class tlm_adjoint.instructions.GarbageCollection(comm=None, *, generation=2, garbage_cleanup=True)

An Instruction which indicates that garbage collection should be performed during forward and adjoint calculations.

Parameters:
  • comm – Communicator to use for PETSc garbage cleanup.

  • generation – Python garbage collection generation. If a value of None is provided then Python garbage collection is not performed.

  • garbage_cleanup – Whether to perform PETSc garbage cleanup.

forward_solve(X, deps=None)

Compute the forward solution.

Can assume that the currently active EquationManager is paused.

Parameters:
  • X – A variable or a Sequence of variables storing the solution. May define an initial guess, and should be set by this method.

  • deps – A tuple of variables, defining values for dependencies. Only the elements corresponding to X may be modified. self.dependencies() should be used if not supplied.

adjoint_jacobian_solve(adj_X, nl_deps, B)

Compute an adjoint solution.

Parameters:
  • adj_X – Either None, or a variable or Sequence of variables defining the initial guess for an iterative solve. May be modified or returned.

  • nl_deps – A Sequence of variables defining values for non-linear dependencies. Should not be modified.

  • B – The right-hand-side. A variable or Sequence of variables storing the value of the right-hand-side. May be modified or returned.

Returns:

A variable or Sequence of variables storing the value of the adjoint solution. May return None to indicate a value of zero.

tangent_linear(tlm_map)

Derive an Equation corresponding to a tangent-linear operation.

Parameters:

tlm_map – A TangentLinearMap storing values for tangent-linear variables.

Returns:

An Equation, corresponding to the tangent-linear operation.