]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
simplify dublicated code in fe_system
authorheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 28 Sep 2012 21:49:00 +0000 (21:49 +0000)
committerheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 28 Sep 2012 21:49:00 +0000 (21:49 +0000)
git-svn-id: https://svn.dealii.org/trunk@26866 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/include/deal.II/fe/fe_system.h
deal.II/source/fe/fe_system.cc

index d8df1cf10c75013e97b22ba27d97fc5e7f297705..939a63ebe48eb6c7e48f1655f5ba5ee9ec32a9ad 100644 (file)
@@ -884,62 +884,16 @@ class FESystem : public FiniteElement<dim,spacedim>
                                       */
     static std::vector<bool>
     compute_restriction_is_additive_flags (
-      const FiniteElement<dim,spacedim> &fe,
-      const unsigned int        N);
-
-                                     /**
-                                      * Same as above for mixed elements
-                                      * with two different sub-elements.
-                                      */
-    static std::vector<bool>
-    compute_restriction_is_additive_flags (
-      const FiniteElement<dim,spacedim> &fe1,
-      const unsigned int        N1,
-      const FiniteElement<dim,spacedim> &fe2,
-      const unsigned int        N2);
-
-                                     /**
-                                      * Same as above for mixed elements
-                                      * with three different sub-elements.
-                                      */
-    static std::vector<bool>
-    compute_restriction_is_additive_flags (
-      const FiniteElement<dim,spacedim> &fe1,
-      const unsigned int        N1,
-      const FiniteElement<dim,spacedim> &fe2,
-      const unsigned int        N2,
-      const FiniteElement<dim,spacedim> &fe3,
-      const unsigned int        N3);
-
-                                   /**
-                                    *  with four different sub-elements
-                                    */
-    static std::vector<bool>
-    compute_restriction_is_additive_flags (
-      const FiniteElement<dim,spacedim> &fe1,
-      const unsigned int        N1,
-      const FiniteElement<dim,spacedim> &fe2,
-      const unsigned int        N2,
-      const FiniteElement<dim,spacedim> &fe3,
-      const unsigned int        N3,
-      const FiniteElement<dim,spacedim> &fe4,
-      const unsigned int        N4);
-
-                                   /**
-                                    *  and with five different sub-elements
-                                    */
-    static std::vector<bool>
-    compute_restriction_is_additive_flags (
-      const FiniteElement<dim,spacedim> &fe1,
+      const FiniteElement<dim,spacedim> *fe1,
       const unsigned int        N1,
-      const FiniteElement<dim,spacedim> &fe2,
-      const unsigned int        N2,
-      const FiniteElement<dim,spacedim> &fe3,
-      const unsigned int        N3,
-      const FiniteElement<dim,spacedim> &fe4,
-      const unsigned int        N4,
-      const FiniteElement<dim,spacedim> &fe5,
-      const unsigned int        N5);
+      const FiniteElement<dim,spacedim> *fe2=NULL,
+      const unsigned int        N2=0,
+      const FiniteElement<dim,spacedim> *fe3=NULL,
+      const unsigned int        N3=0,
+      const FiniteElement<dim,spacedim> *fe4=NULL,
+      const unsigned int        N4=0,
+      const FiniteElement<dim,spacedim> *fe5=NULL,
+      const unsigned int        N5=0);
 
                                      /**
                                       * Compute the named flags for a
index 707b22f67279d6ec241f7eac0908807a447a8f85..fd9d131cee5354ab59224bb3ef76e51df0225e81 100644 (file)
@@ -160,7 +160,7 @@ template <int dim, int spacedim>
 FESystem<dim,spacedim>::FESystem (const FiniteElement<dim,spacedim> &fe,
                                   const unsigned int n_elements) :
                 FiniteElement<dim,spacedim> (multiply_dof_numbers(&fe, n_elements),
-                                    compute_restriction_is_additive_flags (fe, n_elements),
+                                    compute_restriction_is_additive_flags (&fe, n_elements),
                                     compute_nonzero_components(fe, n_elements)),
                 base_elements((n_elements>0))
 {
@@ -179,8 +179,8 @@ FESystem<dim,spacedim>::FESystem (const FiniteElement<dim,spacedim> &fe1,
                                   const FiniteElement<dim,spacedim> &fe2,
                                   const unsigned int        n2) :
                 FiniteElement<dim,spacedim> (multiply_dof_numbers(&fe1, n1, &fe2, n2),
-                                    compute_restriction_is_additive_flags (fe1, n1,
-                                                                           fe2, n2),
+                                    compute_restriction_is_additive_flags (&fe1, n1,
+                                                                           &fe2, n2),
                                     compute_nonzero_components(fe1, n1,
                                                                fe2, n2)),
                 base_elements((n1>0)+(n2>0))
@@ -206,9 +206,9 @@ FESystem<dim,spacedim>::FESystem (const FiniteElement<dim,spacedim> &fe1,
        FiniteElement<dim,spacedim> (multiply_dof_numbers(&fe1, n1,
                                                          &fe2, n2,
                                                          &fe3, n3),
-                                    compute_restriction_is_additive_flags (fe1, n1,
-                                                                           fe2, n2,
-                                                                           fe3, n3),
+                                    compute_restriction_is_additive_flags (&fe1, n1,
+                                                                           &fe2, n2,
+                                                                           &fe3, n3),
                                     compute_nonzero_components(fe1, n1,
                                                                fe2, n2,
                                                                fe3, n3)),
@@ -239,10 +239,10 @@ FESystem<dim,spacedim>::FESystem (const FiniteElement<dim,spacedim> &fe1,
                                                     &fe2, n2,
                                                     &fe3, n3,
                                                     &fe4, n4),
-                               compute_restriction_is_additive_flags (fe1, n1,
-                                                                      fe2, n2,
-                                                                      fe3, n3,
-                                                                      fe4, n4),
+                               compute_restriction_is_additive_flags (&fe1, n1,
+                                                                      &fe2, n2,
+                                                                      &fe3, n3,
+                                                                      &fe4, n4),
                                compute_nonzero_components(fe1, n1,
                                                           fe2, n2,
                                                           fe3, n3,
@@ -278,11 +278,11 @@ FESystem<dim,spacedim>::FESystem (const FiniteElement<dim,spacedim> &fe1,
                                                     &fe3, n3,
                                                     &fe4, n4,
                                                     &fe5, n5),
-                               compute_restriction_is_additive_flags (fe1, n1,
-                                                                      fe2, n2,
-                                                                      fe3, n3,
-                                                                      fe4, n4,
-                                                                      fe5, n5),
+                               compute_restriction_is_additive_flags (&fe1, n1,
+                                                                      &fe2, n2,
+                                                                      &fe3, n3,
+                                                                      &fe4, n4,
+                                                                      &fe5, n5),
                                compute_nonzero_components(fe1, n1,
                                                           fe2, n2,
                                                           fe3, n3,
@@ -2719,125 +2719,33 @@ FESystem<dim,spacedim>::multiply_dof_numbers (
 
 template <int dim, int spacedim>
 std::vector<bool>
-FESystem<dim,spacedim>::compute_restriction_is_additive_flags (const FiniteElement<dim,spacedim> &fe,
-                                                      const unsigned int n_elements)
-{
-  std::vector<const FiniteElement<dim,spacedim>*> fe_list;
-  std::vector<unsigned int>              multiplicities;
-
-  fe_list.push_back (&fe);
-  multiplicities.push_back (n_elements);
-
-  return compute_restriction_is_additive_flags (fe_list, multiplicities);
-}
-
-
-
-template <int dim, int spacedim>
-std::vector<bool>
-FESystem<dim,spacedim>::compute_restriction_is_additive_flags (const FiniteElement<dim,spacedim> &fe1,
-                                                      const unsigned int        N1,
-                                                      const FiniteElement<dim,spacedim> &fe2,
-                                                      const unsigned int        N2)
-{
-  std::vector<const FiniteElement<dim,spacedim>*> fe_list;
-  std::vector<unsigned int>              multiplicities;
-
-  fe_list.push_back (&fe1);
-  multiplicities.push_back (N1);
-
-  fe_list.push_back (&fe2);
-  multiplicities.push_back (N2);
-
-  return compute_restriction_is_additive_flags (fe_list, multiplicities);
-}
-
-
-
-template <int dim, int spacedim>
-std::vector<bool>
-FESystem<dim,spacedim>::compute_restriction_is_additive_flags (const FiniteElement<dim,spacedim> &fe1,
-                                                      const unsigned int        N1,
-                                                      const FiniteElement<dim,spacedim> &fe2,
-                                                      const unsigned int        N2,
-                                                      const FiniteElement<dim,spacedim> &fe3,
-                                                      const unsigned int        N3)
-{
-  std::vector<const FiniteElement<dim,spacedim>*> fe_list;
-  std::vector<unsigned int>              multiplicities;
-
-  fe_list.push_back (&fe1);
-  multiplicities.push_back (N1);
-
-  fe_list.push_back (&fe2);
-  multiplicities.push_back (N2);
-
-  fe_list.push_back (&fe3);
-  multiplicities.push_back (N3);
-
-  return compute_restriction_is_additive_flags (fe_list, multiplicities);
-}
-
-
-template <int dim, int spacedim>
-std::vector<bool>
-FESystem<dim,spacedim>::compute_restriction_is_additive_flags (const FiniteElement<dim,spacedim> &fe1,
+FESystem<dim,spacedim>::compute_restriction_is_additive_flags (const FiniteElement<dim,spacedim> *fe1,
                                                                const unsigned int        N1,
-                                                               const FiniteElement<dim,spacedim> &fe2,
+                                                               const FiniteElement<dim,spacedim> *fe2,
                                                                const unsigned int        N2,
-                                                               const FiniteElement<dim,spacedim> &fe3,
+                                                               const FiniteElement<dim,spacedim> *fe3,
                                                                const unsigned int        N3,
-                                                               const FiniteElement<dim,spacedim> &fe4,
-                                                               const unsigned int        N4)
-{
-  std::vector<const FiniteElement<dim,spacedim>*> fe_list;
-  std::vector<unsigned int>              multiplicities;
-
-  fe_list.push_back (&fe1);
-  multiplicities.push_back (N1);
-
-  fe_list.push_back (&fe2);
-  multiplicities.push_back (N2);
-
-  fe_list.push_back (&fe3);
-  multiplicities.push_back (N3);
-
-  fe_list.push_back (&fe4);
-  multiplicities.push_back (N4);
-
-  return compute_restriction_is_additive_flags (fe_list, multiplicities);
-}
-
-
-template <int dim, int spacedim>
-std::vector<bool>
-FESystem<dim,spacedim>::compute_restriction_is_additive_flags (const FiniteElement<dim,spacedim> &fe1,
-                                                               const unsigned int        N1,
-                                                               const FiniteElement<dim,spacedim> &fe2,
-                                                               const unsigned int        N2,
-                                                               const FiniteElement<dim,spacedim> &fe3,
-                                                               const unsigned int        N3,
-                                                               const FiniteElement<dim,spacedim> &fe4,
+                                                               const FiniteElement<dim,spacedim> *fe4,
                                                                const unsigned int        N4,
-                                                               const FiniteElement<dim,spacedim> &fe5,
+                                                               const FiniteElement<dim,spacedim> *fe5,
                                                                const unsigned int        N5)
 {
   std::vector<const FiniteElement<dim,spacedim>*> fe_list;
   std::vector<unsigned int>              multiplicities;
 
-  fe_list.push_back (&fe1);
+  fe_list.push_back (fe1);
   multiplicities.push_back (N1);
 
-  fe_list.push_back (&fe2);
+  fe_list.push_back (fe2);
   multiplicities.push_back (N2);
 
-  fe_list.push_back (&fe3);
+  fe_list.push_back (fe3);
   multiplicities.push_back (N3);
 
-  fe_list.push_back (&fe4);
+  fe_list.push_back (fe4);
   multiplicities.push_back (N4);
 
-  fe_list.push_back (&fe5);
+  fe_list.push_back (fe5);
   multiplicities.push_back (N5);
   return compute_restriction_is_additive_flags (fe_list, multiplicities);
 }
@@ -2856,7 +2764,8 @@ compute_restriction_is_additive_flags (const std::vector<const FiniteElement<dim
                                    // from the given FEs
   unsigned int n_shape_functions = 0;
   for (unsigned int i=0; i<fes.size(); ++i)
-    n_shape_functions += fes[i]->dofs_per_cell * multiplicities[i];
+    if (multiplicities[i]>0) // check needed as fe might be NULL
+      n_shape_functions += fes[i]->dofs_per_cell * multiplicities[i];
 
                                    // generate the array that will
                                    // hold the output

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.