Skip to content

Commit

Permalink
Replace BlockMatrix with BlockLinearOperator in projectors and remove…
Browse files Browse the repository at this point in the history
… duplicated __del__ in StencilVector
  • Loading branch information
Florian Holderied committed Feb 24, 2023
1 parent 654f1d9 commit f9a92b8
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 13 deletions.
4 changes: 2 additions & 2 deletions psydac/feec/global_projectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]]])
Expand Down
4 changes: 2 additions & 2 deletions psydac/linalg/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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):
Expand Down
8 changes: 4 additions & 4 deletions psydac/linalg/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 0 additions & 5 deletions psydac/linalg/stencil.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

2 comments on commit f9a92b8

@max-models
Copy link
Contributor

Choose a reason for hiding this comment

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

Once #347 goes through, we need to use BlockLinearOperator

@spossann
Copy link
Collaborator

Choose a reason for hiding this comment

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

Everything else has been fixed already in Psydac.

Please sign in to comment.