From 873817090c97094cce68f7c0741b9a0fb2de02b4 Mon Sep 17 00:00:00 2001 From: guido Date: Thu, 22 Apr 2004 14:12:26 +0000 Subject: [PATCH] reinsert reinitialization of vectors in MGTransferPrebuilt::copy_to_mg Provide default arguments in MGTools::reinit_vector git-svn-id: https://svn.dealii.org/trunk@9081 0785d39b-7218-0410-832d-ea1e28bc413d --- .../deal.II/include/multigrid/mg_dof_tools.h | 25 +++++++------ .../include/multigrid/mg_transfer.templates.h | 2 +- .../deal.II/source/multigrid/mg_dof_tools.cc | 36 ++++++++++++------- 3 files changed, 39 insertions(+), 24 deletions(-) diff --git a/deal.II/deal.II/include/multigrid/mg_dof_tools.h b/deal.II/deal.II/include/multigrid/mg_dof_tools.h index b11b6954f0..b5dc3bd530 100644 --- a/deal.II/deal.II/include/multigrid/mg_dof_tools.h +++ b/deal.II/deal.II/include/multigrid/mg_dof_tools.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 by the deal.II authors +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -156,12 +156,14 @@ class MGTools * The boolean field @p selected * allows restricting this * operation to certain - * components. In this case, - * @p vector will only have as - * many blocks as there are true + * components. In this case, @p + * vector will only have as many + * blocks as there are true * values in @p selected (no * blocks of length zero are - * padded in). + * padded in). If this argument + * is omitted, all blocks will be + * considered. * * Degrees of freedom must be * sorted by component in order @@ -170,16 +172,19 @@ class MGTools * * The argument * @p target_component allows to - * re-sort and groupt components + * re-sort and group components * as in - * @p DoFRenumbering::component_wise. + * DoFRenumbering::component_wise. + * + * */ template static void reinit_vector (const MGDoFHandler& mg_dof, MGLevelObject >& v, - const std::vector& selected, - const std::vector& target_component); + const std::vector selected = std::vector(), + const std::vector target_component + = std::vector()); /** * Adjust vectors on all levels * to correct size. Count the @@ -204,7 +209,7 @@ class MGTools * @p target_component allows to * re-sort and groupt components * as in - * @p DoFRenumbering::component_wise. + * DoFRenumbering::component_wise. */ template static void diff --git a/deal.II/deal.II/include/multigrid/mg_transfer.templates.h b/deal.II/deal.II/include/multigrid/mg_transfer.templates.h index fcc48e3cd0..ce42ffd8e1 100644 --- a/deal.II/deal.II/include/multigrid/mg_transfer.templates.h +++ b/deal.II/deal.II/include/multigrid/mg_transfer.templates.h @@ -77,7 +77,7 @@ MGTransferPrebuilt::copy_to_mg ( unsigned int minlevel = dst.get_minlevel(); unsigned int maxlevel = dst.get_maxlevel(); - dst.clear(); + MGTools::reinit_vector(mg_dof_handler, dst); Assert(sizes.size()==mg_dof_handler.get_tria().n_levels(), ExcMatricesNotBuilt()); diff --git a/deal.II/deal.II/source/multigrid/mg_dof_tools.cc b/deal.II/deal.II/source/multigrid/mg_dof_tools.cc index 72319c5255..b989337108 100644 --- a/deal.II/deal.II/source/multigrid/mg_dof_tools.cc +++ b/deal.II/deal.II/source/multigrid/mg_dof_tools.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 by the deal.II authors +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -392,16 +392,26 @@ template void MGTools::reinit_vector (const MGDoFHandler& mg_dof, MGLevelObject >& v, - const std::vector& selected_in, - const std::vector& target_component) + std::vector selected, + std::vector target_component) { - // Copy selection vector to - // non-const since we may want to - // do some manipulations. - std::vector selected = selected_in; - const unsigned int ncomp = mg_dof.get_fe().n_components(); - + + // If the selected and + // target_component have size 0, + // they must be replaced by default + // values. + // + // Since we already made copies + // when this function was called, + // we use the arguments directly. + if (target_component.size() == 0) + { + target_component.resize(ncomp); + for (unsigned int i=0;i ( template void MGTools::reinit_vector ( const MGDoFHandler&, MGLevelObject >&, - const std::vector&, - const std::vector&); + const std::vector, + const std::vector); template void MGTools::reinit_vector ( const MGDoFHandler&, MGLevelObject >&, - const std::vector&, - const std::vector&); + const std::vector, + const std::vector); template void MGTools::reinit_vector ( const MGDoFHandler&, -- 2.39.5