Skip to content
Snippets Groups Projects
Commit 7e464f73 authored by oliver.sander_at_tu-dresden.de's avatar oliver.sander_at_tu-dresden.de
Browse files

Merge branch 'umfpacksolver-with-scalar-matrix-entries' into 'master'

Implement addToDiagonal for scalars (interpreted as 1x1 matrices)

See merge request agnumpde/dune-matrix-vector!12
parents 7bbb4d31 b92e8adc
No related branches found
No related tags found
No related merge requests found
...@@ -9,6 +9,6 @@ dune:git gcc-8 C++17: ...@@ -9,6 +9,6 @@ dune:git gcc-8 C++17:
image: registry.dune-project.org/docker/ci/dune:git-debian-10-gcc-8-17 image: registry.dune-project.org/docker/ci/dune:git-debian-10-gcc-8-17
script: duneci-standard-test script: duneci-standard-test
dune:git gcc-6 C++14: dune:git gcc-9 C++20:
image: registry.dune-project.org/docker/ci/dune:git-debian-9-gcc-6-14 image: registry.dune-project.org/docker/ci/dune:git-debian-11-gcc-9-20
script: duneci-standard-test script: duneci-standard-test
# Master (will become release 2.8) # Master (will become release 2.8)
- ... - The method `addToDiagonal` can now also be called if the matrix is a scalar number type.
This is needed since nowadays scalar entries can end the nesting recursion of dune-istl
matrices.
## Deprecations and removals ## Deprecations and removals
......
...@@ -11,6 +11,14 @@ namespace MatrixVector { ...@@ -11,6 +11,14 @@ namespace MatrixVector {
x[i][i] += a; x[i][i] += a;
} }
/** \brief Specialization for scalars (to be interpreted as 1x1 matrices) */
template <class Matrix>
static void addToDiagonal(Matrix& x, const Matrix& a)
{
static_assert(IsNumber<Matrix>::value, "Only scalars can be treated both as matrix and as number!");
x += a;
}
/* /*
the line the line
......
...@@ -77,7 +77,7 @@ bool checkResize() { ...@@ -77,7 +77,7 @@ bool checkResize() {
FV fv; FV fv;
resize(fv, Dune::FieldVector<int, 5>()); resize(fv, Dune::FieldVector<int, 5>());
return false; return false;
} catch (Dune::Exception) { } catch (Dune::Exception&) {
// TODO make sure the right exception is thrown // TODO make sure the right exception is thrown
} }
...@@ -116,9 +116,9 @@ bool checkResize() { ...@@ -116,9 +116,9 @@ bool checkResize() {
// test "unnatural" matrix types // test "unnatural" matrix types
// TODO // TODO
} catch (Dune::Exception e) { } catch (Dune::Exception& e) {
std::cout << "FAILURE." << std::endl; std::cout << "FAILURE." << std::endl;
std::cout << e << std::endl; std::cout << e.what() << std::endl;
return false; return false;
} }
......
...@@ -35,6 +35,16 @@ private: ...@@ -35,6 +35,16 @@ private:
// SQUARE MATRICES // SQUARE MATRICES
// scalars
{
FieldType scalarMatrix_x = 1,
scalarMatrix_check = 4;
addToDiagonal(scalarMatrix_x, scalar_a);
passed = passed and
myDiff(scalarMatrix_x, scalarMatrix_check) < 1e-12;
}
// case FM // case FM
{ {
Dune::FieldMatrix<FieldType, 2, 2> squareFieldMatrix_x = {{1, 2}, {3, 4}}, Dune::FieldMatrix<FieldType, 2, 2> squareFieldMatrix_x = {{1, 2}, {3, 4}},
......
...@@ -37,7 +37,7 @@ namespace MatrixVector { ...@@ -37,7 +37,7 @@ namespace MatrixVector {
// Note: We could drop the check for ignore nodes here bcs. b[j] will // Note: We could drop the check for ignore nodes here bcs. b[j] will
// be ignored anyway due to the check above. // be ignored anyway due to the check above.
if (ignore == nullptr or (*ignore)[j].none()) if (ignore == nullptr or (*ignore)[j].none())
b[j] -= x[i] * *cIt; cIt->mmv(x[i], b[j]);
} }
} }
} else { } else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment