Skip to content

Commit

Permalink
Get petsc vec (#3657)
Browse files Browse the repository at this point in the history
* _ad_to_petsc/_ad_from_petsc
  • Loading branch information
Ig-dolci authored Aug 7, 2024
1 parent 5ab86d9 commit c397fd2
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions firedrake/adjoint_utils/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,5 +398,17 @@ def _applyBinary(self, f, y):
npdata[i] = f(npdata[i], npdatay[i])
vec.set_local(npdata)

def _ad_from_petsc(self, vec):
with self.dat.vec_wo as self_v:
vec.copy(result=self_v)

def _ad_to_petsc(self, vec=None):
with self.dat.vec_ro as self_v:
if vec:
self_v.copy(result=vec)
else:
vec = self_v.copy()
return vec

def __deepcopy__(self, memodict={}):
return self.copy(deepcopy=True)

0 comments on commit c397fd2

Please sign in to comment.