From: Daniel Arndt Date: Fri, 23 Aug 2019 19:15:05 +0000 (+0000) Subject: Add initializing constructor to DiagonalMatrix X-Git-Tag: v9.2.0-rc1~1184^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=65be9996557c30c0f789eccf299e717eb80aac78;p=dealii.git Add initializing constructor to DiagonalMatrix --- diff --git a/doc/news/changes/minor/20190823DanielArndt b/doc/news/changes/minor/20190823DanielArndt new file mode 100644 index 0000000000..05ac2464bd --- /dev/null +++ b/doc/news/changes/minor/20190823DanielArndt @@ -0,0 +1,4 @@ +New: There is a new constructor for DiagonalMatrix that immediately initializes +the underlying vector. +
+(Daniel Arndt, 2019/08/23) diff --git a/include/deal.II/lac/diagonal_matrix.h b/include/deal.II/lac/diagonal_matrix.h index 48f87eef7b..86d96250db 100644 --- a/include/deal.II/lac/diagonal_matrix.h +++ b/include/deal.II/lac/diagonal_matrix.h @@ -52,10 +52,16 @@ public: using size_type = typename VectorType::size_type; /** - * Constructor. + * Default constructor. The object needs still to be reinitialized to be + * usable. */ DiagonalMatrix() = default; + /** + * Constructor immediately initializing the object properly. + */ + explicit DiagonalMatrix(const VectorType &vec); + /** * Initialize with a given vector by copying the content of the vector * @p vec. @@ -215,6 +221,13 @@ private: #ifndef DOXYGEN +template +DiagonalMatrix::DiagonalMatrix(const VectorType &vec) + : diagonal(vec) +{} + + + template void DiagonalMatrix::clear() diff --git a/tests/lac/diagonal_matrix_02.cc b/tests/lac/diagonal_matrix_02.cc index e34af9249b..e48b7ce0bd 100644 --- a/tests/lac/diagonal_matrix_02.cc +++ b/tests/lac/diagonal_matrix_02.cc @@ -100,12 +100,10 @@ test(const bool hanging_nodes = true) sparse_matrix.reinit(csp); } - DiagonalMatrix> diagonal_matrix; - { - LinearAlgebra::distributed::Vector dummy; - dummy.reinit(owned_set, relevant_set, MPI_COMM_WORLD); - diagonal_matrix.reinit(dummy); - } + DiagonalMatrix> diagonal_matrix( + LinearAlgebra::distributed::Vector(owned_set, + relevant_set, + MPI_COMM_WORLD)); { QGauss quadrature_formula(fe_degree + 1);