From: Guido Kanschat Date: Fri, 18 Nov 2005 20:59:39 +0000 (+0000) Subject: development of MGTransferBlock continued X-Git-Tag: v8.0.0~12862 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5468e314733cf82ff6accc78672de61e0533e147;p=dealii.git development of MGTransferBlock continued git-svn-id: https://svn.dealii.org/trunk@11773 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/include/multigrid/mg_transfer.h b/deal.II/deal.II/include/multigrid/mg_transfer.h index f1da850a8b..b39a342e53 100644 --- a/deal.II/deal.II/include/multigrid/mg_transfer.h +++ b/deal.II/deal.II/include/multigrid/mg_transfer.h @@ -23,9 +23,13 @@ # include # include #endif +#include + #include #include + + #include #include @@ -314,7 +318,7 @@ class MGTransferBlockBase * all levels. */ std::vector > mg_component_start; - + /** * Call build_matrices() * function first. @@ -388,11 +392,25 @@ class MGTransferBlock : public MGTransferBase >, private MGTransferBlockBase { public: + /** + * Default constructor. + */ + MGTransferBlock(); + /** * Destructor. */ virtual ~MGTransferBlock (); + /** + * Initialize additional #factors + * and #memory if the restriction + * of the components is to be + * weighted differently. + */ + void initialize (const std::vector& factors, + VectorMemory >& memory); + /** * Build the prolongation * matrices for each level. @@ -401,12 +419,6 @@ class MGTransferBlock : public MGTransferBase >, * for the same function in * MGTransferBlockBase. * - * @arg selected: Opional - * argument indicating that only - * matrices for these components - * are to be built. By default, - * all matrices are built. - * * If mg_target_component is * present, this refers to the * renumbered components. @@ -428,7 +440,6 @@ class MGTransferBlock : public MGTransferBase >, template void build_matrices (const DoFHandler &dof, const MGDoFHandler &mg_dof, - std::vector selected = std::vector(), const std::vector& target_component = std::vector(), const std::vector& mg_target_component @@ -556,6 +567,21 @@ class MGTransferBlock : public MGTransferBase >, MGLevelObject > &dst, const InVector &src, const is_1d &) const; + + /** + * Optional multiplication + * factors for each + * component. Requires + * initialization of #memory. + */ + std::vector factors; + + /** + * Memory pool required if + * additional multiplication + * using #factors is desired. + */ + SmartPointer > > memory; }; diff --git a/deal.II/deal.II/source/multigrid/mg_transfer_block.cc b/deal.II/deal.II/source/multigrid/mg_transfer_block.cc index aba3ca141d..c4bb55cea6 100644 --- a/deal.II/deal.II/source/multigrid/mg_transfer_block.cc +++ b/deal.II/deal.II/source/multigrid/mg_transfer_block.cc @@ -336,12 +336,11 @@ template void MGTransferBlock::build_matrices ( const DoFHandler &dof, const MGDoFHandler &mg_dof, - std::vector select, const std::vector& t_component, const std::vector& mg_t_component) { -//TODO:[GK] What about selected? - mg_selected = select; + if (selected.size() == 0) + selected = std::vector (mg_dof.get_fe().n_components(), true); if (mg_selected.size() == 0) mg_selected = std::vector (mg_dof.get_fe().n_components(), true); @@ -445,7 +444,6 @@ template void MGTransferBlock::build_matrices (const DoFHandler &, const MGDoFHandler &, - std::vector, const std::vector&, const std::vector&); @@ -461,7 +459,6 @@ template void MGTransferBlock::build_matrices (const DoFHandler &, const MGDoFHandler &, - std::vector, const std::vector&, const std::vector&); diff --git a/deal.II/deal.II/source/multigrid/multigrid.all_dimensions.cc b/deal.II/deal.II/source/multigrid/multigrid.all_dimensions.cc index c7d73a3680..27aeee3645 100644 --- a/deal.II/deal.II/source/multigrid/multigrid.all_dimensions.cc +++ b/deal.II/deal.II/source/multigrid/multigrid.all_dimensions.cc @@ -21,8 +21,6 @@ #include #include - - // Warning: the following function is for debugging purposes only. It // will be compiled only, if the additional and undocumented compiler // flag MG_DEBUG is set. Furthermore, as soon as this function is @@ -133,10 +131,29 @@ void MGTransferPrebuilt::restrict_and_add ( template -MGTransferBlock::~MGTransferBlock () +MGTransferBlock::MGTransferBlock () + : + memory(0, typeid(*this).name()) {} +template +MGTransferBlock::~MGTransferBlock () +{ + if (memory != 0) memory = 0; +} + + +template +void +MGTransferBlock::initialize (const std::vector& f, + VectorMemory >& mem) +{ + factors = f; + memory = &mem; +} + + template void MGTransferBlock::prolongate ( const unsigned int to_level, @@ -171,7 +188,20 @@ void MGTransferBlock::restrict_and_add ( { if (!selected[k]) ++k; - prolongation_matrices[from_level-1]->block(k,k).Tvmult_add (dst.block(b), src.block(b)); + if (factors.size() != 0) + { + Assert (memory != 0, ExcNotInitialized()); + Vector* aux = memory->alloc(); + aux->reinit(dst.block(b)); + prolongation_matrices[from_level-1]->block(k,k).Tvmult (*aux, src.block(b)); + dst.block(b).add(factors[k], *aux); + memory->free(aux); + } + else + { + prolongation_matrices[from_level-1]->block(k,k).Tvmult_add (dst.block(b), + src.block(b)); + } ++k; } }