]> https://gitweb.dealii.org/ - dealii.git/commitdiff
reinsert reinitialization of vectors in MGTransferPrebuilt::copy_to_mg
authorGuido Kanschat <dr.guido.kanschat@gmail.com>
Thu, 22 Apr 2004 14:12:26 +0000 (14:12 +0000)
committerGuido Kanschat <dr.guido.kanschat@gmail.com>
Thu, 22 Apr 2004 14:12:26 +0000 (14:12 +0000)
Provide default arguments in MGTools::reinit_vector

git-svn-id: https://svn.dealii.org/trunk@9081 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/multigrid/mg_dof_tools.h
deal.II/deal.II/include/multigrid/mg_transfer.templates.h
deal.II/deal.II/source/multigrid/mg_dof_tools.cc

index b11b6954f0c9cce66456d54fd7a3a7555f861c14..b5dc3bd5306010b7bf1fc6a96cd89d8329036e9a 100644 (file)
@@ -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 <int dim, typename number>
       static void
       reinit_vector (const MGDoFHandler<dim>& mg_dof,
                     MGLevelObject<BlockVector<number> >& v,
-                    const std::vector<bool>& selected,
-                    const std::vector<unsigned int>& target_component);
+                    const std::vector<bool> selected = std::vector<bool>(),
+                    const std::vector<unsigned int> target_component
+                    = std::vector<unsigned int>());
                                     /**
                                      * 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 <int dim, typename number>
       static void
index fcc48e3cd0a5cd24afc481bd0b67b73140cf5916..ce42ffd8e150df237dab66849ff50be045cff037 100644 (file)
@@ -77,7 +77,7 @@ MGTransferPrebuilt<VECTOR>::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());
index 72319c525509294022a54a5b85415f204c3d5399..b989337108d90f9f0476ac124f2f7e6e2e18d42a 100644 (file)
@@ -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<int dim, typename number>
 void
 MGTools::reinit_vector (const MGDoFHandler<dim>& mg_dof,
                         MGLevelObject<BlockVector<number> >& v,
-                        const std::vector<bool>& selected_in,
-                       const std::vector<unsigned int>& target_component)
+                        std::vector<bool> selected,
+                       std::vector<unsigned int> target_component)
 {
-                                  // Copy selection vector to
-                                  // non-const since we may want to
-                                  // do some manipulations.
-  std::vector<bool> 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<ncomp;++i)
+       target_component[i] = i;
+    }
+  
                                   // If selected is an empty vector,
                                   // all components are selected.
   if (selected.size() == 0)
@@ -585,13 +595,13 @@ template void MGTools::reinit_vector<deal_II_dimension> (
 template void MGTools::reinit_vector<deal_II_dimension> (
   const MGDoFHandler<deal_II_dimension>&,
   MGLevelObject<BlockVector<double> >&,
-  const std::vector<bool>&,
-  const std::vector<unsigned int>&);
+  const std::vector<bool>,
+  const std::vector<unsigned int>);
 template void MGTools::reinit_vector<deal_II_dimension> (
   const MGDoFHandler<deal_II_dimension>&,
   MGLevelObject<BlockVector<float> >&,
-  const std::vector<bool>&,
-  const std::vector<unsigned int>&);
+  const std::vector<bool>,
+  const std::vector<unsigned int>);
 
 template void MGTools::reinit_vector<deal_II_dimension> (
   const MGDoFHandler<deal_II_dimension>&,

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.