From e0c5119a779a31c33b1707015805b19fe85bfe19 Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Tue, 8 Aug 2017 17:47:23 -0500 Subject: [PATCH] add a test --- tests/lac/constraints_get_lines.cc | 67 ++++++++++++++++++++++++++ tests/lac/constraints_get_lines.output | 6 +++ 2 files changed, 73 insertions(+) create mode 100644 tests/lac/constraints_get_lines.cc create mode 100644 tests/lac/constraints_get_lines.output diff --git a/tests/lac/constraints_get_lines.cc b/tests/lac/constraints_get_lines.cc new file mode 100644 index 0000000000..20f5ed74b4 --- /dev/null +++ b/tests/lac/constraints_get_lines.cc @@ -0,0 +1,67 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2009 - 2015 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. +// +// --------------------------------------------------------------------- + + + +// test: test the ConstraintMatrix::get_lines() range object + + +#include "../tests.h" +#include + + +void test () +{ + ConstraintMatrix cm; + + // an inhomogeneous constraint + cm.add_line (4); + cm.set_inhomogeneity (4, 3.14159); + + // a homogeneous constraint that is + // constrained to the inhomogeneous one + cm.add_line (1); + cm.add_entry (1, 2, 42.); + cm.add_entry (1, 4, 1.); + + // and a standard homogeneous constraint + cm.add_line (17); + cm.add_entry(17, 6, 2.); + cm.add_entry(17, 15, 3.); + + // a "singular" constraint + cm.add_line (3); + + // now close the constraint matrix + cm.close(); + + for (auto line : cm.get_lines()) + { + deallog << line.index; + for (auto entry : line.entries) + { + deallog << " (" << entry.first << "," << entry.second << ")"; + } + deallog << " - " << line.inhomogeneity << std::endl; + } +} + + +int main () +{ + initlog(); + test(); + deallog << "OK" << std::endl; +} diff --git a/tests/lac/constraints_get_lines.output b/tests/lac/constraints_get_lines.output new file mode 100644 index 0000000000..1b528d20ca --- /dev/null +++ b/tests/lac/constraints_get_lines.output @@ -0,0 +1,6 @@ + +DEAL::1 (2,42.0000) - 3.14159 +DEAL::3 - 0.00000 +DEAL::4 - 3.14159 +DEAL::17 (6,2.00000) (15,3.00000) - 0.00000 +DEAL::OK -- 2.39.5