Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion feectools/accelerate/compile_psydac.mk
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ all: $(OUTPUTS)
@for dep in $^ ; do \
echo $$dep ; \
done
pyccel compile -v $(FLAGS)$(FLAGS_openmp) $<
pyccel compile $(FLAGS)$(FLAGS_openmp) $<
@echo ""

#--------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions feectools/api/fem_bilinear_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,9 +594,9 @@ def allocate_matrices(self, backend=None):
if is_conformal:
matrix[k1, k2] = global_mats[k1, k2]
elif use_restriction:
matrix.multiplicants[-1][k1, k2] = global_mats[k1, k2]
matrix.multiplicands[-1][k1, k2] = global_mats[k1, k2]
elif use_prolongation:
matrix.multiplicants[0][k1, k2] = global_mats[k1, k2]
matrix.multiplicands[0][k1, k2] = global_mats[k1, k2]

else: # case of scalar equation
if is_broken: # multi-patch
Expand Down
2 changes: 1 addition & 1 deletion feectools/api/fem_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ def extract_stencil_mats(mats):
if isinstance(M, (StencilInterfaceMatrix, StencilMatrix)):
new_mats.append(M)
elif isinstance(M, ComposedLinearOperator):
new_mats += [i for i in M.multiplicants if isinstance(i, (StencilInterfaceMatrix, StencilMatrix))]
new_mats += [i for i in M.multiplicands if isinstance(i, (StencilInterfaceMatrix, StencilMatrix))]
return new_mats

#==============================================================================
Expand Down
15 changes: 15 additions & 0 deletions feectools/feec/derivatives.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,21 @@ def codomain(self):
def dtype( self ):
return self.domain.dtype

@property
def diffdir(self) -> int:
"""Direction (axis) of the derivative."""
return self._diffdir

@property
def negative(self) -> bool:
"""Whether the operator is the negative derivative."""
return self._negative

@property
def transposed(self) -> bool:
"""Whether the operator is the transposed derivative."""
return self._transposed

def __truediv__(self, a):
""" Divide by scalar. """
return self * (1.0 / a)
Expand Down
44 changes: 26 additions & 18 deletions feectools/linalg/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"""

import itertools
import warnings
from abc import ABC, abstractmethod
from types import LambdaType
from inspect import signature
Expand Down Expand Up @@ -1057,27 +1058,27 @@ def __init__(self, domain, codomain, *args):
for i in range(len(args)-1):
assert args[i].domain == args[i+1].codomain

multiplicants = ()
multiplicands = ()
tmp_vectors = []
for a in args[:-1]:
if isinstance(a, ComposedLinearOperator):
multiplicants = (*multiplicants, *a.multiplicants)
multiplicands = (*multiplicands, *a.multiplicands)
tmp_vectors.extend(a.tmp_vectors)
tmp_vectors.append(a.domain.zeros())
else:
multiplicants = (*multiplicants, a)
multiplicands = (*multiplicands, a)
tmp_vectors.append(a.domain.zeros())

last = args[-1]
if isinstance(last, ComposedLinearOperator):
multiplicants = (*multiplicants, *last.multiplicants)
multiplicands = (*multiplicands, *last.multiplicands)
tmp_vectors.extend(last.tmp_vectors)
else:
multiplicants = (*multiplicants, last)
multiplicands = (*multiplicands, last)

self._domain = domain
self._codomain = codomain
self._multiplicants = multiplicants
self._multiplicands = multiplicands
self._tmp_vectors = tuple(tmp_vectors)

@property
Expand All @@ -1098,34 +1099,41 @@ def codomain(self):
return self._codomain

@property
def multiplicants(self):
def multiplicands(self):
r"""
A tuple $(A_1,\dots,A_n)$ containing the multiplicants of the linear operator
A tuple $(A_1,\dots,A_n)$ containing the multiplicands of the linear operator
$self = A_n\circ\dots\circ A_1$.

"""
return self._multiplicants
return self._multiplicands

@property
def multiplicants(self):
"""Deprecated alias of ``multiplicands``."""
warnings.warn("ComposedLinearOperator.multiplicants is deprecated, use multiplicands instead.",
DeprecationWarning, stacklevel=2)
return self._multiplicands

@property
def dtype(self):
return None

def tosparse(self):
mats = [M.tosparse() for M in self._multiplicants]
mats = [M.tosparse() for M in self._multiplicands]
M = mats[0]
for Mi in mats[1:]:
M = M @ Mi
return coo_matrix(M)

def transpose(self, conjugate=False):
t_multiplicants = ()
for a in self._multiplicants:
t_multiplicants = (a.transpose(conjugate=conjugate), *t_multiplicants)
t_multiplicands = ()
for a in self._multiplicands:
t_multiplicands = (a.transpose(conjugate=conjugate), *t_multiplicands)
new_dom = self.codomain
new_cod = self.domain
assert isinstance(new_dom, VectorSpace)
assert isinstance(new_cod, VectorSpace)
return ComposedLinearOperator(self.codomain, self.domain, *t_multiplicants)
return ComposedLinearOperator(self.codomain, self.domain, *t_multiplicands)

def dot(self, v, out=None):
assert isinstance(v, Vector)
Expand All @@ -1137,11 +1145,11 @@ def dot(self, v, out=None):
x = v
for i in range(len(self._tmp_vectors)):
y = self._tmp_vectors[-1-i]
A = self._multiplicants[-1-i]
A = self._multiplicands[-1-i]
A.dot(x, out=y)
x = y

A = self._multiplicants[0]
A = self._multiplicands[0]
if out is not None:

A.dot(x, out=out)
Expand All @@ -1150,11 +1158,11 @@ def dot(self, v, out=None):
return out

def exchange_assembly_data(self):
for op in self._multiplicants:
for op in self._multiplicands:
op.exchange_assembly_data()

def set_backend(self, backend, precompiled=False):
for op in self._multiplicants:
for op in self._multiplicands:
op.set_backend(backend)

#===============================================================================
Expand Down
Loading
Loading