Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pyadjoint/optimization/tao_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def to_petsc(self, x, y):
y_i._ad_to_petsc(vec=x_sub)
else:
raise TypeError(f"Unexpected type: {type(y_i)}")
x_sub.restoreSubVector(iset, x_sub)
x.restoreSubVector(iset, x_sub)


def new_control_variable(reduced_functional, *, dual=False):
Expand Down Expand Up @@ -699,9 +699,6 @@ def objective_gradient(tao, x, g):
hessian_mat.getPythonContext().update,
H=hessian_mat, P=Pmat or hessian_mat)

Minv_mat = RieszMapMat(rf.controls, comm=comm)
tao.setGradientNorm(Minv_mat)

if problem.bounds is not None:
lbs = []
ubs = []
Expand All @@ -727,6 +724,9 @@ def objective_gradient(tao, x, g):
if tao.getType() in {PETSc.TAO.Type.LMVM, PETSc.TAO.Type.BLMVM}:
n, N = vec_interface.n, vec_interface.N

Minv_mat = RieszMapMat(rf.controls, comm=comm)
tao.setGradientNorm(Minv_mat)

class InitialHessian:
""":class:`petsc4py.PETSc.Mat` context.
"""
Expand Down