]> https://gitweb.dealii.org/ - dealii.git/commitdiff
simplify more dublicated code in fe_system
authorTimo Heister <timo.heister@gmail.com>
Fri, 28 Sep 2012 21:56:08 +0000 (21:56 +0000)
committerTimo Heister <timo.heister@gmail.com>
Fri, 28 Sep 2012 21:56:08 +0000 (21:56 +0000)
git-svn-id: https://svn.dealii.org/trunk@26867 0785d39b-7218-0410-832d-ea1e28bc413d

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

index 939a63ebe48eb6c7e48f1655f5ba5ee9ec32a9ad..e36ad3df6c0740c7466de56b272401ed4eb59144 100644 (file)
@@ -914,63 +914,17 @@ class FESystem : public FiniteElement<dim,spacedim>
                                       * components of a composed
                                       * finite element.
                                       */
-    static std::vector<ComponentMask>
-    compute_nonzero_components (const FiniteElement<dim,spacedim> &fe1,
-                                const unsigned int        N1);
-
-                                     /**
-                                      * Compute the non-zero vector
-                                      * components of a composed
-                                      * finite element.
-                                      */
-    static std::vector<ComponentMask>
-    compute_nonzero_components (const FiniteElement<dim,spacedim> &fe1,
-                                const unsigned int        N1,
-                                const FiniteElement<dim,spacedim> &fe2,
-                                const unsigned int        N2);
-
-                                     /**
-                                      * Compute the non-zero vector
-                                      * components of a composed
-                                      * finite element.
-                                      */
-    static std::vector<ComponentMask>
-    compute_nonzero_components (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);
-
-                                   /**
-                                    * Compute the non-zero vector
-                                    * components of a composed
-                                    * finite element.
-                                    */
-   static std::vector<ComponentMask>
-    compute_nonzero_components (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);
-
-                                     /**
-                                      * With 5 elements.
-                                      */
    static std::vector<ComponentMask>
-    compute_nonzero_components (const FiniteElement<dim,spacedim> &fe1,
+    compute_nonzero_components (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 nonzero components
index fd9d131cee5354ab59224bb3ef76e51df0225e81..6579fb6cc82b97b4e71da67ca9ae37fbfffbc1da 100644 (file)
@@ -161,7 +161,7 @@ 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_nonzero_components(fe, n_elements)),
+                                    compute_nonzero_components(&fe, n_elements)),
                 base_elements((n_elements>0))
 {
   std::vector<const FiniteElement<dim,spacedim>*> fes;
@@ -181,8 +181,8 @@ FESystem<dim,spacedim>::FESystem (const FiniteElement<dim,spacedim> &fe1,
                 FiniteElement<dim,spacedim> (multiply_dof_numbers(&fe1, n1, &fe2, n2),
                                     compute_restriction_is_additive_flags (&fe1, n1,
                                                                            &fe2, n2),
-                                    compute_nonzero_components(fe1, n1,
-                                                               fe2, n2)),
+                                    compute_nonzero_components(&fe1, n1,
+                                                               &fe2, n2)),
                 base_elements((n1>0)+(n2>0))
 {
   std::vector<const FiniteElement<dim,spacedim>*> fes;
@@ -209,9 +209,9 @@ FESystem<dim,spacedim>::FESystem (const FiniteElement<dim,spacedim> &fe1,
                                     compute_restriction_is_additive_flags (&fe1, n1,
                                                                            &fe2, n2,
                                                                            &fe3, n3),
-                                    compute_nonzero_components(fe1, n1,
-                                                               fe2, n2,
-                                                               fe3, n3)),
+                                    compute_nonzero_components(&fe1, n1,
+                                                               &fe2, n2,
+                                                               &fe3, n3)),
                 base_elements((n1>0)+(n2>0)+(n3>0))
 {
   std::vector<const FiniteElement<dim,spacedim>*> fes;
@@ -243,10 +243,10 @@ FESystem<dim,spacedim>::FESystem (const FiniteElement<dim,spacedim> &fe1,
                                                                       &fe2, n2,
                                                                       &fe3, n3,
                                                                       &fe4, n4),
-                               compute_nonzero_components(fe1, n1,
-                                                          fe2, n2,
-                                                          fe3, n3,
-                                                          fe4 ,n4)),
+                               compute_nonzero_components(&fe1, n1,
+                                                          &fe2, n2,
+                                                          &fe3, n3,
+                                                          &fe4 ,n4)),
   base_elements((n1>0)+(n2>0)+(n3>0)+(n4>0))
 {
   std::vector<const FiniteElement<dim,spacedim>*> fes;
@@ -283,11 +283,11 @@ FESystem<dim,spacedim>::FESystem (const FiniteElement<dim,spacedim> &fe1,
                                                                       &fe3, n3,
                                                                       &fe4, n4,
                                                                       &fe5, n5),
-                               compute_nonzero_components(fe1, n1,
-                                                          fe2, n2,
-                                                          fe3, n3,
-                                                          fe4 ,n4,
-                                                          fe5, n5)),
+                               compute_nonzero_components(&fe1, n1,
+                                                          &fe2, n2,
+                                                          &fe3, n3,
+                                                          &fe4 ,n4,
+                                                          &fe5, n5)),
   base_elements((n1>0)+(n2>0)+(n3>0)+(n4>0)+(n5>0))
 {
   std::vector<const FiniteElement<dim,spacedim>*> fes;
@@ -2886,127 +2886,33 @@ compute_restriction_is_additive_flags (const std::vector<const FiniteElement<dim
 
 template <int dim, int spacedim>
 std::vector<ComponentMask>
-FESystem<dim,spacedim>::compute_nonzero_components (const FiniteElement<dim,spacedim> &fe1,
-                                           const unsigned int        N1)
-{
-  std::vector<const FiniteElement<dim,spacedim>*> fe_list;
-  std::vector<unsigned int>              multiplicities;
-
-  fe_list.push_back (&fe1);
-  multiplicities.push_back (N1);
-
-  return compute_nonzero_components (fe_list, multiplicities);
-}
-
-
-
-template <int dim, int spacedim>
-std::vector<ComponentMask>
-FESystem<dim,spacedim>::compute_nonzero_components (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_nonzero_components (fe_list, multiplicities);
-}
-
-
-
-template <int dim, int spacedim>
-std::vector<ComponentMask>
-FESystem<dim,spacedim>::compute_nonzero_components (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_nonzero_components (fe_list, multiplicities);
-}
-
-
-
-template <int dim, int spacedim>
-std::vector<ComponentMask>
-FESystem<dim,spacedim>::compute_nonzero_components (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)
-{
-  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_nonzero_components (fe_list, multiplicities);
-}
-
-
-
-template <int dim, int spacedim>
-std::vector<ComponentMask>
-FESystem<dim,spacedim>::compute_nonzero_components (const FiniteElement<dim,spacedim> &fe1,
+FESystem<dim,spacedim>::compute_nonzero_components (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 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_nonzero_components (fe_list, multiplicities);
@@ -3027,11 +2933,13 @@ compute_nonzero_components (const std::vector<const FiniteElement<dim,spacedim>*
                                    // 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) //needed because fe might be NULL
+      n_shape_functions += fes[i]->dofs_per_cell * multiplicities[i];
 
   unsigned int n_components = 0;
   for (unsigned int i=0; i<fes.size(); ++i)
-    n_components += fes[i]->n_components() * multiplicities[i];
+    if (multiplicities[i]>0) //needed because fe might be NULL
+      n_components += fes[i]->n_components() * 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.