From 6a0671474605f9dc66fcd2a9508b8780af68f9b2 Mon Sep 17 00:00:00 2001 From: David Wells Date: Fri, 28 Aug 2020 11:20:18 -0400 Subject: [PATCH] Fix some type limit warnings in TensorProductPolynomials. GCC 10.2.0 complains when we instantiate with dim = 0 since a lot of loops then have checks 0 < 0. Get around this by specializing templates in this case. --- .../deal.II/base/tensor_product_polynomials.h | 28 +++ source/base/tensor_product_polynomials.cc | 160 ++++++++++++++++-- 2 files changed, 178 insertions(+), 10 deletions(-) diff --git a/include/deal.II/base/tensor_product_polynomials.h b/include/deal.II/base/tensor_product_polynomials.h index 678ea38962..4a8715e55a 100644 --- a/include/deal.II/base/tensor_product_polynomials.h +++ b/include/deal.II/base/tensor_product_polynomials.h @@ -659,6 +659,20 @@ TensorProductPolynomials::compute_derivative( +template <> +template +Tensor +TensorProductPolynomials<0, Polynomials::Polynomial>:: + compute_derivative(const unsigned int, const Point<0> &) const +{ + constexpr int dim = 0; + AssertThrow(dim > 0, ExcNotImplemented()); + + return {}; +} + + + template inline Tensor<1, dim> TensorProductPolynomials::compute_1st_derivative( @@ -823,6 +837,20 @@ AnisotropicPolynomials::compute_derivative(const unsigned int i, +template <> +template +Tensor +AnisotropicPolynomials<0>::compute_derivative(const unsigned int, + const Point<0> &) const +{ + constexpr int dim = 0; + AssertThrow(dim > 0, ExcNotImplemented()); + + return {}; +} + + + template inline Tensor<1, dim> AnisotropicPolynomials::compute_1st_derivative(const unsigned int i, diff --git a/source/base/tensor_product_polynomials.cc b/source/base/tensor_product_polynomials.cc index 77e1460672..6472cc5db4 100644 --- a/source/base/tensor_product_polynomials.cc +++ b/source/base/tensor_product_polynomials.cc @@ -94,6 +94,18 @@ TensorProductPolynomials::compute_index( +template <> +inline void +TensorProductPolynomials<0, Polynomials::Polynomial>::compute_index( + const unsigned int, + std::array &) const +{ + constexpr int dim = 0; + AssertThrow(dim > 0, ExcNotImplemented()); +} + + + template void TensorProductPolynomials::output_indices( @@ -112,6 +124,17 @@ TensorProductPolynomials::output_indices( +template <> +void +TensorProductPolynomials<0, Polynomials::Polynomial>::output_indices( + std::ostream &) const +{ + constexpr int dim = 0; + AssertThrow(dim > 0, ExcNotImplemented()); +} + + + template void TensorProductPolynomials::set_numbering( @@ -128,13 +151,12 @@ TensorProductPolynomials::set_numbering( template <> -double -TensorProductPolynomials<0, Polynomials::Polynomial>::compute_value( - const unsigned int, - const Point<0> &) const +void +TensorProductPolynomials<0, Polynomials::Polynomial>::set_numbering( + const std::vector &) { - Assert(false, ExcNotImplemented()); - return 0; + constexpr int dim = 0; + AssertThrow(dim > 0, ExcNotImplemented()); } @@ -159,6 +181,20 @@ TensorProductPolynomials::compute_value( +template <> +double +TensorProductPolynomials<0, Polynomials::Polynomial>::compute_value( + const unsigned int, + const Point<0> &) const +{ + constexpr int dim = 0; + AssertThrow(dim > 0, ExcNotImplemented()); + + return {}; +} + + + template Tensor<1, dim> TensorProductPolynomials::compute_grad( @@ -202,6 +238,9 @@ TensorProductPolynomials<0, Polynomials::Polynomial>::compute_grad( const unsigned int, const Point<0> &) const { + constexpr int dim = 0; + AssertThrow(dim > 0, ExcNotImplemented()); + return {}; } @@ -426,6 +465,22 @@ TensorProductPolynomials::evaluate( +template <> +void +TensorProductPolynomials<0, Polynomials::Polynomial>::evaluate( + const Point<0> &, + std::vector &, + std::vector> &, + std::vector> &, + std::vector> &, + std::vector> &) const +{ + constexpr int dim = 0; + AssertThrow(dim > 0, ExcNotImplemented()); +} + + + template std::unique_ptr> TensorProductPolynomials::clone() const @@ -456,10 +511,13 @@ AnisotropicPolynomials::AnisotropicPolynomials( , polynomials(pols) { Assert(pols.size() == dim, ExcDimensionMismatch(pols.size(), dim)); - for (unsigned int d = 0; d < dim; ++d) - Assert(pols[d].size() > 0, - ExcMessage("The number of polynomials must be larger than zero " - "for all coordinate directions.")); + for (const auto &pols_d : pols) + { + (void)pols_d; + Assert(pols_d.size() > 0, + ExcMessage("The number of polynomials must be larger than zero " + "for all coordinate directions.")); + } } @@ -494,6 +552,17 @@ AnisotropicPolynomials::compute_index( +template <> +void +AnisotropicPolynomials<0>::compute_index(const unsigned int, + std::array &) const +{ + constexpr int dim = 0; + AssertThrow(dim > 0, ExcNotImplemented()); +} + + + template double AnisotropicPolynomials::compute_value(const unsigned int i, @@ -510,6 +579,20 @@ AnisotropicPolynomials::compute_value(const unsigned int i, } + +template <> +double +AnisotropicPolynomials<0>::compute_value(const unsigned int, + const Point<0> &) const +{ + constexpr int dim = 0; + AssertThrow(dim > 0, ExcNotImplemented()); + + return {}; +} + + + template Tensor<1, dim> AnisotropicPolynomials::compute_grad(const unsigned int i, @@ -538,6 +621,20 @@ AnisotropicPolynomials::compute_grad(const unsigned int i, } + +template <> +Tensor<1, 0> +AnisotropicPolynomials<0>::compute_grad(const unsigned int, + const Point<0> &) const +{ + constexpr int dim = 0; + AssertThrow(dim > 0, ExcNotImplemented()); + + return {}; +} + + + template Tensor<2, dim> AnisotropicPolynomials::compute_grad_grad(const unsigned int i, @@ -574,6 +671,19 @@ AnisotropicPolynomials::compute_grad_grad(const unsigned int i, +template <> +Tensor<2, 0> +AnisotropicPolynomials<0>::compute_grad_grad(const unsigned int, + const Point<0> &) const +{ + constexpr int dim = 0; + AssertThrow(dim > 0, ExcNotImplemented()); + + return {}; +} + + + template void AnisotropicPolynomials::evaluate( @@ -721,6 +831,22 @@ AnisotropicPolynomials::evaluate( } + +template <> +void +AnisotropicPolynomials<0>::evaluate(const Point<0> &, + std::vector &, + std::vector> &, + std::vector> &, + std::vector> &, + std::vector> &) const +{ + constexpr int dim = 0; + AssertThrow(dim > 0, ExcNotImplemented()); +} + + + template unsigned int AnisotropicPolynomials::get_n_tensor_pols( @@ -733,6 +859,20 @@ AnisotropicPolynomials::get_n_tensor_pols( } + +template <> +unsigned int +AnisotropicPolynomials<0>::get_n_tensor_pols( + const std::vector>> &) +{ + constexpr int dim = 0; + AssertThrow(dim > 0, ExcNotImplemented()); + + return {}; +} + + + template std::unique_ptr> AnisotropicPolynomials::clone() const -- 2.39.5