From 1c286d8e7879b777ffe4fda0a58652cdeb46146b Mon Sep 17 00:00:00 2001 From: janssen Date: Wed, 6 Jan 2010 08:13:21 +0000 Subject: [PATCH] changed the reinit_vector function git-svn-id: https://svn.dealii.org/trunk@20299 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/include/multigrid/mg_base.h | 10 ++++++- .../deal.II/include/multigrid/mg_smoother.h | 20 ++++++++++++++ deal.II/deal.II/source/multigrid/mg_base.cc | 26 +++++++++++++++++-- 3 files changed, 53 insertions(+), 3 deletions(-) diff --git a/deal.II/deal.II/include/multigrid/mg_base.h b/deal.II/deal.II/include/multigrid/mg_base.h index 0c8a42d5e9..8bea78bf4e 100644 --- a/deal.II/deal.II/include/multigrid/mg_base.h +++ b/deal.II/deal.II/include/multigrid/mg_base.h @@ -42,10 +42,15 @@ namespace internal * of freedom on each level and * @p reinit each level vector * to this length. + * For compatibility reasons with + * the next function + * the target_component is added + * here but is not used. */ template static void reinit_vector (const dealii::MGDoFHandler &mg_dof, + std::vector target_component, MGLevelObject > &vector); /** @@ -54,11 +59,14 @@ namespace internal * count the numbers of degrees * of freedom on each level and * @p reinit each level vector - * to this length. + * to this length. The target_component + * is handed to MGTools::count_dofs_per_block. + * See for documentation there. */ template static void reinit_vector (const dealii::MGDoFHandler &mg_dof, + std::vector target_component, MGLevelObject > &vector); diff --git a/deal.II/deal.II/include/multigrid/mg_smoother.h b/deal.II/deal.II/include/multigrid/mg_smoother.h index fdcb4b729f..ac6b7078c5 100644 --- a/deal.II/deal.II/include/multigrid/mg_smoother.h +++ b/deal.II/deal.II/include/multigrid/mg_smoother.h @@ -641,6 +641,11 @@ MGSmootherRelaxation::initialize ( { const unsigned int min = m.get_minlevel(); const unsigned int max = m.get_maxlevel(); + + Assert (data.get_minlevel() == min, + ExcDimensionMismatch(data.get_minlevel(), min)); + Assert (data.get_maxlevel() == max, + ExcDimensionMismatch(data.get_maxlevel(), max)); matrices.resize(min, max); smoothers.resize(min, max); @@ -686,6 +691,11 @@ MGSmootherRelaxation::initialize ( const unsigned int min = m.get_minlevel(); const unsigned int max = m.get_maxlevel(); + Assert (data.get_minlevel() == min, + ExcDimensionMismatch(data.get_minlevel(), min)); + Assert (data.get_maxlevel() == max, + ExcDimensionMismatch(data.get_maxlevel(), max)); + matrices.resize(min, max); smoothers.resize(min, max); @@ -862,6 +872,11 @@ MGSmootherPrecondition::initialize ( const unsigned int min = m.get_minlevel(); const unsigned int max = m.get_maxlevel(); + Assert (data.get_minlevel() == min, + ExcDimensionMismatch(data.get_minlevel(), min)); + Assert (data.get_maxlevel() == max, + ExcDimensionMismatch(data.get_maxlevel(), max)); + matrices.resize(min, max); smoothers.resize(min, max); @@ -906,6 +921,11 @@ MGSmootherPrecondition::initialize ( const unsigned int min = m.get_minlevel(); const unsigned int max = m.get_maxlevel(); + Assert (data.get_minlevel() == min, + ExcDimensionMismatch(data.get_minlevel(), min)); + Assert (data.get_maxlevel() == max, + ExcDimensionMismatch(data.get_maxlevel(), max)); + matrices.resize(min, max); smoothers.resize(min, max); diff --git a/deal.II/deal.II/source/multigrid/mg_base.cc b/deal.II/deal.II/source/multigrid/mg_base.cc index ab2cc9bec1..77e6ea3a0e 100644 --- a/deal.II/deal.II/source/multigrid/mg_base.cc +++ b/deal.II/deal.II/source/multigrid/mg_base.cc @@ -32,6 +32,7 @@ namespace internal template void reinit_vector (const dealii::MGDoFHandler &mg_dof, + std::vector , MGLevelObject > &v) { for (unsigned int level=v.get_minlevel(); @@ -47,18 +48,35 @@ namespace internal template void reinit_vector (const dealii::MGDoFHandler &mg_dof, + std::vector target_component, MGLevelObject > &v) { const unsigned int n_blocks = mg_dof.get_fe().n_blocks(); + if (target_component.size()==0) + { + target_component.resize(n_blocks); + for (unsigned int i=0;i > ndofs(mg_dof.get_tria().n_levels(), std::vector(n_blocks)); - MGTools::count_dofs_per_block (mg_dof, ndofs); + MGTools::count_dofs_per_block (mg_dof, ndofs, target_component); for (unsigned int level=v.get_minlevel(); level<=v.get_maxlevel();++level) { - v[level].reinit(ndofs[level]); + v[level].reinit(n_target_blocks); + for (unsigned int b=0; b ( const dealii::MGDoFHandler&, + std::vector, MGLevelObject >&); template void reinit_vector ( const dealii::MGDoFHandler&, + std::vector, MGLevelObject >&); template void reinit_vector ( const dealii::MGDoFHandler&, + std::vector, MGLevelObject >&); template void reinit_vector ( const dealii::MGDoFHandler&, + std::vector, MGLevelObject >&); template void reinit_vector_by_components ( -- 2.39.5