From 299ee2277caac60a3b4d924c2b1d81143362e736 Mon Sep 17 00:00:00 2001 From: Martin Kronbichler Date: Wed, 30 Aug 2023 15:26:39 +0200 Subject: [PATCH] Fix some additional warnings --- source/base/tensor_product_polynomials.cc | 35 ++++++++++++++--------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/source/base/tensor_product_polynomials.cc b/source/base/tensor_product_polynomials.cc index ddb49ff65f..cf14a7de7f 100644 --- a/source/base/tensor_product_polynomials.cc +++ b/source/base/tensor_product_polynomials.cc @@ -405,20 +405,25 @@ namespace internal if (update_grads) { grads[index][0] = value_outer[0] * val_x[1]; - for (unsigned int d = 1; d < dim; ++d) - grads[index][d] = value_outer[d] * val_x[0]; + if constexpr (dim > 1) + for (unsigned int d = 1; d < dim; ++d) + grads[index][d] = value_outer[d] * val_x[0]; } if (update_grad_grads) { grad_grads[index][0][0] = value_outer[0] * val_x[2]; - for (unsigned int d = 1; d < dim; ++d) - grad_grads[index][0][d] = grad_grads[index][d][0] = - value_outer[d] * val_x[1]; - for (unsigned int d1 = 1, count = dim; d1 < dim; ++d1) - for (unsigned int d2 = d1; d2 < dim; ++d2, ++count) - grad_grads[index][d1][d2] = grad_grads[index][d2][d1] = - value_outer[count] * val_x[0]; + if constexpr (dim > 1) + { + for (unsigned int d = 1; d < dim; ++d) + grad_grads[index][0][d] = grad_grads[index][d][0] = + value_outer[d] * val_x[1]; + for (unsigned int d1 = 1, count = dim; d1 < dim; ++d1) + for (unsigned int d2 = d1; d2 < dim; ++d2, ++count) + grad_grads[index][d1][d2] = + grad_grads[index][d2][d1] = + value_outer[count] * val_x[0]; + } } } @@ -505,6 +510,9 @@ TensorProductPolynomials::evaluate( std::vector> &third_derivatives, std::vector> &fourth_derivatives) const { + if constexpr (dim == 0) + return; + Assert(dim <= 3, ExcNotImplemented()); Assert(values.size() == this->n() || values.empty(), ExcDimensionMismatch2(values.size(), this->n(), 0)); @@ -530,15 +538,14 @@ TensorProductPolynomials::evaluate( if (fourth_derivatives.size() == this->n()) n_derivatives = 4; - // Compute the values (and derivatives, if necessary) of all 1d polynomials - // at this evaluation point. We can use the more optimized values_of_array - // function to compute 'dim' polynomials at once + // Compute the values (and derivatives, if necessary) of all 1d + // polynomials at this evaluation point. We can use the more optimized + // values_of_array function to compute 'dim' polynomials at once const unsigned int n_polynomials = polynomials.size(); boost::container::small_vector, 10> values_1d( n_polynomials); if constexpr (std::is_same>::value && - dim > 0) + dealii::Polynomials::Polynomial>::value) { std::array point_array; for (unsigned int d = 0; d < dim; ++d) -- 2.39.5