From 55663284a2b8d406bbb821e6df441d56d1ccf41b Mon Sep 17 00:00:00 2001 From: bangerth Date: Wed, 23 Jan 2008 16:40:04 +0000 Subject: [PATCH] One more testcase in the same direction. git-svn-id: https://svn.dealii.org/trunk@15649 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/deal.II/constraints_zero_condense.cc | 78 +++++++++++++++++++ .../constraints_zero_condense/cmp/generic | 7 ++ 2 files changed, 85 insertions(+) create mode 100644 tests/deal.II/constraints_zero_condense.cc create mode 100644 tests/deal.II/constraints_zero_condense/cmp/generic diff --git a/tests/deal.II/constraints_zero_condense.cc b/tests/deal.II/constraints_zero_condense.cc new file mode 100644 index 0000000000..3a1e303027 --- /dev/null +++ b/tests/deal.II/constraints_zero_condense.cc @@ -0,0 +1,78 @@ +//---------------------------- constraints_zero_condense.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2005, 2006, 2007, 2008 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_zero_condense.cc --------------------------- + + +// generate the constraints for a case where there are nodes that have +// a constraint x[i]=0, i.e. where the right hand side is a trivial +// linear combination of other degrees of freedom. then check that if +// we condense a matrix with this then the right thing happens + + +#include "../tests.h" +#include +#include +#include + +#include + + +void test () +{ + + // constrain each dof to zero. this + // should yield a diagonal matrix + ConstraintMatrix cm; + + for (unsigned int i=0; i<5; ++i) + cm.add_line (i); + cm.close (); + + // completely fill a 5x5 matrix + // with some values + SparsityPattern sp (5,5,5); + for (unsigned int i=0; i<5; ++i) + for (unsigned int j=0; j<5; ++j) + sp.add(i,j); + sp.compress (); + + SparseMatrix m(sp); + for (unsigned int i=0; i<5; ++i) + for (unsigned int j=0; j<5; ++j) + m.set(i,j, i+j+2); + + // now condense it + cm.condense (m); + + // and print it + for (unsigned int i=0; i<5; ++i) + { + for (unsigned int j=0; j<5; ++j) + deallog << m(i,j) << ' '; + deallog << std::endl; + } +} + + +int main () +{ + std::ofstream logfile("constraints_zero_condense/output"); + logfile.precision(2); + + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + test (); + + deallog << "OK" << std::endl; +} diff --git a/tests/deal.II/constraints_zero_condense/cmp/generic b/tests/deal.II/constraints_zero_condense/cmp/generic new file mode 100644 index 0000000000..e808e1b403 --- /dev/null +++ b/tests/deal.II/constraints_zero_condense/cmp/generic @@ -0,0 +1,7 @@ + +DEAL::6.0 0 0 0 0 +DEAL::0 6.0 0 0 0 +DEAL::0 0 6.0 0 0 +DEAL::0 0 0 6.0 0 +DEAL::0 0 0 0 6.0 +DEAL::OK -- 2.39.5