Skip to content

Commit

Permalink
Merge pull request #112 from dolfin-adjoint/sanitize_rf_adj_input
Browse files Browse the repository at this point in the history
Sanitize adjoint input of ReducedFunctional
  • Loading branch information
jorgensd authored Sep 13, 2023
2 parents 42959ef + dd7d9bd commit 8e524e4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pyadjoint/reduced_functional.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from .drivers import compute_gradient, compute_hessian
from .enlisting import Enlist
from .tape import get_working_tape, stop_annotating, no_annotations
from .overloaded_type import OverloadedType
from .overloaded_type import OverloadedType, create_overloaded_object


def _get_extract_derivative_components(derivative_components):
Expand Down Expand Up @@ -123,7 +123,9 @@ def derivative(self, adj_input=1.0, options={}):

# Scale adjoint input
with stop_annotating():
adj_value = self.scale * adj_input
# Make sure `adj_input` is an OverloadedType
adj_input = create_overloaded_object(adj_input)
adj_value = adj_input._ad_mul(self.scale)

derivatives = compute_gradient(self.functional,
controls,
Expand Down

0 comments on commit 8e524e4

Please sign in to comment.