*
* @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.
*/
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.
*
* missing.
*/
std::vector<FEValues<dim,spacedim>*> differences;
+
+ private:
+ /**
+ * The value returned by @p is_first_cell.
+ */
+ bool first_cell;
};
public:
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>::
+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;
}