From 784bdfc8dc9f7d40f57799ed63d1dc58add9ca78 Mon Sep 17 00:00:00 2001 From: wolf Date: Thu, 1 Apr 2004 15:26:10 +0000 Subject: [PATCH] New tests. git-svn-id: https://svn.dealii.org/trunk@8942 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/bits/dof_constraints_10.cc | 116 ++++++++++++++++++++++++++++ tests/bits/dof_constraints_11.cc | 128 +++++++++++++++++++++++++++++++ 2 files changed, 244 insertions(+) create mode 100644 tests/bits/dof_constraints_10.cc create mode 100644 tests/bits/dof_constraints_11.cc diff --git a/tests/bits/dof_constraints_10.cc b/tests/bits/dof_constraints_10.cc new file mode 100644 index 0000000000..1c4acea19a --- /dev/null +++ b/tests/bits/dof_constraints_10.cc @@ -0,0 +1,116 @@ +//---------------------------- dof_constraints_10.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2004 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. +// +//---------------------------- dof_constraints_10.cc --------------------------- + + +// simply check what happens when condensing compressed sparsity +// patterns. This test was written when I changed a few things in the +// algorithm. + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +template +void test () +{ + deallog << dim << "D" << std::endl; + + Triangulation triangulation; + GridGenerator::hyper_cube (triangulation); + + // refine once, then refine first cell to + // create hanging nodes + triangulation.refine_global (1); + triangulation.begin_active()->set_refine_flag (); + triangulation.execute_coarsening_and_refinement (); + deallog << "Number of cells: " << triangulation.n_active_cells() << std::endl; + + // set up a DoFHandler and compute hanging + // node constraints for a Q2 element + FE_Q fe(2); + DoFHandler dof_handler (triangulation); + dof_handler.distribute_dofs (fe); + deallog << "Number of dofs: " << dof_handler.n_dofs() << std::endl; + + ConstraintMatrix constraints; + DoFTools::make_hanging_node_constraints (dof_handler, constraints); + constraints.close (); + deallog << "Number of constraints: " << constraints.n_constraints() << std::endl; + + // then set up a sparsity pattern and a + // matrix on top of it + CompressedSparsityPattern sparsity (dof_handler.n_dofs(), + dof_handler.n_dofs()); + DoFTools::make_sparsity_pattern (dof_handler, sparsity); + constraints.condense (sparsity); + + // and output what we have + SparsityPattern A; + A.copy_from (sparsity); + for (SparsityPattern::const_iterator i=A.begin(); i!=A.end(); ++i) + deallog << i->row() << ' ' << i->column() + << std::endl; +} + + + +int main () +{ + std::ofstream logfile("dof_constraints_10.output"); + deallog.attach(logfile); + deallog.depth_console(0); + + try + { + test<1> (); + test<2> (); + test<3> (); + } + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/bits/dof_constraints_11.cc b/tests/bits/dof_constraints_11.cc new file mode 100644 index 0000000000..c50ae1267e --- /dev/null +++ b/tests/bits/dof_constraints_11.cc @@ -0,0 +1,128 @@ +//---------------------------- dof_constraints_11.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2004 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. +// +//---------------------------- dof_constraints_11.cc --------------------------- + + +// simply check what happens when condensing compressed block sparsity +// patterns. This test was written when I changed a few things in the +// algorithm. + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +template +void test () +{ + deallog << dim << "D" << std::endl; + + Triangulation triangulation; + GridGenerator::hyper_cube (triangulation); + + // refine once, then refine first cell to + // create hanging nodes + triangulation.refine_global (1); + triangulation.begin_active()->set_refine_flag (); + triangulation.execute_coarsening_and_refinement (); + deallog << "Number of cells: " << triangulation.n_active_cells() << std::endl; + + // set up a DoFHandler and compute hanging + // node constraints for a Q2 element + FE_Q fe(2); + DoFHandler dof_handler (triangulation); + dof_handler.distribute_dofs (fe); + deallog << "Number of dofs: " << dof_handler.n_dofs() << std::endl; + + ConstraintMatrix constraints; + DoFTools::make_hanging_node_constraints (dof_handler, constraints); + constraints.close (); + deallog << "Number of constraints: " << constraints.n_constraints() << std::endl; + + // then set up a sparsity pattern and a + // matrix on top of it + std::vector block_sizes(2); + block_sizes[0] = dof_handler.n_dofs()/3; + block_sizes[1] = dof_handler.n_dofs() - block_sizes[0]; + + CompressedBlockSparsityPattern sparsity(2,2); + for (unsigned int i=0; i<2; ++i) + for (unsigned int j=0; j<2; ++j) + sparsity.block(i,j).reinit (block_sizes[i], block_sizes[j]); + sparsity.collect_sizes(); + + DoFTools::make_sparsity_pattern (dof_handler, sparsity); + constraints.condense (sparsity); + + // and output what we have + BlockSparsityPattern A; + A.copy_from (sparsity); + for (unsigned int r=0; rrow() << ' ' << i->column() + << std::endl; +} + + + +int main () +{ + std::ofstream logfile("dof_constraints_11.output"); + deallog.attach(logfile); + deallog.depth_console(0); + + try + { + test<1> (); + test<2> (); + test<3> (); + } + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} -- 2.39.5