From: kanschat Date: Fri, 17 Jun 2011 21:41:21 +0000 (+0000) Subject: push block list into AdditionalData X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5ff48cd1d3b58186ae7f45a5a22808c47d8b98ac;p=dealii-svn.git push block list into AdditionalData git-svn-id: https://svn.dealii.org/trunk@23838 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/include/deal.II/lac/relaxation_block.h b/deal.II/include/deal.II/lac/relaxation_block.h index d89f38d100..15726a3cce 100644 --- a/deal.II/include/deal.II/lac/relaxation_block.h +++ b/deal.II/include/deal.II/lac/relaxation_block.h @@ -68,7 +68,7 @@ class RelaxationBlock : * Parameters for block * relaxation methods. */ - class AdditionalData + class AdditionalData : public Subscriptor { public: /** @@ -79,16 +79,30 @@ class RelaxationBlock : /** * Constructor. */ + AdditionalData (const double relaxation = 1., + const bool invert_diagonal = true, + const bool same_diagonal = false); + + /** + * @deprecated Since the + * BlockList is now a data + * member of this class, it + * is not recommended anymore + * to generate it independently. + * + * Constructor. + */ AdditionalData (const BlockList& block_list, const double relaxation = 1., const bool invert_diagonal = true, const bool same_diagonal = false); + /** - * Pointer to the DoFHandler - * providing the cells. + * The mapping from indices + * to blocks. */ - SmartPointer::AdditionalData> block_list; + BlockList block_list; /** * Relaxation parameter. @@ -137,7 +151,7 @@ class RelaxationBlock : * may be provided. */ void initialize (const MATRIX& A, - const AdditionalData parameters); + const AdditionalData& parameters); /** * Deletes the inverse diagonal @@ -229,7 +243,7 @@ class RelaxationBlock : /** * Control information. */ - AdditionalData additional_data; + SmartPointer > additional_data; }; 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 1ede67e156..791fbb2da6 100644 --- a/deal.II/include/deal.II/lac/relaxation_block.templates.h +++ b/deal.II/include/deal.II/lac/relaxation_block.templates.h @@ -31,6 +31,21 @@ RelaxationBlock::AdditionalData::AdditionalData () {} +template +inline +RelaxationBlock::AdditionalData::AdditionalData ( + const double relaxation, + const bool invert_diagonal, + const bool same_diagonal) + : + relaxation(relaxation), + invert_diagonal(invert_diagonal), + same_diagonal(same_diagonal), + inversion(PreconditionBlockBase::gauss_jordan), + threshold(0.) +{} + + template inline RelaxationBlock::AdditionalData::AdditionalData ( @@ -39,7 +54,7 @@ RelaxationBlock::AdditionalData::AdditionalData ( const bool invert_diagonal, const bool same_diagonal) : - block_list(&bl), + block_list(bl), relaxation(relaxation), invert_diagonal(invert_diagonal), same_diagonal(same_diagonal), @@ -53,19 +68,19 @@ inline void RelaxationBlock::initialize ( const MATRIX& M, - const AdditionalData parameters) + const AdditionalData& parameters) { Assert (parameters.invert_diagonal, ExcNotImplemented()); - + clear(); // Assert (M.m() == M.n(), ExcNotQuadratic()); A = &M; - additional_data = parameters; - - this->reinit(additional_data.block_list->size(), 0, additional_data.same_diagonal, - additional_data.inversion); - - if (parameters.invert_diagonal) + additional_data = ¶meters; + + this->reinit(additional_data->block_list.size(), 0, additional_data->same_diagonal, + additional_data->inversion); + + if (additional_data->invert_diagonal) invert_diagblocks(); } @@ -76,7 +91,6 @@ void RelaxationBlock::clear () { A = 0; - additional_data.block_list = 0; PreconditionBlockBase::clear (); } @@ -95,15 +109,15 @@ RelaxationBlock::invert_diagblocks () } else { - for (unsigned int block=0;blocksize();++block) + for (unsigned int block=0;blockblock_list.size();++block) { - const unsigned int bs = additional_data.block_list->block_size(block); + const unsigned int bs = additional_data->block_list.block_size(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); + BlockList::const_iterator row = additional_data->block_list.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.local_index(block, column); if (col_cell != numbers::invalid_unsigned_int) M_cell(row_cell, col_cell) = entry->value(); } @@ -137,7 +151,7 @@ RelaxationBlock::invert_diagblocks () case PreconditionBlockBase::svd: this->inverse_svd(block).reinit(bs, bs); this->inverse_svd(block) = M_cell; - this->inverse_svd(block).compute_inverse_svd(additional_data.threshold); + this->inverse_svd(block).compute_inverse_svd(additional_data->threshold); break; default: Assert(false, ExcNotImplemented()); @@ -158,21 +172,21 @@ RelaxationBlock::do_step ( const Vector &src, const bool backward) const { - Assert (additional_data.invert_diagonal, ExcNotImplemented()); + Assert (additional_data->invert_diagonal, ExcNotImplemented()); const MATRIX &M=*this->A; Vector b_cell, x_cell; - const unsigned int n_blocks = additional_data.block_list->size(); + const unsigned int n_blocks = additional_data->block_list.size(); for (unsigned int bi=0;biblock_size(block); + const unsigned int bs = additional_data->block_list.block_size(block); b_cell.reinit(bs); x_cell.reinit(bs); // Collect off-diagonal parts - BlockList::const_iterator row = additional_data.block_list->begin(block); + BlockList::const_iterator row = additional_data->block_list.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.begin(block); for (unsigned int row_cell=0; row_cellrelaxation * x_cell(row_cell); } }