]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix some type limit warnings in TensorProductPolynomials. 10854/head
authorDavid Wells <drwells@email.unc.edu>
Fri, 28 Aug 2020 15:20:18 +0000 (11:20 -0400)
committerDavid Wells <drwells@email.unc.edu>
Fri, 28 Aug 2020 15:20:18 +0000 (11:20 -0400)
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.

include/deal.II/base/tensor_product_polynomials.h
source/base/tensor_product_polynomials.cc

index 678ea3896234ad3bbfd247d56c41e082146f4b36..4a8715e55ade92afbe6af6d65f102b045608b81c 100644 (file)
@@ -659,6 +659,20 @@ TensorProductPolynomials<dim, PolynomialType>::compute_derivative(
 
 
 
+template <>
+template <int order>
+Tensor<order, 0>
+TensorProductPolynomials<0, Polynomials::Polynomial<double>>::
+  compute_derivative(const unsigned int, const Point<0> &) const
+{
+  constexpr int dim = 0;
+  AssertThrow(dim > 0, ExcNotImplemented());
+
+  return {};
+}
+
+
+
 template <int dim, typename PolynomialType>
 inline Tensor<1, dim>
 TensorProductPolynomials<dim, PolynomialType>::compute_1st_derivative(
@@ -823,6 +837,20 @@ AnisotropicPolynomials<dim>::compute_derivative(const unsigned int i,
 
 
 
+template <>
+template <int order>
+Tensor<order, 0>
+AnisotropicPolynomials<0>::compute_derivative(const unsigned int,
+                                              const Point<0> &) const
+{
+  constexpr int dim = 0;
+  AssertThrow(dim > 0, ExcNotImplemented());
+
+  return {};
+}
+
+
+
 template <int dim>
 inline Tensor<1, dim>
 AnisotropicPolynomials<dim>::compute_1st_derivative(const unsigned int i,
index 77e146067265f14d59a535c48969ebf00906dde8..6472cc5db46a06652f55f936da9f7a6a09d5c0eb 100644 (file)
@@ -94,6 +94,18 @@ TensorProductPolynomials<dim, PolynomialType>::compute_index(
 
 
 
+template <>
+inline void
+TensorProductPolynomials<0, Polynomials::Polynomial<double>>::compute_index(
+  const unsigned int,
+  std::array<unsigned int, 0> &) const
+{
+  constexpr int dim = 0;
+  AssertThrow(dim > 0, ExcNotImplemented());
+}
+
+
+
 template <int dim, typename PolynomialType>
 void
 TensorProductPolynomials<dim, PolynomialType>::output_indices(
@@ -112,6 +124,17 @@ TensorProductPolynomials<dim, PolynomialType>::output_indices(
 
 
 
+template <>
+void
+TensorProductPolynomials<0, Polynomials::Polynomial<double>>::output_indices(
+  std::ostream &) const
+{
+  constexpr int dim = 0;
+  AssertThrow(dim > 0, ExcNotImplemented());
+}
+
+
+
 template <int dim, typename PolynomialType>
 void
 TensorProductPolynomials<dim, PolynomialType>::set_numbering(
@@ -128,13 +151,12 @@ TensorProductPolynomials<dim, PolynomialType>::set_numbering(
 
 
 template <>
-double
-TensorProductPolynomials<0, Polynomials::Polynomial<double>>::compute_value(
-  const unsigned int,
-  const Point<0> &) const
+void
+TensorProductPolynomials<0, Polynomials::Polynomial<double>>::set_numbering(
+  const std::vector<unsigned int> &)
 {
-  Assert(false, ExcNotImplemented());
-  return 0;
+  constexpr int dim = 0;
+  AssertThrow(dim > 0, ExcNotImplemented());
 }
 
 
@@ -159,6 +181,20 @@ TensorProductPolynomials<dim, PolynomialType>::compute_value(
 
 
 
+template <>
+double
+TensorProductPolynomials<0, Polynomials::Polynomial<double>>::compute_value(
+  const unsigned int,
+  const Point<0> &) const
+{
+  constexpr int dim = 0;
+  AssertThrow(dim > 0, ExcNotImplemented());
+
+  return {};
+}
+
+
+
 template <int dim, typename PolynomialType>
 Tensor<1, dim>
 TensorProductPolynomials<dim, PolynomialType>::compute_grad(
@@ -202,6 +238,9 @@ TensorProductPolynomials<0, Polynomials::Polynomial<double>>::compute_grad(
   const unsigned int,
   const Point<0> &) const
 {
+  constexpr int dim = 0;
+  AssertThrow(dim > 0, ExcNotImplemented());
+
   return {};
 }
 
@@ -426,6 +465,22 @@ TensorProductPolynomials<dim, PolynomialType>::evaluate(
 
 
 
+template <>
+void
+TensorProductPolynomials<0, Polynomials::Polynomial<double>>::evaluate(
+  const Point<0> &,
+  std::vector<double> &,
+  std::vector<Tensor<1, 0>> &,
+  std::vector<Tensor<2, 0>> &,
+  std::vector<Tensor<3, 0>> &,
+  std::vector<Tensor<4, 0>> &) const
+{
+  constexpr int dim = 0;
+  AssertThrow(dim > 0, ExcNotImplemented());
+}
+
+
+
 template <int dim, typename PolynomialType>
 std::unique_ptr<ScalarPolynomialsBase<dim>>
 TensorProductPolynomials<dim, PolynomialType>::clone() const
@@ -456,10 +511,13 @@ AnisotropicPolynomials<dim>::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<dim>::compute_index(
 
 
 
+template <>
+void
+AnisotropicPolynomials<0>::compute_index(const unsigned int,
+                                         std::array<unsigned int, 0> &) const
+{
+  constexpr int dim = 0;
+  AssertThrow(dim > 0, ExcNotImplemented());
+}
+
+
+
 template <int dim>
 double
 AnisotropicPolynomials<dim>::compute_value(const unsigned int i,
@@ -510,6 +579,20 @@ AnisotropicPolynomials<dim>::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 <int dim>
 Tensor<1, dim>
 AnisotropicPolynomials<dim>::compute_grad(const unsigned int i,
@@ -538,6 +621,20 @@ AnisotropicPolynomials<dim>::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 <int dim>
 Tensor<2, dim>
 AnisotropicPolynomials<dim>::compute_grad_grad(const unsigned int i,
@@ -574,6 +671,19 @@ AnisotropicPolynomials<dim>::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 <int dim>
 void
 AnisotropicPolynomials<dim>::evaluate(
@@ -721,6 +831,22 @@ AnisotropicPolynomials<dim>::evaluate(
 }
 
 
+
+template <>
+void
+AnisotropicPolynomials<0>::evaluate(const Point<0> &,
+                                    std::vector<double> &,
+                                    std::vector<Tensor<1, 0>> &,
+                                    std::vector<Tensor<2, 0>> &,
+                                    std::vector<Tensor<3, 0>> &,
+                                    std::vector<Tensor<4, 0>> &) const
+{
+  constexpr int dim = 0;
+  AssertThrow(dim > 0, ExcNotImplemented());
+}
+
+
+
 template <int dim>
 unsigned int
 AnisotropicPolynomials<dim>::get_n_tensor_pols(
@@ -733,6 +859,20 @@ AnisotropicPolynomials<dim>::get_n_tensor_pols(
 }
 
 
+
+template <>
+unsigned int
+AnisotropicPolynomials<0>::get_n_tensor_pols(
+  const std::vector<std::vector<Polynomials::Polynomial<double>>> &)
+{
+  constexpr int dim = 0;
+  AssertThrow(dim > 0, ExcNotImplemented());
+
+  return {};
+}
+
+
+
 template <int dim>
 std::unique_ptr<ScalarPolynomialsBase<dim>>
 AnisotropicPolynomials<dim>::clone() const

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.