Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get petsc vec #3657

Merged
merged 11 commits into from
Aug 7, 2024
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)
Loading