From 7ae21f45d06b89c4c3f870e9eefbaf78b35ae2f3 Mon Sep 17 00:00:00 2001 From: kanschat Date: Mon, 26 Sep 2011 15:26:36 +0000 Subject: [PATCH] BlockList obsolete git-svn-id: https://svn.dealii.org/trunk@24429 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/doc/news/changes.h | 6 +++ deal.II/include/deal.II/lac/block_list.h | 37 ++++++++++++++++++- .../include/deal.II/lac/relaxation_block.h | 2 +- .../deal.II/lac/relaxation_block.templates.h | 24 ++++++------ 4 files changed, 55 insertions(+), 14 deletions(-) diff --git a/deal.II/doc/news/changes.h b/deal.II/doc/news/changes.h index de6bdb9ecc..e030ab9e50 100644 --- a/deal.II/doc/news/changes.h +++ b/deal.II/doc/news/changes.h @@ -325,6 +325,12 @@ and DoF handlers embedded in higher dimensional space have been added.
    +
  1. Improved: The class BlockList used in RelaxationBlock has been replaced +by SparsityPattern, since it only reproduced its functionality. +
    +(Guido Kanschat, 2011/09/26) + +
  2. New: SparsityPattern::row_position() finds a column index in a row and returns its "local" index or numbers::invalid_unsigned_int.
    diff --git a/deal.II/include/deal.II/lac/block_list.h b/deal.II/include/deal.II/lac/block_list.h index 203e5549aa..65511f7ac4 100644 --- a/deal.II/include/deal.II/lac/block_list.h +++ b/deal.II/include/deal.II/lac/block_list.h @@ -15,6 +15,7 @@ #include #include +#include #include #include @@ -22,8 +23,8 @@ DEAL_II_NAMESPACE_OPEN /** - * @warning This class is still experimental and will most likely be - * changed in a future release. + * @deprecated This class is experimental and will be + * removed in a future release. * * A vector of index sets listing the indices of small blocks of a * linear system. For each block, the indices in that block are @@ -52,6 +53,20 @@ class BlockList : /// The iterator for individual indices typedef block_container::const_iterator const_iterator; + /** + * Since SparsityPattern can + * handle the tasks of BlockList, + * this function allows us to + * create one from an already + * filled BlockList. A first step + * to make BlockList obsolete. + * + * The additional integer + * argument is the dimension of + * the vector space. + */ + void create_sparsity_pattern(SparsityPattern& sparsity, unsigned int n) const; + /** * Add the indices in * indices to block @@ -271,6 +286,24 @@ class BlockList : }; +inline +void +BlockList::create_sparsity_pattern(SparsityPattern& sparsity, unsigned int n) const +{ + std::vector sizes(size()); + for (unsigned int b=0;b& indices) diff --git a/deal.II/include/deal.II/lac/relaxation_block.h b/deal.II/include/deal.II/lac/relaxation_block.h index d27a5e5fa1..07d6c238b7 100644 --- a/deal.II/include/deal.II/lac/relaxation_block.h +++ b/deal.II/include/deal.II/lac/relaxation_block.h @@ -96,7 +96,7 @@ class RelaxationBlock : * The mapping from indices * to blocks. */ - BlockList block_list; + SparsityPattern block_list; /** * Relaxation parameter. diff --git a/deal.II/include/deal.II/lac/relaxation_block.templates.h b/deal.II/include/deal.II/lac/relaxation_block.templates.h index 1e1bf43058..65f779280c 100644 --- a/deal.II/include/deal.II/lac/relaxation_block.templates.h +++ b/deal.II/include/deal.II/lac/relaxation_block.templates.h @@ -41,13 +41,14 @@ RelaxationBlock::AdditionalData::AdditionalData ( const bool invert_diagonal, const bool same_diagonal) : - block_list(bl), relaxation(relaxation), invert_diagonal(invert_diagonal), same_diagonal(same_diagonal), inversion(PreconditionBlockBase::gauss_jordan), threshold(0.) -{} +{ + bl.create_sparsity_pattern(block_list, 0); +} template @@ -65,7 +66,7 @@ RelaxationBlock::initialize ( additional_data = ¶meters; this->inversion = parameters.inversion; - this->reinit(additional_data->block_list.size(), 0, additional_data->same_diagonal, + this->reinit(additional_data->block_list.n_rows(), 0, additional_data->same_diagonal, additional_data->inversion); if (additional_data->invert_diagonal) @@ -97,15 +98,16 @@ RelaxationBlock::invert_diagblocks () } else { - for (unsigned int block=0;blockblock_list.size();++block) + for (unsigned int block=0;blockblock_list.n_rows();++block) { - const unsigned int bs = additional_data->block_list.block_size(block); + const unsigned int bs = additional_data->block_list.row_length(block); M_cell.reinit(bs, bs); // Copy rows for this block // into the matrix for the // diagonal block - BlockList::const_iterator row = additional_data->block_list.begin(block); + SparsityPattern::row_iterator row + = additional_data->block_list.row_begin(block); for (unsigned int row_cell=0; row_cell::invert_diagblocks () entry != M.end(*row); ++entry) { const unsigned int column = entry->column(); - const unsigned int col_cell = additional_data->block_list.local_index(block, column); + const unsigned int col_cell = additional_data->block_list.row_position(block, column); if (col_cell != numbers::invalid_unsigned_int) M_cell(row_cell, col_cell) = entry->value(); } @@ -168,7 +170,7 @@ RelaxationBlock::do_step ( const bool permutation_empty = additional_data->order.size() == 0; const unsigned int n_permutations = (permutation_empty) ? 1U : additional_data->order.size(); - const unsigned int n_blocks = additional_data->block_list.size(); + const unsigned int n_blocks = additional_data->block_list.n_rows(); if (!permutation_empty) for (unsigned int i=0;iorder.size();++i) @@ -185,12 +187,12 @@ RelaxationBlock::do_step ( ? (additional_data->order[n_permutations-1-perm][raw_block]) : (additional_data->order[perm][raw_block])); - const unsigned int bs = additional_data->block_list.block_size(block); + const unsigned int bs = additional_data->block_list.row_length(block); b_cell.reinit(bs); x_cell.reinit(bs); // Collect off-diagonal parts - BlockList::const_iterator row = additional_data->block_list.begin(block); + SparsityPattern::row_iterator row = additional_data->block_list.row_begin(block); for (unsigned int row_cell=0; row_cell::do_step ( // Apply inverse diagonal this->inverse_vmult(block, x_cell, b_cell); // Store in result vector - row=additional_data->block_list.begin(block); + row=additional_data->block_list.row_begin(block); for (unsigned int row_cell=0; row_cellrelaxation * x_cell(row_cell); } -- 2.39.5