From: grahambenharper Date: Fri, 16 Aug 2019 07:37:23 +0000 (-0600) Subject: Change Polynomials classes to derive from TensorPolynomialsBase X-Git-Tag: v9.2.0-rc1~1229^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F8588%2Fhead;p=dealii.git Change Polynomials classes to derive from TensorPolynomialsBase --- diff --git a/include/deal.II/base/polynomials_abf.h b/include/deal.II/base/polynomials_abf.h index 1be8c69dec..44ef70688b 100644 --- a/include/deal.II/base/polynomials_abf.h +++ b/include/deal.II/base/polynomials_abf.h @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -51,7 +52,7 @@ DEAL_II_NAMESPACE_OPEN * @date 2006 */ template -class PolynomialsABF +class PolynomialsABF : public TensorPolynomialsBase { public: /** @@ -82,26 +83,13 @@ public: std::vector> &grads, std::vector> &grad_grads, std::vector> &third_derivatives, - std::vector> &fourth_derivatives) const; - - /** - * Return the number of ABF polynomials. - */ - unsigned int - n() const; - - /** - * Return the degree of the ABF space, which is two less than the highest - * polynomial degree. - */ - unsigned int - degree() const; + std::vector> &fourth_derivatives) const override; /** * Return the name of the space, which is ABF. */ std::string - name() const; + name() const override; /** * Return the number of polynomials in the space RT(degree) without @@ -111,12 +99,13 @@ public: static unsigned int compute_n_pols(unsigned int degree); -private: /** - * The degree of this object as given to the constructor. + * @copydoc TensorPolynomialsBase::clone() */ - const unsigned int my_degree; + virtual std::unique_ptr> + clone() const override; +private: /** * An object representing the polynomial space for a single component. We * can re-use it for the other vector components by rotating the @@ -124,11 +113,6 @@ private: */ const AnisotropicPolynomials polynomial_space; - /** - * Number of Raviart-Thomas polynomials. - */ - unsigned int n_pols; - /** * A mutex that guards the following scratch arrays. */ @@ -161,22 +145,6 @@ private: }; -template -inline unsigned int -PolynomialsABF::n() const -{ - return n_pols; -} - - -template -inline unsigned int -PolynomialsABF::degree() const -{ - return my_degree; -} - - template inline std::string PolynomialsABF::name() const diff --git a/include/deal.II/base/polynomials_bdm.h b/include/deal.II/base/polynomials_bdm.h index 45d962ae5b..be37ecc584 100644 --- a/include/deal.II/base/polynomials_bdm.h +++ b/include/deal.II/base/polynomials_bdm.h @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -97,7 +98,7 @@ DEAL_II_NAMESPACE_OPEN * @date 2003, 2005, 2009 */ template -class PolynomialsBDM +class PolynomialsBDM : public TensorPolynomialsBase { public: /** @@ -128,13 +129,7 @@ public: std::vector> &grads, std::vector> &grad_grads, std::vector> &third_derivatives, - std::vector> &fourth_derivatives) const; - - /** - * Return the number of BDM polynomials. - */ - unsigned int - n() const; + std::vector> &fourth_derivatives) const override; /** * Return the degree of the BDM space, which is one less than the highest @@ -147,7 +142,7 @@ public: * Return the name of the space, which is BDM. */ std::string - name() const; + name() const override; /** * Return the number of polynomials in the space BDM(degree) @@ -157,6 +152,12 @@ public: static unsigned int compute_n_pols(unsigned int degree); + /** + * @copydoc TensorPolynomialsBase::clone() + */ + virtual std::unique_ptr> + clone() const override; + private: /** * An object representing the polynomial space used here. The constructor @@ -170,11 +171,6 @@ private: */ std::vector> monomials; - /** - * Number of BDM polynomials. - */ - unsigned int n_pols; - /** * A mutex that guards the following scratch arrays. */ @@ -207,14 +203,6 @@ private: }; -template -inline unsigned int -PolynomialsBDM::n() const -{ - return n_pols; -} - - template inline unsigned int PolynomialsBDM::degree() const diff --git a/include/deal.II/base/polynomials_bernardi_raugel.h b/include/deal.II/base/polynomials_bernardi_raugel.h index eb37c35106..3c4c605256 100644 --- a/include/deal.II/base/polynomials_bernardi_raugel.h +++ b/include/deal.II/base/polynomials_bernardi_raugel.h @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -81,7 +82,7 @@ DEAL_II_NAMESPACE_OPEN * @date 2018 */ template -class PolynomialsBernardiRaugel +class PolynomialsBernardiRaugel : public TensorPolynomialsBase { public: /** @@ -93,26 +94,11 @@ public: */ PolynomialsBernardiRaugel(const unsigned int k); - /** - * Return the number of Bernardi-Raugel polynomials. - */ - unsigned int - n() const; - - - /** - * Return the degree of Bernardi-Raugel polynomials. - * Since the bubble functions are quadratic in at least one variable, - * the degree of the Bernardi-Raugel polynomials is two. - */ - unsigned int - degree() const; - /** * Return the name of the space, which is BernardiRaugel. */ std::string - name() const; + name() const override; /** * Compute the value and derivatives of each Bernardi-Raugel @@ -132,7 +118,7 @@ public: std::vector> &grads, std::vector> &grad_grads, std::vector> &third_derivatives, - std::vector> &fourth_derivatives) const; + std::vector> &fourth_derivatives) const override; /** * Return the number of polynomials in the space BR(degree) without @@ -142,17 +128,13 @@ public: static unsigned int compute_n_pols(const unsigned int k); -private: - /** - * The degree of this object given to the constructor (must be 1). - */ - const unsigned int my_degree; - /** - * The number of Bernardi-Raugel polynomials. + * @copydoc TensorPolynomialsBase::clone() */ - const unsigned int n_pols; + virtual std::unique_ptr> + clone() const override; +private: /** * An object representing the polynomial space of Q * functions which forms the BR polynomials through @@ -184,24 +166,6 @@ private: }; -template -inline unsigned int -PolynomialsBernardiRaugel::n() const -{ - return n_pols; -} - - - -template -inline unsigned int -PolynomialsBernardiRaugel::degree() const -{ - return 2; -} - - - template inline std::string PolynomialsBernardiRaugel::name() const diff --git a/include/deal.II/base/polynomials_nedelec.h b/include/deal.II/base/polynomials_nedelec.h index d082478075..ef1e061a26 100644 --- a/include/deal.II/base/polynomials_nedelec.h +++ b/include/deal.II/base/polynomials_nedelec.h @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -49,7 +50,7 @@ DEAL_II_NAMESPACE_OPEN * @date 2009, 2010 */ template -class PolynomialsNedelec +class PolynomialsNedelec : public TensorPolynomialsBase { public: /** @@ -79,26 +80,13 @@ public: std::vector> &grads, std::vector> &grad_grads, std::vector> &third_derivatives, - std::vector> &fourth_derivatives) const; - - /** - * Return the number of Nédélec polynomials. - */ - unsigned int - n() const; - - /** - * Return the degree of the Nédélec space, which is one less than the - * highest polynomial degree. - */ - unsigned int - degree() const; + std::vector> &fourth_derivatives) const override; /** * Return the name of the space, which is Nedelec. */ std::string - name() const; + name() const override; /** * Return the number of polynomials in the space N(degree) without @@ -108,23 +96,19 @@ public: static unsigned int compute_n_pols(unsigned int degree); -private: /** - * The degree of this object as given to the constructor. + * @copydoc TensorPolynomialsBase::clone() */ - const unsigned int my_degree; + virtual std::unique_ptr> + clone() const override; +private: /** * An object representing the polynomial space for a single component. We * can re-use it by rotating the coordinates of the evaluation point. */ const AnisotropicPolynomials polynomial_space; - /** - * Number of Nédélec polynomials. - */ - const unsigned int n_pols; - /** * A static member function that creates the polynomial space we use to * initialize the #polynomial_space member variable. @@ -134,22 +118,6 @@ private: }; -template -inline unsigned int -PolynomialsNedelec::n() const -{ - return n_pols; -} - - -template -inline unsigned int -PolynomialsNedelec::degree() const -{ - return my_degree; -} - - template inline std::string PolynomialsNedelec::name() const diff --git a/include/deal.II/base/polynomials_raviart_thomas.h b/include/deal.II/base/polynomials_raviart_thomas.h index 15501e71b9..c0cd7c7bc4 100644 --- a/include/deal.II/base/polynomials_raviart_thomas.h +++ b/include/deal.II/base/polynomials_raviart_thomas.h @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -46,7 +47,7 @@ DEAL_II_NAMESPACE_OPEN * @date 2005 */ template -class PolynomialsRaviartThomas +class PolynomialsRaviartThomas : public TensorPolynomialsBase { public: /** @@ -77,26 +78,13 @@ public: std::vector> &grads, std::vector> &grad_grads, std::vector> &third_derivatives, - std::vector> &fourth_derivatives) const; - - /** - * Return the number of Raviart-Thomas polynomials. - */ - unsigned int - n() const; - - /** - * Return the degree of the Raviart-Thomas space, which is one less than - * the highest polynomial degree. - */ - unsigned int - degree() const; + std::vector> &fourth_derivatives) const override; /** * Return the name of the space, which is RaviartThomas. */ std::string - name() const; + name() const override; /** * Return the number of polynomials in the space RT(degree) without @@ -106,23 +94,19 @@ public: static unsigned int compute_n_pols(unsigned int degree); -private: /** - * The degree of this object as given to the constructor. + * @copydoc TensorPolynomialsBase::clone() */ - const unsigned int my_degree; + virtual std::unique_ptr> + clone() const override; +private: /** * An object representing the polynomial space for a single component. We * can re-use it by rotating the coordinates of the evaluation point. */ const AnisotropicPolynomials polynomial_space; - /** - * Number of Raviart-Thomas polynomials. - */ - const unsigned int n_pols; - /** * A static member function that creates the polynomial space we use to * initialize the #polynomial_space member variable. @@ -132,25 +116,6 @@ private: }; - -template -inline unsigned int -PolynomialsRaviartThomas::n() const -{ - return n_pols; -} - - - -template -inline unsigned int -PolynomialsRaviartThomas::degree() const -{ - return my_degree; -} - - - template inline std::string PolynomialsRaviartThomas::name() const diff --git a/include/deal.II/base/polynomials_rt_bubbles.h b/include/deal.II/base/polynomials_rt_bubbles.h index 6643d789a9..a77f1af360 100644 --- a/include/deal.II/base/polynomials_rt_bubbles.h +++ b/include/deal.II/base/polynomials_rt_bubbles.h @@ -24,6 +24,7 @@ #include #include #include +#include #include @@ -84,7 +85,7 @@ DEAL_II_NAMESPACE_OPEN */ template -class PolynomialsRT_Bubbles +class PolynomialsRT_Bubbles : public TensorPolynomialsBase { public: /** @@ -111,26 +112,13 @@ public: std::vector> &grads, std::vector> &grad_grads, std::vector> &third_derivatives, - std::vector> &fourth_derivatives) const; - - /** - * Returns the number of enhanced Raviart-Thomas polynomials. - */ - unsigned int - n() const; - - /** - * Returns the degree of the RT_bubble space, which is one less than the - * highest polynomial degree. - */ - unsigned int - degree() const; + std::vector> &fourth_derivatives) const override; /** * Return the name of the space, which is RT_Bubbles. */ std::string - name() const; + name() const override; /** * Return the number of polynomials in the space RT_Bubbles(degree) @@ -140,12 +128,13 @@ public: static unsigned int compute_n_pols(const unsigned int degree); -private: /** - * The degree of this object as given to the constructor. + * @copydoc TensorPolynomialsBase::clone() */ - const unsigned int my_degree; + virtual std::unique_ptr> + clone() const override; +private: /** * An object representing the Raviart-Thomas part of the space */ @@ -156,33 +145,9 @@ private: * to k+1. */ std::vector> monomials; - - /** - * Number of RT_Bubbles polynomials. - */ - unsigned int n_pols; }; - -template -inline unsigned int -PolynomialsRT_Bubbles::n() const -{ - return n_pols; -} - - - -template -inline unsigned int -PolynomialsRT_Bubbles::degree() const -{ - return my_degree; -} - - - template inline std::string PolynomialsRT_Bubbles::name() const diff --git a/source/base/polynomials_abf.cc b/source/base/polynomials_abf.cc index 4615c88156..6bd98f5747 100644 --- a/source/base/polynomials_abf.cc +++ b/source/base/polynomials_abf.cc @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -47,9 +48,8 @@ namespace template PolynomialsABF::PolynomialsABF(const unsigned int k) - : my_degree(k) + : TensorPolynomialsBase(k, compute_n_pols(k)) , polynomial_space(get_abf_polynomials(k)) - , n_pols(compute_n_pols(k)) { // check that the dimensions match. we only store one of the 'dim' // anisotropic polynomials that make up the vector-valued space, so @@ -69,16 +69,17 @@ PolynomialsABF::compute( std::vector> &third_derivatives, std::vector> &fourth_derivatives) const { - Assert(values.size() == n_pols || values.size() == 0, - ExcDimensionMismatch(values.size(), n_pols)); - Assert(grads.size() == n_pols || grads.size() == 0, - ExcDimensionMismatch(grads.size(), n_pols)); - Assert(grad_grads.size() == n_pols || grad_grads.size() == 0, - ExcDimensionMismatch(grad_grads.size(), n_pols)); - Assert(third_derivatives.size() == n_pols || third_derivatives.size() == 0, - ExcDimensionMismatch(third_derivatives.size(), n_pols)); - Assert(fourth_derivatives.size() == n_pols || fourth_derivatives.size() == 0, - ExcDimensionMismatch(fourth_derivatives.size(), n_pols)); + Assert(values.size() == this->n() || values.size() == 0, + ExcDimensionMismatch(values.size(), this->n())); + Assert(grads.size() == this->n() || grads.size() == 0, + ExcDimensionMismatch(grads.size(), this->n())); + Assert(grad_grads.size() == this->n() || grad_grads.size() == 0, + ExcDimensionMismatch(grad_grads.size(), this->n())); + Assert(third_derivatives.size() == this->n() || third_derivatives.size() == 0, + ExcDimensionMismatch(third_derivatives.size(), this->n())); + Assert(fourth_derivatives.size() == this->n() || + fourth_derivatives.size() == 0, + ExcDimensionMismatch(fourth_derivatives.size(), this->n())); const unsigned int n_sub = polynomial_space.n(); // guard access to the scratch @@ -180,6 +181,14 @@ PolynomialsABF::compute_n_pols(const unsigned int k) } +template +std::unique_ptr> +PolynomialsABF::clone() const +{ + return std_cxx14::make_unique>(*this); +} + + template class PolynomialsABF<1>; template class PolynomialsABF<2>; template class PolynomialsABF<3>; diff --git a/source/base/polynomials_bdm.cc b/source/base/polynomials_bdm.cc index 51338da71d..4669b0ddbb 100644 --- a/source/base/polynomials_bdm.cc +++ b/source/base/polynomials_bdm.cc @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -27,9 +28,9 @@ DEAL_II_NAMESPACE_OPEN template PolynomialsBDM::PolynomialsBDM(const unsigned int k) - : polynomial_space(Polynomials::Legendre::generate_complete_basis(k)) + : TensorPolynomialsBase(k, compute_n_pols(k)) + , polynomial_space(Polynomials::Legendre::generate_complete_basis(k)) , monomials((dim == 2) ? (1) : (k + 2)) - , n_pols(compute_n_pols(k)) , p_values(polynomial_space.n()) , p_grads(polynomial_space.n()) , p_grad_grads(polynomial_space.n()) @@ -60,16 +61,17 @@ PolynomialsBDM::compute( std::vector> &third_derivatives, std::vector> &fourth_derivatives) const { - Assert(values.size() == n_pols || values.size() == 0, - ExcDimensionMismatch(values.size(), n_pols)); - Assert(grads.size() == n_pols || grads.size() == 0, - ExcDimensionMismatch(grads.size(), n_pols)); - Assert(grad_grads.size() == n_pols || grad_grads.size() == 0, - ExcDimensionMismatch(grad_grads.size(), n_pols)); - Assert(third_derivatives.size() == n_pols || third_derivatives.size() == 0, - ExcDimensionMismatch(third_derivatives.size(), n_pols)); - Assert(fourth_derivatives.size() == n_pols || fourth_derivatives.size() == 0, - ExcDimensionMismatch(fourth_derivatives.size(), n_pols)); + Assert(values.size() == this->n() || values.size() == 0, + ExcDimensionMismatch(values.size(), this->n())); + Assert(grads.size() == this->n() || grads.size() == 0, + ExcDimensionMismatch(grads.size(), this->n())); + Assert(grad_grads.size() == this->n() || grad_grads.size() == 0, + ExcDimensionMismatch(grad_grads.size(), this->n())); + Assert(third_derivatives.size() == this->n() || third_derivatives.size() == 0, + ExcDimensionMismatch(third_derivatives.size(), this->n())); + Assert(fourth_derivatives.size() == this->n() || + fourth_derivatives.size() == 0, + ExcDimensionMismatch(fourth_derivatives.size(), this->n())); // third and fourth derivatives not implemented (void)third_derivatives; @@ -353,7 +355,7 @@ PolynomialsBDM::compute( grad_grads[start + 2][2][2][2] = 0.; } } - Assert(start == n_pols, ExcInternalError()); + Assert(start == this->n(), ExcInternalError()); } } @@ -440,6 +442,14 @@ PolynomialsBDM::compute_n_pols(unsigned int k) } +template +std::unique_ptr> +PolynomialsBDM::clone() const +{ + return std_cxx14::make_unique>(*this); +} + + template class PolynomialsBDM<1>; template class PolynomialsBDM<2>; template class PolynomialsBDM<3>; diff --git a/source/base/polynomials_bernardi_raugel.cc b/source/base/polynomials_bernardi_raugel.cc index af1570d297..62e643274e 100644 --- a/source/base/polynomials_bernardi_raugel.cc +++ b/source/base/polynomials_bernardi_raugel.cc @@ -15,14 +15,14 @@ #include +#include DEAL_II_NAMESPACE_OPEN template PolynomialsBernardiRaugel::PolynomialsBernardiRaugel(const unsigned int k) - : my_degree(k) - , n_pols(compute_n_pols(k)) + : TensorPolynomialsBase(k + 1, compute_n_pols(k)) , polynomial_space_Q(create_polynomials_Q()) , polynomial_space_bubble(create_polynomials_bubble()) {} @@ -75,16 +75,17 @@ PolynomialsBernardiRaugel::compute( std::vector> &third_derivatives, std::vector> &fourth_derivatives) const { - Assert(values.size() == n_pols || values.size() == 0, - ExcDimensionMismatch(values.size(), n_pols)); - Assert(grads.size() == n_pols || grads.size() == 0, - ExcDimensionMismatch(grads.size(), n_pols)); - Assert(grad_grads.size() == n_pols || grad_grads.size() == 0, - ExcDimensionMismatch(grad_grads.size(), n_pols)); - Assert(third_derivatives.size() == n_pols || third_derivatives.size() == 0, - ExcDimensionMismatch(third_derivatives.size(), n_pols)); - Assert(fourth_derivatives.size() == n_pols || fourth_derivatives.size() == 0, - ExcDimensionMismatch(fourth_derivatives.size(), n_pols)); + Assert(values.size() == this->n() || values.size() == 0, + ExcDimensionMismatch(values.size(), this->n())); + Assert(grads.size() == this->n() || grads.size() == 0, + ExcDimensionMismatch(grads.size(), this->n())); + Assert(grad_grads.size() == this->n() || grad_grads.size() == 0, + ExcDimensionMismatch(grad_grads.size(), this->n())); + Assert(third_derivatives.size() == this->n() || third_derivatives.size() == 0, + ExcDimensionMismatch(third_derivatives.size(), this->n())); + Assert(fourth_derivatives.size() == this->n() || + fourth_derivatives.size() == 0, + ExcDimensionMismatch(fourth_derivatives.size(), this->n())); std::vector Q_values; std::vector> Q_grads; @@ -248,6 +249,14 @@ PolynomialsBernardiRaugel::compute_n_pols(const unsigned int k) return 0; } + +template +std::unique_ptr> +PolynomialsBernardiRaugel::clone() const +{ + return std_cxx14::make_unique>(*this); +} + template class PolynomialsBernardiRaugel<1>; // to prevent errors template class PolynomialsBernardiRaugel<2>; template class PolynomialsBernardiRaugel<3>; diff --git a/source/base/polynomials_nedelec.cc b/source/base/polynomials_nedelec.cc index 1b48d076af..de531fada5 100644 --- a/source/base/polynomials_nedelec.cc +++ b/source/base/polynomials_nedelec.cc @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -26,9 +27,8 @@ DEAL_II_NAMESPACE_OPEN template PolynomialsNedelec::PolynomialsNedelec(const unsigned int k) - : my_degree(k) + : TensorPolynomialsBase(k, compute_n_pols(k)) , polynomial_space(create_polynomials(k)) - , n_pols(compute_n_pols(k)) {} template @@ -59,16 +59,17 @@ PolynomialsNedelec::compute( std::vector> &third_derivatives, std::vector> &fourth_derivatives) const { - Assert(values.size() == n_pols || values.size() == 0, - ExcDimensionMismatch(values.size(), n_pols)); - Assert(grads.size() == n_pols || grads.size() == 0, - ExcDimensionMismatch(grads.size(), n_pols)); - Assert(grad_grads.size() == n_pols || grad_grads.size() == 0, - ExcDimensionMismatch(grad_grads.size(), n_pols)); - Assert(third_derivatives.size() == n_pols || third_derivatives.size() == 0, - ExcDimensionMismatch(third_derivatives.size(), n_pols)); - Assert(fourth_derivatives.size() == n_pols || fourth_derivatives.size() == 0, - ExcDimensionMismatch(fourth_derivatives.size(), n_pols)); + Assert(values.size() == this->n() || values.size() == 0, + ExcDimensionMismatch(values.size(), this->n())); + Assert(grads.size() == this->n() || grads.size() == 0, + ExcDimensionMismatch(grads.size(), this->n())); + Assert(grad_grads.size() == this->n() || grad_grads.size() == 0, + ExcDimensionMismatch(grad_grads.size(), this->n())); + Assert(third_derivatives.size() == this->n() || third_derivatives.size() == 0, + ExcDimensionMismatch(third_derivatives.size(), this->n())); + Assert(fourth_derivatives.size() == this->n() || + fourth_derivatives.size() == 0, + ExcDimensionMismatch(fourth_derivatives.size(), this->n())); // third and fourth derivatives not implemented (void)third_derivatives; @@ -80,7 +81,8 @@ PolynomialsNedelec::compute( // and second derivatives vectors of // polynomial_space at // unit_point - const unsigned int n_basis = polynomial_space.n(); + const unsigned int n_basis = polynomial_space.n(); + const unsigned int my_degree = this->degree(); std::vector unit_point_values((values.size() == 0) ? 0 : n_basis); std::vector> unit_point_grads((grads.size() == 0) ? 0 : n_basis); @@ -1506,6 +1508,14 @@ PolynomialsNedelec::compute_n_pols(unsigned int k) } +template +std::unique_ptr> +PolynomialsNedelec::clone() const +{ + return std_cxx14::make_unique>(*this); +} + + template class PolynomialsNedelec<1>; template class PolynomialsNedelec<2>; template class PolynomialsNedelec<3>; diff --git a/source/base/polynomials_raviart_thomas.cc b/source/base/polynomials_raviart_thomas.cc index ed4f3525b7..d15e210ca8 100644 --- a/source/base/polynomials_raviart_thomas.cc +++ b/source/base/polynomials_raviart_thomas.cc @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -35,9 +36,8 @@ DEAL_II_NAMESPACE_OPEN template PolynomialsRaviartThomas::PolynomialsRaviartThomas(const unsigned int k) - : my_degree(k) + : TensorPolynomialsBase(k, compute_n_pols(k)) , polynomial_space(create_polynomials(k)) - , n_pols(compute_n_pols(k)) {} @@ -69,16 +69,17 @@ PolynomialsRaviartThomas::compute( std::vector> &third_derivatives, std::vector> &fourth_derivatives) const { - Assert(values.size() == n_pols || values.size() == 0, - ExcDimensionMismatch(values.size(), n_pols)); - Assert(grads.size() == n_pols || grads.size() == 0, - ExcDimensionMismatch(grads.size(), n_pols)); - Assert(grad_grads.size() == n_pols || grad_grads.size() == 0, - ExcDimensionMismatch(grad_grads.size(), n_pols)); - Assert(third_derivatives.size() == n_pols || third_derivatives.size() == 0, - ExcDimensionMismatch(third_derivatives.size(), n_pols)); - Assert(fourth_derivatives.size() == n_pols || fourth_derivatives.size() == 0, - ExcDimensionMismatch(fourth_derivatives.size(), n_pols)); + Assert(values.size() == this->n() || values.size() == 0, + ExcDimensionMismatch(values.size(), this->n())); + Assert(grads.size() == this->n() || grads.size() == 0, + ExcDimensionMismatch(grads.size(), this->n())); + Assert(grad_grads.size() == this->n() || grad_grads.size() == 0, + ExcDimensionMismatch(grad_grads.size(), this->n())); + Assert(third_derivatives.size() == this->n() || third_derivatives.size() == 0, + ExcDimensionMismatch(third_derivatives.size(), this->n())); + Assert(fourth_derivatives.size() == this->n() || + fourth_derivatives.size() == 0, + ExcDimensionMismatch(fourth_derivatives.size(), this->n())); // have a few scratch // arrays. because we don't want to @@ -183,6 +184,14 @@ PolynomialsRaviartThomas::compute_n_pols(unsigned int k) } +template +std::unique_ptr> +PolynomialsRaviartThomas::clone() const +{ + return std_cxx14::make_unique>(*this); +} + + template class PolynomialsRaviartThomas<1>; template class PolynomialsRaviartThomas<2>; template class PolynomialsRaviartThomas<3>; diff --git a/source/base/polynomials_rt_bubbles.cc b/source/base/polynomials_rt_bubbles.cc index 117d244723..c4412c930c 100644 --- a/source/base/polynomials_rt_bubbles.cc +++ b/source/base/polynomials_rt_bubbles.cc @@ -17,6 +17,7 @@ #include "deal.II/base/polynomials_rt_bubbles.h" #include +#include #include #include @@ -27,10 +28,9 @@ DEAL_II_NAMESPACE_OPEN template PolynomialsRT_Bubbles::PolynomialsRT_Bubbles(const unsigned int k) - : my_degree(k) + : TensorPolynomialsBase(k, compute_n_pols(k)) , raviart_thomas_space(k - 1) , monomials(k + 2) - , n_pols(compute_n_pols(k)) { Assert(dim >= 2, ExcImpossibleInDim(dim)); @@ -50,16 +50,17 @@ PolynomialsRT_Bubbles::compute( std::vector> &third_derivatives, std::vector> &fourth_derivatives) const { - Assert(values.size() == n_pols || values.size() == 0, - ExcDimensionMismatch(values.size(), n_pols)); - Assert(grads.size() == n_pols || grads.size() == 0, - ExcDimensionMismatch(grads.size(), n_pols)); - Assert(grad_grads.size() == n_pols || grad_grads.size() == 0, - ExcDimensionMismatch(grad_grads.size(), n_pols)); - Assert(third_derivatives.size() == n_pols || third_derivatives.size() == 0, - ExcDimensionMismatch(third_derivatives.size(), n_pols)); - Assert(fourth_derivatives.size() == n_pols || fourth_derivatives.size() == 0, - ExcDimensionMismatch(fourth_derivatives.size(), n_pols)); + Assert(values.size() == this->n() || values.size() == 0, + ExcDimensionMismatch(values.size(), this->n())); + Assert(grads.size() == this->n() || grads.size() == 0, + ExcDimensionMismatch(grads.size(), this->n())); + Assert(grad_grads.size() == this->n() || grad_grads.size() == 0, + ExcDimensionMismatch(grad_grads.size(), this->n())); + Assert(third_derivatives.size() == this->n() || third_derivatives.size() == 0, + ExcDimensionMismatch(third_derivatives.size(), this->n())); + Assert(fourth_derivatives.size() == this->n() || + fourth_derivatives.size() == 0, + ExcDimensionMismatch(fourth_derivatives.size(), this->n())); // Third and fourth derivatives are not implemented (void)third_derivatives; @@ -67,7 +68,8 @@ PolynomialsRT_Bubbles::compute( (void)fourth_derivatives; Assert(fourth_derivatives.size() == 0, ExcNotImplemented()); - const unsigned int n_sub = raviart_thomas_space.n(); + const unsigned int n_sub = raviart_thomas_space.n(); + const unsigned int my_degree = this->degree(); // Guard access to the scratch arrays in the following block // using a mutex to make sure they are not used by multiple threads @@ -194,7 +196,7 @@ PolynomialsRT_Bubbles::compute( monoval_plus[0][1] * monoval_i[1][2]; } } - Assert(start == n_pols - my_degree - 1, ExcInternalError()); + Assert(start == this->n() - my_degree - 1, ExcInternalError()); } else if (dim == 3) { @@ -825,7 +827,7 @@ PolynomialsRT_Bubbles::compute( start += 2; } } - Assert(start == n_pols - 2 * n_curls, ExcInternalError()); + Assert(start == this->n() - 2 * n_curls, ExcInternalError()); } } @@ -843,6 +845,14 @@ PolynomialsRT_Bubbles::compute_n_pols(const unsigned int k) } +template +std::unique_ptr> +PolynomialsRT_Bubbles::clone() const +{ + return std_cxx14::make_unique>(*this); +} + + template class PolynomialsRT_Bubbles<1>; template class PolynomialsRT_Bubbles<2>; template class PolynomialsRT_Bubbles<3>;