From: Wolfgang Bangerth Date: Mon, 31 Aug 2015 21:58:49 +0000 (-0500) Subject: Squash warnings. X-Git-Tag: v8.4.0-rc2~494^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F1494%2Fhead;p=dealii.git Squash warnings. We previously had warnings about invalid array accesses for dim==1. The function in question doesn't implement this, but is instantiated anyway. --- diff --git a/include/deal.II/base/polynomials_rannacher_turek.h b/include/deal.II/base/polynomials_rannacher_turek.h index 635bceb6c6..fab597edff 100644 --- a/include/deal.II/base/polynomials_rannacher_turek.h +++ b/include/deal.II/base/polynomials_rannacher_turek.h @@ -91,85 +91,115 @@ public: std::vector > &fourth_derivatives) const; }; -// template functions -template -template -Tensor -PolynomialsRannacherTurek::compute_derivative (const unsigned int i, - const Point &p) const + +namespace internal { - Assert(dim == 2, ExcNotImplemented()); - Tensor derivative; - switch (order) - { - case 1: + namespace PolynomialsRannacherTurek + { + template + inline + Tensor + compute_derivative (const unsigned int, + const Point &) { - Tensor<1,dim> &grad = *reinterpret_cast*>(&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(); } - case 2: + + + template + inline + Tensor + compute_derivative (const unsigned int i, + const Point<2> &p) { - Tensor<2,dim> &grad_grad = *reinterpret_cast*>(&derivative); - if (i == 0) + const unsigned int dim = 2; + + Tensor 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*>(&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*>(&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(); + } } - return derivative; - } - default: - { - // higher derivatives are all zero - return Tensor(); - } } + } +} + + + +// template functions +template +template +Tensor +PolynomialsRannacherTurek::compute_derivative (const unsigned int i, + const Point &p) const +{ + return internal::PolynomialsRannacherTurek::compute_derivative (i, p); }