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 OverloadType PETSc.vec #157

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 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
10 changes: 10 additions & 0 deletions pyadjoint/adjfloat.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,16 @@ def _ad_str(self):
"""Return the string of the taped value of this variable."""
return str(self.block_variable.saved_output)

def _ad_petsc_vec_write_only(self):
raise NotImplementedError(
"It requires more thought to write only a PETSc Vec from `AdjFloat`."
)

def _ad_petsc_vec_read_only(self):
raise NotImplementedError(
"It requires more thought to read only a PETSc Vec from `AdjFloat`."
)


_exp = math.exp
_log = math.log
Expand Down
22 changes: 22 additions & 0 deletions pyadjoint/overloaded_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,28 @@ def _ad_str(self):
"""
return str(self)

def _ad_petsc_vec_read_only(self):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I consider adding an optional argument like with_halos? Or does it not make sense?

"""This method should be overwritten by types which can return a PETSc Vec.

The method should implement a routine to return a read only a PETSc Vec object.

Returns:
PETSc.Vec: A PETSc Vec object containing the data of the overloaded.

"""
raise NotImplementedError

def _ad_petsc_vec_write_only(self):
"""This method must be overridden.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

Ig-dolci marked this conversation as resolved.
Show resolved Hide resolved

The method should implement a routine to write only a PETSc Vec object.

Returns:
PETSc.Vec: A PETSc Vec object containing the data of the overloaded.

"""
raise NotImplementedError


class FloatingType(OverloadedType):
def __init__(self, *args, **kwargs):
Expand Down