From: Daniel Arndt Date: Thu, 21 May 2020 16:04:10 +0000 (-0400) Subject: Implement compute_*_derivative X-Git-Tag: v9.3.0-rc1~1594^2~8 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=26e0940aca6fddf6ca69c30897041f951e9c56f2;p=dealii.git Implement compute_*_derivative --- diff --git a/include/deal.II/base/polynomial_space.h b/include/deal.II/base/polynomial_space.h index 4e050b6225..e1260dd53a 100644 --- a/include/deal.II/base/polynomial_space.h +++ b/include/deal.II/base/polynomial_space.h @@ -171,6 +171,34 @@ public: Tensor compute_derivative(const unsigned int i, const Point &p) const; + /** + * @copydoc ScalarPolynomialsBase::compute_1st_derivative() + */ + virtual Tensor<1, dim> + compute_1st_derivative(const unsigned int i, + const Point & p) const override; + + /** + * @copydoc ScalarPolynomialsBase::compute_2nd_derivative() + */ + virtual Tensor<2, dim> + compute_2nd_derivative(const unsigned int i, + const Point & p) const override; + + /** + * @copydoc ScalarPolynomialsBase::compute_3rd_derivative() + */ + virtual Tensor<3, dim> + compute_3rd_derivative(const unsigned int i, + const Point & p) const override; + + /** + * @copydoc ScalarPolynomialsBase::compute_4th_derivative() + */ + virtual Tensor<4, dim> + compute_4th_derivative(const unsigned int i, + const Point & p) const override; + /** * Compute the gradient of the ith polynomial at unit point * p. @@ -425,6 +453,45 @@ PolynomialSpace::compute_derivative(const unsigned int i, } + +template +inline Tensor<1, dim> +PolynomialSpace::compute_1st_derivative(const unsigned int i, + const Point & p) const +{ + return compute_derivative<1>(i, p); +} + + + +template +inline Tensor<2, dim> +PolynomialSpace::compute_2nd_derivative(const unsigned int i, + const Point & p) const +{ + return compute_derivative<2>(i, p); +} + + + +template +inline Tensor<3, dim> +PolynomialSpace::compute_3rd_derivative(const unsigned int i, + const Point & p) const +{ + return compute_derivative<3>(i, p); +} + + + +template +inline Tensor<4, dim> +PolynomialSpace::compute_4th_derivative(const unsigned int i, + const Point & p) const +{ + return compute_derivative<4>(i, p); +} + DEAL_II_NAMESPACE_CLOSE #endif diff --git a/include/deal.II/base/polynomials_adini.h b/include/deal.II/base/polynomials_adini.h index 64daffad89..49eb1033f0 100644 --- a/include/deal.II/base/polynomials_adini.h +++ b/include/deal.II/base/polynomials_adini.h @@ -80,6 +80,34 @@ public: double compute_value(const unsigned int i, const Point &p) const override; + /** + * @copydoc ScalarPolynomialsBase::compute_1st_derivative() + */ + virtual Tensor<1, dim> + compute_1st_derivative(const unsigned int i, + const Point & p) const override; + + /** + * @copydoc ScalarPolynomialsBase::compute_2nd_derivative() + */ + virtual Tensor<2, dim> + compute_2nd_derivative(const unsigned int i, + const Point & p) const override; + + /** + * @copydoc ScalarPolynomialsBase::compute_3rd_derivative() + */ + virtual Tensor<3, dim> + compute_3rd_derivative(const unsigned int i, + const Point & p) const override; + + /** + * @copydoc ScalarPolynomialsBase::compute_4th_derivative() + */ + virtual Tensor<4, dim> + compute_4th_derivative(const unsigned int i, + const Point & p) const override; + /** * Compute the gradient of the ith polynomial at * unit_point. @@ -150,6 +178,50 @@ private: +template +inline Tensor<1, dim> +PolynomialsAdini::compute_1st_derivative(const unsigned int /*i*/, + const Point & /*p*/) const +{ + Assert(false, ExcNotImplemented()); + return {}; +} + + + +template +inline Tensor<2, dim> +PolynomialsAdini::compute_2nd_derivative(const unsigned int /*i*/, + const Point & /*p*/) const +{ + Assert(false, ExcNotImplemented()); + return {}; +} + + + +template +inline Tensor<3, dim> +PolynomialsAdini::compute_3rd_derivative(const unsigned int /*i*/, + const Point & /*p*/) const +{ + Assert(false, ExcNotImplemented()); + return {}; +} + + + +template +inline Tensor<4, dim> +PolynomialsAdini::compute_4th_derivative(const unsigned int /*i*/, + const Point & /*p*/) const +{ + Assert(false, ExcNotImplemented()); + return {}; +} + + + template inline std::string PolynomialsAdini::name() const diff --git a/include/deal.II/base/polynomials_rannacher_turek.h b/include/deal.II/base/polynomials_rannacher_turek.h index 4fb378458b..b411c6e74c 100644 --- a/include/deal.II/base/polynomials_rannacher_turek.h +++ b/include/deal.II/base/polynomials_rannacher_turek.h @@ -69,6 +69,34 @@ public: Tensor compute_derivative(const unsigned int i, const Point &p) const; + /** + * @copydoc ScalarPolynomialsBase::compute_1st_derivative() + */ + virtual Tensor<1, dim> + compute_1st_derivative(const unsigned int i, + const Point & p) const override; + + /** + * @copydoc ScalarPolynomialsBase::compute_2nd_derivative() + */ + virtual Tensor<2, dim> + compute_2nd_derivative(const unsigned int i, + const Point & p) const override; + + /** + * @copydoc ScalarPolynomialsBase::compute_3rd_derivative() + */ + virtual Tensor<3, dim> + compute_3rd_derivative(const unsigned int i, + const Point & p) const override; + + /** + * @copydoc ScalarPolynomialsBase::compute_4th_derivative() + */ + virtual Tensor<4, dim> + compute_4th_derivative(const unsigned int i, + const Point & p) const override; + /** * Gradient of basis function @p i at @p p. */ @@ -220,6 +248,50 @@ PolynomialsRannacherTurek::compute_derivative(const unsigned int i, +template +inline Tensor<1, dim> +PolynomialsRannacherTurek::compute_1st_derivative( + const unsigned int i, + const Point & p) const +{ + return compute_derivative<1>(i, p); +} + + + +template +inline Tensor<2, dim> +PolynomialsRannacherTurek::compute_2nd_derivative( + const unsigned int i, + const Point & p) const +{ + return compute_derivative<2>(i, p); +} + + + +template +inline Tensor<3, dim> +PolynomialsRannacherTurek::compute_3rd_derivative( + const unsigned int i, + const Point & p) const +{ + return compute_derivative<3>(i, p); +} + + + +template +inline Tensor<4, dim> +PolynomialsRannacherTurek::compute_4th_derivative( + const unsigned int i, + const Point & p) const +{ + return compute_derivative<4>(i, p); +} + + + template inline std::string PolynomialsRannacherTurek::name() const diff --git a/include/deal.II/base/scalar_polynomials_base.h b/include/deal.II/base/scalar_polynomials_base.h index dc702bbc06..bd56e81936 100644 --- a/include/deal.II/base/scalar_polynomials_base.h +++ b/include/deal.II/base/scalar_polynomials_base.h @@ -113,11 +113,7 @@ public: * Consider using compute() instead. */ virtual double - compute_value(const unsigned int /*i*/, const Point & /*p*/) const - { - Assert(false, ExcNotImplemented()); - return 0; - } + compute_value(const unsigned int /*i*/, const Point & /*p*/) const = 0; /** * Compute the orderth derivative of the ith polynomial @@ -129,12 +125,43 @@ public: */ template Tensor - compute_derivative(const unsigned int /*i*/, const Point & /*p*/) const - { - Assert(false, ExcNotImplemented()); - Tensor empty; - return empty; - } + compute_derivative(const unsigned int i, const Point &p) const; + + /** + * Compute the first derivative of the ith polynomial + * at unit point p. + * + * Consider using evaluate() instead. + */ + virtual Tensor<1, dim> + compute_1st_derivative(const unsigned int i, const Point &p) const = 0; + + /** + * Compute the second derivative of the ith polynomial + * at unit point p. + * + * Consider using evaluate() instead. + */ + virtual Tensor<2, dim> + compute_2nd_derivative(const unsigned int i, const Point &p) const = 0; + + /** + * Compute the third derivative of the ith polynomial + * at unit point p. + * + * Consider using evaluate() instead. + */ + virtual Tensor<3, dim> + compute_3rd_derivative(const unsigned int i, const Point &p) const = 0; + + /** + * Compute the fourth derivative of the ith polynomial + * at unit point p. + * + * Consider using evaluate() instead. + */ + virtual Tensor<4, dim> + compute_4th_derivative(const unsigned int i, const Point &p) const = 0; /** * Compute the gradient of the ith polynomial at unit point @@ -143,12 +170,7 @@ public: * Consider using compute() instead. */ virtual Tensor<1, dim> - compute_grad(const unsigned int /*i*/, const Point & /*p*/) const - { - Assert(false, ExcNotImplemented()); - Tensor<1, dim> empty; - return empty; - } + compute_grad(const unsigned int /*i*/, const Point & /*p*/) const = 0; /** * Compute the second derivative (grad_grad) of the ith polynomial @@ -157,12 +179,8 @@ public: * Consider using compute() instead. */ virtual Tensor<2, dim> - compute_grad_grad(const unsigned int /*i*/, const Point & /*p*/) const - { - Assert(false, ExcNotImplemented()); - Tensor<2, dim> empty; - return empty; - } + compute_grad_grad(const unsigned int /*i*/, + const Point & /*p*/) const = 0; /** * Return the number of polynomials. @@ -235,6 +253,37 @@ ScalarPolynomialsBase::degree() const +template +template +inline Tensor +ScalarPolynomialsBase::compute_derivative(const unsigned int i, + const Point & p) const +{ + if (order == 1) + { + auto derivative = compute_1st_derivative(i, p); + return *reinterpret_cast *>(&derivative); + } + if (order == 2) + { + auto derivative = compute_2nd_derivative(i, p); + return *reinterpret_cast *>(&derivative); + } + if (order == 3) + { + auto derivative = compute_3rd_derivative(i, p); + return *reinterpret_cast *>(&derivative); + } + if (order == 4) + { + auto derivative = compute_4th_derivative(i, p); + return *reinterpret_cast *>(&derivative); + } + Assert(false, ExcNotImplemented()); + Tensor empty; + return empty; +} + DEAL_II_NAMESPACE_CLOSE #endif diff --git a/include/deal.II/base/tensor_product_polynomials.h b/include/deal.II/base/tensor_product_polynomials.h index e024553d69..653fbcbd8b 100644 --- a/include/deal.II/base/tensor_product_polynomials.h +++ b/include/deal.II/base/tensor_product_polynomials.h @@ -167,6 +167,34 @@ public: Tensor compute_derivative(const unsigned int i, const Point &p) const; + /** + * @copydoc ScalarPolynomialsBase::compute_1st_derivative() + */ + virtual Tensor<1, dim> + compute_1st_derivative(const unsigned int i, + const Point & p) const override; + + /** + * @copydoc ScalarPolynomialsBase::compute_2nd_derivative() + */ + virtual Tensor<2, dim> + compute_2nd_derivative(const unsigned int i, + const Point & p) const override; + + /** + * @copydoc ScalarPolynomialsBase::compute_3rd_derivative() + */ + virtual Tensor<3, dim> + compute_3rd_derivative(const unsigned int i, + const Point & p) const override; + + /** + * @copydoc ScalarPolynomialsBase::compute_4th_derivative() + */ + virtual Tensor<4, dim> + compute_4th_derivative(const unsigned int i, + const Point & p) const override; + /** * Compute the grad of the ith tensor product polynomial at * unit_point. Here i is given in tensor product @@ -360,6 +388,34 @@ public: Tensor compute_derivative(const unsigned int i, const Point &p) const; + /** + * @copydoc ScalarPolynomialsBase::compute_1st_derivative() + */ + virtual Tensor<1, dim> + compute_1st_derivative(const unsigned int i, + const Point & p) const override; + + /** + * @copydoc ScalarPolynomialsBase::compute_2nd_derivative() + */ + virtual Tensor<2, dim> + compute_2nd_derivative(const unsigned int i, + const Point & p) const override; + + /** + * @copydoc ScalarPolynomialsBase::compute_3rd_derivative() + */ + virtual Tensor<3, dim> + compute_3rd_derivative(const unsigned int i, + const Point & p) const override; + + /** + * @copydoc ScalarPolynomialsBase::compute_4th_derivative() + */ + virtual Tensor<4, dim> + compute_4th_derivative(const unsigned int i, + const Point & p) const override; + /** * Compute the grad of the ith tensor product polynomial at * unit_point. Here i is given in tensor product @@ -606,6 +662,52 @@ TensorProductPolynomials::compute_derivative( } } + + +template +inline Tensor<1, dim> +TensorProductPolynomials::compute_1st_derivative( + const unsigned int i, + const Point & p) const +{ + return compute_derivative<1>(i, p); +} + + + +template +inline Tensor<2, dim> +TensorProductPolynomials::compute_2nd_derivative( + const unsigned int i, + const Point & p) const +{ + return compute_derivative<2>(i, p); +} + + + +template +inline Tensor<3, dim> +TensorProductPolynomials::compute_3rd_derivative( + const unsigned int i, + const Point & p) const +{ + return compute_derivative<3>(i, p); +} + + + +template +inline Tensor<4, dim> +TensorProductPolynomials::compute_4th_derivative( + const unsigned int i, + const Point & p) const +{ + return compute_derivative<4>(i, p); +} + + + template template Tensor @@ -725,6 +827,47 @@ AnisotropicPolynomials::compute_derivative(const unsigned int i, } + +template +inline Tensor<1, dim> +AnisotropicPolynomials::compute_1st_derivative(const unsigned int i, + const Point & p) const +{ + return compute_derivative<1>(i, p); +} + + + +template +inline Tensor<2, dim> +AnisotropicPolynomials::compute_2nd_derivative(const unsigned int i, + const Point & p) const +{ + return compute_derivative<2>(i, p); +} + + + +template +inline Tensor<3, dim> +AnisotropicPolynomials::compute_3rd_derivative(const unsigned int i, + const Point & p) const +{ + return compute_derivative<3>(i, p); +} + + + +template +inline Tensor<4, dim> +AnisotropicPolynomials::compute_4th_derivative(const unsigned int i, + const Point & p) const +{ + return compute_derivative<4>(i, p); +} + + + template inline std::string AnisotropicPolynomials::name() const diff --git a/include/deal.II/base/tensor_product_polynomials_bubbles.h b/include/deal.II/base/tensor_product_polynomials_bubbles.h index 0e8d28823f..59baa0366e 100644 --- a/include/deal.II/base/tensor_product_polynomials_bubbles.h +++ b/include/deal.II/base/tensor_product_polynomials_bubbles.h @@ -138,6 +138,34 @@ public: Tensor compute_derivative(const unsigned int i, const Point &p) const; + /** + * @copydoc ScalarPolynomialsBase::compute_1st_derivative() + */ + virtual Tensor<1, dim> + compute_1st_derivative(const unsigned int i, + const Point & p) const override; + + /** + * @copydoc ScalarPolynomialsBase::compute_2nd_derivative() + */ + virtual Tensor<2, dim> + compute_2nd_derivative(const unsigned int i, + const Point & p) const override; + + /** + * @copydoc ScalarPolynomialsBase::compute_3rd_derivative() + */ + virtual Tensor<3, dim> + compute_3rd_derivative(const unsigned int i, + const Point & p) const override; + + /** + * @copydoc ScalarPolynomialsBase::compute_4th_derivative() + */ + virtual Tensor<4, dim> + compute_4th_derivative(const unsigned int i, + const Point & p) const override; + /** * Compute the grad of the ith tensor product polynomial at * unit_point. Here i is given in tensor product @@ -427,6 +455,49 @@ TensorProductPolynomialsBubbles::compute_derivative( } + +template +inline Tensor<1, dim> +TensorProductPolynomialsBubbles::compute_1st_derivative( + const unsigned int i, + const Point & p) const +{ + return compute_derivative<1>(i, p); +} + + + +template +inline Tensor<2, dim> +TensorProductPolynomialsBubbles::compute_2nd_derivative( + const unsigned int i, + const Point & p) const +{ + return compute_derivative<2>(i, p); +} + + + +template +inline Tensor<3, dim> +TensorProductPolynomialsBubbles::compute_3rd_derivative( + const unsigned int i, + const Point & p) const +{ + return compute_derivative<3>(i, p); +} + + + +template +inline Tensor<4, dim> +TensorProductPolynomialsBubbles::compute_4th_derivative( + const unsigned int i, + const Point & p) const +{ + return compute_derivative<4>(i, p); +} + #endif // DOXYGEN DEAL_II_NAMESPACE_CLOSE diff --git a/include/deal.II/base/tensor_product_polynomials_const.h b/include/deal.II/base/tensor_product_polynomials_const.h index 0c75e2f59c..274f247492 100644 --- a/include/deal.II/base/tensor_product_polynomials_const.h +++ b/include/deal.II/base/tensor_product_polynomials_const.h @@ -141,6 +141,34 @@ public: Tensor compute_derivative(const unsigned int i, const Point &p) const; + /** + * @copydoc ScalarPolynomialsBase::compute_1st_derivative() + */ + virtual Tensor<1, dim> + compute_1st_derivative(const unsigned int i, + const Point & p) const override; + + /** + * @copydoc ScalarPolynomialsBase::compute_2nd_derivative() + */ + virtual Tensor<2, dim> + compute_2nd_derivative(const unsigned int i, + const Point & p) const override; + + /** + * @copydoc ScalarPolynomialsBase::compute_3rd_derivative() + */ + virtual Tensor<3, dim> + compute_3rd_derivative(const unsigned int i, + const Point & p) const override; + + /** + * @copydoc ScalarPolynomialsBase::compute_4th_derivative() + */ + virtual Tensor<4, dim> + compute_4th_derivative(const unsigned int i, + const Point & p) const override; + /** * Compute the grad of the ith tensor product polynomial at * unit_point. Here i is given in tensor product @@ -287,6 +315,49 @@ TensorProductPolynomialsConst::compute_derivative( } + +template +inline Tensor<1, dim> +TensorProductPolynomialsConst::compute_1st_derivative( + const unsigned int i, + const Point & p) const +{ + return compute_derivative<1>(i, p); +} + + + +template +inline Tensor<2, dim> +TensorProductPolynomialsConst::compute_2nd_derivative( + const unsigned int i, + const Point & p) const +{ + return compute_derivative<2>(i, p); +} + + + +template +inline Tensor<3, dim> +TensorProductPolynomialsConst::compute_3rd_derivative( + const unsigned int i, + const Point & p) const +{ + return compute_derivative<3>(i, p); +} + + + +template +inline Tensor<4, dim> +TensorProductPolynomialsConst::compute_4th_derivative( + const unsigned int i, + const Point & p) const +{ + return compute_derivative<4>(i, p); +} + #endif // DOXYGEN DEAL_II_NAMESPACE_CLOSE