diff --git a/firedrake/adjoint_utils/function.py b/firedrake/adjoint_utils/function.py index 5e87751d36..ed4c73e60a 100644 --- a/firedrake/adjoint_utils/function.py +++ b/firedrake/adjoint_utils/function.py @@ -226,6 +226,7 @@ def _ad_convert_riesz(self, value, options=None): options = {} if options is None else options riesz_representation = options.get("riesz_representation", "L2") solver_options = options.get("solver_options", {}) + mensure_options = options.get("mensure_options", {}) V = options.get("function_space", self.function_space()) if value == 0.: # In adjoint-based differentiation, value == 0. arises only when @@ -243,7 +244,8 @@ def _ad_convert_riesz(self, value, options=None): raise TypeError("Expected a Cofunction") ret = Function(V) - a = self._define_riesz_map_form(riesz_representation, V) + a = self._define_riesz_map_form( + riesz_representation, V, mensure_options) firedrake.solve(a == value, ret, **solver_options) return ret @@ -254,17 +256,18 @@ def _ad_convert_riesz(self, value, options=None): raise ValueError( "Unknown Riesz representation %s" % riesz_representation) - def _define_riesz_map_form(self, riesz_representation, V): + def _define_riesz_map_form(self, riesz_representation, V, mensure_options): from firedrake import TrialFunction, TestFunction u = TrialFunction(V) v = TestFunction(V) if riesz_representation == "L2": - a = firedrake.inner(u, v)*firedrake.dx + a = firedrake.inner(u, v)*firedrake.dx(**mensure_options) elif riesz_representation == "H1": - a = firedrake.inner(u, v)*firedrake.dx \ - + firedrake.inner(firedrake.grad(u), firedrake.grad(v))*firedrake.dx + a = firedrake.inner(u, v)*firedrake.dx(**mensure_options) \ + + firedrake.inner(firedrake.grad(u), firedrake.grad(v) + ) * firedrake.dx(**mensure_options) else: raise NotImplementedError(