From: Peter Munch Date: Thu, 12 Nov 2020 11:49:51 +0000 (+0100) Subject: QCollection accept Quadrature<1> X-Git-Tag: v9.3.0-rc1~907^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c48d97e83d1e883ec63e55614eaee2194d97d096;p=dealii.git QCollection accept Quadrature<1> --- diff --git a/doc/news/changes/minor/20201112Munch b/doc/news/changes/minor/20201112Munch new file mode 100644 index 0000000000..c378175aa8 --- /dev/null +++ b/doc/news/changes/minor/20201112Munch @@ -0,0 +1,7 @@ +Improved: QCollection now also accepts Quadrature<1> and converts this +input quadrature rule to a dim-dimensional quadrature rule internally via +tensor product. Furthermore, a copy constructor has been added +accepting QCollection<1>. +
+(Peter Munch, 2020/11/12) + diff --git a/include/deal.II/hp/q_collection.h b/include/deal.II/hp/q_collection.h index 0ead13dc43..073bac7968 100644 --- a/include/deal.II/hp/q_collection.h +++ b/include/deal.II/hp/q_collection.h @@ -52,13 +52,20 @@ namespace hp */ QCollection() = default; + /** + * Copy constructor. + */ + template + QCollection(const QCollection &other); + /** * Conversion constructor. This constructor creates a QCollection from a * single quadrature rule. More quadrature formulas can be added with * push_back(), if desired, though it would probably be clearer to add all * mappings the same way. */ - explicit QCollection(const Quadrature &quadrature); + template + explicit QCollection(const Quadrature &quadrature); /** * Constructor. This constructor creates a QCollection from one or @@ -93,8 +100,9 @@ namespace hp * is later destroyed by this object upon destruction of the entire * collection. */ + template void - push_back(const Quadrature &new_quadrature); + push_back(const Quadrature &new_quadrature); /** * Return a reference to the quadrature rule specified by the argument. @@ -150,21 +158,41 @@ namespace hp /* --------------- inline functions ------------------- */ + template + template + QCollection::QCollection(const QCollection &other) + { + for (unsigned int i = 0; i < other.size(); ++i) + push_back(other[i]); + } + + + template template QCollection::QCollection(const QTypes &... quadrature_objects) { - static_assert(is_base_of_all, QTypes...>::value, - "Not all of the input arguments of this function " - "are derived from Quadrature!"); - // loop over all of the given arguments and add the quadrature objects to // this collection. Inlining the definition of q_pointers causes internal // compiler errors on GCC 7.1.1 so we define it separately: - const auto q_pointers = { - (static_cast *>(&quadrature_objects))...}; - for (const auto p : q_pointers) - push_back(*p); + if (is_base_of_all, QTypes...>::value) + { + const auto q_pointers = { + (reinterpret_cast *>(&quadrature_objects))...}; + for (const auto p : q_pointers) + push_back(*p); + } + else if (is_base_of_all, QTypes...>::value) + { + const auto q_pointers = { + (reinterpret_cast *>(&quadrature_objects))...}; + for (const auto p : q_pointers) + push_back(*p); + } + else + { + Assert(false, ExcNotImplemented()); + } } @@ -223,7 +251,8 @@ namespace hp template - inline QCollection::QCollection(const Quadrature &quadrature) + template + inline QCollection::QCollection(const Quadrature &quadrature) { quadratures.push_back(std::make_shared>(quadrature)); } @@ -239,8 +268,9 @@ namespace hp template + template inline void - QCollection::push_back(const Quadrature &new_quadrature) + QCollection::push_back(const Quadrature &new_quadrature) { quadratures.push_back( std::make_shared>(new_quadrature));