From 8f423baaa207d96e62ccb35e83fc0c067c210db0 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Thu, 3 Jun 2004 04:25:20 +0000 Subject: [PATCH] New test. git-svn-id: https://svn.dealii.org/trunk@9367 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/bits/block_sparse_matrix_2.cc | 95 +++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 tests/bits/block_sparse_matrix_2.cc diff --git a/tests/bits/block_sparse_matrix_2.cc b/tests/bits/block_sparse_matrix_2.cc new file mode 100644 index 0000000000..2e2eed21ba --- /dev/null +++ b/tests/bits/block_sparse_matrix_2.cc @@ -0,0 +1,95 @@ +//---------------------------- block_sparse_matrix_2.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2002, 2003, 2004 by the deal.II authors and Brian Carnes +// +// 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_2.cc --------------------------- + +// BlockSparseMatrix::clear used to forget to reset all sizes to zero + +#include "../tests.h" +#include +#include +#include + +#include +#include + +#include +#include + +#include +#include + + + +int main() +{ + std::ofstream logfile("block_sparse_matrix_2.output"); + deallog.attach(logfile); + deallog.depth_console(0); + + Triangulation<2> tria; + GridGenerator::hyper_cube (tria,0,1); + tria.refine_global (1); + + FE_Q_Hierarchical<2> fe (1); + DoFHandler<2> dof_handler (tria); + dof_handler.distribute_dofs (fe); + + BlockSparsityPattern sparsity_pattern; + sparsity_pattern.reinit (2,2); + sparsity_pattern.collect_sizes (); + + sparsity_pattern.block(0,0).reinit (dof_handler.n_dofs(), + dof_handler.n_dofs(), + dof_handler.max_couplings_between_dofs()); + sparsity_pattern.block(0,1).reinit (dof_handler.n_dofs(), + 1, + 1); + sparsity_pattern.block(1,0).reinit (1, + dof_handler.n_dofs(), + dof_handler.n_dofs()); + sparsity_pattern.block(1,1).reinit (1, + 1, + 1); + sparsity_pattern.collect_sizes (); + + DoFTools::make_sparsity_pattern (dof_handler, sparsity_pattern.block(0,0)); + + for (unsigned int j=0; j B; + B.reinit (sparsity_pattern); + + // check some sizes + Assert (B.m() == B.block(0,0).m() + B.block(1,1).m(), + ExcInternalError()); + Assert (B.n() == B.block(0,0).n() + B.block(1,1).n(), + ExcInternalError()); + Assert (B.n_block_rows() == 2, ExcInternalError()); + Assert (B.n_block_cols() == 2, ExcInternalError()); + + // then clear, and check again + B.clear (); + Assert (B.m() == 0, ExcInternalError()); + Assert (B.n() == 0, ExcInternalError()); + Assert (B.n_block_rows() == 0, ExcInternalError()); + Assert (B.n_block_cols() == 0, ExcInternalError()); + + deallog << "OK" << std::endl; + + return 0; +} -- 2.39.5