From: Wolfgang Bangerth Date: Fri, 26 Mar 2004 16:54:56 +0000 (+0000) Subject: New test. X-Git-Tag: v8.0.0~15472 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=14aa0a599bd5c622e6bb47a9e4b749dce5f8939e;p=dealii.git New test. git-svn-id: https://svn.dealii.org/trunk@8876 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/tests/bits/dof_constraints_03.cc b/tests/bits/dof_constraints_03.cc new file mode 100644 index 0000000000..6904e66678 --- /dev/null +++ b/tests/bits/dof_constraints_03.cc @@ -0,0 +1,139 @@ +//---------------------------- dof_constraints_03.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_03.cc --------------------------- + + +// simply check what happens when condensing matrices. 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 + SparsityPattern sparsity (dof_handler.n_dofs(), + dof_handler.n_dofs(), + dof_handler.max_couplings_between_dofs()); + DoFTools::make_sparsity_pattern (dof_handler, sparsity); + constraints.condense (sparsity); + SparseMatrix A(sparsity); + + // then fill the matrix by setting up + // bogus matrix entries + std::vector local_dofs (fe.dofs_per_cell); + FullMatrix local_matrix (fe.dofs_per_cell, fe.dofs_per_cell); + for (typename DoFHandler::active_cell_iterator + cell = dof_handler.begin_active(); + cell != dof_handler.end(); ++cell) + { + cell->get_dof_indices (local_dofs); + local_matrix.clear (); + for (unsigned int i=0; i::const_iterator i=A.begin(); i!=A.end(); ++i) + deallog << i->row() << ' ' << i->column() << ' ' << i->value() + << std::endl; +} + + + +int main () +{ + std::ofstream logfile("dof_constraints_03.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_04.cc b/tests/bits/dof_constraints_04.cc new file mode 100644 index 0000000000..2f610db9d0 --- /dev/null +++ b/tests/bits/dof_constraints_04.cc @@ -0,0 +1,119 @@ +//---------------------------- dof_constraints_04.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_04.cc --------------------------- + + +// simply check what happens when condensing vectors. 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; + + Vector b(dof_handler.n_dofs()); + for (unsigned int i=0; i::const_iterator i=b.begin(); i!=b.end(); ++i) + deallog << *i << std::endl; + + // now also make sure that the elements in + // constrained rows are zero + for (unsigned int i=0; i (); + 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; + }; +}