From 2d25cbea09ec8bc9d4833cc3d031d3812ddc6f84 Mon Sep 17 00:00:00 2001 From: David Wells Date: Wed, 4 Sep 2019 09:35:02 -0400 Subject: [PATCH] Make hp::FEvaluesBase non-internal. 1. We publicly inherit from it and 2. this fixes some doxygen issues. --- include/deal.II/hp/fe_values.h | 353 ++++++++++++++++----------------- source/hp/fe_values.cc | 215 ++++++++++---------- source/hp/fe_values.inst.in | 63 +++--- 3 files changed, 299 insertions(+), 332 deletions(-) diff --git a/include/deal.II/hp/fe_values.h b/include/deal.II/hp/fe_values.h index 971a625bfc..5591144050 100644 --- a/include/deal.II/hp/fe_values.h +++ b/include/deal.II/hp/fe_values.h @@ -37,154 +37,147 @@ class FiniteElement; #endif -namespace internal +namespace hp { - namespace hp + /** + * Base class for the hp::FE*Values classes, storing the data + * that is common to them. The main task of this class is to provide a + * table where for every combination of finite element, mapping, and + * quadrature object from their corresponding collection objects there is + * a matching ::FEValues, ::FEFaceValues, or ::FESubfaceValues object. To + * make things more efficient, however, these FE*Values objects are only + * created once requested (lazy allocation). + * + * The first template parameter denotes the space dimension we are in, the + * second the dimensionality of the object that we integrate on, i.e. for + * usual @p hp::FEValues it is equal to the first one, while for face + * integration it is one less. The third template parameter indicates the + * type of underlying non-hp FE*Values base type, i.e. it could either be + * ::FEValues, ::FEFaceValues, or ::FESubfaceValues. + * + * @ingroup hp + * + * @author Wolfgang Bangerth, 2003 + */ + template + class FEValuesBase { + public: /** - * Base class for the hp::FE*Values classes, storing the data - * that is common to them. The main task of this class is to provide a - * table where for every combination of finite element, mapping, and - * quadrature object from their corresponding collection objects there is - * a matching ::FEValues, ::FEFaceValues, or ::FESubfaceValues object. To - * make things more efficient, however, these FE*Values objects are only - * created once requested (lazy allocation). - * - * The first template parameter denotes the space dimension we are in, the - * second the dimensionality of the object that we integrate on, i.e. for - * usual @p hp::FEValues it is equal to the first one, while for face - * integration it is one less. The third template parameter indicates the - * type of underlying non-hp FE*Values base type, i.e. it could either be - * dealii::FEValues, dealii::FEFaceValues, or dealii::FESubfaceValues. + * Constructor. Set the fields of this class to the values indicated by + * the parameters to the constructor. + */ + FEValuesBase( + const MappingCollection + &mapping_collection, + const FECollection &fe_collection, + const QCollection & q_collection, + const UpdateFlags update_flags); + /** + * Constructor. This constructor is equivalent to the other one except + * that it makes the object use a $Q_1$ mapping (i.e., an object of type + * MappingQGeneric(1)) implicitly. + */ + FEValuesBase( + const FECollection &fe_collection, + const QCollection & q_collection, + const UpdateFlags update_flags); + + /** + * Get a reference to the collection of finite element objects used + * here. + */ + const FECollection & + get_fe_collection() const; + + /** + * Get a reference to the collection of mapping objects used here. + */ + const MappingCollection & + get_mapping_collection() const; + + /** + * Get a reference to the collection of quadrature objects used here. + */ + const QCollection & + get_quadrature_collection() const; + + /** + * Get the underlying update flags. + */ + UpdateFlags + get_update_flags() const; + + /** + * Return a reference to the @p FEValues object selected by the last + * call to select_fe_values(). select_fe_values() in turn is called when + * you called the @p reinit function of the hp::FE*Values class + * the last time. + */ + const FEValuesType & + get_present_fe_values() const; + + protected: + /** + * Select a FEValues object suitable for the given FE, quadrature, and + * mapping indices. If such an object doesn't yet exist, create one. * - * @ingroup hp + * The function returns a writable reference so that derived classes can + * also reinit() the selected FEValues object. + */ + FEValuesType & + select_fe_values(const unsigned int fe_index, + const unsigned int mapping_index, + const unsigned int q_index); + + protected: + /** + * A pointer to the collection of finite elements to be used. + */ + const SmartPointer, + FEValuesBase> + fe_collection; + + /** + * A pointer to the collection of mappings to be used. + */ + const SmartPointer< + const MappingCollection, + FEValuesBase> + mapping_collection; + + /** + * Copy of the quadrature collection object provided to the constructor. + */ + const QCollection q_collection; + + private: + /** + * A table in which we store pointers to fe_values objects for different + * finite element, mapping, and quadrature objects from our collection. + * The first index indicates the index of the finite element within the + * fe_collection, the second the index of the mapping within the mapping + * collection, and the last one the index of the quadrature formula + * within the q_collection. * - * @author Wolfgang Bangerth, 2003 + * Initially, all entries have zero pointers, and we will allocate them + * lazily as needed in select_fe_values(). + */ + Table<3, std::shared_ptr> fe_values_table; + + /** + * Set of indices pointing at the fe_values object selected last time + * the select_fe_value() function was called. + */ + TableIndices<3> present_fe_values_index; + + /** + * Values of the update flags as given to the constructor. */ - template - class FEValuesBase - { - public: - /** - * Constructor. Set the fields of this class to the values indicated by - * the parameters to the constructor. - */ - FEValuesBase( - const dealii::hp::MappingCollection - &mapping_collection, - const dealii::hp::FECollection - & fe_collection, - const dealii::hp::QCollection &q_collection, - const dealii::UpdateFlags update_flags); - /** - * Constructor. This constructor is equivalent to the other one except - * that it makes the object use a $Q_1$ mapping (i.e., an object of type - * MappingQGeneric(1)) implicitly. - */ - FEValuesBase( - const dealii::hp::FECollection - & fe_collection, - const dealii::hp::QCollection &q_collection, - const UpdateFlags update_flags); - - /** - * Get a reference to the collection of finite element objects used - * here. - */ - const dealii::hp::FECollection & - get_fe_collection() const; - - /** - * Get a reference to the collection of mapping objects used here. - */ - const dealii::hp::MappingCollection & - get_mapping_collection() const; - - /** - * Get a reference to the collection of quadrature objects used here. - */ - const dealii::hp::QCollection & - get_quadrature_collection() const; - - /** - * Get the underlying update flags. - */ - UpdateFlags - get_update_flags() const; - - /** - * Return a reference to the @p FEValues object selected by the last - * call to select_fe_values(). select_fe_values() in turn is called when - * you called the @p reinit function of the hp::FE*Values class - * the last time. - */ - const FEValuesType & - get_present_fe_values() const; - - protected: - /** - * Select a FEValues object suitable for the given FE, quadrature, and - * mapping indices. If such an object doesn't yet exist, create one. - * - * The function returns a writable reference so that derived classes can - * also reinit() the selected FEValues object. - */ - FEValuesType & - select_fe_values(const unsigned int fe_index, - const unsigned int mapping_index, - const unsigned int q_index); - - protected: - /** - * A pointer to the collection of finite elements to be used. - */ - const SmartPointer< - const dealii::hp::FECollection, - FEValuesBase> - fe_collection; - - /** - * A pointer to the collection of mappings to be used. - */ - const SmartPointer< - const dealii::hp::MappingCollection, - FEValuesBase> - mapping_collection; - - /** - * Copy of the quadrature collection object provided to the constructor. - */ - const dealii::hp::QCollection q_collection; - - private: - /** - * A table in which we store pointers to fe_values objects for different - * finite element, mapping, and quadrature objects from our collection. - * The first index indicates the index of the finite element within the - * fe_collection, the second the index of the mapping within the mapping - * collection, and the last one the index of the quadrature formula - * within the q_collection. - * - * Initially, all entries have zero pointers, and we will allocate them - * lazily as needed in select_fe_values(). - */ - dealii::Table<3, std::shared_ptr> fe_values_table; - - /** - * Set of indices pointing at the fe_values object selected last time - * the select_fe_value() function was called. - */ - TableIndices<3> present_fe_values_index; - - /** - * Values of the update flags as given to the constructor. - */ - const UpdateFlags update_flags; - }; - - } // namespace hp - -} // namespace internal + const UpdateFlags update_flags; + }; + +} // namespace hp namespace hp @@ -238,8 +231,8 @@ namespace hp * @author Wolfgang Bangerth, 2003 */ template - class FEValues : public dealii::internal::hp:: - FEValuesBase> + class FEValues + : public hp::FEValuesBase> { public: static const unsigned int dimension = dim; @@ -379,8 +372,7 @@ namespace hp */ template class FEFaceValues - : public dealii::internal::hp:: - FEValuesBase> + : public hp::FEValuesBase> { public: /** @@ -499,7 +491,7 @@ namespace hp */ template class FESubfaceValues - : public dealii::internal::hp:: + : public hp:: FEValuesBase> { public: @@ -606,56 +598,51 @@ namespace hp // -------------- inline and template functions -------------- -namespace internal +namespace hp { - namespace hp + template + inline const FEValuesType & + FEValuesBase::get_present_fe_values() const { - template - inline const FEValuesType & - FEValuesBase::get_present_fe_values() const - { - return *fe_values_table(present_fe_values_index); - } - + return *fe_values_table(present_fe_values_index); + } - template - inline const dealii::hp::FECollection & - FEValuesBase::get_fe_collection() const - { - return *fe_collection; - } + template + inline const FECollection & + FEValuesBase::get_fe_collection() const + { + return *fe_collection; + } - template - inline const dealii::hp::MappingCollection & - FEValuesBase::get_mapping_collection() const - { - return *mapping_collection; - } + template + inline const MappingCollection & + FEValuesBase::get_mapping_collection() const + { + return *mapping_collection; + } - template - inline const dealii::hp::QCollection & - FEValuesBase::get_quadrature_collection() const - { - return q_collection; - } + template + inline const QCollection & + FEValuesBase::get_quadrature_collection() const + { + return q_collection; + } - template - inline dealii::UpdateFlags - FEValuesBase::get_update_flags() const - { - return update_flags; - } - } // namespace hp -} // namespace internal + template + inline UpdateFlags + FEValuesBase::get_update_flags() const + { + return update_flags; + } +} // namespace hp DEAL_II_NAMESPACE_CLOSE diff --git a/source/hp/fe_values.cc b/source/hp/fe_values.cc index 16977521e6..2852f19d69 100644 --- a/source/hp/fe_values.cc +++ b/source/hp/fe_values.cc @@ -19,90 +19,85 @@ DEAL_II_NAMESPACE_OPEN -namespace internal +namespace hp { - namespace hp - { - // -------------------------- FEValuesBase ------------------------- - - template - FEValuesBase::FEValuesBase( - const dealii::hp::MappingCollection - &mapping_collection, - const dealii::hp::FECollection - & fe_collection, - const dealii::hp::QCollection &q_collection, - const UpdateFlags update_flags) - : fe_collection(&fe_collection) - , mapping_collection(&mapping_collection) - , q_collection(q_collection) - , fe_values_table(fe_collection.size(), - mapping_collection.size(), - q_collection.size()) - , present_fe_values_index(numbers::invalid_unsigned_int, - numbers::invalid_unsigned_int, - numbers::invalid_unsigned_int) - , update_flags(update_flags) - {} - - - template - FEValuesBase::FEValuesBase( - const dealii::hp::FECollection - & fe_collection, - const dealii::hp::QCollection &q_collection, - const UpdateFlags update_flags) - : fe_collection(&fe_collection) - , mapping_collection( - &dealii::hp::StaticMappingQ1:: - mapping_collection) - , q_collection(q_collection) - , fe_values_table(fe_collection.size(), 1, q_collection.size()) - , present_fe_values_index(numbers::invalid_unsigned_int, - numbers::invalid_unsigned_int, - numbers::invalid_unsigned_int) - , update_flags(update_flags) - {} - - - - template - FEValuesType & - FEValuesBase::select_fe_values( - const unsigned int fe_index, - const unsigned int mapping_index, - const unsigned int q_index) - { - Assert(fe_index < fe_collection->size(), - ExcIndexRange(fe_index, 0, fe_collection->size())); - Assert(mapping_index < mapping_collection->size(), - ExcIndexRange(mapping_index, 0, mapping_collection->size())); - Assert(q_index < q_collection.size(), - ExcIndexRange(q_index, 0, q_collection.size())); - - - // set the triple of indices - // that we want to work with - present_fe_values_index = - TableIndices<3>(fe_index, mapping_index, q_index); - - // first check whether we - // already have an object for - // this particular combination - // of indices - if (fe_values_table(present_fe_values_index).get() == nullptr) - fe_values_table(present_fe_values_index) = - std::make_shared((*mapping_collection)[mapping_index], - (*fe_collection)[fe_index], - q_collection[q_index], - update_flags); - - // now there definitely is one! - return *fe_values_table(present_fe_values_index); - } - } // namespace hp -} // namespace internal + // -------------------------- FEValuesBase ------------------------- + + template + FEValuesBase::FEValuesBase( + const dealii::hp::MappingCollection + &mapping_collection, + const dealii::hp::FECollection + & fe_collection, + const dealii::hp::QCollection &q_collection, + const UpdateFlags update_flags) + : fe_collection(&fe_collection) + , mapping_collection(&mapping_collection) + , q_collection(q_collection) + , fe_values_table(fe_collection.size(), + mapping_collection.size(), + q_collection.size()) + , present_fe_values_index(numbers::invalid_unsigned_int, + numbers::invalid_unsigned_int, + numbers::invalid_unsigned_int) + , update_flags(update_flags) + {} + + + template + FEValuesBase::FEValuesBase( + const dealii::hp::FECollection + & fe_collection, + const dealii::hp::QCollection &q_collection, + const UpdateFlags update_flags) + : fe_collection(&fe_collection) + , mapping_collection( + &dealii::hp::StaticMappingQ1:: + mapping_collection) + , q_collection(q_collection) + , fe_values_table(fe_collection.size(), 1, q_collection.size()) + , present_fe_values_index(numbers::invalid_unsigned_int, + numbers::invalid_unsigned_int, + numbers::invalid_unsigned_int) + , update_flags(update_flags) + {} + + + template + FEValuesType & + FEValuesBase::select_fe_values( + const unsigned int fe_index, + const unsigned int mapping_index, + const unsigned int q_index) + { + Assert(fe_index < fe_collection->size(), + ExcIndexRange(fe_index, 0, fe_collection->size())); + Assert(mapping_index < mapping_collection->size(), + ExcIndexRange(mapping_index, 0, mapping_collection->size())); + Assert(q_index < q_collection.size(), + ExcIndexRange(q_index, 0, q_collection.size())); + + + // set the triple of indices + // that we want to work with + present_fe_values_index = TableIndices<3>(fe_index, mapping_index, q_index); + + // first check whether we + // already have an object for + // this particular combination + // of indices + if (fe_values_table(present_fe_values_index).get() == nullptr) + fe_values_table(present_fe_values_index) = + std::make_shared((*mapping_collection)[mapping_index], + (*fe_collection)[fe_index], + q_collection[q_index], + update_flags); + + // now there definitely is one! + return *fe_values_table(present_fe_values_index); + } +} // namespace hp namespace hp @@ -116,11 +111,10 @@ namespace hp const hp::FECollection & fe_collection, const hp::QCollection & q_collection, const UpdateFlags update_flags) - : internal::hp::FEValuesBase>( - mapping, - fe_collection, - q_collection, - update_flags) + : hp::FEValuesBase>(mapping, + fe_collection, + q_collection, + update_flags) {} @@ -129,10 +123,9 @@ namespace hp const hp::FECollection &fe_collection, const hp::QCollection & q_collection, const UpdateFlags update_flags) - : internal::hp::FEValuesBase>( - fe_collection, - q_collection, - update_flags) + : hp::FEValuesBase>(fe_collection, + q_collection, + update_flags) {} @@ -237,12 +230,11 @@ namespace hp const hp::FECollection & fe_collection, const hp::QCollection & q_collection, const UpdateFlags update_flags) - : internal::hp:: - FEValuesBase>( - mapping, - fe_collection, - q_collection, - update_flags) + : hp::FEValuesBase>( + mapping, + fe_collection, + q_collection, + update_flags) {} @@ -251,11 +243,10 @@ namespace hp const hp::FECollection &fe_collection, const hp::QCollection & q_collection, const UpdateFlags update_flags) - : internal::hp:: - FEValuesBase>( - fe_collection, - q_collection, - update_flags) + : hp::FEValuesBase>( + fe_collection, + q_collection, + update_flags) {} @@ -362,12 +353,11 @@ namespace hp const hp::FECollection & fe_collection, const hp::QCollection & q_collection, const UpdateFlags update_flags) - : internal::hp:: - FEValuesBase>( - mapping, - fe_collection, - q_collection, - update_flags) + : hp::FEValuesBase>( + mapping, + fe_collection, + q_collection, + update_flags) {} @@ -376,11 +366,10 @@ namespace hp const hp::FECollection &fe_collection, const hp::QCollection & q_collection, const UpdateFlags update_flags) - : internal::hp:: - FEValuesBase>( - fe_collection, - q_collection, - update_flags) + : hp::FEValuesBase>( + fe_collection, + q_collection, + update_flags) {} diff --git a/source/hp/fe_values.inst.in b/source/hp/fe_values.inst.in index 97823e535a..8683eb5ddd 100644 --- a/source/hp/fe_values.inst.in +++ b/source/hp/fe_values.inst.in @@ -16,20 +16,17 @@ for (deal_II_dimension : DIMENSIONS) { - namespace internal + namespace hp \{ - namespace hp - \{ - template class FEValuesBase>; - template class FEValuesBase>; - template class FEValuesBase>; - \} + template class FEValuesBase>; + template class FEValuesBase>; + template class FEValuesBase>; \} namespace hp @@ -43,23 +40,20 @@ for (deal_II_dimension : DIMENSIONS) #if deal_II_dimension != 3 - namespace internal + namespace hp \{ - namespace hp - \{ - template class FEValuesBase< - deal_II_dimension, - deal_II_dimension, - dealii::FEValues>; - template class FEValuesBase< - deal_II_dimension, - deal_II_dimension - 1, - dealii::FEFaceValues>; - template class FEValuesBase< - deal_II_dimension, - deal_II_dimension - 1, - dealii::FESubfaceValues>; - \} + template class FEValuesBase< + deal_II_dimension, + deal_II_dimension, + dealii::FEValues>; + template class FEValuesBase< + deal_II_dimension, + deal_II_dimension - 1, + dealii::FEFaceValues>; + template class FEValuesBase< + deal_II_dimension, + deal_II_dimension - 1, + dealii::FESubfaceValues>; \} namespace hp @@ -72,14 +66,11 @@ for (deal_II_dimension : DIMENSIONS) #if deal_II_dimension == 3 - namespace internal + namespace hp \{ - namespace hp - \{ - template class FEValuesBase<1, 1, dealii::FEValues<1, 3>>; - template class FEValuesBase<1, 1 - 1, dealii::FEFaceValues<1, 3>>; - template class FEValuesBase<1, 1 - 1, dealii::FESubfaceValues<1, 3>>; - \} + template class FEValuesBase<1, 1, dealii::FEValues<1, 3>>; + template class FEValuesBase<1, 1 - 1, dealii::FEFaceValues<1, 3>>; + template class FEValuesBase<1, 1 - 1, dealii::FESubfaceValues<1, 3>>; \} namespace hp -- 2.39.5