From 9efcd48e5ef1af9638498d3a7ec6da08c2e20e5a Mon Sep 17 00:00:00 2001 From: bangerth Date: Sun, 19 Sep 2010 03:40:08 +0000 Subject: [PATCH] New test. git-svn-id: https://svn.dealii.org/trunk@22044 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/deal.II/constraints_merge_02.cc | 95 +++++++++++++++++++ .../deal.II/constraints_merge_02/cmp/generic | 26 +++++ 2 files changed, 121 insertions(+) create mode 100644 tests/deal.II/constraints_merge_02.cc create mode 100644 tests/deal.II/constraints_merge_02/cmp/generic diff --git a/tests/deal.II/constraints_merge_02.cc b/tests/deal.II/constraints_merge_02.cc new file mode 100644 index 0000000000..27b29c4270 --- /dev/null +++ b/tests/deal.II/constraints_merge_02.cc @@ -0,0 +1,95 @@ +//---------------------------- constraints.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2008, 2010 by the deal.II authors +// +// This file is subject to QPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//---------------------------- constraints.cc --------------------------- + + +// merge and print a bunch of ConstrainMatrices. test the case that we +// have inhomogeneities in the constraints + +#include "../tests.h" +#include +#include + +#include +#include + + +std::ofstream logfile("constraints_merge_02/output"); + + +void merge_check () +{ + deallog << "Checking ConstraintMatrix::merge" << std::endl; + + // check twice, once with closed + // objects, once with open ones + for (unsigned int run=0; run<2; ++run) + { + deallog << "Checking with " << (run == 0 ? "open" : "closed") + << " objects" << std::endl; + + // check that the `merge' function + // works correctly + ConstraintMatrix c1, c2; + + // enter simple line + c1.add_line (0); + c1.add_entry (0, 11, 1.); + c1.set_inhomogeneity (0, 42); + + // add more complex line + c1.add_line (1); + c1.add_entry (1, 3, 0.5); + c1.add_entry (1, 4, 0.5); + c1.set_inhomogeneity (1, 100); + + // fill second constraints + // object with one trivial line + // and one which further + // constrains one of the + // entries in the first object + c2.add_line (10); + c2.add_entry (10, 11, 1.); + c2.set_inhomogeneity (10, 142); + + c2.add_line (3); + c2.add_entry (3, 12, 0.25); + c2.add_entry (3, 13, 0.75); + c2.set_inhomogeneity (3, 242); + + // in one of the two runs, + // close the objects + if (run == 1) + { + c1.close (); + c2.close (); + }; + + // now merge the two and print the + // results + c1.merge (c2); + c1.print (logfile); + }; +} + + +int main () +{ + deallog << std::setprecision (2); + logfile << std::setprecision (2); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + merge_check (); +} + diff --git a/tests/deal.II/constraints_merge_02/cmp/generic b/tests/deal.II/constraints_merge_02/cmp/generic new file mode 100644 index 0000000000..42499bd7a4 --- /dev/null +++ b/tests/deal.II/constraints_merge_02/cmp/generic @@ -0,0 +1,26 @@ + +DEAL::Checking ConstraintMatrix::merge +DEAL::Checking with open objects + 0 11: 1.0 + 0: 42. + 1 12: 0.12 + 1 13: 0.38 + 1 4: 0.50 + 1: 2.2e+02 + 10 11: 1.0 + 10: 1.4e+02 + 3 12: 0.25 + 3 13: 0.75 + 3: 2.4e+02 +DEAL::Checking with closed objects + 0 11: 1.0 + 0: 42. + 1 4: 0.50 + 1 12: 0.12 + 1 13: 0.38 + 1: 2.2e+02 + 3 12: 0.25 + 3 13: 0.75 + 3: 2.4e+02 + 10 11: 1.0 + 10: 1.4e+02 -- 2.39.5