]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Move the collection classes into namespace hp. Make the collection classes all alike.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Mon, 9 Jan 2006 02:34:30 +0000 (02:34 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Mon, 9 Jan 2006 02:34:30 +0000 (02:34 +0000)
git-svn-id: https://svn.dealii.org/trunk@11964 0785d39b-7218-0410-832d-ea1e28bc413d

26 files changed:
deal.II/deal.II/include/dofs/dof_accessor.h
deal.II/deal.II/include/dofs/hp_dof_handler.h
deal.II/deal.II/include/dofs/hp_dof_levels.h
deal.II/deal.II/include/fe/fe.h
deal.II/deal.II/include/fe/fe_collection.h
deal.II/deal.II/include/fe/hp_fe_values.h
deal.II/deal.II/include/fe/mapping.h
deal.II/deal.II/include/fe/mapping_c1.h
deal.II/deal.II/include/fe/mapping_cartesian.h
deal.II/deal.II/include/fe/mapping_collection.h
deal.II/deal.II/include/fe/mapping_q.h
deal.II/deal.II/include/fe/mapping_q1.h
deal.II/deal.II/include/fe/mapping_q1_eulerian.h
deal.II/deal.II/include/fe/q_collection.h
deal.II/deal.II/source/dofs/hp_dof_handler.cc
deal.II/deal.II/source/fe/fe_collection.cc
deal.II/deal.II/source/fe/hp_fe_values.cc
deal.II/deal.II/source/fe/mapping_c1.cc
deal.II/deal.II/source/fe/mapping_cartesian.cc
deal.II/deal.II/source/fe/mapping_collection.cc
deal.II/deal.II/source/fe/mapping_q.cc
deal.II/deal.II/source/fe/mapping_q1.cc
deal.II/deal.II/source/fe/mapping_q1_eulerian.cc
deal.II/deal.II/source/fe/q_collection.cc
deal.II/doc/news/changes.html
deal.II/examples/step-21/step-21.cc

index 31c42fc6c42d2547100217c282dd3bdbd1c7dc36..9746526c0f50192fb469b689d2a3f3fe69939d3f 100644 (file)
@@ -428,8 +428,9 @@ class DoFObjectAccessor : public DoFAccessor<dim, DH>,
     get_fe () const;
     
                                      /**
-                                     *  Returns the index inside the FECollection
-                                     *  of the FiniteElement used for this cell.
+                                     *  Returns the index inside the
+                                     *  hp::FECollection of the FiniteElement
+                                     *  used for this cell.
                                      */
     unsigned int active_fe_index () const;
 
@@ -734,8 +735,9 @@ class DoFObjectAccessor<1, dim, DH> :  public DoFAccessor<dim, DH>,
     get_fe () const;
     
                                      /**
-                                     *  Returns the index inside the FECollection
-                                     *  of the FiniteElement used for this cell.
+                                     *  Returns the index inside the
+                                     *  hp::FECollection of the FiniteElement
+                                     *  used for this cell.
                                      */
     unsigned int active_fe_index () const;
 
@@ -974,8 +976,9 @@ class DoFObjectAccessor<2, dim, DH> :  public DoFAccessor<dim, DH>,
     get_fe () const;
     
                                      /**
-                                     *  Returns the index inside the FECollection
-                                     *  of the FiniteElement used for this cell.
+                                     *  Returns the index inside the
+                                     *  hp::FECollection of the FiniteElement
+                                     *  used for this cell.
                                      */
     unsigned int active_fe_index () const;
 
@@ -1222,8 +1225,9 @@ class DoFObjectAccessor<3, dim, DH> :  public DoFAccessor<dim, DH>,
     get_fe () const;
 
                                      /**
-                                     *  Returns the index inside the FECollection
-                                     *  of the FiniteElement used for this cell.
+                                     *  Returns the index inside the
+                                     *  hp::FECollection of the FiniteElement
+                                     *  used for this cell.
                                      */
     unsigned int active_fe_index () const;
 
index 5f52df7dbaf7e26987721209aec7bff1e0321e80..d298fa8d762ca59bd2db6c2b34eb755e8a27439b 100644 (file)
@@ -129,7 +129,7 @@ namespace hp
                                         * releases the lock of this
                                         * object to the finite element.
                                         */
-      virtual void distribute_dofs (const FECollection<dim> &fe);
+      virtual void distribute_dofs (const hp::FECollection<dim> &fe);
 
                                        /**
                                         * Clear all data of this object and
@@ -796,7 +796,7 @@ namespace hp
                                         * objects that are used by this
                                         * @p DoFHandler.
                                         */
-      const FECollection<dim> & get_fe () const;
+      const hp::FECollection<dim> & get_fe () const;
 
                                        /**
                                         * Return a constant reference to the
@@ -879,7 +879,7 @@ namespace hp
                                         * (this clears all data of this
                                         * object as well, though).
                                         */
-      SmartPointer<const FECollection<dim> > finite_elements;
+      SmartPointer<const hp::FECollection<dim> > finite_elements;
 
     private:
 
@@ -1002,11 +1002,6 @@ namespace hp
                                         * Make accessor objects friends.
                                         */
       template <int dim1, int dim2, template <int> class DH> friend class DoFObjectAccessor;
-
-                                       /**
-                                        * Make Triangulation friend.
-                                        */
-//    friend class Triangulation<dim>;
   };
 
 
@@ -1147,7 +1142,7 @@ namespace hp
 
   template <int dim>
   inline
-  const FECollection<dim> &
+  const hp::FECollection<dim> &
   DoFHandler<dim>::get_fe () const
   {
     return *finite_elements;
index 6245c53504bd262b7066ad11437ef05567e44a22..20f994324c6ab815095337e8b33c30b8027a596b 100644 (file)
@@ -47,25 +47,26 @@ namespace hp
  *  hierarchy.
  *
  *  In @ref{DoFLevel<0>} all data is stored which is not dependent on the
- *  dimension, e.g. a field to store the index referring to the FECollection
- *  class. The data therefore corresponds to cells, rather than vertices,
- *  lines, quads, etc.
+ *  dimension, e.g. a field to store the index referring to the
+ *  hp::FECollection class. The data therefore corresponds to cells, rather
+ *  than vertices, lines, quads, etc.
  */
   template <>
   class DoFLevel<0>
   {
     public:
                                        /**
-                                        *  Indices specifying the finite element
-                                        *  of FECollection to use for the
-                                        *  different cells. The meaning
-                                        *  what a cell is, is dimension specific,
-                                        *  therefore also the length of this
-                                        *  vector depends on the dimension: in
-                                        *  one dimension, the length of this
-                                        *  vector equals the length of the
-                                        *  @p lines vector, in two dimensions
-                                        *  that of the @p quads vector, etc.
+                                        *  Indices specifying the finite
+                                        *  element of hp::FECollection to use
+                                        *  for the different cells. The
+                                        *  meaning what a cell is, is
+                                        *  dimension specific, therefore also
+                                        *  the length of this vector depends
+                                        *  on the dimension: in one dimension,
+                                        *  the length of this vector equals
+                                        *  the length of the @p lines vector,
+                                        *  in two dimensions that of the @p
+                                        *  quads vector, etc.
                                         */
 
       std::vector<unsigned int> active_fe_indices;
index 27713d5aeb5951cfbfd1f9e904d94b98a52b5004..d28a420a11d4bb4b7fdce3580ab80f00342bdd39 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 by the deal.II authors
+//    Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -23,7 +23,11 @@ template <int dim> class FEValues;
 template <int dim> class FEFaceValues;
 template <int dim> class FESubfaceValues;
 template <int dim> class FESystem;
-template <int dim> class FECollection;
+namespace hp
+{
+  template <int dim> class FECollection;
+}
+
 
 /*!@addtogroup febase */
 /*@{*/
@@ -1999,7 +2003,7 @@ class FiniteElement : public Subscriptor,
                                      *
                                      * This function is needed by the
                                      * constructors of FESystem as well
-                                     * as by the FECollection class.
+                                     * as by the hp::FECollection class.
                                      */
     virtual FiniteElement<dim> *clone() const = 0;
     
@@ -2136,7 +2140,7 @@ class FiniteElement : public Subscriptor,
     friend class FEFaceValues<dim>;
     friend class FESubfaceValues<dim>;
     friend class FESystem<dim>;
-    friend class FECollection<dim>;
+    friend class hp::FECollection<dim>;
 };
 
 /*@}*/
index 04816909a82374f512df1cde5842d7a991fe9db7..67d01f48fed9be0c326a35e5657006a0ed91dd3f 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 2003, 2004 by the deal.II authors
+//    Copyright (C) 2003, 2004, 2006 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
 #define __deal2__fe_collection_h
 
 #include <base/config.h>
-#include <base/subscriptor.h>
+#include <boost/shared_ptr.hpp>
 #include <fe/fe.h>
 
 
+namespace hp
+{
+  
 /**
  * This class acts as a collection of finite element objects used in the
- * hp::DoFHandler(). It is thus to a hp::DoFHandler() what a
- * FiniteElement is to a DoFHandler. This collection stores copies
+ * hp::DoFHandler. It is thus to a hp::DoFHandler what a
+ * FiniteElement is to a ::DoFHandler. This collection stores copies
  * of the original elements added to it, and is therefore handling its memory
  * manegement itself.
  *
  * 
  * @author Wolfgang Bangerth, 2003
  */
-template <int dim>
-class FECollection : public Subscriptor
-{
-  public:
-                                     /**
-                                      * Destructor. Destroy the elements of
-                                      * the collection.
-                                      */
-    ~FECollection ();
+  template <int dim>
+  class FECollection : public Subscriptor
+  {
+    public:
+                                       /**
+                                        * Add a finite element. This function
+                                        * generates a copy of the given
+                                        * element, i.e. you can do things like
+                                        * <tt>add_fe(FE_Q<dim>(1));</tt>. The
+                                        * internal copy is later destroyed by
+                                        * this object upon destruction of the
+                                        * entire collection.
+                                        *
+                                        * The returned value is the new number
+                                        * of finite elements in the collection.
+                                        *
+                                        * When a new element is added, it needs
+                                        * to have the same number of vector
+                                        * components as all other elements
+                                        * already in the collection.
+                                        */
+      unsigned int
+      add_fe (const FiniteElement<dim> &new_fe);
+
+                                       /**
+                                        * Get a reference to the given element
+                                        * in this collection.
+                                        */
+      const FiniteElement<dim> &
+      get_fe (const unsigned int index) const;
+
+                                       /**
+                                        * Return the number of finite element
+                                        * objects stored in this collection.
+                                        */
+      unsigned int n_finite_elements () const;
+
+                                       /**
+                                        * Return the number of vector
+                                        * components of the finite elements in
+                                        * this collection.  This number must
+                                        * be the same for all elements in the
+                                        * collection.
+                                        */
+      unsigned int n_components () const;
+
+                                       /**
+                                        * Return the maximal number of degrees
+                                        * of freedom per vertex over all
+                                        * elements of this collection.
+                                        */
+      unsigned int max_dofs_per_vertex () const;
+
+                                       /**
+                                        * Return the maximal number of degrees
+                                        * of freedom per line over all elements
+                                        * of this collection.
+                                        */
+      unsigned int max_dofs_per_line () const;
+
+                                       /**
+                                        * Return the maximal number of degrees
+                                        * of freedom per quad over all elements
+                                        * of this collection.
+                                        */
+      unsigned int max_dofs_per_quad () const;
+
+                                       /**
+                                        * Return the maximal number of degrees
+                                        * of freedom per hex over all elements
+                                        * of this collection.
+                                        */
+      unsigned int max_dofs_per_hex () const;
+
+                                       /**
+                                        * Return the maximal number of degrees
+                                        * of freedom per face over all elements
+                                        * of this collection.
+                                        */
+      unsigned int max_dofs_per_face () const;
+
+                                       /**
+                                        * Return the maximal number of degrees
+                                        * of freedom per cell over all elements
+                                        * of this collection.
+                                        */
+      unsigned int max_dofs_per_cell () const;
+
+                                       /**
+                                        * Return an estimate for the memory
+                                        * allocated for this object.
+                                        */
+      unsigned int memory_consumption () const;
+
+                                       /**
+                                        * Exception
+                                        */
+      DeclException0 (ExcNoFiniteElements);    
     
-                                     /**
-                                      * Add a finite element. This function
-                                      * generates a copy of the given element,
-                                      * i.e. you can do things like
-                                      * <tt>add_fe(FE_Q<dim>(1));</tt>. The
-                                      * internal copy is later destroyed by
-                                      * this object upon destruction of the
-                                      * entire collection.
-                                      *
-                                      * The returned value is the new number
-                                      * of finite elements in the collection.
-                                      *
-                                      * When a new element is added, it needs
-                                      * to have the same number of vector
-                                      * components as all other elements
-                                      * already in the collection.
-                                      */
-    unsigned int
-    add_fe (const FiniteElement<dim> &new_fe);
-
-                                     /**
-                                      * Get a reference to the given element
-                                      * in this collection.
-                                      */
-    const FiniteElement<dim> &
-    get_fe (const unsigned int index) const;
-
-                                     /**
-                                      * Return the number of finite element
-                                      * objects stored in this collection.
-                                      */
-    unsigned int n_finite_elements () const;
-
-                                     /**
-                                      * Return the number of vector components
-                                      * of the finite elements in this
-                                      * collection.  This number must be the
-                                      * same for all elements in the
-                                      * collection.
-                                      */
-    unsigned int n_components () const;
-
-                                     /**
-                                      * Return the maximal number of degrees
-                                      * of freedom per vertex over all
-                                      * elements of this collection.
-                                      */
-    unsigned int max_dofs_per_vertex () const;
-
-                                     /**
-                                      * Return the maximal number of degrees
-                                      * of freedom per line over all elements
-                                      * of this collection.
-                                      */
-    unsigned int max_dofs_per_line () const;
-
-                                     /**
-                                      * Return the maximal number of degrees
-                                      * of freedom per quad over all elements
-                                      * of this collection.
-                                      */
-    unsigned int max_dofs_per_quad () const;
-
-                                     /**
-                                      * Return the maximal number of degrees
-                                      * of freedom per hex over all elements
-                                      * of this collection.
-                                      */
-    unsigned int max_dofs_per_hex () const;
-
-                                     /**
-                                      * Return the maximal number of degrees
-                                      * of freedom per face over all elements
-                                      * of this collection.
-                                      */
-    unsigned int max_dofs_per_face () const;
-
-                                     /**
-                                      * Return the maximal number of degrees
-                                      * of freedom per cell over all elements
-                                      * of this collection.
-                                      */
-    unsigned int max_dofs_per_cell () const;
-
-                                     /**
-                                      * Return an estimate for the memory
-                                      * allocated for this object.
-                                      */
-    unsigned int memory_consumption () const;
-
-                                     /**
-                                      * Exception
-                                      */
-    DeclException0 (ExcNoFiniteElements);    
-    
-  private:
-                                     /**
-                                      * Array of pointers to the finite
-                                      * elements stored by this collection.
-                                      */
-    std::vector<SmartPointer<const FiniteElement<dim> > > finite_elements;
-};
+    private:
+                                       /**
+                                        * Array of pointers to the finite
+                                        * elements stored by this collection.
+                                        */
+      std::vector<boost::shared_ptr<const FiniteElement<dim> > > finite_elements;
+  };
 
 
 
 /* --------------- inline functions ------------------- */
 
-template <int dim>
-inline
-unsigned int
-FECollection<dim>::n_finite_elements () const 
-{
-  return finite_elements.size();
-}
-
-
-template <int dim>
-inline
-unsigned int
-FECollection<dim>::n_components () const
-{
-  Assert (finite_elements.size () > 0, ExcNoFiniteElements());
-  return finite_elements[0]->n_components ();
-}
-
-
-template <int dim>
-inline
-const FiniteElement<dim> &
-FECollection<dim>::get_fe (const unsigned int index) const 
-{
-  Assert (index < finite_elements.size(),
-          ExcIndexRange (index, 0, finite_elements.size()));
-  return *finite_elements[index];
-}
-
-
-
-template <int dim>
-unsigned int
-FECollection<dim>::max_dofs_per_vertex () const 
-{
-  Assert (finite_elements.size() > 0, ExcNoFiniteElements());
+  template <int dim>
+  inline
+  unsigned int
+  FECollection<dim>::n_finite_elements () const 
+  {
+    return finite_elements.size();
+  }
+
+
+  template <int dim>
+  inline
+  unsigned int
+  FECollection<dim>::n_components () const
+  {
+    Assert (finite_elements.size () > 0, ExcNoFiniteElements());
+    return finite_elements[0]->n_components ();
+  }
+
+
+  template <int dim>
+  inline
+  const FiniteElement<dim> &
+  FECollection<dim>::get_fe (const unsigned int index) const 
+  {
+    Assert (index < finite_elements.size(),
+            ExcIndexRange (index, 0, finite_elements.size()));
+    return *finite_elements[index];
+  }
+
+
+
+  template <int dim>
+  unsigned int
+  FECollection<dim>::max_dofs_per_vertex () const 
+  {
+    Assert (finite_elements.size() > 0, ExcNoFiniteElements());
   
-  unsigned int max = 0;
-  for (unsigned int i=0; i<finite_elements.size(); ++i)
-    if (finite_elements[i]->dofs_per_vertex > max)
-      max = finite_elements[i]->dofs_per_vertex;
+    unsigned int max = 0;
+    for (unsigned int i=0; i<finite_elements.size(); ++i)
+      if (finite_elements[i]->dofs_per_vertex > max)
+        max = finite_elements[i]->dofs_per_vertex;
 
-  return max;
-}
+    return max;
+  }
 
 
 
-template <int dim>
-unsigned int
-FECollection<dim>::max_dofs_per_line () const 
-{
-  Assert (finite_elements.size() > 0, ExcNoFiniteElements());
+  template <int dim>
+  unsigned int
+  FECollection<dim>::max_dofs_per_line () const 
+  {
+    Assert (finite_elements.size() > 0, ExcNoFiniteElements());
   
-  unsigned int max = 0;
-  for (unsigned int i=0; i<finite_elements.size(); ++i)
-    if (finite_elements[i]->dofs_per_line > max)
-      max = finite_elements[i]->dofs_per_line;
+    unsigned int max = 0;
+    for (unsigned int i=0; i<finite_elements.size(); ++i)
+      if (finite_elements[i]->dofs_per_line > max)
+        max = finite_elements[i]->dofs_per_line;
 
-  return max;
-}
+    return max;
+  }
 
 
 
-template <int dim>
-unsigned int
-FECollection<dim>::max_dofs_per_quad () const 
-{
-  Assert (finite_elements.size() > 0, ExcNoFiniteElements());
+  template <int dim>
+  unsigned int
+  FECollection<dim>::max_dofs_per_quad () const 
+  {
+    Assert (finite_elements.size() > 0, ExcNoFiniteElements());
   
-  unsigned int max = 0;
-  for (unsigned int i=0; i<finite_elements.size(); ++i)
-    if (finite_elements[i]->dofs_per_quad > max)
-      max = finite_elements[i]->dofs_per_quad;
+    unsigned int max = 0;
+    for (unsigned int i=0; i<finite_elements.size(); ++i)
+      if (finite_elements[i]->dofs_per_quad > max)
+        max = finite_elements[i]->dofs_per_quad;
 
-  return max;
-}
+    return max;
+  }
 
 
 
-template <int dim>
-unsigned int
-FECollection<dim>::max_dofs_per_hex () const 
-{
-  Assert (finite_elements.size() > 0, ExcNoFiniteElements());
+  template <int dim>
+  unsigned int
+  FECollection<dim>::max_dofs_per_hex () const 
+  {
+    Assert (finite_elements.size() > 0, ExcNoFiniteElements());
   
-  unsigned int max = 0;
-  for (unsigned int i=0; i<finite_elements.size(); ++i)
-    if (finite_elements[i]->dofs_per_hex > max)
-      max = finite_elements[i]->dofs_per_hex;
+    unsigned int max = 0;
+    for (unsigned int i=0; i<finite_elements.size(); ++i)
+      if (finite_elements[i]->dofs_per_hex > max)
+        max = finite_elements[i]->dofs_per_hex;
 
-  return max;
-}
+    return max;
+  }
 
 
 
-template <int dim>
-unsigned int
-FECollection<dim>::max_dofs_per_face () const 
-{
-  Assert (finite_elements.size() > 0, ExcNoFiniteElements());
+  template <int dim>
+  unsigned int
+  FECollection<dim>::max_dofs_per_face () const 
+  {
+    Assert (finite_elements.size() > 0, ExcNoFiniteElements());
   
-  unsigned int max = 0;
-  for (unsigned int i=0; i<finite_elements.size(); ++i)
-    if (finite_elements[i]->dofs_per_face > max)
-      max = finite_elements[i]->dofs_per_face;
+    unsigned int max = 0;
+    for (unsigned int i=0; i<finite_elements.size(); ++i)
+      if (finite_elements[i]->dofs_per_face > max)
+        max = finite_elements[i]->dofs_per_face;
 
-  return max;
-}
+    return max;
+  }
 
 
 
-template <int dim>
-unsigned int
-FECollection<dim>::max_dofs_per_cell () const 
-{
-  Assert (finite_elements.size() > 0, ExcNoFiniteElements());
+  template <int dim>
+  unsigned int
+  FECollection<dim>::max_dofs_per_cell () const 
+  {
+    Assert (finite_elements.size() > 0, ExcNoFiniteElements());
   
-  unsigned int max = 0;
-  for (unsigned int i=0; i<finite_elements.size(); ++i)
-    if (finite_elements[i]->dofs_per_cell > max)
-      max = finite_elements[i]->dofs_per_cell;
-
-  return max;
-}
+    unsigned int max = 0;
+    for (unsigned int i=0; i<finite_elements.size(); ++i)
+      if (finite_elements[i]->dofs_per_cell > max)
+        max = finite_elements[i]->dofs_per_cell;
 
+    return max;
+  }
+  
+} // namespace hp
 
+  
 #endif
index dfc7bd1cba41222e1f622289a8422e2ed30de904..dd42c6e75c83ceb8c1438067cb25a44428163026 100644 (file)
@@ -167,8 +167,8 @@ namespace hp
                                           * indicated by the parameters
                                           * to the constructor.
                                           */
-        FEValuesBase (const MappingCollection<dim> &mapping_collection,
-                      const QCollection<q_dim>     &qcollection,
+        FEValuesBase (const hp::MappingCollection<dim> &mapping_collection,
+                      const hp::QCollection<q_dim>     &q_collection,
                       const UpdateFlags             update_flags);
 
 
@@ -181,18 +181,18 @@ namespace hp
                                           * object for the mapping
                                           * object.
                                           */
-        FEValuesBase (const QCollection<q_dim> &qcollection,
+        FEValuesBase (const hp::QCollection<q_dim> &q_collection,
                       const UpdateFlags         update_flags);
 
 
       protected:
                                          /**
-                                          * A copy of the MappingCollection
+                                          * A copy of the hp::MappingCollection
                                           * object, which was specified
                                           * upon construction of the
                                           * object.
                                           */
-        const MappingCollection<dim> mapping_collection;
+        const hp::MappingCollection<dim> mapping_collection;
     
                                          /**
                                           * Copy of the quadrature
@@ -200,7 +200,7 @@ namespace hp
                                           * provided to the
                                           * constructor.
                                           */
-        const QCollection<q_dim> qcollection;
+        const hp::QCollection<q_dim> q_collection;
 
                                          /**
                                           * Values of the update flags as
@@ -237,9 +237,9 @@ namespace hp
                                         * DoFHandler<tt>::get_fe()</tt>
                                         * function.
                                         */
-      FEValues (const MappingCollection<dim> &mapping_collection,
-                const FECollection<dim>      &fe_collection,
-                const QCollection<dim>       &qcollection,
+      FEValues (const hp::MappingCollection<dim> &mapping_collection,
+                const hp::FECollection<dim>  &fe_collection,
+                const hp::QCollection<dim>       &q_collection,
                 const UpdateFlags             update_flags);
 
 
@@ -265,9 +265,9 @@ namespace hp
                                         * DoFHandler<tt>::get_fe()</tt>
                                         * function.
                                         */
-      FEValues (const FECollection<dim> &fe_collection,
-                const QCollection<dim>  &qcollection,
-                const UpdateFlags        update_flags);
+      FEValues (const hp::FECollection<dim> &fe_collection,
+                const hp::QCollection<dim>      &q_collection,
+                const UpdateFlags            update_flags);
 
 
                                        /**
@@ -321,9 +321,9 @@ namespace hp
                                         * DoFHandler<tt>::get_fe()</tt>
                                         * function.
                                         */
-      FEFaceValues (const MappingCollection<dim> &mapping_collection,
-                    const FECollection<dim>      &fe_collection,
-                    const QCollection<dim-1>     &qcollection,
+      FEFaceValues (const hp::MappingCollection<dim> &mapping_collection,
+                    const hp::FECollection<dim>  &fe_collection,
+                    const hp::QCollection<dim-1>     &q_collection,
                     const UpdateFlags             update_flags);
 
 
@@ -349,9 +349,9 @@ namespace hp
                                         * DoFHandler<tt>::get_fe()</tt>
                                         * function.
                                         */
-      FEFaceValues (const FECollection<dim>  &fe_collection,
-                    const QCollection<dim-1> &qcollection,
-                    const UpdateFlags         update_flags);
+      FEFaceValues (const hp::FECollection<dim>  &fe_collection,
+                    const hp::QCollection<dim-1>     &q_collection,
+                    const UpdateFlags             update_flags);
 
 
                                        /**
@@ -430,9 +430,9 @@ namespace hp
                                         * DoFHandler<tt>::get_fe()</tt>
                                         * function.
                                         */
-      FESubfaceValues (const MappingCollection<dim> &mapping_collection,
-                       const FECollection<dim>      &fe_collection,
-                       const QCollection<dim-1>     &qcollection,
+      FESubfaceValues (const hp::MappingCollection<dim> &mapping_collection,
+                       const hp::FECollection<dim>  &fe_collection,
+                       const hp::QCollection<dim-1>     &q_collection,
                        const UpdateFlags             update_flags);
 
 
@@ -458,9 +458,9 @@ namespace hp
                                         * DoFHandler<tt>::get_fe()</tt>
                                         * function.
                                         */
-      FESubfaceValues (const FECollection<dim>  &fe_collection,
-                       const QCollection<dim-1> &qcollection,
-                       const UpdateFlags         update_flags);
+      FESubfaceValues (const hp::FECollection<dim> &fe_collection,
+                       const hp::QCollection<dim-1>    &q_collection,
+                       const UpdateFlags            update_flags);
 
 
                                        /**
index 157d7c74b438c45ad95546d59c04832ac1b37706..83950c4ee68bc422b5a0a4908de5fa90b79da6d0 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 by the deal.II authors
+//    Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -354,6 +354,22 @@ class Mapping : public Subscriptor
                                      * each grid cell.
                                      */
     virtual UpdateFlags update_each (const UpdateFlags) const = 0;
+
+                                     /**
+                                      * Return a pointer to a copy of the
+                                      * present object. The caller of this
+                                      * copy then assumes ownership of it.
+                                      *
+                                      * Since one can't create
+                                      * objects of class Mapping, this
+                                      * function of course has to be
+                                      * implemented by derived classes.
+                                      *
+                                      * This function is mainly used by the
+                                      * hp::MappingCollection class.
+                                      */
+    virtual
+    Mapping<dim> * clone () const = 0;
     
                                     /**
                                      * Exception
index d7405a65c37f041100a0263b926fa0dda84462d8..f3c5c32ab5e64517a1d471d40d92d8b2e6e06f37 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 2001, 2002, 2003, 2004, 2005 by the deal.II authors
+//    Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -50,6 +50,14 @@ class MappingC1 : public MappingQ<dim>
                                      */
     MappingC1 ();
 
+                                     /**
+                                      * Return a pointer to a copy of the
+                                      * present object. The caller of this
+                                      * copy then assumes ownership of it.
+                                      */
+    virtual
+    Mapping<dim> * clone () const;
+
   protected:
                                     /**
                                      * For <tt>dim=2,3</tt>. Append the
index dde71233a31970b2c447357f005b3df47c7fed40..804ab76a9e5ae6613ed522f46e19774711db7945 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 2001, 2002, 2003, 2004, 2005 by the deal.II authors
+//    Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -143,7 +143,16 @@ class MappingCartesian : public Mapping<dim>
     virtual UpdateFlags update_once (const UpdateFlags) const;    
     virtual UpdateFlags update_each (const UpdateFlags) const;
     
-                                    /**
+
+                                     /**
+                                      * Return a pointer to a copy of the
+                                      * present object. The caller of this
+                                      * copy then assumes ownership of it.
+                                      */
+    virtual
+    Mapping<dim> * clone () const;
+
+                                    /**
                                      * Exception
                                      */
     DeclException0 (ExcInvalidData);
index 65377a67ee841dedbc2353b142694e545f5f4efc..f8bc4a0ee48de3069a95f1b6e9c500381a9efb91 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 2005 by the deal.II authors
+//    Copyright (C) 2005, 2006 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -15,7 +15,6 @@
 
 #include <base/config.h>
 #include <base/subscriptor.h>
-#include <base/smartpointer.h>
 #include <fe/mapping.h>
 #include <fe/fe.h>
 
 #include <boost/shared_ptr.hpp>
 
 
+namespace hp
+{
 /**
- * This class implements a collection of mapping objects used in the
- * hp::DoFHandler(). It is thus to a hp::DoFHandler() what a Mapping is to a
- * DoFHandler. This collection stores pointers to the original mapping
- * objects added to it. Hence the handling of the memory consumed by
- * the mapping objects must be done by the user of the class.
+ * This class implements a collection of mapping objects in the same way as
+ * the hp::FECollection implements a collection of finite element classes.
  *
- * Although it is strongly recommended to supply an appropriate mapping
- * for each finite element type used in a hp-computation, the MappingCollection
- * class implements a conversion constructor from a single mapping.
- * Therefore it is possible to offer only a single mapping to the
- * hpFEValues class instead of a MappingCollection. This is for the
- * convenience of the user, as many simple geometries do not require
- * different mappings along the boundary to achieve optimal convergence rates.
- * Hence providing a single mapping object will usually suffice.
+ * Although it is recommended to supply an appropriate mapping for each finite
+ * element kind used in a hp-computation, the MappingCollection class
+ * implements a conversion constructor from a single mapping.  Therefore it is
+ * possible to offer only a single mapping to the hpFEValues class instead of
+ * a MappingCollection. This is for the convenience of the user, as many
+ * simple geometries do not require different mappings along the boundary to
+ * achieve optimal convergence rates.  Hence providing a single mapping object
+ * will usually suffice.
  * 
  * @author Oliver Kayser-Herold, 2005
  */
-template <int dim>
-class MappingCollection : public Subscriptor
-{
-  public:
-                                     /**
-                                      * Default constructor. Initialises
-                                     * this QCollection.
-                                     */
-    MappingCollection ();
-
-                                     /**
-                                      * Conversion constructor. This
-                                     * constructor creates a MappingCollection
-                                     * from a single mapping. In
-                                     * the newly created MappingCollection, this
-                                     * mapping is used for all active_fe
-                                     * indices.
-                                     */
-    MappingCollection (const Mapping<dim> &mapping);
-
-                                     /**
-                                      * Returns the number of mapping
-                                     * objects stored in this container.
-                                     */
-    unsigned int n_mappings () const;
-
-                                     /**
-                                      * Returns the mapping object which
-                                     * was specified by the user for the
-                                     * active_fe_index which is provided
-                                     * as a parameter to this method.
-                                     */
-    const Mapping<dim> &
-    get_mapping (const unsigned int active_fe_index) const;
+  template <int dim>
+  class MappingCollection : public Subscriptor
+  {
+    public:
+                                       /**
+                                        * Default constructor. Initialises
+                                        * this MappingCollection.
+                                        */
+      MappingCollection ();
+
+                                       /**
+                                        * Conversion constructor. This
+                                        * constructor creates a MappingCollection
+                                        * from a single mapping. In
+                                        * the newly created MappingCollection, this
+                                        * mapping is used for all active_fe
+                                        * indices.
+                                        */
+      MappingCollection (const Mapping<dim> &mapping);
+
+                                       /**
+                                        * Returns the number of mapping
+                                        * objects stored in this container.
+                                        */
+      unsigned int n_mappings () const;
+
+                                       /**
+                                        * Returns the mapping object which
+                                        * was specified by the user for the
+                                        * active_fe_index which is provided
+                                        * as a parameter to this method.
+                                        */
+      const Mapping<dim> &
+      get_mapping (const unsigned int active_fe_index) const;
     
-                                    /**
-                                     * Determine an estimate for the
-                                     * memory consumption (in bytes)
-                                     * of this object.
-                                     */
-    unsigned int memory_consumption () const;
-
-                                     /**
-                                      * Adds a new mapping to the MappingCollection.
-                                     * The mappings have to be added in the order
-                                     * of the active_fe_indices. Thus the reference
-                                     * to the mapping object for active_fe_index 0
-                                     * has to be added first, followed by the
-                                     * mapping object for active_fe_index 1.
-                                     */
-    unsigned int add_mapping (const Mapping<dim> &new_mapping);
-
-  private:
-                                    /**
-                                     * Upon construction of a <tt>MappingCollection</tt>
-                                     * the later functionality of the class is specified.
-                                     * Either it is a real collection, which provides
-                                     * different mappings for each active_fe_index
-                                     * or its a "unreal" collection, which returns
-                                     * a the same mapping for all active_fe_indices.
-                                     * This boolean remembers which type this object
-                                     * is.
-                                     */
-    bool single_mapping;
-
-                                    /**
-                                     * The real container, which stores pointers
-                                     * to the different Mapping objects.
-                                     */
-    std::vector<SmartPointer<const Mapping<dim> > > mappings;
-};
+                                       /**
+                                        * Determine an estimate for the
+                                        * memory consumption (in bytes)
+                                        * of this object.
+                                        */
+      unsigned int memory_consumption () const;
+
+                                       /**
+                                        * Adds a new mapping to the
+                                        * MappingCollection.  The mappings
+                                        * have to be added in the order of the
+                                        * active_fe_indices. Thus the
+                                        * reference to the mapping object for
+                                        * active_fe_index 0 has to be added
+                                        * first, followed by the mapping
+                                        * object for active_fe_index 1.
+                                        */
+      unsigned int add_mapping (const Mapping<dim> &new_mapping);
+
+    private:
+                                       /**
+                                        * Upon construction of a
+                                        * <tt>MappingCollection</tt> the later
+                                        * functionality of the class is
+                                        * specified.  Either it is a real
+                                        * collection, which provides different
+                                        * mappings for each active_fe_index or
+                                        * its a "unreal" collection, which
+                                        * returns a the same mapping for all
+                                        * active_fe_indices.  This boolean
+                                        * remembers which type this object is.
+                                        */
+      const bool single_mapping;
+
+                                       /**
+                                        * The real container, which stores
+                                        * pointers to the different Mapping
+                                        * objects.
+                                        */
+      std::vector<boost::shared_ptr<const Mapping<dim> > > mappings;
+  };
 
 
 
 /* --------------- inline functions ------------------- */
 
-template <int dim>
-inline
-unsigned int
-MappingCollection<dim>::n_mappings () const 
-{
+  template <int dim>
+  inline
+  unsigned int
+  MappingCollection<dim>::n_mappings () const 
+  {
     return mappings.size();
-}
+  }
+  
+} // namespace hp
 
 
 #endif
index 135e855400fbf3a31725fb4160c1af170552a1a5..82df1bda2c9ee574f087d9bcc37f2bbf182cbe15 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 2001, 2002, 2003, 2004, 2005 by the deal.II authors
+//    Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -123,6 +123,14 @@ class MappingQ : public MappingQ1<dim>
                                      * was passed to the constructor.
                                      */
     unsigned int get_degree () const;
+
+                                     /**
+                                      * Return a pointer to a copy of the
+                                      * present object. The caller of this
+                                      * copy then assumes ownership of it.
+                                      */
+    virtual
+    Mapping<dim> * clone () const;
     
                                     /** 
                                      * Storage for internal data of
index d02932a4ecb7fbeca655a2794eeb143c1323766d..1810833ab5e83a0dabfe314b912d24b78e586b18 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 by the deal.II authors
+//    Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -194,6 +194,14 @@ class MappingQ1 : public Mapping<dim>
                                      */
     virtual UpdateFlags update_each (const UpdateFlags flags) const;
 
+                                     /**
+                                      * Return a pointer to a copy of the
+                                      * present object. The caller of this
+                                      * copy then assumes ownership of it.
+                                      */
+    virtual
+    Mapping<dim> * clone () const;
+
                                     /** 
                                      * Storage for internal data of
                                      * d-linear transformation.
index 6851cb9015625472e2317eeb8ccf8908311fdf8b..24e447d4ce644dd7e426fc2013d93ac45c1b74c6 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 2001, 2002, 2003, 2004, 2005 by the deal.II authors
+//    Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -107,8 +107,16 @@ class MappingQ1Eulerian : public MappingQ1<dim>
                                      */
     MappingQ1Eulerian (const EulerVectorType  &euler_transform_vectors,
                        const DoFHandler<dim> &shiftmap_dof_handler);
+    
+                                     /**
+                                      * Return a pointer to a copy of the
+                                      * present object. The caller of this
+                                      * copy then assumes ownership of it.
+                                      */
+    virtual
+    Mapping<dim> * clone () const;
 
-
+    
                                     /**
                                      * Exception
                                      */
index aba72b788f079a143844357985557edb306a18d7..efe6c6a5667dd3ee2477b38db1f51739d4f1637c 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 2005 by the deal.II authors
+//    Copyright (C) 2005, 2006 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
 #include <vector>
 #include <boost/shared_ptr.hpp>
 
+
+namespace hp
+{
 /**
- * This class implements a collection of quadrature objects used in the
- * hp::DoFHandler(). It is thus to a hp::DoFHandler() what a Quadrature is to a
- * DoFHandler. This collection stores pointers to the original quadrature
- * elements added to it. Hence the handling of the memory consumed by
- * the quadrature objects must be done by the user of the class.
+ * This class implements a collection of quadrature objects in the same way as
+ * the hp::FECollection implements a collection of finite element classes.
  *
  * Although it is strongly recommended to supply an appropriate quadrature
  * for each finite element type used in a hp-computation, the QCollection
  * 
  * @author Oliver Kayser-Herold, 2005
  */
-template <int dim>
-class QCollection : public Subscriptor
-{
-  public:
-                                     /**
-                                      * Default constructor. Initialises
-                                     * this QCollection.
-                                     */
-    QCollection ();
-
-                                     /**
-                                      * Conversion constructor. This
-                                     * constructor creates a QCollection
-                                     * from a single quadrature rule. In
-                                     * the newly created QCollection, this
-                                     * quadrature is used for all active_fe
-                                     * indices.
-                                     */
-    QCollection (const Quadrature<dim> &quadrature);
-
-                                     /**
-                                      * Returns the number of quadrature
-                                     * pointers stored in this object.
-                                     */
-    unsigned int n_quadratures () const;
-
-                                     /**
-                                      * Returns a reference to the quadrature rule which
-                                     * was specified by the user for the
-                                     * active_fe_index which is provided
-                                     * as a parameter to this method.
-                                     */
-    const Quadrature<dim> &
-    get_quadrature (const unsigned int active_fe_index) const;
+  template <int dim>
+  class QCollection : public Subscriptor
+  {
+    public:
+                                       /**
+                                        * Default constructor. Initialises
+                                        * this QCollection.
+                                        */
+      QCollection ();
+
+                                       /**
+                                        * Conversion constructor. This
+                                        * constructor creates a QCollection
+                                        * from a single quadrature rule. In
+                                        * the newly created QCollection, this
+                                        * quadrature is used for all active_fe
+                                        * indices.
+                                        */
+      QCollection (const Quadrature<dim> &quadrature);
+
+                                       /**
+                                        * Returns the number of quadrature
+                                        * pointers stored in this object.
+                                        */
+      unsigned int n_quadratures () const;
+
+                                       /**
+                                        * Returns a reference to the
+                                        * quadrature rule which was specified
+                                        * by the user for the active_fe_index
+                                        * which is provided as a parameter to
+                                        * this method.
+                                        */
+      const Quadrature<dim> &
+      get_quadrature (const unsigned int active_fe_index) const;
+
+                                       /**
+                                        * Adds a new quadrature rule to the
+                                        * QCollection.  The quadrature rules
+                                        * have to be added in the same order
+                                        * as for the FECollection for which
+                                        * this quadrature rule collection is
+                                        * meant. Thus the reference to the
+                                        * quadrature rule for active_fe_index
+                                        * 0 has to be added first, followed by
+                                        * the quadrature rule for
+                                        * active_fe_index 1.
+                                        *
+                                        * This class creates a copy of the
+                                        * given quadrature object, i.e. you
+                                        * can do things like
+                                        * <tt>add_quadrature(QGauss<dim>(3));</tt>. The
+                                        * internal copy is later destroyed by
+                                        * this object upon destruction of the
+                                        * entire collection.
+                                        */
+      unsigned int add_quadrature (const Quadrature<dim> &new_quadrature);
     
-                                    /**
-                                     * Determine an estimate for the
-                                     * memory consumption (in bytes)
-                                     * of this object.
-                                     */
-    unsigned int memory_consumption () const;
-
-                                     /**
-                                      * Adds a new quadrature rule to the QCollection.
-                                     * The quadrature rules have to be added in the order
-                                     * of the active_fe_indices. Thus the reference
-                                     * to the quadrature rule for active_fe_index 0
-                                     * has to be added first, followed by the
-                                     * quadrature rule for active_fe_index 1.
-                                     */
-    unsigned int add_quadrature (const Quadrature<dim> &new_quadrature);
-
-    DeclException0 (ExcNoQuadrature);
+                                       /**
+                                        * Determine an estimate for the
+                                        * memory consumption (in bytes)
+                                        * of this object.
+                                        */
+      unsigned int memory_consumption () const;
+
+                                       /**
+                                        * Exception
+                                        */
+      DeclException0 (ExcNoQuadrature);
     
-  private:
-                                    /**
-                                     * Upon construction of a <tt>QCollection</tt>
-                                     * the later functionality of the class is specified.
-                                     * Either it is a real collection, which provides
-                                     * different quadrature rules for each active_fe_index
-                                     * or its a "unreal" collection, which returns
-                                     * a the same quadrature rule for all active_fe_indices.
-                                     * This boolean remembers which type this object
-                                     * is.
-                                     */
-    bool single_quadrature;
-
-                                    /**
-                                     * The real container, which stores pointers
-                                     * to the different quadrature objects.
-                                     */
-    std::vector<SmartPointer<const Quadrature<dim> > > quadratures;
-};
+    private:
+                                       /**
+                                        * Upon construction of a
+                                        * <tt>QCollection</tt> the later
+                                        * functionality of the class is
+                                        * specified.  Either it is a real
+                                        * collection, which provides different
+                                        * quadrature rules for each
+                                        * active_fe_index or its a "unreal"
+                                        * collection, which returns a the same
+                                        * quadrature rule for all
+                                        * active_fe_indices.  This boolean
+                                        * remembers which type this object is.
+                                        */
+      const bool single_quadrature;
+
+                                       /**
+                                        * The real container, which stores
+                                        * pointers to the different quadrature
+                                        * objects.
+                                        */
+      std::vector<boost::shared_ptr<const Quadrature<dim> > > quadratures;
+  };
 
 
 
 /* --------------- inline functions ------------------- */
 
-template <int dim>
-inline
-unsigned int
-QCollection<dim>::n_quadratures () const 
-{
+  template <int dim>
+  inline
+  unsigned int
+  QCollection<dim>::n_quadratures () const 
+  {
     return quadratures.size();
-}
+  }
+  
+} // namespace hp
 
 
 #endif
index 291fc44265ec56c609f16458ca933d08080a1612..d4045a9e02d38e6cdb5dee4486cc92177c49485d 100644 (file)
@@ -1377,7 +1377,7 @@ namespace hp
 
 
   template <int dim>
-  void DoFHandler<dim>::distribute_dofs (const FECollection<dim> &ff)
+  void DoFHandler<dim>::distribute_dofs (const hp::FECollection<dim> &ff)
   {
     Assert (tria->n_levels() > 0, ExcInvalidTriangulation());
 
index 0587a091b15ae3b6fe947d053b179b9c68f8c223..917e3ba2d863c342abc90cd85f648a57b9b3a033 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 2003, 2004 by the deal.II authors
+//    Copyright (C) 2003, 2004, 2006 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
 #include <fe/fe_collection.h>
 
 
-template <int dim>
-FECollection<dim>::~FECollection ()
+namespace hp
 {
-  for (unsigned int i=0; i<finite_elements.size(); ++i)
-    {
-      const FiniteElement<dim> *p = finite_elements[i];
-      finite_elements[i] = 0;
-      delete p;
-    }
+  template <int dim>
+  unsigned int FECollection<dim>::add_fe (const FiniteElement<dim> &new_fe)
+  {
+                                     // check that the new element has the right
+                                     // number of components. only check with
+                                     // the first element, since all the other
+                                     // elements have already passed the test
+                                     // against the first element
+    if (finite_elements.size() != 0)
+      Assert (new_fe.n_components() == finite_elements[0]->n_components(),
+              ExcMessage ("All elements inside a collection need to have the "
+                          "same number of vector components!"));
   
-  finite_elements.clear ();
-}
-
+    finite_elements
+      .push_back (boost::shared_ptr<const FiniteElement<dim> >(new_fe.clone()));
+    
+    return finite_elements.size ();
+  }
 
 
-template <int dim>
-unsigned int FECollection<dim>::add_fe (const FiniteElement<dim> &new_fe)
-{
-                                   // check that the new element has the right
-                                   // number of components. only check with
-                                   // the first element, since all the other
-                                   // elements have already passed the test
-                                   // against the first element
-  if (finite_elements.size() != 0)
-    Assert (new_fe.n_components() == finite_elements[0]->n_components(),
-            ExcMessage ("All elements inside a collection need to have the "
-                        "same number of vector components!"));
-  
-  finite_elements.push_back (new_fe.clone());
-  return (finite_elements.size ());
-}
 
+  template <int dim>
+  unsigned int
+  FECollection<dim>::memory_consumption () const
+  {
+    unsigned int mem
+      = (sizeof(*this) +
+         MemoryConsumption::memory_consumption (finite_elements));
+    for (unsigned int i=0; i<finite_elements.size(); ++i)
+      mem += finite_elements[i]->memory_consumption();
 
-
-template <int dim>
-unsigned int
-FECollection<dim>::memory_consumption () const
-{
-  unsigned int mem
-    = (sizeof(*this) +
-       MemoryConsumption::memory_consumption (finite_elements));
-  for (unsigned int i=0; i<finite_elements.size(); ++i)
-    mem += finite_elements[i]->memory_consumption();
-
-  return mem;
-}
+    return mem;
+  }
 
 
 // explicit instantiations
-template class FECollection<deal_II_dimension>;
+  template class FECollection<deal_II_dimension>;
+  
+}
index 243e0df076e6af78ed14718d66440c3700e76e75..89d711a596933719ad68d5591a0a792b9feaea6b 100644 (file)
@@ -61,22 +61,22 @@ namespace hp
 
     template <int dim, int q_dim>
     FEValuesBase<dim,q_dim>::FEValuesBase (
-      const MappingCollection<dim> &mapping_collection,
-      const QCollection<q_dim>     &qcollection,
+      const hp::MappingCollection<dim> &mapping_collection,
+      const hp::QCollection<q_dim>     &q_collection,
       const UpdateFlags             update_flags)
                     :
                     mapping_collection (mapping_collection),
-                    qcollection (qcollection),
+                    q_collection (q_collection),
                     update_flags (update_flags)
     {}
 
 
     template <int dim, int q_dim>
-    FEValuesBase<dim,q_dim>::FEValuesBase (const QCollection<q_dim> &qcollection,
+    FEValuesBase<dim,q_dim>::FEValuesBase (const hp::QCollection<q_dim> &q_collection,
                                            const UpdateFlags         update_flags)
                     :
                     mapping_collection (default_mapping),
-                    qcollection (qcollection),
+                    q_collection (q_collection),
                     update_flags (update_flags)
     {}
 
@@ -87,23 +87,23 @@ namespace hp
 
 
   template <int dim>
-  FEValues<dim>::FEValues (const MappingCollection<dim> &mapping,
-                           const FECollection<dim>      &/*fe_collection*/,
-                           const QCollection<dim>       &qcollection,
+  FEValues<dim>::FEValues (const hp::MappingCollection<dim> &mapping,
+                           const hp::FECollection<dim>  &/*fe_collection*/,
+                           const hp::QCollection<dim>       &q_collection,
                            const UpdateFlags             update_flags)
                   :
                   internal::FEValuesBase<dim,dim> (mapping,
-                                                   qcollection,
+                                                   q_collection,
                                                    update_flags)
   {}
 
 
   template <int dim>
-  FEValues<dim>::FEValues (const FECollection<dim> &/*fe_collection*/,
-                           const QCollection<dim>  &qcollection,
-                           const UpdateFlags        update_flags)
+  FEValues<dim>::FEValues (const hp::FECollection<dim> &/*fe_collection*/,
+                           const hp::QCollection<dim>      &q_collection,
+                           const UpdateFlags            update_flags)
                   :
-                  internal::FEValuesBase<dim,dim> (qcollection,
+                  internal::FEValuesBase<dim,dim> (q_collection,
                                                    update_flags)
   {}
 
@@ -125,7 +125,7 @@ namespace hp
   {
     return new ::FEValues<dim> (
       this->mapping_collection.get_mapping (active_fe_index), fe,
-      this->qcollection.get_quadrature (active_fe_index),
+      this->q_collection.get_quadrature (active_fe_index),
       this->update_flags);
   }
 
@@ -134,23 +134,23 @@ namespace hp
 
 
   template <int dim>
-  FEFaceValues<dim>::FEFaceValues (const MappingCollection<dim> &mapping,
-                                   const FECollection<dim>  &/*fe_collection*/,
-                                   const QCollection<dim-1> &qcollection,
+  FEFaceValues<dim>::FEFaceValues (const hp::MappingCollection<dim> &mapping,
+                                   const hp::FECollection<dim>  &/*fe_collection*/,
+                                   const hp::QCollection<dim-1> &q_collection,
                                    const UpdateFlags         update_flags)
                   :
                   internal::FEValuesBase<dim,dim-1> (mapping,
-                                                     qcollection,
+                                                     q_collection,
                                                      update_flags)
   {}
 
 
   template <int dim>
-  FEFaceValues<dim>::FEFaceValues (const FECollection<dim>  &/*fe_collection*/,
-                                   const QCollection<dim-1> &qcollection,
+  FEFaceValues<dim>::FEFaceValues (const hp::FECollection<dim>  &/*fe_collection*/,
+                                   const hp::QCollection<dim-1> &q_collection,
                                    const UpdateFlags         update_flags)
                   :
-                  internal::FEValuesBase<dim,dim-1> (qcollection,
+                  internal::FEValuesBase<dim,dim-1> (q_collection,
                                                      update_flags)
   {}
 
@@ -183,7 +183,7 @@ namespace hp
   {
     return new ::FEFaceValues<dim> (
       this->mapping_collection.get_mapping (active_fe_index), fe,
-      this->qcollection.get_quadrature (active_fe_index),
+      this->q_collection.get_quadrature (active_fe_index),
       this->update_flags);
   }
 
@@ -192,23 +192,23 @@ namespace hp
 
 
   template <int dim>
-  FESubfaceValues<dim>::FESubfaceValues (const MappingCollection<dim> &mapping,
-                                         const FECollection<dim>  &/*fe_collection*/,
-                                         const QCollection<dim-1> &qcollection,
+  FESubfaceValues<dim>::FESubfaceValues (const hp::MappingCollection<dim> &mapping,
+                                         const hp::FECollection<dim>  &/*fe_collection*/,
+                                         const hp::QCollection<dim-1> &q_collection,
                                          const UpdateFlags         update_flags)
                   :
                   internal::FEValuesBase<dim,dim-1> (mapping,
-                                                     qcollection,
+                                                     q_collection,
                                                      update_flags)
   {}
 
 
   template <int dim>
-  FESubfaceValues<dim>::FESubfaceValues (const FECollection<dim>  &/*fe_collection*/,
-                                         const QCollection<dim-1> &qcollection,
+  FESubfaceValues<dim>::FESubfaceValues (const hp::FECollection<dim>  &/*fe_collection*/,
+                                         const hp::QCollection<dim-1> &q_collection,
                                          const UpdateFlags         update_flags)
                   :
-                  internal::FEValuesBase<dim,dim-1> (qcollection,
+                  internal::FEValuesBase<dim,dim-1> (q_collection,
                                                      update_flags)
   {}
 
@@ -243,7 +243,7 @@ namespace hp
   {
     return new ::FESubfaceValues<dim> (
       this->mapping_collection.get_mapping (active_fe_index), fe,
-      this->qcollection.get_quadrature (active_fe_index),
+      this->q_collection.get_quadrature (active_fe_index),
       this->update_flags);
   }
 
index 01465466efd343c48e05aaddb4b2e6199c0eb5a8..d989af09ab5a381e01ac51df1d42143c701fa098 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 2001, 2002, 2003, 2005 by the deal.II authors
+//    Copyright (C) 2001, 2002, 2003, 2005, 2006 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -241,6 +241,15 @@ MappingC1<dim>::add_quad_support_points (const typename Triangulation<dim>::cell
 
 
 
+template <int dim>
+Mapping<dim> *
+MappingC1<dim>::clone () const
+{
+  return new MappingC1<dim>(*this);
+}
+
+
+
 
 // explicit instantiations
 template class MappingC1<deal_II_dimension>;
index 911ee3553870ab5ff842c2d1c5d4aac42cdc9d3e..35e43ed841300533c5161b4248ebd3be65e4a692 100644 (file)
@@ -603,6 +603,14 @@ MappingCartesian<dim>::transform_real_to_unit_cell (
 }
 
 
+template <int dim>
+Mapping<dim> *
+MappingCartesian<dim>::clone () const
+{
+  return new MappingCartesian<dim>(*this);
+}
+
+
 //---------------------------------------------------------------------------
 // explicit instantiations
 
index a29d3c5327b789ff555a2c56b5ae707f99a50188..f2086f5f9e1cb0b2045a5aec9b7108b643ad1315 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 2003 by the deal.II authors
+//    Copyright (C) 2003, 2006 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
 #include <fe/mapping_collection.h>
 
 
-template <int dim>
-MappingCollection<dim>::MappingCollection () :
-    single_mapping (false)
+namespace hp
 {
-}
 
+  template <int dim>
+  MappingCollection<dim>::MappingCollection () :
+                  single_mapping (false)
+  {
+  }
 
-template <int dim>
-MappingCollection<dim>::MappingCollection (const Mapping<dim> &mapping) :
-    single_mapping (true)
-{
-    mappings.push_back (&mapping);
-}
 
+  template <int dim>
+  MappingCollection<dim>::MappingCollection (const Mapping<dim> &mapping) :
+                  single_mapping (true)
+  {
+    mappings
+      .push_back (boost::shared_ptr<const Mapping<dim> >(mapping.clone()));
+  }
 
-template <int dim>
-inline
-const Mapping<dim> &
-MappingCollection<dim>::get_mapping (const unsigned int active_fe_index) const
-{
-    SmartPointer<const Mapping<dim> > mapping;
 
+  template <int dim>
+  inline
+  const Mapping<dim> &
+  MappingCollection<dim>::get_mapping (const unsigned int active_fe_index) const
+  {
     if (single_mapping)
-       mapping = mappings[0];
+      return *mappings[0];
     else
-    {
+      {
        Assert (active_fe_index < mappings.size (),
                ExcIndexRange (active_fe_index, 0, mappings.size ()));
-       mapping = mappings[active_fe_index];
-    }
-
-    return *mapping;
-}
+       return *mappings[active_fe_index];
+      }
+  }
 
 
-template <int dim>
-unsigned int
-MappingCollection<dim>::memory_consumption () const
-{
+  template <int dim>
+  unsigned int
+  MappingCollection<dim>::memory_consumption () const
+  {
     return (sizeof(*this) +
            MemoryConsumption::memory_consumption (mappings));
-}
+  }
 
 
-template <int dim>
-unsigned int MappingCollection<dim>::
-add_mapping (const Mapping<dim> &new_mapping)
-{
-    // A MappingCollection, which was initialized as single 
-    // MappingCollection cannot administrate other Mappings.
-    Assert (!single_mapping,
-           ExcNotInitialized ());
-    mappings.push_back (&new_mapping);
-    return (mappings.size ());
-}
+  template <int dim>
+  unsigned int MappingCollection<dim>::
+  add_mapping (const Mapping<dim> &new_mapping)
+  {
+                                     // A MappingCollection, which was
+                                     // initialized as single
+                                     // MappingCollection cannot administrate
+                                     // other Mappings.
+    Assert (!single_mapping, ExcNotInitialized ());
+    
+    mappings
+      .push_back (boost::shared_ptr<const Mapping<dim> >(new_mapping.clone()));
+
+    return mappings.size ();
+  }
 
 
 // explicit instantiations
-template class MappingCollection<deal_II_dimension>;
+  template class MappingCollection<deal_II_dimension>;
+
+  
+}
index b04936012573954e46de74ffa0e6a16db14ce9af..720d8201460f35ee1b2f148d7ddd5a009ceac814 100644 (file)
@@ -1299,6 +1299,15 @@ MappingQ<dim>::get_degree() const
   return degree;
 }
 
+
+
+template <int dim>
+Mapping<dim> *
+MappingQ<dim>::clone () const
+{
+  return new MappingQ<dim>(*this);
+}
+
   
 // explicit instantiation
 template class MappingQ<deal_II_dimension>;
index 4c68f11193f00e9d80218a0c4c5afa4f9ee137e8..c1a5cc54dcaf52a81ea4e2f05cc372bd0a1fc015 100644 (file)
@@ -1021,6 +1021,15 @@ transform_real_to_unit_cell_internal
     }
 }
 
+
+
+template <int dim>
+Mapping<dim> *
+MappingQ1<dim>::clone () const
+{
+  return new MappingQ1<dim>(*this);
+}
+
 //---------------------------------------------------------------------------
 
 template class MappingQ1<deal_II_dimension>;
index e305c1471e1c197e99c632c079c7dd1f5850c24e..1fac0108ec669524b6e2a3c4b69896c47d2ac1b2 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 2001, 2002, 2003, 2004, 2005 by the deal.II authors
+//    Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -104,6 +104,15 @@ compute_mapping_support_points(const typename Triangulation<dim>::cell_iterator
 }
 
 
+
+template <int dim, class EulerVectorType>
+Mapping<dim> *
+MappingQ1Eulerian<dim, EulerVectorType>::clone () const
+{
+  return new MappingQ1Eulerian<dim,EulerVectorType>(*this);
+}
+
+
 // explicit instantiation
 template class MappingQ1Eulerian<deal_II_dimension, Vector<double> >;
 #ifdef DEAL_II_USE_PETSC
index bdfe0fc882577e70cc533fc2b91b9cc1d65156a5..32e84e8edfc9e64dd65674cb5c96a4fdcdbc10c0 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 2003 by the deal.II authors
+//    Copyright (C) 2003, 2006 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
 #include <fe/q_collection.h>
 
 
-template <int dim>
-QCollection<dim>::QCollection () :
-    single_quadrature (false)
-{
-}
 
-
-template <int dim>
-QCollection<dim>::QCollection (const Quadrature<dim> &quadrature) :
-    single_quadrature (true)
+namespace hp
 {
-    quadratures.push_back (&quadrature);
-}
+  
+  template <int dim>
+  QCollection<dim>::QCollection ()
+                  :
+                  single_quadrature (false)
+  {
+  }
 
 
-template <int dim>
-inline
-const Quadrature<dim> &
-QCollection<dim>::get_quadrature (const unsigned int active_fe_index) const
-{
-    SmartPointer<const Quadrature<dim> > quad;
+  template <int dim>
+  QCollection<dim>::QCollection (const Quadrature<dim> &quadrature)
+                  :
+                  single_quadrature (true)
+  {
+    quadratures
+      .push_back (boost::shared_ptr<const Quadrature<dim> >(new Quadrature<dim>(quadrature)));
+  }
+
+  
 
+  template <int dim>
+  inline
+  const Quadrature<dim> &
+  QCollection<dim>::get_quadrature (const unsigned int active_fe_index) const
+  {
+                                     // if we have only a single quadrature
+                                     // that was given during construction,
+                                     // return this one. otherwise pick out
+                                     // the correct one
     if (single_quadrature)
-       quad = quadratures[0];
+      return *quadratures[0];
     else
-    {
+      {
        Assert (active_fe_index < quadratures.size (),
                ExcIndexRange (active_fe_index, 0, quadratures.size ()));
-       quad = quadratures[active_fe_index];
-    }
-
-    return *quad;
-}
+       return *quadratures[active_fe_index];
+      }
+  }
 
 
-template <int dim>
-unsigned int
-QCollection<dim>::memory_consumption () const
-{
+  template <int dim>
+  unsigned int
+  QCollection<dim>::memory_consumption () const
+  {
     return (sizeof(*this) +
            MemoryConsumption::memory_consumption (quadratures));
-}
+  }
 
 
-template <int dim>
-unsigned int QCollection<dim>::
-add_quadrature (const Quadrature<dim> &new_quadrature)
-{
-    // A QCollection, which was initialized as single QCollection cannot
-    // administrate other Quadratures.
-    Assert (!single_quadrature,
-           ExcNotInitialized ());
-    quadratures.push_back (&new_quadrature);
-    return (quadratures.size ());
-}
+  template <int dim>
+  unsigned int QCollection<dim>::
+  add_quadrature (const Quadrature<dim> &new_quadrature)
+  {
+                                     // A QCollection, which was initialized
+                                     // as single QCollection cannot
+                                     // administrate other Quadratures.
+    Assert (!single_quadrature, ExcNotInitialized ());
+
+    quadratures
+      .push_back (boost::shared_ptr<const Quadrature<dim> >(new Quadrature<dim>(new_quadrature)));
+    return quadratures.size ();
+  }
 
 
 // explicit instantiations
-template class QCollection<deal_II_dimension>;
+  template class QCollection<deal_II_dimension>;
 #if deal_II_dimension >= 2
-template class QCollection<deal_II_dimension-1>;
+  template class QCollection<deal_II_dimension-1>;
 #endif
+
+  
+}
index 779ed6ff1ab19d91349c70d6d6deddeb6d94db7f..f0d95d64c65bc56da4f55c2cbee3189757929135 100644 (file)
@@ -258,6 +258,14 @@ inconvenience this causes.
 <h3>deal.II</h3>
 
 <ol>
+  <li> <p>
+       New: The <code>Mapping</code> class and derived classes now have
+       functions <code>clone()</code> that return a new object of the same
+       (derived) type.
+       <br> 
+       (WB 2006/1/8)
+       </p>
+
   <li> <p>
        Improved: The <code>KellyErrorEstimator</code> class now also allows to
        select the cells on which it is supposed to work by giving a material
index f4bb9e71b638addd346ceadcef7d12e0f2e4928c..35ff4bd5ba0946cdbeea2bf98cc6a10072982f63 100644 (file)
@@ -614,7 +614,7 @@ class DGMethod
                                      // objects for the different polynomial
                                      // degrees will be stored in the
                                      // fe_collection object.
-    FECollection<dim>    fe_collection;
+    hp::FECollection<dim>    fe_collection;
 
                                     // As already mentioned, the
                                      // standard DoFHandler has to be
@@ -633,10 +633,8 @@ class DGMethod
                                      // rules for each polynomial
                                      // degree which will be used in the
                                      // computations.
-    std::vector<Quadrature<dim> *> quad;
-    QCollection<dim>   *quadrature;
-    std::vector<Quadrature<dim-1> *> face_quad;
-    QCollection<dim-1> *face_quadrature;
+    hp::QCollection<dim>   quadratures;
+    hp::QCollection<dim-1> face_quadratures;
     
                                     // And there are two solution
                                     // vectors, that store the
@@ -664,11 +662,6 @@ DGMethod<dim>::DGMethod ()
                dof_handler (triangulation),
                dg ()
 {
-    quadrature = new QCollection<dim> ();
-    face_quadrature = new QCollection<dim-1> (); 
-    
-    Quadrature<dim> *quad_temp;
-    Quadrature<dim-1> *face_quad_temp;
                                     // Change here for hp
                                     // methods of
                                     // different maximum degrees.
@@ -677,15 +670,8 @@ DGMethod<dim>::DGMethod ()
     for (unsigned int i = 0; i < hp_degree; ++i)
     {
        elm_no = fe_collection.add_fe (FE_DGQ<dim> (i+1));
-
-       quad_temp = new QGauss<dim> (i+2);
-       quad.push_back (quad_temp);
-       quadrature->add_quadrature (*quad_temp);
-
-       //      face_quad_temp = new QGauss<dim-1> (7);
-       face_quad_temp = new QGauss<dim-1> (i+2);
-       face_quad.push_back (face_quad_temp);
-       face_quadrature->add_quadrature (*face_quad_temp);
+       quadratures.add_quadrature (QGauss<dim> (i+2));
+       face_quadratures.add_quadrature (QGauss<dim-1> (i+2));
     }
 }
 
@@ -694,19 +680,6 @@ template <int dim>
 DGMethod<dim>::~DGMethod () 
 {
   dof_handler.clear ();
-
-  // Free the dynamically created quadrature rules
-  delete quadrature;
-  delete face_quadrature;
-
-  typename std::vector<Quadrature<dim> *>::iterator quad_iter;
-  for (quad_iter = quad.begin (); quad_iter != quad.end (); ++quad_iter)
-    delete (*quad_iter);
-
-  typename std::vector<Quadrature<dim-1> *>::iterator face_quad_iter;
-  for (face_quad_iter = face_quad.begin (); 
-       face_quad_iter != face_quad.end (); ++face_quad_iter)
-    delete (*face_quad_iter);
 }
 
 
@@ -854,7 +827,7 @@ void DGMethod<dim>::assemble_system1 ()
                                   // assumes a ``MappingQ1'' mapping)
                                   // and makes it easier to change
                                   // the mapping object later.
-  hp::FEValues<dim> fe_v_x (mapping, fe_collection, *quadrature, update_flags);
+  hp::FEValues<dim> fe_v_x (mapping, fe_collection, quadratures, update_flags);
   
                                   // Similarly we create the
                                   // ``FEFaceValues'' and
@@ -867,13 +840,13 @@ void DGMethod<dim>::assemble_system1 ()
                                   // current cell and the face (and
                                   // subface) number.
   hp::FEFaceValues<dim> fe_v_face_x (
-    mapping, fe_collection, *face_quadrature, face_update_flags);
+    mapping, fe_collection, face_quadratures, face_update_flags);
   hp::FESubfaceValues<dim> fe_v_subface_x (
-    mapping, fe_collection, *face_quadrature, face_update_flags);
+    mapping, fe_collection, face_quadratures, face_update_flags);
   hp::FEFaceValues<dim> fe_v_face_neighbor_x (
-    mapping, fe_collection, *face_quadrature, neighbor_face_update_flags);
+    mapping, fe_collection, face_quadratures, neighbor_face_update_flags);
   hp::FESubfaceValues<dim> fe_v_subface_neighbor_x (
-    mapping, fe_collection, *face_quadrature, neighbor_face_update_flags);
+    mapping, fe_collection, face_quadratures, neighbor_face_update_flags);
 
                                   // Now we create the cell matrices
                                   // and vectors. Here we need two
@@ -1348,13 +1321,13 @@ void DGMethod<dim>::assemble_system2 ()
                                   // ``fe_v_face_neighbor'' as case 4
                                   // does not occur.
   hp::FEValues<dim> fe_v_x (
-    mapping, fe_collection, *quadrature, update_flags);
+    mapping, fe_collection, quadratures, update_flags);
   hp::FEFaceValues<dim> fe_v_face_x (
-    mapping, fe_collection, *face_quadrature, face_update_flags);
+    mapping, fe_collection, face_quadratures, face_update_flags);
   hp::FESubfaceValues<dim> fe_v_subface_x (
-    mapping, fe_collection, *face_quadrature, face_update_flags);
+    mapping, fe_collection, face_quadratures, face_update_flags);
   hp::FEFaceValues<dim> fe_v_face_neighbor_x (
-    mapping, fe_collection, *face_quadrature, neighbor_face_update_flags);
+    mapping, fe_collection, face_quadratures, neighbor_face_update_flags);
 
   const unsigned int max_dofs_per_cell = fe_collection.max_dofs_per_cell ();
 

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.