From: Martin Kronbichler Date: Tue, 26 Mar 2024 16:43:55 +0000 (+0100) Subject: FEEvaluation: Add static asserts to functions selected by enable_if X-Git-Tag: v9.6.0-rc1~429^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=62e24379ec3a69dd0f82171610eee77b6b9fa359;p=dealii.git FEEvaluation: Add static asserts to functions selected by enable_if --- diff --git a/include/deal.II/matrix_free/fe_evaluation.h b/include/deal.II/matrix_free/fe_evaluation.h index 857927cd79..876ac6083b 100644 --- a/include/deal.II/matrix_free/fe_evaluation.h +++ b/include/deal.II/matrix_free/fe_evaluation.h @@ -4869,6 +4869,9 @@ FEEvaluationBase:: submit_value(const Tensor<1, 1, VectorizedArrayType> val_in, const unsigned int q_point) { + static_assert(n_components == 1 && dim == 1, + "Do not try to modify the default template parameters used for" + " selectively enabling this function via std::enable_if!"); submit_value(val_in[0], q_point); } @@ -5149,6 +5152,9 @@ FEEvaluationBase:: submit_gradient(const Tensor<2, 1, VectorizedArrayType> grad_in, const unsigned int q_point) { + static_assert(n_components == 1 && dim == 1, + "Do not try to modify the default template parameters used for" + " selectively enabling this function via std::enable_if!"); submit_gradient(grad_in[0], q_point); } @@ -5422,6 +5428,10 @@ inline DEAL_II_ALWAYS_INLINE VectorizedArrayType FEEvaluationBase:: get_divergence(const unsigned int q_point) const { + static_assert(n_components == dim, + "Do not try to modify the default template parameters used for" + " selectively enabling this function via std::enable_if!"); + # ifdef DEBUG Assert(this->gradients_quad_initialized == true, internal::ExcAccessToUninitializedField()); @@ -5503,6 +5513,10 @@ inline DEAL_II_ALWAYS_INLINE SymmetricTensor<2, dim, VectorizedArrayType> FEEvaluationBase:: get_symmetric_gradient(const unsigned int q_point) const { + static_assert(n_components == dim, + "Do not try to modify the default template parameters used for" + " selectively enabling this function via std::enable_if!"); + // copy from generic function into dim-specialization function const auto grad = get_gradient(q_point); VectorizedArrayType symmetrized[(dim * dim + dim) / 2]; @@ -5544,6 +5558,10 @@ inline DEAL_II_ALWAYS_INLINE FEEvaluationBase:: get_curl(const unsigned int q_point) const { + static_assert(dim > 1 && n_components == dim, + "Do not try to modify the default template parameters used for" + " selectively enabling this function via std::enable_if!"); + // copy from generic function into dim-specialization function const Tensor<2, dim, VectorizedArrayType> grad = get_gradient(q_point); Tensor<1, (dim == 2 ? 1 : dim), VectorizedArrayType> curl; @@ -5576,6 +5594,10 @@ FEEvaluationBase:: submit_divergence(const VectorizedArrayType div_in, const unsigned int q_point) { + static_assert(n_components == dim, + "Do not try to modify the default template parameters used for" + " selectively enabling this function via std::enable_if!"); + # ifdef DEBUG Assert(this->is_reinitialized, ExcNotInitialized()); # endif @@ -5669,6 +5691,10 @@ FEEvaluationBase:: const SymmetricTensor<2, dim, VectorizedArrayType> sym_grad, const unsigned int q_point) { + static_assert(n_components == dim, + "Do not try to modify the default template parameters used for" + " selectively enabling this function via std::enable_if!"); + AssertThrow( this->data->element_type != internal::MatrixFreeFunctions::ElementType::tensor_raviart_thomas, @@ -5756,6 +5782,10 @@ FEEvaluationBase:: submit_curl(const Tensor<1, dim == 2 ? 1 : dim, VectorizedArrayType> curl, const unsigned int q_point) { + static_assert(n_components == dim, + "Do not try to modify the default template parameters used for" + " selectively enabling this function via std::enable_if!"); + Tensor<2, dim, VectorizedArrayType> grad; switch (dim) {