From 994fc4ed5fd478c3d1fdf43ee8d86a4ed4e88cbe Mon Sep 17 00:00:00 2001 From: Guido Kanschat Date: Thu, 30 Mar 2006 20:57:45 +0000 Subject: [PATCH] initialization with row_length vector from DoFTools git-svn-id: https://svn.dealii.org/trunk@12782 0785d39b-7218-0410-832d-ea1e28bc413d --- .../lac/include/lac/block_sparsity_pattern.h | 36 +++++++++++++++++-- deal.II/lac/source/block_sparsity_pattern.cc | 31 ++++++++++++++-- 2 files changed, 62 insertions(+), 5 deletions(-) diff --git a/deal.II/lac/include/lac/block_sparsity_pattern.h b/deal.II/lac/include/lac/block_sparsity_pattern.h index f725f68570..1a4613068e 100644 --- a/deal.II/lac/include/lac/block_sparsity_pattern.h +++ b/deal.II/lac/include/lac/block_sparsity_pattern.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 by the deal.II authors +// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -103,7 +103,7 @@ class BlockSparsityPatternBase : public Subscriptor */ BlockSparsityPatternBase (const unsigned int n_block_rows, const unsigned int n_block_columns); - + /** * Copy constructor. This * constructor is only allowed to @@ -437,6 +437,26 @@ class BlockSparsityPattern : public BlockSparsityPatternBase BlockSparsityPattern (const unsigned int n_rows, const unsigned int n_columns); + /** + * Forwarding to + * BlockSparsityPatternBase::reinit(). + */ + void reinit (const unsigned int n_block_rows, + const unsigned int n_block_columns); + + /** + * Initialize the pattern with + * two BlockIndices for the block + * structures of matrix rows and + * columns as well as a row + * length vector in the format + * produced by DoFTools. + */ + void reinit (const BlockIndices& row_indices, + const BlockIndices& col_indices, + const std::vector >& row_lengths); + + /** * Return whether the structure * is compressed or not, @@ -613,4 +633,16 @@ BlockSparsityPatternBase::n_block_rows () const return rows; } + +inline +void +BlockSparsityPattern::reinit ( + const unsigned int n_block_rows, + const unsigned int n_block_columns) +{ + BlockSparsityPatternBase::reinit ( + n_block_rows, n_block_columns); +} + + #endif diff --git a/deal.II/lac/source/block_sparsity_pattern.cc b/deal.II/lac/source/block_sparsity_pattern.cc index 31fd7dff6b..1d0e76e8e4 100644 --- a/deal.II/lac/source/block_sparsity_pattern.cc +++ b/deal.II/lac/source/block_sparsity_pattern.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 by the deal.II authors +// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -11,6 +11,7 @@ // //--------------------------------------------------------------------------- +#include #include #include @@ -244,7 +245,7 @@ BlockSparsityPatternBase::print(std::ostream& out) const unsigned int k=0; for (unsigned int ib=0;ib::print(std::ostream& out) const } out << ']' << std::endl; } - k += block(ib,ib).n_rows(); + k += block(ib,0).n_rows(); } } @@ -297,7 +298,31 @@ BlockSparsityPattern::BlockSparsityPattern (const unsigned int n_rows, {} +void +BlockSparsityPattern::reinit( + const BlockIndices& rows, + const BlockIndices& cols, + const std::vector >& row_lengths) +{ + this->reinit(rows.size(), cols.size()); + for (unsigned int j=0;j > + block_rows(row_lengths[j], start, length); + block(i,j).reinit(rows.block_size(i), + cols.block_size(j), + block_rows); + } + this->collect_sizes(); + Assert (this->row_indices == rows, ExcInternalError()); + Assert (this->column_indices == cols, ExcInternalError()); +} + bool BlockSparsityPattern::is_compressed () const { -- 2.39.5