]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Improve hp::FECollection
authorDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Sat, 19 Aug 2017 21:41:01 +0000 (23:41 +0200)
committerDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Sat, 19 Aug 2017 22:13:18 +0000 (00:13 +0200)
include/deal.II/hp/fe_collection.h
source/hp/fe_collection.cc

index 37562d8e02797ffeed50da7db0c070746e3f5f8a..f81839f2aba421d0a3eb17f67c60cd44c69faf3b 100644 (file)
@@ -69,38 +69,11 @@ namespace hp
     explicit FECollection (const FiniteElement<dim,spacedim> &fe);
 
     /**
-     * Constructor. This constructor creates a FECollection from two finite
-     * elements.
+     * Constructor. This constructor creates a FECollection from more than
+     * one finite element.
      */
-    FECollection (const FiniteElement<dim,spacedim> &fe1,
-                  const FiniteElement<dim,spacedim> &fe2);
-
-    /**
-     * Constructor. This constructor creates a FECollection from three finite
-     * elements.
-     */
-    FECollection (const FiniteElement<dim,spacedim> &fe1,
-                  const FiniteElement<dim,spacedim> &fe2,
-                  const FiniteElement<dim,spacedim> &fe3);
-
-    /**
-     * Constructor. This constructor creates a FECollection from four finite
-     * elements.
-     */
-    FECollection (const FiniteElement<dim,spacedim> &fe1,
-                  const FiniteElement<dim,spacedim> &fe2,
-                  const FiniteElement<dim,spacedim> &fe3,
-                  const FiniteElement<dim,spacedim> &fe4);
-
-    /**
-     * Constructor. This constructor creates a FECollection from five finite
-     * elements.
-     */
-    FECollection (const FiniteElement<dim,spacedim> &fe1,
-                  const FiniteElement<dim,spacedim> &fe2,
-                  const FiniteElement<dim,spacedim> &fe3,
-                  const FiniteElement<dim,spacedim> &fe4,
-                  const FiniteElement<dim,spacedim> &fe5);
+    template<class... FETypes>
+    explicit FECollection (const FETypes &... fes);
 
     /**
      * Constructor. Same as above but for any number of elements. Pointers to
@@ -114,7 +87,18 @@ namespace hp
     /**
      * Copy constructor.
      */
-    FECollection (const FECollection<dim,spacedim> &fe_collection);
+    FECollection (const FECollection<dim,spacedim> &fe_collection) = default;
+
+    /**
+     * Move constructor.
+     */
+    FECollection (FECollection<dim,spacedim> &&fe_collection) = default;
+
+    /**
+     * Move assignement operator.
+     */
+    FECollection<dim, spacedim> &
+    operator= (FECollection<dim,spacedim> &&fe_collection) = default;
 
     /**
      * Add a finite element. This function generates a copy of the given
@@ -466,6 +450,14 @@ namespace hp
 
   /* --------------- inline functions ------------------- */
 
+  template <int dim, int spacedim>
+  template <class... FETypes>
+  FECollection<dim,spacedim>::FECollection (const FETypes &... fes)
+  {
+    [](...) {}((push_back(fes),0)...);
+  }
+
+
   template <int dim, int spacedim>
   inline
   unsigned int
index e7a4c3a400d531566bafd82fdf5500131931a24a..b41bb529c74e5973a3b3c9cb764598a99b8c220e 100644 (file)
@@ -100,58 +100,6 @@ namespace hp
 
 
 
-  template <int dim, int spacedim>
-  FECollection<dim,spacedim>::FECollection (const FiniteElement<dim,spacedim> &fe1,
-                                            const FiniteElement<dim,spacedim> &fe2)
-  {
-    push_back(fe1);
-    push_back(fe2);
-  }
-
-
-
-  template <int dim, int spacedim>
-  FECollection<dim,spacedim>::FECollection (const FiniteElement<dim,spacedim> &fe1,
-                                            const FiniteElement<dim,spacedim> &fe2,
-                                            const FiniteElement<dim,spacedim> &fe3)
-  {
-    push_back(fe1);
-    push_back(fe2);
-    push_back(fe3);
-  }
-
-
-
-  template <int dim, int spacedim>
-  FECollection<dim,spacedim>::FECollection (const FiniteElement<dim,spacedim> &fe1,
-                                            const FiniteElement<dim,spacedim> &fe2,
-                                            const FiniteElement<dim,spacedim> &fe3,
-                                            const FiniteElement<dim,spacedim> &fe4)
-  {
-    push_back(fe1);
-    push_back(fe2);
-    push_back(fe3);
-    push_back(fe4);
-  }
-
-
-
-  template <int dim, int spacedim>
-  FECollection<dim,spacedim>::FECollection (const FiniteElement<dim,spacedim> &fe1,
-                                            const FiniteElement<dim,spacedim> &fe2,
-                                            const FiniteElement<dim,spacedim> &fe3,
-                                            const FiniteElement<dim,spacedim> &fe4,
-                                            const FiniteElement<dim,spacedim> &fe5)
-  {
-    push_back(fe1);
-    push_back(fe2);
-    push_back(fe3);
-    push_back(fe4);
-    push_back(fe5);
-  }
-
-
-
   template <int dim, int spacedim>
   FECollection<dim,spacedim>::
   FECollection (const std::vector<const FiniteElement<dim,spacedim>*>  &fes)
@@ -165,27 +113,6 @@ namespace hp
 
 
 
-  template <int dim, int spacedim>
-  FECollection<dim,spacedim>::
-  FECollection (const FECollection<dim,spacedim> &fe_collection)
-    :
-    Subscriptor (),
-    // copy the array
-    // of shared
-    // pointers. nothing
-    // bad should
-    // happen -- they
-    // simply all point
-    // to the same
-    // objects, and the
-    // last one to die
-    // will delete the
-    // mappings
-    finite_elements (fe_collection.finite_elements)
-  {}
-
-
-
   template <int dim, int spacedim>
   void FECollection<dim,spacedim>::push_back (const FiniteElement<dim,spacedim> &new_fe)
   {

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.