]> https://gitweb.dealii.org/ - dealii.git/commitdiff
instantiate TensorProductPolynomials for dim=0
authorTimo Heister <timo.heister@gmail.com>
Fri, 20 Sep 2019 14:13:17 +0000 (10:13 -0400)
committerTimo Heister <timo.heister@gmail.com>
Fri, 20 Sep 2019 14:13:17 +0000 (10:13 -0400)
include/deal.II/base/tensor_product_polynomials.h
source/base/scalar_polynomials_base.cc
source/base/tensor_product_polynomials.cc

index 28f7c9d03672bbd6aca46f6c2d3ae6c302012c63..546904b53fa51f34849c56965551db186c530b4d 100644 (file)
@@ -410,7 +410,8 @@ private:
    * <tt>i</tt>.
    */
   void
-  compute_index(const unsigned int i, unsigned int (&indices)[dim]) const;
+  compute_index(const unsigned int i,
+                unsigned int (&indices)[(dim > 0 ? dim : 1)]) const;
 
   /**
    * Given the input to the constructor, compute <tt>n_pols</tt>.
index c067980ed45c68950f8fcae833230728af440c8b..8eedfaf6dad0b2220b1f5d06d8aed75a75186140 100644 (file)
@@ -35,6 +35,7 @@ ScalarPolynomialsBase<dim>::ScalarPolynomialsBase(
 
 
 
+template class ScalarPolynomialsBase<0>;
 template class ScalarPolynomialsBase<1>;
 template class ScalarPolynomialsBase<2>;
 template class ScalarPolynomialsBase<3>;
index 49ce046c0d256a0d69407d6d33a01847cae63b09..7db3763f10ac73fd279f5b3d7601aacefb701b77 100644 (file)
@@ -98,7 +98,7 @@ void
 TensorProductPolynomials<dim, PolynomialType>::output_indices(
   std::ostream &out) const
 {
-  unsigned int ix[dim];
+  unsigned int ix[(dim > 0) ? dim : 1];
   for (unsigned int i = 0; i < this->n(); ++i)
     {
       compute_index(i, ix);
@@ -164,7 +164,7 @@ TensorProductPolynomials<dim, PolynomialType>::compute_grad(
   const unsigned int i,
   const Point<dim> & p) const
 {
-  unsigned int indices[dim];
+  unsigned int indices[(dim > 0) ? dim : 1];
   compute_index(i, indices);
 
   // compute values and
@@ -201,7 +201,7 @@ TensorProductPolynomials<dim, PolynomialType>::compute_grad_grad(
   const unsigned int i,
   const Point<dim> & p) const
 {
-  unsigned int indices[dim];
+  unsigned int indices[(dim > 0) ? dim : 1];
   compute_index(i, indices);
 
   double v[dim][3];
@@ -433,8 +433,9 @@ AnisotropicPolynomials<dim>::AnisotropicPolynomials(
 
 template <int dim>
 void
-AnisotropicPolynomials<dim>::compute_index(const unsigned int i,
-                                           unsigned int (&indices)[dim]) const
+AnisotropicPolynomials<dim>::compute_index(
+  const unsigned int i,
+  unsigned int (&indices)[(dim > 0 ? dim : 1)]) const
 {
 #ifdef DEBUG
   unsigned int n_poly = 1;
@@ -443,7 +444,10 @@ AnisotropicPolynomials<dim>::compute_index(const unsigned int i,
   Assert(i < n_poly, ExcInternalError());
 #endif
 
-  if (dim == 1)
+  if (dim == 0)
+    {
+    }
+  else if (dim == 1)
     internal::compute_tensor_index(i,
                                    polynomials[0].size(),
                                    0 /*not used*/,
@@ -462,7 +466,7 @@ double
 AnisotropicPolynomials<dim>::compute_value(const unsigned int i,
                                            const Point<dim> & p) const
 {
-  unsigned int indices[dim];
+  unsigned int indices[(dim > 0) ? dim : 1];
   compute_index(i, indices);
 
   double value = 1.;
@@ -478,7 +482,7 @@ Tensor<1, dim>
 AnisotropicPolynomials<dim>::compute_grad(const unsigned int i,
                                           const Point<dim> & p) const
 {
-  unsigned int indices[dim];
+  unsigned int indices[(dim > 0) ? dim : 1];
   compute_index(i, indices);
 
   // compute values and
@@ -506,7 +510,7 @@ Tensor<2, dim>
 AnisotropicPolynomials<dim>::compute_grad_grad(const unsigned int i,
                                                const Point<dim> & p) const
 {
-  unsigned int indices[dim];
+  unsigned int indices[(dim > 0) ? dim : 1];
   compute_index(i, indices);
 
   std::vector<std::vector<double>> v(dim, std::vector<double>(3));
@@ -601,7 +605,7 @@ AnisotropicPolynomials<dim>::evaluate(
       // one-dimensional indices of
       // this particular tensor
       // product polynomial
-      unsigned int indices[dim];
+      unsigned int indices[(dim > 0) ? dim : 1];
       compute_index(i, indices);
 
       if (update_values)
@@ -706,6 +710,7 @@ AnisotropicPolynomials<dim>::clone() const
 
 
 /* ------------------- explicit instantiations -------------- */
+template class TensorProductPolynomials<0, Polynomials::Polynomial<double>>;
 template class TensorProductPolynomials<1, Polynomials::Polynomial<double>>;
 template class TensorProductPolynomials<2, Polynomials::Polynomial<double>>;
 template class TensorProductPolynomials<3, Polynomials::Polynomial<double>>;
@@ -720,6 +725,7 @@ template class TensorProductPolynomials<
   3,
   Polynomials::PiecewisePolynomial<double>>;
 
+template class AnisotropicPolynomials<0>;
 template class AnisotropicPolynomials<1>;
 template class AnisotropicPolynomials<2>;
 template class AnisotropicPolynomials<3>;

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.