]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add initializing constructor to DiagonalMatrix
authorDaniel Arndt <arndtd@ornl.gov>
Fri, 23 Aug 2019 19:15:05 +0000 (19:15 +0000)
committerDaniel Arndt <arndtd@ornl.gov>
Fri, 23 Aug 2019 19:35:04 +0000 (15:35 -0400)
doc/news/changes/minor/20190823DanielArndt [new file with mode: 0644]
include/deal.II/lac/diagonal_matrix.h
tests/lac/diagonal_matrix_02.cc

diff --git a/doc/news/changes/minor/20190823DanielArndt b/doc/news/changes/minor/20190823DanielArndt
new file mode 100644 (file)
index 0000000..05ac246
--- /dev/null
@@ -0,0 +1,4 @@
+New: There is a new constructor for DiagonalMatrix that immediately initializes
+the underlying vector.
+<br>
+(Daniel Arndt, 2019/08/23)
index 48f87eef7b3aaf8e7af6074d065f85b8bf283d4f..86d96250dbdb3c26a452dbdb141cfad12ffdbdec 100644 (file)
@@ -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 <typename VectorType>
+DiagonalMatrix<VectorType>::DiagonalMatrix(const VectorType &vec)
+  : diagonal(vec)
+{}
+
+
+
 template <typename VectorType>
 void
 DiagonalMatrix<VectorType>::clear()
index e34af9249bc23d5688fc8319f97a58eb8122681c..e48b7ce0bda15e548d9c78ce144c85d535c65919 100644 (file)
@@ -100,12 +100,10 @@ test(const bool hanging_nodes = true)
     sparse_matrix.reinit(csp);
   }
 
-  DiagonalMatrix<LinearAlgebra::distributed::Vector<double>> diagonal_matrix;
-  {
-    LinearAlgebra::distributed::Vector<double> dummy;
-    dummy.reinit(owned_set, relevant_set, MPI_COMM_WORLD);
-    diagonal_matrix.reinit(dummy);
-  }
+  DiagonalMatrix<LinearAlgebra::distributed::Vector<double>> diagonal_matrix(
+    LinearAlgebra::distributed::Vector<double>(owned_set,
+                                               relevant_set,
+                                               MPI_COMM_WORLD));
 
   {
     QGauss<dim> quadrature_formula(fe_degree + 1);

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.