From f9a92b8abbbb1a5115add492eb21707ce39aa0fa Mon Sep 17 00:00:00 2001 From: Florian Holderied Date: Fri, 24 Feb 2023 16:05:32 +0100 Subject: [PATCH] Replace BlockMatrix with BlockLinearOperator in projectors and remove duplicated __del__ in StencilVector --- psydac/feec/global_projectors.py | 4 ++-- psydac/linalg/basic.py | 4 ++-- psydac/linalg/block.py | 8 ++++---- psydac/linalg/stencil.py | 5 ----- 4 files changed, 8 insertions(+), 13 deletions(-) diff --git a/psydac/feec/global_projectors.py b/psydac/feec/global_projectors.py index cc329b9d4..d8e0db56f 100644 --- a/psydac/feec/global_projectors.py +++ b/psydac/feec/global_projectors.py @@ -4,7 +4,7 @@ from psydac.linalg.kron import KroneckerLinearSolver, KroneckerStencilMatrix from psydac.linalg.stencil import StencilVector, StencilMatrix, StencilVectorSpace -from psydac.linalg.block import BlockDiagonalSolver, BlockVector, BlockMatrix +from psydac.linalg.block import BlockDiagonalSolver, BlockVector, BlockLinearOperator from psydac.core.bsplines import quadrature_grid from psydac.utilities.quadratures import gauss_legendre from psydac.fem.basic import FemField @@ -217,7 +217,7 @@ def __init__(self, space, nquads = None): if isinstance(self.space, TensorFemSpace): self._imat_kronecker = matrixblocks[0] else: - self._imat_kronecker = BlockMatrix(self.space.vector_space, self.space.vector_space, + self._imat_kronecker = BlockLinearOperator(self.space.vector_space, self.space.vector_space, blocks=[[matrixblocks[0], None, None], [None, matrixblocks[1], None], [None, None, matrixblocks[2]]]) diff --git a/psydac/linalg/basic.py b/psydac/linalg/basic.py index 2dc33c008..991bb0559 100644 --- a/psydac/linalg/basic.py +++ b/psydac/linalg/basic.py @@ -645,7 +645,7 @@ def __init__(self, domain, codomain, *args): last = args[-1] if isinstance(last, ComposedLinearOperator): multiplicants = (*multiplicants, *last.multiplicants) - tmp_vectors.extend(last.tmp_vectors[:-1]) + tmp_vectors.extend(last.tmp_vectors) else: multiplicants = (*multiplicants, last) @@ -688,7 +688,7 @@ def transpose(self): new_cod = self._domain assert isinstance(new_dom, VectorSpace) assert isinstance(new_cod, VectorSpace) - print(*t_multiplicants) + #print(*t_multiplicants) return ComposedLinearOperator(self._codomain, self._domain, *t_multiplicants) def dot(self, v, out=None): diff --git a/psydac/linalg/block.py b/psydac/linalg/block.py index 200734f97..2f1fe4a7c 100644 --- a/psydac/linalg/block.py +++ b/psydac/linalg/block.py @@ -1255,13 +1255,13 @@ def set_backend(self, backend): if interface: def func(blocks, v, out, **args): - vs = [vi._interface_data[d_axis, d_ext] for vi in v.blocks] if isinstance(v, BlockVector) else v._data - outs = [outi._data for outi in out.blocks] if isinstance(out, BlockVector) else out._data + vs = [vi._interface_data[d_axis, d_ext] for vi in v.blocks] if isinstance(v, BlockVector) else [v._data] + outs = [outi._data for outi in out.blocks] if isinstance(out, BlockVector) else [out._data] dot(*blocks, *vs, *outs, **args) else: def func(blocks, v, out, **args): - vs = [vi._data for vi in v.blocks] if isinstance(v, BlockVector) else v._data - outs = [outi._data for outi in out.blocks] if isinstance(out, BlockVector) else out._data + vs = [vi._data for vi in v.blocks] if isinstance(v, BlockVector) else [v._data] + outs = [outi._data for outi in out.blocks] if isinstance(out, BlockVector) else [out._data] dot(*blocks, *vs, *outs, **args) self._func = func diff --git a/psydac/linalg/stencil.py b/psydac/linalg/stencil.py index 305657fb1..00db0489c 100644 --- a/psydac/linalg/stencil.py +++ b/psydac/linalg/stencil.py @@ -432,11 +432,6 @@ def __isub__(self, v): self._interface_data[axis, ext] -= v._interface_data[axis, ext] self._sync = v._sync and self._sync return self - - def __del__(self): - if self._requests: - for request in self._requests: - request.Free() #-------------------------------------- # Other properties/methods