diff --git a/devito/types/sparse.py b/devito/types/sparse.py index 0ac006c26b7..d2eb1047b99 100644 --- a/devito/types/sparse.py +++ b/devito/types/sparse.py @@ -80,6 +80,16 @@ def __shape_setup__(cls, **kwargs): shape = (glb_npoint[grid.distributor.myrank],) return shape + def func(self, *args, **kwargs): + # Rebuild subfunctions first to avoid new data creation as we have to use `_data` + # as a reconstruction kwargs to avoid the circular dependency + # with the parent in SubFunction + # This is also necessary to avoid shaoe issue in the SubFunction with mpi + for s in self._sub_functions: + if getattr(self, s) is not None: + kwargs.update({s: getattr(self, s).func(*args, **kwargs)}) + return super().func(*args, **kwargs) + def __fd_setup__(self): """ Dynamically add derivative short-cuts. diff --git a/requirements-optional.txt b/requirements-optional.txt index eaff31931bf..b3f80f0d424 100644 --- a/requirements-optional.txt +++ b/requirements-optional.txt @@ -1,5 +1,5 @@ matplotlib pandas -pyrevolve +pyrevolve==2.2.3 scipy distributed \ No newline at end of file