From 1b5e6484c094ca10f4094628e21371b4f386aa52 Mon Sep 17 00:00:00 2001 From: danshapero Date: Tue, 9 May 2017 19:48:58 -0700 Subject: [PATCH] Added default move operations to ConstraintMatrix --- include/deal.II/lac/constraint_matrix.h | 10 +++++ tests/lac/constraints_move.cc | 52 +++++++++++++++++++++++++ tests/lac/constraints_move.output | 27 +++++++++++++ 3 files changed, 89 insertions(+) create mode 100644 tests/lac/constraints_move.cc create mode 100644 tests/lac/constraints_move.output diff --git a/include/deal.II/lac/constraint_matrix.h b/include/deal.II/lac/constraint_matrix.h index 54504012b4..bea74a52d0 100644 --- a/include/deal.II/lac/constraint_matrix.h +++ b/include/deal.II/lac/constraint_matrix.h @@ -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 index 0000000000..de1fab7fba --- /dev/null +++ b/tests/lac/constraints_move.cc @@ -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 +#include + +#include + +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 index 0000000000..d44670c0ec --- /dev/null +++ b/tests/lac/constraints_move.output @@ -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 -- 2.39.5