From 6aee32dfc2f9c84ba2dca426830565d5ff12be55 Mon Sep 17 00:00:00 2001 From: kanschat Date: Wed, 29 Sep 2010 17:07:58 +0000 Subject: [PATCH] add simplified reinit with row length vector git-svn-id: https://svn.dealii.org/trunk@22195 0785d39b-7218-0410-832d-ea1e28bc413d --- .../lac/include/lac/block_sparsity_pattern.h | 21 +++++++++++++++++-- deal.II/lac/source/block_sparsity_pattern.cc | 16 +++++++++----- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/deal.II/lac/include/lac/block_sparsity_pattern.h b/deal.II/lac/include/lac/block_sparsity_pattern.h index b5a32f7e93..29fbdb146c 100644 --- a/deal.II/lac/include/lac/block_sparsity_pattern.h +++ b/deal.II/lac/include/lac/block_sparsity_pattern.h @@ -73,6 +73,9 @@ namespace TrilinosWrappers * You will in general not want to use this class, but one of the * derived classes. * + * @todo Handle opitmization of diagonal elements of the underlying + * SparsityPattern correctly. + * * @see @ref GlossBlockLA "Block (linear algebra)" * @author Wolfgang Bangerth, 2000, 2001 */ @@ -514,8 +517,22 @@ class BlockSparsityPattern : public BlockSparsityPatternBase * two BlockIndices for the block * structures of matrix rows and * columns as well as a row - * length vector in the format - * produced by DoFTools. + * length vector. + * + * The row length vector should + * be in the format produced by + * DoFTools. Alternatively, there + * is a simplified version, + * where each of the inner + * vectors has length one. Then, + * the corresponding entry is + * used as the maximal row length. + * + * For the diagonal blocks, the + * inner SparsityPattern is + * initialized with optimized + * diagonals, while this is not + * done for the off-diagonal blocks. */ void reinit (const BlockIndices& row_indices, const BlockIndices& col_indices, diff --git a/deal.II/lac/source/block_sparsity_pattern.cc b/deal.II/lac/source/block_sparsity_pattern.cc index 1d3840245f..50e3c59605 100644 --- a/deal.II/lac/source/block_sparsity_pattern.cc +++ b/deal.II/lac/source/block_sparsity_pattern.cc @@ -343,11 +343,17 @@ BlockSparsityPattern::reinit( const unsigned int start = rows.local_to_global(i, 0); const unsigned int length = rows.block_size(i); - VectorSlice > - block_rows(row_lengths[j], start, length); - block(i,j).reinit(rows.block_size(i), - cols.block_size(j), - block_rows); + if (row_lengths[j].size()==1) + block(i,j).reinit(rows.block_size(i), + cols.block_size(j), row_lengths[j][0], i==j); + else + { + VectorSlice > + 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()); -- 2.39.5