]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Squash warnings. 1494/head
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Mon, 31 Aug 2015 21:58:49 +0000 (16:58 -0500)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Mon, 31 Aug 2015 21:58:49 +0000 (16:58 -0500)
We previously had warnings about invalid array accesses for dim==1. The
function in question doesn't implement this, but is instantiated anyway.

include/deal.II/base/polynomials_rannacher_turek.h

index 635bceb6c64a9d01aa6b4881d6fab95e16c2b464..fab597edffea918d99aa4cf36b2273ee44c9f2a6 100644 (file)
@@ -91,85 +91,115 @@ public:
                std::vector<Tensor<4,dim> > &fourth_derivatives) const;
 };
 
-// template functions
-template <int dim>
-template <int order>
-Tensor<order,dim>
-PolynomialsRannacherTurek<dim>::compute_derivative (const unsigned int i,
-                                                    const Point<dim> &p) const
+
+namespace internal
 {
-  Assert(dim == 2, ExcNotImplemented());
-  Tensor<order,dim> derivative;
-  switch (order)
-    {
-    case 1:
+  namespace PolynomialsRannacherTurek
+  {
+    template <int order, int dim>
+    inline
+    Tensor<order,dim>
+    compute_derivative (const unsigned int,
+                        const Point<dim> &)
     {
-      Tensor<1,dim> &grad = *reinterpret_cast<Tensor<1,dim>*>(&derivative);
-      if (i == 0)
-        {
-          grad[0] = -2.5 + 3*p(0);
-          grad[1] = 1.5 - 3*p(1);
-        }
-      else if (i == 1)
-        {
-          grad[0] = -0.5 + 3.0*p(0);
-          grad[1] = 1.5 - 3.0*p(1);
-        }
-      else if (i == 2)
-        {
-          grad[0] = 1.5 - 3.0*p(0);
-          grad[1] = -2.5 + 3.0*p(1);
-        }
-      else if (i == 3)
-        {
-          grad[0] = 1.5 - 3.0*p(0);
-          grad[1] = -0.5 + 3.0*p(1);
-        }
-      else
-        {
-          Assert(false, ExcNotImplemented());
-        }
-      return derivative;
+      Assert (dim == 2, ExcNotImplemented());
+      return Tensor<order,dim>();
     }
-    case 2:
+
+
+    template <int order>
+    inline
+    Tensor<order,2>
+    compute_derivative (const unsigned int i,
+                        const Point<2> &p)
     {
-      Tensor<2,dim> &grad_grad = *reinterpret_cast<Tensor<2,dim>*>(&derivative);
-      if (i == 0)
+      const unsigned int dim = 2;
+
+      Tensor<order,dim> derivative;
+      switch (order)
         {
-          grad_grad[0][0] = 3;
-          grad_grad[0][1] = 0;
-          grad_grad[1][0] = 0;
-          grad_grad[1][1] = -3;
-        }
-      else if (i == 1)
+        case 1:
         {
-          grad_grad[0][0] = 3;
-          grad_grad[0][1] = 0;
-          grad_grad[1][0] = 0;
-          grad_grad[1][1] = -3;
+          Tensor<1,dim> &grad = *reinterpret_cast<Tensor<1,dim>*>(&derivative);
+          if (i == 0)
+            {
+              grad[0] = -2.5 + 3*p(0);
+              grad[1] = 1.5 - 3*p(1);
+            }
+          else if (i == 1)
+            {
+              grad[0] = -0.5 + 3.0*p(0);
+              grad[1] = 1.5 - 3.0*p(1);
+            }
+          else if (i == 2)
+            {
+              grad[0] = 1.5 - 3.0*p(0);
+              grad[1] = -2.5 + 3.0*p(1);
+            }
+          else if (i == 3)
+            {
+              grad[0] = 1.5 - 3.0*p(0);
+              grad[1] = -0.5 + 3.0*p(1);
+            }
+          else
+            {
+              Assert(false, ExcNotImplemented());
+            }
+          return derivative;
         }
-      else if (i == 2)
+        case 2:
         {
-          grad_grad[0][0] = -3;
-          grad_grad[0][1] = 0;
-          grad_grad[1][0] = 0;
-          grad_grad[1][1] = 3;
+          Tensor<2,dim> &grad_grad = *reinterpret_cast<Tensor<2,dim>*>(&derivative);
+          if (i == 0)
+            {
+              grad_grad[0][0] = 3;
+              grad_grad[0][1] = 0;
+              grad_grad[1][0] = 0;
+              grad_grad[1][1] = -3;
+            }
+          else if (i == 1)
+            {
+              grad_grad[0][0] = 3;
+              grad_grad[0][1] = 0;
+              grad_grad[1][0] = 0;
+              grad_grad[1][1] = -3;
+            }
+          else if (i == 2)
+            {
+              grad_grad[0][0] = -3;
+              grad_grad[0][1] = 0;
+              grad_grad[1][0] = 0;
+              grad_grad[1][1] = 3;
+            }
+          else if (i == 3)
+            {
+              grad_grad[0][0] = -3;
+              grad_grad[0][1] = 0;
+              grad_grad[1][0] = 0;
+              grad_grad[1][1] = 3;
+            }
+          return derivative;
         }
-      else if (i == 3)
+        default:
         {
-          grad_grad[0][0] = -3;
-          grad_grad[0][1] = 0;
-          grad_grad[1][0] = 0;
-          grad_grad[1][1] = 3;
+          // higher derivatives are all zero
+          return Tensor<order,dim>();
+        }
         }
-      return derivative;
-    }
-    default:
-    {
-      // higher derivatives are all zero
-      return Tensor<order,dim>();
-    }
     }
+  }
+}
+
+
+
+// template functions
+template <int dim>
+template <int order>
+Tensor<order,dim>
+PolynomialsRannacherTurek<dim>::compute_derivative (const unsigned int i,
+                                                    const Point<dim> &p) const
+{
+  return internal::PolynomialsRannacherTurek::compute_derivative<order> (i, p);
 }
 
 

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.