]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Do not derive FE::InternalDataBase from Mapping::InternalDataBase.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Sat, 8 Aug 2015 02:26:41 +0000 (21:26 -0500)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Sat, 8 Aug 2015 02:26:41 +0000 (21:26 -0500)
It turns out that FiniteElement::InternalDataBase does not actually need any
of the fields of the class it was previously derived from (other than the
is_first_cell/clear_first_cell mechanism, see #1305). So break the inheritance
and have these two classes be completely unrelated.

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

index 261185d988627b6d97135ef0ce4284c16f7285ee..75eae22e1bf12b5b8a65fe28431f379613dd7bec 100644 (file)
@@ -382,9 +382,21 @@ public:
    *
    * @author Guido Kanschat, 2001; Wolfgang Bangerth, 2015.
    */
-  class InternalDataBase : public Mapping<dim,spacedim>::InternalDataBase
+  class InternalDataBase : public Subscriptor
   {
+  private:
+    /**
+     * Copy construction is forbidden.
+     */
+    InternalDataBase (const InternalDataBase &);
+
   public:
+    /**
+     * Constructor. Sets update_flags to @p update_default and @p first_cell
+     * to @p true.
+     */
+    InternalDataBase ();
+
     /**
      * Destructor. Made virtual to allow polymorphism.
      */
@@ -398,6 +410,51 @@ public:
                          const Mapping<dim,spacedim>       &mapping,
                          const Quadrature<dim>    &quadrature);
 
+    /**
+     * Values updated by the constructor or by reinit.
+     */
+    UpdateFlags          update_flags;
+
+    /**
+     * Values computed by constructor.
+     */
+    UpdateFlags          update_once;
+
+    /**
+     * Values updated on each cell by reinit.
+     */
+    UpdateFlags          update_each;
+
+    /**
+     * If <tt>first_cell==true</tt> this function returns @p update_flags,
+     * i.e. <tt>update_once|update_each</tt>. If <tt>first_cell==false</tt> it
+     * returns @p update_each.
+     */
+    UpdateFlags  current_update_flags() const;
+
+    /**
+     * Return whether we are presently initializing data for the first cell.
+     * The value of the field this function is returning is set to @p true in
+     * the constructor, and cleared by the @p FEValues class after the first
+     * cell has been initialized.
+     *
+     * This function is used to determine whether we need to use the @p
+     * update_once flags for computing data, or whether we can use the @p
+     * update_each flags.
+     */
+    bool is_first_cell () const;
+
+    /**
+     * Set the @p first_cell flag to @p false. Used by the @p FEValues class
+     * to indicate that we have already done the work on the first cell.
+     */
+    virtual void clear_first_cell ();
+
+    /**
+     * Return an estimate (in bytes) or the memory consumption of this object.
+     */
+    virtual std::size_t memory_consumption () const;
+
     /**
      * Storage for FEValues objects needed to approximate second derivatives.
      *
@@ -406,6 +463,12 @@ public:
      * missing.
      */
     std::vector<FEValues<dim,spacedim>*> differences;
+
+  private:
+    /**
+     * The value returned by @p is_first_cell.
+     */
+    bool first_cell;
   };
 
 public:
index 4b70c85f04c07b2d3ed68c19f02a873a3c56ea64..18f846e6b8e19422ab2a4e88157a118536e7bc96 100644 (file)
@@ -38,6 +38,42 @@ template <int dim, int spacedim>
 const double FiniteElement<dim,spacedim>::fd_step_length = 1.0e-6;
 
 
+template <int dim, int spacedim>
+FiniteElement<dim, spacedim>::InternalDataBase::InternalDataBase ():
+  update_flags(update_default),
+  update_once(update_default),
+  update_each(update_default),
+  first_cell(true)
+{}
+
+
+
+template <int dim, int spacedim>
+FiniteElement<dim,spacedim>::InternalDataBase::~InternalDataBase ()
+{
+  for (unsigned int i=0; i<differences.size (); ++i)
+    if (differences[i] != 0)
+      {
+        // delete pointer and set it
+        // to zero to avoid
+        // inadvertent use
+        delete differences[i];
+        differences[i] = 0;
+      }
+}
+
+
+
+template <int dim, int spacedim>
+std::size_t
+FiniteElement<dim, spacedim>::InternalDataBase::memory_consumption () const
+{
+  return sizeof(*this);
+}
+
+
+
+
 template <int dim, int spacedim>
 void
 FiniteElement<dim,spacedim>::
@@ -89,19 +125,39 @@ InternalDataBase::initialize_2nd (const FiniteElement<dim,spacedim> *element,
 
 
 
+template <int dim, int spacedim>
+inline
+UpdateFlags
+FiniteElement<dim,spacedim>::InternalDataBase::current_update_flags () const
+{
+  if (first_cell)
+    {
+      Assert (update_flags==(update_once|update_each),
+              ExcInternalError());
+      return update_flags;
+    }
+  else
+    return update_each;
+}
+
+
 
 template <int dim, int spacedim>
-FiniteElement<dim,spacedim>::InternalDataBase::~InternalDataBase ()
+inline
+bool
+FiniteElement<dim,spacedim>::InternalDataBase::is_first_cell () const
 {
-  for (unsigned int i=0; i<differences.size (); ++i)
-    if (differences[i] != 0)
-      {
-        // delete pointer and set it
-        // to zero to avoid
-        // inadvertent use
-        delete differences[i];
-        differences[i] = 0;
-      };
+  return first_cell;
+}
+
+
+
+template <int dim, int spacedim>
+inline
+void
+FiniteElement<dim,spacedim>::InternalDataBase::clear_first_cell ()
+{
+  first_cell = false;
 }
 
 

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.