]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Added default move operations to ConstraintMatrix 4365/head
authordanshapero <shapero.daniel@gmail.com>
Wed, 10 May 2017 02:48:58 +0000 (19:48 -0700)
committerdanshapero <shapero.daniel@gmail.com>
Wed, 10 May 2017 05:32:40 +0000 (22:32 -0700)
include/deal.II/lac/constraint_matrix.h
tests/lac/constraints_move.cc [new file with mode: 0644]
tests/lac/constraints_move.output [new file with mode: 0644]

index 54504012b453f05af0d3d701b91889e3fe455e2c..bea74a52d00f91f47a7940f37c6a9072f8ef76bc 100644 (file)
@@ -192,6 +192,16 @@ public:
    */
   explicit ConstraintMatrix (const ConstraintMatrix &constraint_matrix);
 
+  /**
+   * Move constructor
+   */
+  ConstraintMatrix (ConstraintMatrix &&constraint_matrix) = default;
+
+  /**
+   * Move assignment operator
+   */
+  ConstraintMatrix &operator= (ConstraintMatrix &&constraint_matrix) = default;
+
   /**
    * clear() the ConstraintMatrix object and supply an IndexSet with lines
    * that may be constrained. This function is only relevant in the
diff --git a/tests/lac/constraints_move.cc b/tests/lac/constraints_move.cc
new file mode 100644 (file)
index 0000000..de1fab7
--- /dev/null
@@ -0,0 +1,52 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2017 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/lac/constraint_matrix.h>
+
+#include <fstream>
+
+int main ()
+{
+  std::ofstream logfile("output");
+  logfile.precision(2);
+
+  deallog.attach(logfile);
+  deallog.threshold_double(1.0e-10);
+
+  ConstraintMatrix constraints;
+  unsigned int IDs[] = {1, 2, 3, 5, 8, 13, 21};
+  double vals[] = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0};
+  for (unsigned int i=0; i < sizeof(IDs) / sizeof(IDs[0]); ++i)
+    {
+      constraints.add_line(IDs[i]);
+      constraints.set_inhomogeneity(IDs[i], vals[i]);
+    }
+
+  constraints.print (deallog.get_file_stream());
+  deallog << std::endl;
+
+  ConstraintMatrix cm(std::move(constraints));
+  cm.print (deallog.get_file_stream());
+  deallog << constraints.n_constraints() << std::endl << std::endl;
+
+  constraints = std::move(cm);
+  constraints.print(deallog.get_file_stream());
+  deallog << cm.n_constraints() << std::endl;
+
+  deallog << "OK" << std::endl;
+}
diff --git a/tests/lac/constraints_move.output b/tests/lac/constraints_move.output
new file mode 100644 (file)
index 0000000..d44670c
--- /dev/null
@@ -0,0 +1,27 @@
+
+    1 = 0.0
+    2 = 1.0
+    3 = 2.0
+    5 = 3.0
+    8 = 4.0
+    13 = 5.0
+    21 = 6.0
+DEAL::
+    1 = 0.0
+    2 = 1.0
+    3 = 2.0
+    5 = 3.0
+    8 = 4.0
+    13 = 5.0
+    21 = 6.0
+DEAL::0
+DEAL::
+    1 = 0.0
+    2 = 1.0
+    3 = 2.0
+    5 = 3.0
+    8 = 4.0
+    13 = 5.0
+    21 = 6.0
+DEAL::0
+DEAL::OK

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.