Skip to content

Commit

Permalink
ConstantAssignBlock.solve_tlm tidying
Browse files Browse the repository at this point in the history
  • Loading branch information
jrmaddison committed Jul 12, 2024
1 parent 7beba3b commit ad7214d
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions firedrake/adjoint_utils/blocks/constant.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,21 @@ def evaluate_tlm_component(self, inputs, tlm_inputs, block_variable, idx,
return constant_from_values(block_variable.output, values)

def solve_tlm(self):
x, = self.get_outputs()
if len(x.output.ufl_shape) == 0:
x.tlm_value = firedrake.Constant(0.0)
else:
x.tlm_value = firedrake.Constant(
numpy.reshape(numpy.zeros_like(x.output.values()), x.output.ufl_shape))
if self.assigned_list:
# Not reachable?
raise NotImplementedError

x, = self.get_outputs()
dep, = self.get_dependencies()
if dep.tlm_value is None:
x.tlm_value = None
else:
dep, = self.get_dependencies()
if dep.tlm_value is not None:
x.tlm_value.assign(dep.tlm_value)
if len(x.output.ufl_shape) == 0:
x.tlm_value = firedrake.Constant(0.0)
else:
x.tlm_value = firedrake.Constant(
numpy.reshape(numpy.zeros_like(x.output.values()), x.output.ufl_shape))
x.tlm_value.assign(dep.tlm_value)

def prepare_evaluate_hessian(self, inputs, hessian_inputs, adj_inputs,
relevant_dependencies):
Expand Down

0 comments on commit ad7214d

Please sign in to comment.