]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Resolve some of the issues with using deal_II_dimension in header files, which is...
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 29 May 2003 19:44:49 +0000 (19:44 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 29 May 2003 19:44:49 +0000 (19:44 +0000)
git-svn-id: https://svn.dealii.org/trunk@7682 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/multigrid/mg_transfer.h
deal.II/deal.II/include/multigrid/mg_transfer.templates.h [moved from deal.II/deal.II/include/multigrid/mg_tools.templates.h with 91% similarity]

index 98d58c34cd545547fdb922dce24a79b0d518b793..d3a8d9268f7cbe7e67a108195f86b37732f72a41 100644 (file)
@@ -43,7 +43,7 @@ template <int dim> class MGDoFHandler;
  *
  * @author Wolfgang Bangerth, Guido Kanschat, 1999, 2000, 2001, 2002
  */
-template<typename number>
+template <typename number>
 class MGTransferPrebuilt : public MGTransferBase<Vector<number> > 
 {
   public:
@@ -111,7 +111,7 @@ class MGTransferPrebuilt : public MGTransferBase<Vector<number> >
                                      * on each of the levels
                                      * separately, i.a. an @p{MGVector}.
                                      */
-    template<int dim, class InVector>
+    template <int dim, class InVector>
     void
     copy_to_mg (const MGDoFHandler<dim>        &mg_dof,
                MGLevelObject<Vector<number> > &dst,
@@ -129,7 +129,7 @@ class MGTransferPrebuilt : public MGTransferBase<Vector<number> >
                                      * constrained degrees of freedom
                                      * are set to zero.
                                      */
-    template<int dim, class OutVector>
+    template <int dim, class OutVector>
     void
     copy_from_mg (const MGDoFHandler<dim>              &mg_dof,
                  OutVector                            &dst,
@@ -143,7 +143,7 @@ class MGTransferPrebuilt : public MGTransferBase<Vector<number> >
                                      * function, but probably not for
                                      * continuous elements.
                                      */
-    template<int dim, class OutVector>
+    template <int dim, class OutVector>
     void
     copy_from_mg_add (const MGDoFHandler<dim>              &mg_dof,
                      OutVector                            &dst,
@@ -200,6 +200,54 @@ class MGTransferPrebuilt : public MGTransferBase<Vector<number> >
                                      */
     std::vector<boost::shared_ptr<SparseMatrix<double> > > prolongation_matrices;
 #endif
+
+                                    /**
+                                     * Structure that is used to
+                                     * disambiguate calls to
+                                     * @p{copy_to_mg} for 1d and
+                                     * non-1d. We provide two
+                                     * functions of @p{copy_to_mg},
+                                     * where the 1d function takes an
+                                     * argument of type
+                                     * @p{is_1d<true>} and the other
+                                     * one of type @p{is_1d<false>}.
+                                     */
+    template <bool> struct is_1d;
+    
+                                    /**
+                                     * Implementation of the
+                                     * @p{copy_to_mg} function for
+                                     * 1d. We have to resort to some
+                                     * template trickery because we
+                                     * can't specialize template
+                                     * functions on the (outer)
+                                     * template of the class, without
+                                     * also fully specializing the
+                                     * inner (member function)
+                                     * template parameters. However,
+                                     * it can be done by adding the
+                                     * additional argument that
+                                     * converts template
+                                     * specialization into function
+                                     * overloading.
+                                     */
+    template <int dim, class InVector>
+    void
+    copy_to_mg (const MGDoFHandler<dim>        &mg_dof,
+               MGLevelObject<Vector<number> > &dst,
+               const InVector                 &src,
+               const is_1d<true>              &) const;
+
+                                    /**
+                                     * Same for all other space
+                                     * dimensions.
+                                     */
+    template <int dim, class InVector>
+    void
+    copy_to_mg (const MGDoFHandler<dim>        &mg_dof,
+               MGLevelObject<Vector<number> > &dst,
+               const InVector                 &src,
+               const is_1d<false>             &) const;
 };
 
 
@@ -377,7 +425,7 @@ class MGTransferBlock : public MGTransferBase<BlockVector<number> >,
                                      * on each of the levels
                                      * separately, i.a. an @p{MGVector}.
                                      */
-    template<int dim, class InVector>
+    template <int dim, class InVector>
     void
     copy_to_mg (const MGDoFHandler<dim>             &mg_dof,
                MGLevelObject<BlockVector<number> > &dst,
@@ -395,7 +443,7 @@ class MGTransferBlock : public MGTransferBase<BlockVector<number> >,
                                      * constrained degrees of freedom
                                      * are set to zero.
                                      */
-    template<int dim, class OutVector>
+    template <int dim, class OutVector>
     void
     copy_from_mg (const MGDoFHandler<dim>                   &mg_dof,
                  OutVector                                 &dst,
@@ -409,11 +457,60 @@ class MGTransferBlock : public MGTransferBase<BlockVector<number> >,
                                      * function, but probably not for
                                      * continuous elements.
                                      */
-    template<int dim, class OutVector>
+    template <int dim, class OutVector>
     void
     copy_from_mg_add (const MGDoFHandler<dim>                   &mg_dof,
                      OutVector                                 &dst,
                      const MGLevelObject<BlockVector<number> > &src) const;
+
+  private:
+                                    /**
+                                     * Structure that is used to
+                                     * disambiguate calls to
+                                     * @p{copy_to_mg} for 1d and
+                                     * non-1d. We provide two
+                                     * functions of @p{copy_to_mg},
+                                     * where the 1d function takes an
+                                     * argument of type
+                                     * @p{is_1d<true>} and the other
+                                     * one of type @p{is_1d<false>}.
+                                     */
+    template <bool> struct is_1d;
+
+                                    /**
+                                     * Implementation of the
+                                     * @p{copy_to_mg} function for
+                                     * 1d. We have to resort to some
+                                     * template trickery because we
+                                     * can't specialize template
+                                     * functions on the (outer)
+                                     * template of the class, without
+                                     * also fully specializing the
+                                     * inner (member function)
+                                     * template parameters. However,
+                                     * it can be done by adding the
+                                     * additional argument that
+                                     * converts template
+                                     * specialization into function
+                                     * overloading.
+                                     */
+    template <int dim, class InVector>
+    void
+    copy_to_mg (const MGDoFHandler<dim>             &mg_dof,
+               MGLevelObject<BlockVector<number> > &dst,
+               const InVector                      &src,
+               const is_1d<true>                   &) const;
+
+                                    /**
+                                     * Same for all other space
+                                     * dimensions.
+                                     */
+    template <int dim, class InVector>
+    void
+    copy_to_mg (const MGDoFHandler<dim>             &mg_dof,
+               MGLevelObject<BlockVector<number> > &dst,
+               const InVector                      &src,
+               const is_1d<false>                  &) const;    
 };
 
 
@@ -497,13 +594,26 @@ class MGTransferSelect : public MGTransferBase<Vector<number> >,
                                   Vector<number>       &dst,
                                   const Vector<number> &src) const;
 
+                                    /**
+                                     * Structure that is used to
+                                     * disambiguate calls to
+                                     * @p{copy_to_mg} for 1d and
+                                     * non-1d. We provide two
+                                     * functions of @p{copy_to_mg},
+                                     * where the 1d function takes an
+                                     * argument of type
+                                     * @p{is_1d<true>} and the other
+                                     * one of type @p{is_1d<false>}.
+                                     */
+    template <bool> struct is_1d;
+    
                                     /**
                                      * Transfer from a vector on the
                                      * global grid to vectors defined
                                      * on each of the levels
                                      * separately, i.a. an @p{MGVector}.
                                      */
-    template<int dim, class InVector>
+    template <int dim, class InVector>
     void
     copy_to_mg (const MGDoFHandler<dim>        &mg_dof,
                MGLevelObject<Vector<number> > &dst,
@@ -521,7 +631,7 @@ class MGTransferSelect : public MGTransferBase<Vector<number> >,
                                      * constrained degrees of freedom
                                      * are set to zero.
                                      */
-    template<int dim, class OutVector>
+    template <int dim, class OutVector>
     void
     copy_from_mg (const MGDoFHandler<dim>              &mg_dof,
                  OutVector                            &dst,
@@ -535,7 +645,7 @@ class MGTransferSelect : public MGTransferBase<Vector<number> >,
                                      * function, but probably not for
                                      * continuous elements.
                                      */
-    template<int dim, class OutVector>
+    template <int dim, class OutVector>
     void
     copy_from_mg_add (const MGDoFHandler<dim>              &mg_dof,
                      OutVector                            &dst,
@@ -546,6 +656,42 @@ class MGTransferSelect : public MGTransferBase<Vector<number> >,
                                       * Selected component.
                                       */
     unsigned int selected;
+
+
+                                    /**
+                                     * Implementation of the
+                                     * @p{copy_to_mg} function for
+                                     * 1d. We have to resort to some
+                                     * template trickery because we
+                                     * can't specialize template
+                                     * functions on the (outer)
+                                     * template of the class, without
+                                     * also fully specializing the
+                                     * inner (member function)
+                                     * template parameters. However,
+                                     * it can be done by adding the
+                                     * additional argument that
+                                     * converts template
+                                     * specialization into function
+                                     * overloading.
+                                     */
+    template <int dim, class InVector>
+    void
+    copy_to_mg (const MGDoFHandler<dim>        &mg_dof,
+               MGLevelObject<Vector<number> > &dst,
+               const InVector                 &src,
+               const is_1d<true>              &) const;
+
+                                    /**
+                                     * Same for all other space
+                                     * dimensions.
+                                     */
+    template <int dim, class InVector>
+    void
+    copy_to_mg (const MGDoFHandler<dim>        &mg_dof,
+               MGLevelObject<Vector<number> > &dst,
+               const InVector                 &src,
+               const is_1d<false>             &) const;
 };
 
 
similarity index 91%
rename from deal.II/deal.II/include/multigrid/mg_tools.templates.h
rename to deal.II/deal.II/include/multigrid/mg_transfer.templates.h
index 136109baa0a4a5ef3280c22f717bc6fcee742721..589121da600079b00be36985e0b77c439bfd2ecc 100644 (file)
@@ -11,8 +11,8 @@
 //
 //----------------------------------------------------------------------------
 
-#ifndef __deal2__mg_tools_templates_h
-#define __deal2__mg_tools_templates_h
+#ifndef __deal2__mg_transfer_templates_h
+#define __deal2__mg_transfer_templates_h
 
 #include <lac/sparse_matrix.h>
 #include <dofs/dof_constraints.h>
 /* --------------------- MGTransferPrebuilt -------------- */
 
 
-//TODO[GK]: this file must really be changed: it contains #if's for deal_II_dimension, but we can't use this in headers, since application programs might not use this way to select the dimension. the only way in header files is to have proper template specializations
 
+template <typename number>
+template <int dim, class InVector>
+void
+MGTransferPrebuilt<number>::copy_to_mg (const MGDoFHandler<dim>        &mg_dof_handler,
+                                       MGLevelObject<Vector<number> > &dst,
+                                       const InVector                 &src) const
+{
+                                  // forward to the correct
+                                  // specialization
+  copy_to_mg (mg_dof_handler, dst, src, is_1d<dim==1>());
+}
 
-//TODO:[?] This function needs to be specially implemented, since in 2d mode we use faces
-#if deal_II_dimension == 1
 
 template <typename number>
 template <int dim, class InVector>
 void
-MGTransferPrebuilt<number>::copy_to_mg (
-  const MGDoFHandler<dim>&,
-  MGLevelObject<Vector<number> >&,
-  const InVector&) const
+MGTransferPrebuilt<number>::copy_to_mg (const MGDoFHandler<dim>        &,
+                                       MGLevelObject<Vector<number> > &,
+                                       const InVector                 &,
+                                       const is_1d<true>              &) const
 {
   Assert(false, ExcNotImplemented());
 }
 
-#else
-
 
 template <typename number>
 template <int dim, class InVector>
 void
-MGTransferPrebuilt<number>::copy_to_mg (
-  const MGDoFHandler<dim>& mg_dof_handler,
-  MGLevelObject<Vector<number> >& dst,
-  const InVector& src) const
+MGTransferPrebuilt<number>::copy_to_mg (const MGDoFHandler<dim>        &mg_dof_handler,
+                                       MGLevelObject<Vector<number> > &dst,
+                                       const InVector                 &src,
+                                       const is_1d<false>             &) const
 {
                                   // Make src a real finite element function
 //  InVector src = osrc;
@@ -146,7 +152,6 @@ MGTransferPrebuilt<number>::copy_to_mg (
     };
 }
 
-#endif
 
 
 template <typename number>
@@ -250,8 +255,21 @@ copy_from_mg_add (const MGDoFHandler<dim>              &mg_dof_handler,
 /* --------------------- MGTransferSelect -------------- */
 
 
-//TODO:[?] This function needs to be specially implemented, since in 2d mode we use faces
-#if deal_II_dimension == 1
+
+template <typename number>
+template <int dim, class InVector>
+void
+MGTransferSelect<number>::
+copy_to_mg (const MGDoFHandler<dim>        &mg_dof_handler,
+            MGLevelObject<Vector<number> > &dst,
+            const InVector                 &src) const
+{
+                                  // forward to the correct
+                                  // specialization
+  copy_to_mg (mg_dof_handler, dst, src, is_1d<dim==1>());
+}
+
+
 
 template <typename number>
 template <int dim, class InVector>
@@ -259,12 +277,12 @@ void
 MGTransferSelect<number>::
 copy_to_mg (const MGDoFHandler<dim>        &,
             MGLevelObject<Vector<number> > &,
-            const InVector                 &) const
+            const InVector                 &,
+           const is_1d<true>              &) const
 {
   Assert(false, ExcNotImplemented());
 }
 
-#else
 
 
 template <typename number>
@@ -273,7 +291,8 @@ void
 MGTransferSelect<number>::
 copy_to_mg (const MGDoFHandler<dim>        &mg_dof_handler,
             MGLevelObject<Vector<number> > &dst,
-            const InVector                 &osrc) const
+            const InVector                 &osrc,
+           const is_1d<false>             &) const
 {
                                   // Make src a real finite element function
   InVector src = osrc;
@@ -379,7 +398,6 @@ copy_to_mg (const MGDoFHandler<dim>        &mg_dof_handler,
     };
 }
 
-#endif
 
 
 template <typename number>
@@ -507,7 +525,21 @@ copy_from_mg_add (const MGDoFHandler<dim>              &mg_dof_handler,
 /* --------------------- MGTransferBlock -------------- */
 
 
-#if deal_II_dimension == 1
+
+template <typename number>
+template <int dim, class InVector>
+void
+MGTransferBlock<number>::
+copy_to_mg (const MGDoFHandler<dim>             &mg_dof_handler,
+            MGLevelObject<BlockVector<number> > &dst,
+            const InVector                      &src) const
+{
+                                  // forward to the correct
+                                  // specialization
+  copy_to_mg (mg_dof_handler, dst, src, is_1d<dim==1>());
+}
+
+
 
 template <typename number>
 template <int dim, class InVector>
@@ -515,12 +547,12 @@ void
 MGTransferBlock<number>::
 copy_to_mg (const MGDoFHandler<dim>             &,
             MGLevelObject<BlockVector<number> > &,
-            const InVector                      &) const
+            const InVector                      &,
+           const is_1d<true>                   &) const
 {
   Assert(false, ExcNotImplemented());
 }
 
-#else
 
 
 template <typename number>
@@ -529,7 +561,8 @@ void
 MGTransferBlock<number>::
 copy_to_mg (const MGDoFHandler<dim>             &mg_dof_handler,
             MGLevelObject<BlockVector<number> > &dst,
-            const InVector                      &src) const
+            const InVector                      &src,
+           const is_1d<false>                  &) const
 {
                                   // Make src a real finite element
                                   // function
@@ -607,7 +640,7 @@ copy_to_mg (const MGDoFHandler<dim>             &mg_dof_handler,
     };
 }
 
-#endif
+
 
 
 template <typename number>

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.