Skip to content

Commit

Permalink
Convert increment_dat_version to abstract on DataCarrier
Browse files Browse the repository at this point in the history
The inheritance chain for Dat and Global puts VecAccessMixin
(rightly) behind DataCarrier. This means that by MRO, the
increment_dat_version method provided on DataCarrier will be used,
which is a null operation. I think this makes sense, given that not all
classes use this. However, because we're providing
increment_dat_version as an override through VecAccessMixin, we need to
explicitly refer to it in the inheriting classes.
  • Loading branch information
angus-g committed Mar 3, 2025
1 parent 1e37e39 commit bd2f8ad
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions firedrake/preconditioners/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ def _wrapper_cache_key_(self):
def __call__(self, access, map_=None):
return LocalDatLegacyArg(self, map_, access)

def increment_dat_version(self):
pass


register_petsc_function("MatSetValues")

Expand Down
6 changes: 6 additions & 0 deletions pyop2/types/dat.py
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,9 @@ def __init__(self, dat, index):
dtype=dat.dtype,
name="view[%s](%s)" % (index, dat.name))

def increment_dat_version(self):
pass

@utils.cached_property
def _kernel_args_(self):
return self._parent._kernel_args_
Expand Down Expand Up @@ -841,6 +844,9 @@ def vec_context(self, access):
if access is not Access.READ:
self.halo_valid = False

def increment_dat_version(self):
VecAccessMixin.increment_dat_version(self)


class MixedDat(AbstractDat, VecAccessMixin):
r"""A container for a bag of :class:`Dat`\s.
Expand Down
1 change: 1 addition & 0 deletions pyop2/types/data_carrier.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def cdim(self):
the product of the dim tuple."""
return self._cdim

@abc.abstractmethod
def increment_dat_version(self):
pass

Expand Down
6 changes: 6 additions & 0 deletions pyop2/types/glob.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,9 @@ def vec_context(self, access):
data = self._data
self.comm.Bcast(data, 0)

def increment_dat_version(self):
VecAccessMixin.increment_dat_version(self)


# has no comm, can only be READ
class Constant(SetFreeDataCarrier):
Expand Down Expand Up @@ -464,3 +467,6 @@ def duplicate(self):
dtype=self.dtype,
name=self.name
)

def increment_dat_version(self):
pass
3 changes: 3 additions & 0 deletions pyop2/types/mat.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,9 @@ def __repr__(self):
return "Mat(%r, %r, %r)" \
% (self._sparsity, self._datatype, self._name)

def increment_dat_version(self):
pass


class Mat(AbstractMat):
"""OP2 matrix data. A Mat is defined on a sparsity pattern and holds a value
Expand Down

0 comments on commit bd2f8ad

Please sign in to comment.