Skip to content

Commit d160c44

Browse files
authored
Merge pull request #22 from pymor/update_assemble_lincomb
Update DealIIMatrixOperator.assemble_lincomb
2 parents 149d9af + 2eb9f73 commit d160c44

File tree

11 files changed

+38
-32
lines changed

11 files changed

+38
-32
lines changed

.ci/common_setup.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ git submodule update --init
1717

1818
python -m venv ~/venv
1919
source ~/venv/bin/activate
20-
python -m pip install -U pip pytest wheel build
20+
python -m pip install -r ./.ci/requirements-ci.txt
2121

2222
python -m pip install git+https://github.com/pymor/pymor.git#egg=pymor

.ci/pytest.bash

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,4 @@ source ${BASE_DIR}/.ci/common_setup.bash
1010
# if we're in a versioned branch pip will downgrade pymor here from pypi
1111
python -m pip install .
1212

13-
cd ${BASE_DIR}/src/
14-
xvfb-run -a pytest -s -r sxX test/demo.py
13+
xvfb-run -a pytest -s -r sxX test/*py

.ci/requirements-ci.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pytest
2+
wheel
3+
build
4+
pytest
5+
pytest-regressions
6+
pandas

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@
22
build
33
CMakeLists.txt.user
44
.idea
5+
.vscode
6+
cache
7+
__pycache__
8+

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,9 @@ Development notes
2121
We have a `pre-commit` config that is also run/checked in CI.
2222
Python source is formatted with `black`.
2323
C++ source is formatted with `clang-format`.
24+
25+
Dependencies for running the test suite can be installed with
26+
27+
```
28+
python -m pip install -r ./.ci/requirements-ci.txt
29+
```

src/pymor_dealii/pymor/operator.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
# License: BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause)
44

55
from pymor.operators.interface import Operator
6-
from pymor.operators.constructions import ZeroOperator
76

87
from pymor_dealii.pymor.vectorarray import DealIIVectorSpace
98
import pymor_dealii_bindings as pd2
@@ -33,7 +32,7 @@ def apply_transpose(self, V, mu=None):
3332
self.matrix.Tvmult(r.impl, u.impl)
3433
return U
3534

36-
def apply_inverse(self, V, mu=None, least_squares=False):
35+
def apply_inverse(self, V, mu=None, initial_guess=None, least_squares=False):
3736
assert V in self.range
3837
if least_squares:
3938
raise NotImplementedError
@@ -42,18 +41,23 @@ def apply_inverse(self, V, mu=None, least_squares=False):
4241
self.matrix.cg_solve(r.impl, v.impl)
4342
return R
4443

45-
def assemble_lincomb(self, operators, coefficients, solver_options=None, name=None):
46-
if not all(
47-
isinstance(op, (DealIIMatrixOperator, ZeroOperator)) for op in operators
48-
):
44+
def _assemble_lincomb(
45+
self,
46+
operators,
47+
coefficients,
48+
identity_shift=0.0,
49+
solver_options=None,
50+
name=None,
51+
):
52+
if not all(isinstance(op, (DealIIMatrixOperator)) for op in operators):
53+
return None
54+
if identity_shift != 0.0:
4955
return None
5056
assert not solver_options # linear solver is not yet configurable
5157

5258
matrix = pd2.SparseMatrix(operators[0].matrix.get_sparsity_pattern())
5359
matrix.copy_from(operators[0].matrix)
5460
matrix *= coefficients[0]
5561
for op, c in zip(operators[1:], coefficients[1:]):
56-
if isinstance(op, ZeroOperator):
57-
continue
5862
matrix.add(c, op.matrix)
5963
return DealIIMatrixOperator(matrix, name=name)

src/test/demo.py

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/test/demo_result.pickle

-6.04 KB
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# License: BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause)
44

55
import numpy as np
6-
import pydealii_bindings as dealii
6+
import pymor_dealii_bindings as dealii
77

88

99
def test_vector():

test/test_demo.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
def test_demo_results(ndarrays_regression):
2+
from pymor_dealii.pymor.demo import run
3+
4+
result, _, _, _ = run(plot_error=False)
5+
6+
compare = ["errors", "basis_sizes", "rel_errors"]
7+
ndarrays_regression.check({k: v for k, v in result.items() if k in compare})

0 commit comments

Comments
 (0)