From: Martin Kronbichler Date: Thu, 30 Mar 2017 13:19:39 +0000 (+0200) Subject: FEEvaluation: Tidy up selection of templated evaluation calls. X-Git-Tag: v9.0.0-rc1~1756^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F4141%2Fhead;p=dealii.git FEEvaluation: Tidy up selection of templated evaluation calls. --- diff --git a/include/deal.II/matrix_free/fe_evaluation.h b/include/deal.II/matrix_free/fe_evaluation.h index 3eb419d967..7fbced8e57 100644 --- a/include/deal.II/matrix_free/fe_evaluation.h +++ b/include/deal.II/matrix_free/fe_evaluation.h @@ -5373,105 +5373,82 @@ template -::evaluate (const bool evaluate_val, - const bool evaluate_grad, - const bool evaluate_lapl) +::evaluate (const bool evaluate_values, + const bool evaluate_gradients, + const bool evaluate_hessians) { Assert (this->dof_values_initialized == true, internal::ExcAccessToUninitializedField()); Assert(this->matrix_info != 0 || this->mapped_geometry->is_initialized(), ExcNotInitialized()); - // Select algorithm matching the element type at run time - const unsigned int fe_degree_templ = fe_degree != -1 ? fe_degree : 0; - const unsigned int n_q_points_1d_templ = n_q_points_1d > 0 ? n_q_points_1d : 1; - if (fe_degree == -1) + // Run time selection of algorithm matching the element type. Since some + // template combinations do not work for fe_degree==-1, create safe template + // values for the calls below. + const unsigned int fe_degree_nonnegative = fe_degree != -1 ? fe_degree : 0; + const unsigned int n_q_points_1d_positive = n_q_points_1d > 0 ? n_q_points_1d : 1; + const unsigned int n_q_points_1d_adjusted = fe_degree == -1 ? 0 : n_q_points_1d; + if (fe_degree >= 0 && + fe_degree+1 == n_q_points_1d && + this->data->element_type == internal::MatrixFreeFunctions::tensor_symmetric_collocation) { - if (this->data->element_type == internal::MatrixFreeFunctions::tensor_symmetric_plus_dg0) - { - internal::FEEvaluationImpl - ::evaluate(*this->data, &this->values_dofs[0], this->values_quad, - this->gradients_quad, this->hessians_quad, this->scratch_data, - evaluate_val, evaluate_grad, evaluate_lapl); - } - else if (this->data->element_type == internal::MatrixFreeFunctions::truncated_tensor) - { - internal::FEEvaluationImpl - ::evaluate(*this->data, &this->values_dofs[0], this->values_quad, - this->gradients_quad, this->hessians_quad, this->scratch_data, - evaluate_val, evaluate_grad, evaluate_lapl); - } - else - { - internal::FEEvaluationImpl - ::evaluate(*this->data, &this->values_dofs[0], this->values_quad, - this->gradients_quad, this->hessians_quad, this->scratch_data, - evaluate_val, evaluate_grad, evaluate_lapl); - } + internal::FEEvaluationImplCollocation + ::evaluate(*this->data, &this->values_dofs[0], this->values_quad, + this->gradients_quad, this->hessians_quad, this->scratch_data, + evaluate_values, evaluate_gradients, evaluate_hessians); } - else + else if (fe_degree >= 0 && + fe_degree+1 == n_q_points_1d && + this->data->element_type == internal::MatrixFreeFunctions::tensor_symmetric) { - if (fe_degree+1 == n_q_points_1d && - this->data->element_type == internal::MatrixFreeFunctions::tensor_symmetric_collocation) - { - internal::FEEvaluationImplCollocation - ::evaluate(*this->data, &this->values_dofs[0], this->values_quad, - this->gradients_quad, this->hessians_quad, this->scratch_data, - evaluate_val, evaluate_grad, evaluate_lapl); - } - else if (fe_degree+1 == n_q_points_1d && - this->data->element_type == internal::MatrixFreeFunctions::tensor_symmetric) - { - internal::FEEvaluationImplTransformToCollocation - ::evaluate(*this->data, &this->values_dofs[0], this->values_quad, - this->gradients_quad, this->hessians_quad, this->scratch_data, - evaluate_val, evaluate_grad, evaluate_lapl); - } - else if (this->data->element_type == internal::MatrixFreeFunctions::tensor_symmetric) - { - internal::FEEvaluationImpl - ::evaluate(*this->data, &this->values_dofs[0], this->values_quad, - this->gradients_quad, this->hessians_quad, this->scratch_data, - evaluate_val, evaluate_grad, evaluate_lapl); - } - else if (this->data->element_type == internal::MatrixFreeFunctions::tensor_symmetric_plus_dg0) - { - internal::FEEvaluationImpl - ::evaluate(*this->data, &this->values_dofs[0], this->values_quad, - this->gradients_quad, this->hessians_quad, this->scratch_data, - evaluate_val, evaluate_grad, evaluate_lapl); - } - else if (this->data->element_type == internal::MatrixFreeFunctions::tensor_general) - { - internal::FEEvaluationImpl - ::evaluate(*this->data, &this->values_dofs[0], this->values_quad, - this->gradients_quad, this->hessians_quad, this->scratch_data, - evaluate_val, evaluate_grad, evaluate_lapl); - } - else if (this->data->element_type == internal::MatrixFreeFunctions::truncated_tensor) - { - internal::FEEvaluationImpl - ::evaluate(*this->data, &this->values_dofs[0], this->values_quad, - this->gradients_quad, this->hessians_quad, this->scratch_data, - evaluate_val, evaluate_grad, evaluate_lapl); - } - else - AssertThrow(false, ExcNotImplemented()); + internal::FEEvaluationImplTransformToCollocation + ::evaluate(*this->data, &this->values_dofs[0], this->values_quad, + this->gradients_quad, this->hessians_quad, this->scratch_data, + evaluate_values, evaluate_gradients, evaluate_hessians); + } + else if (fe_degree >= 0 && + this->data->element_type == internal::MatrixFreeFunctions::tensor_symmetric) + { + internal::FEEvaluationImpl + ::evaluate(*this->data, &this->values_dofs[0], this->values_quad, + this->gradients_quad, this->hessians_quad, this->scratch_data, + evaluate_values, evaluate_gradients, evaluate_hessians); } + else if (this->data->element_type == internal::MatrixFreeFunctions::tensor_symmetric_plus_dg0) + { + internal::FEEvaluationImpl + ::evaluate(*this->data, &this->values_dofs[0], this->values_quad, + this->gradients_quad, this->hessians_quad, this->scratch_data, + evaluate_values, evaluate_gradients, evaluate_hessians); + } + else if (this->data->element_type == internal::MatrixFreeFunctions::truncated_tensor) + { + internal::FEEvaluationImpl + ::evaluate(*this->data, &this->values_dofs[0], this->values_quad, + this->gradients_quad, this->hessians_quad, this->scratch_data, + evaluate_values, evaluate_gradients, evaluate_hessians); + } + else if (fe_degree == -1 || + this->data->element_type == internal::MatrixFreeFunctions::tensor_general) + { + internal::FEEvaluationImpl + ::evaluate(*this->data, &this->values_dofs[0], this->values_quad, + this->gradients_quad, this->hessians_quad, this->scratch_data, + evaluate_values, evaluate_gradients, evaluate_hessians); + } + else + AssertThrow(false, ExcNotImplemented()); #ifdef DEBUG - if (evaluate_val == true) + if (evaluate_values == true) this->values_quad_initialized = true; - if (evaluate_grad == true) + if (evaluate_gradients == true) this->gradients_quad_initialized = true; - if (evaluate_lapl == true) + if (evaluate_hessians == true) this->hessians_quad_initialized = true; #endif } @@ -5483,100 +5460,78 @@ template -::integrate (bool integrate_val,bool integrate_grad) +::integrate (const bool integrate_values, + const bool integrate_gradients) { - if (integrate_val == true) + if (integrate_values == true) Assert (this->values_quad_submitted == true, internal::ExcAccessToUninitializedField()); - if (integrate_grad == true) + if (integrate_gradients == true) Assert (this->gradients_quad_submitted == true, internal::ExcAccessToUninitializedField()); Assert(this->matrix_info != 0 || this->mapped_geometry->is_initialized(), ExcNotInitialized()); - // Select algorithm matching the element type at run time - const unsigned int fe_degree_templ = fe_degree != -1 ? fe_degree : 0; - const unsigned int n_q_points_1d_templ = n_q_points_1d > 0 ? n_q_points_1d : 1; - if (fe_degree == -1) + // Run time selection of algorithm matching the element type. Since some + // template combinations do not work for fe_degree==-1, create safe template + // values for the calls below. + const unsigned int fe_degree_nonnegative = fe_degree != -1 ? fe_degree : 0; + const unsigned int n_q_points_1d_positive = n_q_points_1d > 0 ? n_q_points_1d : 1; + const unsigned int n_q_points_1d_adjusted = fe_degree == -1 ? 0 : n_q_points_1d; + if (fe_degree >= 0 && + fe_degree+1 == n_q_points_1d && + this->data->element_type == internal::MatrixFreeFunctions::tensor_symmetric_collocation) { - if (this->data->element_type == internal::MatrixFreeFunctions::tensor_symmetric_plus_dg0) - { - internal::FEEvaluationImpl - ::integrate(*this->data, &this->values_dofs[0], this->values_quad, - this->gradients_quad, this->scratch_data, - integrate_val, integrate_grad); - } - else if (this->data->element_type == internal::MatrixFreeFunctions::truncated_tensor) - { - internal::FEEvaluationImpl - ::integrate(*this->data, &this->values_dofs[0], this->values_quad, - this->gradients_quad, this->scratch_data, - integrate_val, integrate_grad); - } - else - { - internal::FEEvaluationImpl - ::integrate(*this->data, &this->values_dofs[0], this->values_quad, - this->gradients_quad, this->scratch_data, - integrate_val, integrate_grad); - } + internal::FEEvaluationImplCollocation + ::integrate(*this->data, &this->values_dofs[0], this->values_quad, + this->gradients_quad, this->scratch_data, + integrate_values, integrate_gradients); } - else + else if (fe_degree >= 0 && + fe_degree+1 == n_q_points_1d && + this->data->element_type == internal::MatrixFreeFunctions::tensor_symmetric) { - if (fe_degree+1 == n_q_points_1d && - this->data->element_type == internal::MatrixFreeFunctions::tensor_symmetric_collocation) - { - internal::FEEvaluationImplCollocation - ::integrate(*this->data, &this->values_dofs[0], this->values_quad, - this->gradients_quad, this->scratch_data, - integrate_val, integrate_grad); - } - else if (fe_degree+1 == n_q_points_1d && - this->data->element_type == internal::MatrixFreeFunctions::tensor_symmetric) - { - internal::FEEvaluationImplTransformToCollocation - ::integrate(*this->data, &this->values_dofs[0], this->values_quad, - this->gradients_quad, this->scratch_data, - integrate_val, integrate_grad); - } - else if (this->data->element_type == internal::MatrixFreeFunctions::tensor_symmetric) - { - internal::FEEvaluationImpl - ::integrate(*this->data, &this->values_dofs[0], this->values_quad, - this->gradients_quad, this->scratch_data, - integrate_val, integrate_grad); - } - else if (this->data->element_type == internal::MatrixFreeFunctions::tensor_symmetric_plus_dg0) - { - internal::FEEvaluationImpl - ::integrate(*this->data, &this->values_dofs[0], this->values_quad, - this->gradients_quad, this->scratch_data, - integrate_val, integrate_grad); - } - else if (this->data->element_type == internal::MatrixFreeFunctions::tensor_general) - { - internal::FEEvaluationImpl - ::integrate(*this->data, &this->values_dofs[0], this->values_quad, - this->gradients_quad, this->scratch_data, - integrate_val, integrate_grad); - } - else if (this->data->element_type == internal::MatrixFreeFunctions::truncated_tensor) - { - internal::FEEvaluationImpl - ::integrate(*this->data, &this->values_dofs[0], this->values_quad, - this->gradients_quad, this->scratch_data, - integrate_val, integrate_grad); - } - else - AssertThrow(false, ExcNotImplemented()); + internal::FEEvaluationImplTransformToCollocation + ::integrate(*this->data, &this->values_dofs[0], this->values_quad, + this->gradients_quad, this->scratch_data, + integrate_values, integrate_gradients); + } + else if (fe_degree >= 0 && + this->data->element_type == internal::MatrixFreeFunctions::tensor_symmetric) + { + internal::FEEvaluationImpl + ::integrate(*this->data, &this->values_dofs[0], this->values_quad, + this->gradients_quad, this->scratch_data, + integrate_values, integrate_gradients); } + else if (this->data->element_type == internal::MatrixFreeFunctions::tensor_symmetric_plus_dg0) + { + internal::FEEvaluationImpl + ::integrate(*this->data, &this->values_dofs[0], this->values_quad, + this->gradients_quad, this->scratch_data, + integrate_values, integrate_gradients); + } + else if (this->data->element_type == internal::MatrixFreeFunctions::truncated_tensor) + { + internal::FEEvaluationImpl + ::integrate(*this->data, &this->values_dofs[0], this->values_quad, + this->gradients_quad, this->scratch_data, + integrate_values, integrate_gradients); + } + else if (fe_degree == -1 || + this->data->element_type == internal::MatrixFreeFunctions::tensor_general) + { + internal::FEEvaluationImpl + ::integrate(*this->data, &this->values_dofs[0], this->values_quad, + this->gradients_quad, this->scratch_data, + integrate_values, integrate_gradients); + } + else + AssertThrow(false, ExcNotImplemented()); #ifdef DEBUG this->dof_values_initialized = true;