From: wolf Date: Mon, 29 Mar 2004 22:55:50 +0000 (+0000) Subject: Commit a test that presently fails. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=be81cbe2875da7e30f93a20fc80ea2a3dc5fdcd9;p=dealii-svn.git Commit a test that presently fails. git-svn-id: https://svn.dealii.org/trunk@8909 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/tests/bits/block_sparse_matrix_iterator_01.cc b/tests/bits/block_sparse_matrix_iterator_01.cc new file mode 100644 index 0000000000..8a4178a84f --- /dev/null +++ b/tests/bits/block_sparse_matrix_iterator_01.cc @@ -0,0 +1,128 @@ +//---------------------------- block_sparse_matrix_iterator_01.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. +// +//---------------------------- block_sparse_matrix_iterator_01.cc --------------------------- + + +// this test, extracted from dof_constraints_09, used to fail with aborts + +#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.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(1); + DoFHandler dof_handler (triangulation); + dof_handler.distribute_dofs (fe); + deallog << "Number of dofs: " << dof_handler.n_dofs() << 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]; + + BlockSparsityPattern 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], + dof_handler.max_couplings_between_dofs()); + sparsity.collect_sizes(); + + DoFTools::make_sparsity_pattern (dof_handler, sparsity); + sparsity.compress (); + BlockSparseMatrix A(sparsity); + + // and output what we have. first for the + // individual blocks, and later for all + // together (which yielded an abort) + deallog << "Blockwise output" << std::endl; + for (unsigned int i=0; i<2; ++i) + for (unsigned int j=0; j<2; ++j) + for (SparseMatrix::const_iterator k=A.block(i,j).begin(); + k!=A.block(i,j).end(); ++k) + deallog << i << ' ' << j << ' ' + << k->row() << ' ' << k->column() << ' ' << k->value() + << std::endl; + + deallog << "Global output" << std::endl; + for (BlockSparseMatrix::const_iterator i=A.begin(); i!=A.end(); ++i) + deallog << i->block_row() << ' ' << i->block_column() << ' ' + << i->row() << ' ' << i->column() << ' ' << i->value() + << std::endl; +} + + + +int main () +{ + std::ofstream logfile("block_sparse_matrix_iterator_01.output"); + deallog.attach(logfile); + deallog.depth_console(0); + + try + { + 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; + }; +}