From c6591ca9743c1fbae5bf181305f0806915e48c05 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Fri, 7 Aug 2015 21:26:41 -0500 Subject: [PATCH] Do not derive FE::InternalDataBase from Mapping::InternalDataBase. 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 | 65 ++++++++++++++++++++++++++++++++++- source/fe/fe.cc | 76 +++++++++++++++++++++++++++++++++++------ 2 files changed, 130 insertions(+), 11 deletions(-) diff --git a/include/deal.II/fe/fe.h b/include/deal.II/fe/fe.h index 261185d988..75eae22e1b 100644 --- a/include/deal.II/fe/fe.h +++ b/include/deal.II/fe/fe.h @@ -382,9 +382,21 @@ public: * * @author Guido Kanschat, 2001; Wolfgang Bangerth, 2015. */ - class InternalDataBase : public Mapping::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 &mapping, const Quadrature &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 first_cell==true this function returns @p update_flags, + * i.e. update_once|update_each. If first_cell==false 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*> differences; + + private: + /** + * The value returned by @p is_first_cell. + */ + bool first_cell; }; public: diff --git a/source/fe/fe.cc b/source/fe/fe.cc index 4b70c85f04..18f846e6b8 100644 --- a/source/fe/fe.cc +++ b/source/fe/fe.cc @@ -38,6 +38,42 @@ template const double FiniteElement::fd_step_length = 1.0e-6; +template +FiniteElement::InternalDataBase::InternalDataBase (): + update_flags(update_default), + update_once(update_default), + update_each(update_default), + first_cell(true) +{} + + + +template +FiniteElement::InternalDataBase::~InternalDataBase () +{ + for (unsigned int i=0; i +std::size_t +FiniteElement::InternalDataBase::memory_consumption () const +{ + return sizeof(*this); +} + + + + template void FiniteElement:: @@ -89,19 +125,39 @@ InternalDataBase::initialize_2nd (const FiniteElement *element, +template +inline +UpdateFlags +FiniteElement::InternalDataBase::current_update_flags () const +{ + if (first_cell) + { + Assert (update_flags==(update_once|update_each), + ExcInternalError()); + return update_flags; + } + else + return update_each; +} + + template -FiniteElement::InternalDataBase::~InternalDataBase () +inline +bool +FiniteElement::InternalDataBase::is_first_cell () const { - for (unsigned int i=0; i +inline +void +FiniteElement::InternalDataBase::clear_first_cell () +{ + first_cell = false; } -- 2.39.5