firedrake.adjoint_utils package¶
Subpackages¶
- firedrake.adjoint_utils.blocks package
- Submodules
- firedrake.adjoint_utils.blocks.assembly module
AssembleBlock
AssembleBlock.adj_state
AssembleBlock.block_helper
AssembleBlock.compute_action_adjoint()
AssembleBlock.evaluate_adj_component()
AssembleBlock.evaluate_hessian_component()
AssembleBlock.evaluate_tlm_component()
AssembleBlock.prepare_evaluate_adj()
AssembleBlock.prepare_evaluate_hessian()
AssembleBlock.prepare_evaluate_tlm()
AssembleBlock.prepare_recompute_component()
AssembleBlock.recompute_component()
AssembleBlock.tag
- firedrake.adjoint_utils.blocks.block_utils module
- firedrake.adjoint_utils.blocks.constant module
ConstantAssignBlock
ConstantAssignBlock.adj_state
ConstantAssignBlock.block_helper
ConstantAssignBlock.evaluate_adj_component()
ConstantAssignBlock.evaluate_hessian_component()
ConstantAssignBlock.evaluate_tlm_component()
ConstantAssignBlock.prepare_evaluate_adj()
ConstantAssignBlock.prepare_evaluate_hessian()
ConstantAssignBlock.recompute_component()
ConstantAssignBlock.tag
constant_from_values()
- firedrake.adjoint_utils.blocks.dirichlet_bc module
- firedrake.adjoint_utils.blocks.function module
CofunctionAssignBlock
FunctionAssignBlock
FunctionAssignBlock.adj_state
FunctionAssignBlock.block_helper
FunctionAssignBlock.evaluate_adj_component()
FunctionAssignBlock.evaluate_hessian_component()
FunctionAssignBlock.evaluate_tlm_component()
FunctionAssignBlock.prepare_evaluate_adj()
FunctionAssignBlock.prepare_evaluate_hessian()
FunctionAssignBlock.prepare_evaluate_tlm()
FunctionAssignBlock.prepare_recompute_component()
FunctionAssignBlock.recompute_component()
FunctionAssignBlock.tag
FunctionMergeBlock
SubfunctionBlock
- firedrake.adjoint_utils.blocks.mesh module
- firedrake.adjoint_utils.blocks.solving module
GenericSolveBlock
GenericSolveBlock.adj_sol
GenericSolveBlock.adj_state
GenericSolveBlock.block_helper
GenericSolveBlock.evaluate_adj_component()
GenericSolveBlock.evaluate_hessian_component()
GenericSolveBlock.evaluate_tlm_component()
GenericSolveBlock.pop_kwargs_keys
GenericSolveBlock.prepare_evaluate_adj()
GenericSolveBlock.prepare_evaluate_hessian()
GenericSolveBlock.prepare_evaluate_tlm()
GenericSolveBlock.prepare_recompute_component()
GenericSolveBlock.recompute_component()
GenericSolveBlock.tag
NonlinearVariationalSolveBlock
ProjectBlock
SolveLinearSystemBlock
SolveVarFormBlock
Solver
SupermeshProjectBlock
SupermeshProjectBlock.adj_state
SupermeshProjectBlock.apply_mixedmass()
SupermeshProjectBlock.block_helper
SupermeshProjectBlock.evaluate_adj_component()
SupermeshProjectBlock.evaluate_hessian_component()
SupermeshProjectBlock.evaluate_tlm_component()
SupermeshProjectBlock.recompute_component()
SupermeshProjectBlock.tag
extract_subfunction()
solve_init_params()
- Module contents
Submodules¶
firedrake.adjoint_utils.assembly module¶
firedrake.adjoint_utils.checkpointing module¶
A module providing support for disk checkpointing of the adjoint tape.
- firedrake.adjoint_utils.checkpointing.checkpointable_mesh(mesh)[source]¶
Write a mesh to disk and read it back.
Since a mesh will be repartitioned by being written to disk and reread, only meshes read from a checkpoint file are safe to use with disk checkpointing.
The workflow for disk checkpointing is therefore to create the mesh(es) required, and then call this function on them. Only the mesh(es) returned by this function can be used in disk checkpointing.
- Parameters:
mesh (firedrake.mesh.MeshGeometry) – The mesh to be checkpointed.
- Returns:
The checkpointed mesh to be used in the rest of the computation.
- Return type:
- firedrake.adjoint_utils.checkpointing.continue_disk_checkpointing()[source]¶
Resume disk checkpointing.
- firedrake.adjoint_utils.checkpointing.disk_checkpointing()[source]¶
Return whether disk checkpointing is enabled.
- firedrake.adjoint_utils.checkpointing.enable_disk_checkpointing(dirname=None, comm=<mpi4py.MPI.Intracomm object>, cleanup=True)[source]¶
Add a DiskCheckpointer to the current tape and switch on disk checkpointing.
- Parameters:
dirname (str) – The directory in which the disk checkpoints should be stored. If not specified then the current working directory is used. Checkpoints are stored in a temporary subdirectory of this directory.
comm (mpi4py.MPI.Intracomm) – The MPI communicator over which the computation to be disk checkpointed is defined. This will usually match the communicator on which the mesh(es) are defined.
cleanup (bool) – If set to False, checkpoint files will not be deleted when no longer required. This is usually only useful for debugging.
firedrake.adjoint_utils.constant module¶
- class firedrake.adjoint_utils.constant.ConstantMixin(*args, **kwargs)[source]¶
Bases:
OverloadedType
firedrake.adjoint_utils.dirichletbc module¶
firedrake.adjoint_utils.function module¶
firedrake.adjoint_utils.mesh module¶
- class firedrake.adjoint_utils.mesh.MeshGeometryMixin(*args, **kwargs)[source]¶
Bases:
OverloadedType
firedrake.adjoint_utils.projection module¶
firedrake.adjoint_utils.solving module¶
- firedrake.adjoint_utils.solving.annotate_solve(solve)[source]¶
This solve routine wraps the Firedrake
solve()
call. Its purpose is to annotate the model, recording what solves occur and what forms are involved, so that the adjoint and tangent linear models may be constructed automatically by pyadjoint.To disable the annotation, just pass
annotate=False
to this routine, and it acts exactly like the Firedrake solve call. This is useful in cases where the solve is known to be irrelevant or diagnostic for the purposes of the adjoint computation (such as projecting fields to other function spaces for the purposes of visualisation).The overloaded solve takes optional callback functions to extract adjoint solutions. All of the callback functions follow the same signature, taking a single argument of type Function.
- Keyword Arguments:
adj_cb (
firedrake.function
, optional) – callback function supplying the adjoint solution in the interior. The boundary values are zero.adj_bdy_cb (
firedrake.function
, optional) – callback function supplying the adjoint solution on the boundary. The interior values are not guaranteed to be zero.adj2_cb (
firedrake.function
, optional) – callback function supplying the second-order adjoint solution in the interior. The boundary values are zero.adj2_bdy_cb (
firedrake.function
, optional) – callback function supplying the second-order adjoint solution on the boundary. The interior values are not guaranteed to be zero.ad_block_tag (
string
, optional) – tag used to label the resulting block on the Pyadjoint tape. This is useful for identifying which block is associated with which equation in the forward model.
firedrake.adjoint_utils.variational_solver module¶
Module contents¶
Infrastructure for Firedrake’s adjoint.
This subpackage contains the Firedrake-specific code required to interface with
pyadjoint
. For the public interface to Firedrake’s adjoint, please see
firedrake.adjoint
.