]> https://gitweb.dealii.org/ - dealii.git/commitdiff
new MGTransferBlock::build_matrices
authorGuido Kanschat <dr.guido.kanschat@gmail.com>
Fri, 27 Aug 2004 08:23:36 +0000 (08:23 +0000)
committerGuido Kanschat <dr.guido.kanschat@gmail.com>
Fri, 27 Aug 2004 08:23:36 +0000 (08:23 +0000)
git-svn-id: https://svn.dealii.org/trunk@9590 0785d39b-7218-0410-832d-ea1e28bc413d

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

index c047b60f7ff2a89fb2e37ea4f607e308bdee66bd..ff4f49e383c4ab9586fa71c015034146ac1d29d7 100644 (file)
@@ -26,6 +26,8 @@
 #include <multigrid/mg_base.h>
 #include <multigrid/mg_level_object.h>
 
+#include <dofs/dof_handler.h>
+
 #include <boost/shared_ptr.hpp>
 
 
@@ -238,23 +240,21 @@ class MGTransferBlockBase
                                      * Actually build the prolongation
                                      * matrices for each level.
                                      *
-                                     * If a field selected is given,
-                                     * only matrices for these
-                                     * components are to be built. By
-                                     * default, all matrices are
-                                     * built.
-                                     *
                                      * This function is only called
                                      * by derived classes. These can
                                      * also set the member variables
+                                     * #selected and #mg_selected to
+                                     * restrict the transfer matrices
+                                     * to certain components.
+                                     * Furthermore, they use
                                      * #target_component and
                                      * #mg_target_component for
                                      * re-ordering and grouping of
                                      * components.
                                      */
     template <int dim>
-    void build_matrices (const MGDoFHandler<dim>& mg_dof,
-                        const std::vector<bool>& selected);
+    void build_matrices (const DoFHandler<dim>& dof,
+                        const MGDoFHandler<dim>& mg_dof);
 
                                   /**
                                    * Flag of selected components.
@@ -346,6 +346,9 @@ class MGTransferBlockBase
                                      */
     std::vector<boost::shared_ptr<BlockSparseMatrix<double> > > prolongation_matrices;
 #endif
+
+    std::vector<std::vector<std::pair<unsigned int, unsigned int> > >
+    copy_to_and_from_indices;
 };
 
 //TODO:[GK] Update this class
@@ -415,7 +418,8 @@ class MGTransferBlock : public MGTransferBase<BlockVector<number> >,
                                      * the <tt>selected</tt> argument
                                      */
     template <int dim>
-    void build_matrices (const MGDoFHandler<dim> &mg_dof,
+    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>(),
@@ -610,7 +614,8 @@ class MGTransferSelect : public MGTransferBase<Vector<number> >,
                                      * the <tt>selected</tt> argument
                                      */
     template <int dim>
-    void build_matrices (const MGDoFHandler<dim> &mg_dof,
+    void build_matrices (const DoFHandler<dim> &dof,
+                        const MGDoFHandler<dim> &mg_dof,
                         unsigned int selected,
                         unsigned int mg_selected,
                         const std::vector<unsigned int>& target_component
index 15301e7f752750b2dfa91943450098e1d62ef41b..309f822c6c776ef70d5615b0f6e6e82c08ae10cb 100644 (file)
@@ -430,7 +430,7 @@ MGTransferSelect<number>::do_copy_to_mg (
                                       // one level higher
       if (static_cast<unsigned int>(level) < maxlevel)
        {
-         ;//     restrict_and_add (level+1, dst[level], dst[level+1]);
+         restrict_and_add (level+1, dst[level], dst[level+1]);
        }
     };
 }
index 0125fdbfe5b914f641f538775ff976c9935ec4d4..defa69125bc9d25ffc0692696609fde7e17474bf 100644 (file)
@@ -31,8 +31,8 @@
 
 template <int dim>
 void MGTransferBlockBase::build_matrices (
-  const MGDoFHandler<dim>& mg_dof,
-  const std::vector<bool>& select)
+  const DoFHandler<dim>& dof,
+  const MGDoFHandler<dim>& mg_dof)
 {
                                   // Fill target component with
                                   // standard values (identity) if it
@@ -86,10 +86,6 @@ void MGTransferBlockBase::build_matrices (
   const unsigned int dofs_per_cell = fe.dofs_per_cell;  
   const unsigned int n_levels      = mg_dof.get_tria().n_levels();
   
-                                  // Selected refers to the component
-                                  // in mg_target_component.
-  mg_selected = select;
-  
   Assert (mg_selected.size() == fe.n_components(),
          ExcDimensionMismatch(mg_selected.size(), fe.n_components()));
   
@@ -125,7 +121,14 @@ void MGTransferBlockBase::build_matrices (
       k += t;
     }
 
-// Building the matrices starts here!
+                                  // Build index vectors for
+                                  // copy_to_mg and
+                                  // copy_from_mg. These vectors must
+                                  // be prebuilt, since the
+                                  // get_dof_indices functions are
+                                  // too slow
+  
+// Building the prolongation matrices starts here!
   
                                   // reset the size of the array of
                                   // matrices. call resize(0) first,
@@ -325,24 +328,28 @@ MGTransferBlockBase::memory_consumption () const
 template <typename number>
 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)
 {
-  if (select.size() == 0)
-    select = std::vector<bool> (mg_dof.get_fe().n_components(), true);
+//TODO:[GK] What about selected?  
+  mg_selected = select;
+  if (mg_selected.size() == 0)
+    mg_selected = std::vector<bool> (mg_dof.get_fe().n_components(), true);
 
   target_component = t_component;
   mg_target_component = mg_t_component;
 
-  MGTransferBlockBase::build_matrices (mg_dof, select);
+  MGTransferBlockBase::build_matrices (dof, mg_dof);
 }
 
 
 template <typename number>
 template <int dim>
 void MGTransferSelect<number>::build_matrices (
+  const DoFHandler<dim> &dof,
   const MGDoFHandler<dim> &mg_dof,
   unsigned int select,
   unsigned int mg_select,
@@ -358,6 +365,8 @@ void MGTransferSelect<number>::build_matrices (
   mg_selected_component = mg_select;
   selected.resize(ncomp, false);
   selected[select] = true;
+  mg_selected.resize(ncomp, false);
+  mg_selected[mg_select] = true;
                                   // If components are renumbered,
                                   // find the first original
                                   // component corresponding to the
@@ -371,10 +380,15 @@ void MGTransferSelect<number>::build_matrices (
        }
     }
     
-  std::vector<bool> s(ncomp, false);
-  s[mg_select] = true;
-
-  MGTransferBlockBase::build_matrices (mg_dof, s);
+  for (unsigned int i=0;i<mg_target_component.size();++i)
+    {
+      if (mg_target_component[i] == mg_select)
+       {
+         mg_selected_component = i;
+         break;
+       }
+    }    
+  MGTransferBlockBase::build_matrices (dof, mg_dof);
 }
 
 
@@ -383,28 +397,32 @@ void MGTransferSelect<number>::build_matrices (
 
 template
 void MGTransferBlock<float>::build_matrices<deal_II_dimension>
-(const MGDoFHandler<deal_II_dimension> &mg_dof,
+(const DoFHandler<deal_II_dimension> &,
+ const MGDoFHandler<deal_II_dimension> &,
  std::vector<bool>,
  const std::vector<unsigned int>&,
  const std::vector<unsigned int>&);
 
 template
 void MGTransferSelect<float>::build_matrices<deal_II_dimension>
-(const MGDoFHandler<deal_II_dimension> &mg_dof,
+(const DoFHandler<deal_II_dimension> &d,
+ const MGDoFHandler<deal_II_dimension> &,
  unsigned int, unsigned int,
  const std::vector<unsigned int>&,
  const std::vector<unsigned int>&);
 
 template
 void MGTransferBlock<double>::build_matrices<deal_II_dimension>
-(const MGDoFHandler<deal_II_dimension> &mg_dof,
+(const DoFHandler<deal_II_dimension> &,
+ const MGDoFHandler<deal_II_dimension> &,
  std::vector<bool>,
  const std::vector<unsigned int>&,
  const std::vector<unsigned int>&);
 
 template
 void MGTransferSelect<double>::build_matrices<deal_II_dimension>
-(const MGDoFHandler<deal_II_dimension> &mg_dof,
+(const DoFHandler<deal_II_dimension> &,
+ const MGDoFHandler<deal_II_dimension> &,
  unsigned int, unsigned int,
  const std::vector<unsigned int>&,
  const std::vector<unsigned int>&);

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.