]> https://gitweb.dealii.org/ - dealii.git/commitdiff
development of MGTransferBlock continued
authorGuido Kanschat <dr.guido.kanschat@gmail.com>
Fri, 18 Nov 2005 20:59:39 +0000 (20:59 +0000)
committerGuido Kanschat <dr.guido.kanschat@gmail.com>
Fri, 18 Nov 2005 20:59:39 +0000 (20:59 +0000)
git-svn-id: https://svn.dealii.org/trunk@11773 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/multigrid/mg_transfer.h
deal.II/deal.II/source/multigrid/mg_transfer_block.cc
deal.II/deal.II/source/multigrid/multigrid.all_dimensions.cc

index f1da850a8b27a32e73749ab1a4f07f3c6a596db8..b39a342e5337e5e3bd5b42067f11500b3f2d2a4a 100644 (file)
 #  include <lac/sparsity_pattern.h>
 #  include <lac/block_sparsity_pattern.h>
 #endif
+#include <lac/vector_memory.h>
+
 #include <multigrid/mg_base.h>
 #include <multigrid/mg_level_object.h>
 
+
+
 #include <dofs/dof_handler.h>
 
 #include <boost/shared_ptr.hpp>
@@ -314,7 +318,7 @@ class MGTransferBlockBase
                                    * all levels.
                                    */
     std::vector<std::vector<unsigned int> > mg_component_start;
-
+    
                                     /**
                                      * Call build_matrices()
                                      * function first.
@@ -388,11 +392,25 @@ class MGTransferBlock : public MGTransferBase<BlockVector<number> >,
                        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<number>& factors,
+                    VectorMemory<Vector<number> >& memory);
+    
                                     /**
                                      * Build the prolongation
                                      * matrices for each level.
@@ -401,12 +419,6 @@ class MGTransferBlock : public MGTransferBase<BlockVector<number> >,
                                      * 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 <tt>mg_target_component</tt> is
                                      * present, this refers to the
                                      * renumbered components.
@@ -428,7 +440,6 @@ class MGTransferBlock : public MGTransferBase<BlockVector<number> >,
     template <int dim>
     void build_matrices (const DoFHandler<dim> &dof,
                         const MGDoFHandler<dim> &mg_dof,
-                        std::vector<bool> selected = std::vector<bool>(),
                         const std::vector<unsigned int>& target_component
                         = std::vector<unsigned int>(),
                         const std::vector<unsigned int>& mg_target_component
@@ -556,6 +567,21 @@ class MGTransferBlock : public MGTransferBase<BlockVector<number> >,
                MGLevelObject<BlockVector<number> > &dst,
                const InVector                      &src,
                const is_1d<false>                  &) const;    
+    
+                                    /**
+                                     * Optional multiplication
+                                     * factors for each
+                                     * component. Requires
+                                     * initialization of #memory.
+                                     */
+    std::vector<number> factors;
+
+                                    /**
+                                     * Memory pool required if
+                                     * additional multiplication
+                                     * using #factors is desired.
+                                     */
+    SmartPointer<VectorMemory<Vector<number> > > memory;
 };
 
 
index aba3ca141d7217fdffb1ea6640ce0a799c20d8cf..c4bb55cea6a24a2be51ef689db3cf6bdc16874b3 100644 (file)
@@ -336,12 +336,11 @@ template <int dim>
 void MGTransferBlock<number>::build_matrices (
   const DoFHandler<dim> &dof,
   const MGDoFHandler<dim> &mg_dof,
-  std::vector<bool> select,
   const std::vector<unsigned int>& t_component,
   const std::vector<unsigned int>& mg_t_component)
 {
-//TODO:[GK] What about selected?  
-  mg_selected = select;
+  if (selected.size() == 0)
+    selected = std::vector<bool> (mg_dof.get_fe().n_components(), true);
   if (mg_selected.size() == 0)
     mg_selected = std::vector<bool> (mg_dof.get_fe().n_components(), true);
 
@@ -445,7 +444,6 @@ template
 void MGTransferBlock<float>::build_matrices<deal_II_dimension>
 (const DoFHandler<deal_II_dimension> &,
  const MGDoFHandler<deal_II_dimension> &,
- std::vector<bool>,
  const std::vector<unsigned int>&,
  const std::vector<unsigned int>&);
 
@@ -461,7 +459,6 @@ template
 void MGTransferBlock<double>::build_matrices<deal_II_dimension>
 (const DoFHandler<deal_II_dimension> &,
  const MGDoFHandler<deal_II_dimension> &,
- std::vector<bool>,
  const std::vector<unsigned int>&,
  const std::vector<unsigned int>&);
 
index c7d73a368057c2a56515246995e6d5757b4423f9..27aeee36453512cb6bc244f3f02580a16ea7f477 100644 (file)
@@ -21,8 +21,6 @@
 #include <multigrid/mg_transfer.templates.h>
 #include <multigrid/multigrid.templates.h>
 
-
-
 // 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<VECTOR>::restrict_and_add (
 
 
 template <typename number>
-MGTransferBlock<number>::~MGTransferBlock () 
+MGTransferBlock<number>::MGTransferBlock ()
+               :
+               memory(0, typeid(*this).name())
 {}
 
 
+template <typename number>
+MGTransferBlock<number>::~MGTransferBlock ()
+{
+  if (memory != 0) memory = 0;
+}
+
+
+template <typename number>
+void
+MGTransferBlock<number>::initialize (const std::vector<number>& f,
+                                    VectorMemory<Vector<number> >& mem) 
+{
+  factors = f;
+  memory = &mem;
+}
+
+
 template <typename number>
 void MGTransferBlock<number>::prolongate (
   const unsigned int   to_level,
@@ -171,7 +188,20 @@ void MGTransferBlock<number>::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<number>* 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;
     }
 }

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.