From 14be3a25a0290e1dd8303b05b856360feaa75e89 Mon Sep 17 00:00:00 2001 From: bangerth Date: Wed, 23 Sep 2009 18:35:41 +0000 Subject: [PATCH] Use SymmetricTensor::n_independent_components instead of duplicating this information. git-svn-id: https://svn.dealii.org/trunk@19513 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/include/fe/fe_values.h | 11 ++--------- deal.II/deal.II/source/fe/fe_values.cc | 25 +++++++++++++++---------- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/deal.II/deal.II/include/fe/fe_values.h b/deal.II/deal.II/include/fe/fe_values.h index 6fd91bcf6b..6d2143550d 100644 --- a/deal.II/deal.II/include/fe/fe_values.h +++ b/deal.II/deal.II/include/fe/fe_values.h @@ -986,13 +986,6 @@ namespace FEValuesViews */ const unsigned int first_tensor_component; - /** - * The number of unique - * components of a symmetric - * second-order tensor - */ - static const unsigned int n_independent_components = (dim*dim + dim)/2; - /** * The index of the first-order * tensor representation of a @@ -1025,7 +1018,7 @@ namespace FEValuesViews * (e.g. for RT elements it depends * on the shape of a cell). */ - bool is_nonzero_shape_function_component[n_independent_components]; + bool is_nonzero_shape_function_component[value_type::n_independent_components]; /** * For each pair (shape function, @@ -1043,7 +1036,7 @@ namespace FEValuesViews * harder to compute this * information. */ - unsigned int row_index[n_independent_components]; + unsigned int row_index[value_type::n_independent_components]; /** * For each shape function say the diff --git a/deal.II/deal.II/source/fe/fe_values.cc b/deal.II/deal.II/source/fe/fe_values.cc index 83106bb6f2..6e35000ee7 100644 --- a/deal.II/deal.II/source/fe/fe_values.cc +++ b/deal.II/deal.II/source/fe/fe_values.cc @@ -234,14 +234,19 @@ namespace FEValuesViews shape_function_data(fe_values.fe->dofs_per_cell) { - Assert(first_tensor_component + n_independent_components - 1 < fe_values.fe->n_components(), - ExcIndexRange(first_tensor_component + n_independent_components - 1, 0, + Assert(first_tensor_component + value_type::n_independent_components - 1 + < + fe_values.fe->n_components(), + ExcIndexRange(first_tensor_component + + value_type::n_independent_components - 1, + 0, fe_values.fe->n_components())); const std::vector shape_function_to_row_table = make_shape_function_to_row_table(*fe_values.fe); - for (unsigned int d = 0; d < n_independent_components; ++d) { + for (unsigned int d = 0; d < value_type::n_independent_components; ++d) + { const unsigned int component = first_tensor_component + d; for (unsigned int i = 0; i < fe_values.fe->dofs_per_cell; ++i) { @@ -278,7 +283,7 @@ namespace FEValuesViews for (unsigned int i = 0; i < fe_values.fe->dofs_per_cell; ++i) { unsigned int n_nonzero_components = 0; - for (unsigned int d = 0; d < n_independent_components; ++d) + for (unsigned int d = 0; d < value_type::n_independent_components; ++d) if (shape_function_data[i].is_nonzero_shape_function_component[d] == true) ++n_nonzero_components; @@ -288,7 +293,7 @@ namespace FEValuesViews else if (n_nonzero_components > 1) shape_function_data[i].single_nonzero_component = -1; else { - for (unsigned int d = 0; d < n_independent_components; ++d) + for (unsigned int d = 0; d < value_type::n_independent_components; ++d) if (shape_function_data[i].is_nonzero_shape_function_component[d] == true) { shape_function_data[i].single_nonzero_component @@ -929,7 +934,7 @@ namespace FEValuesViews // second order tensor stored as // a vector (i.e. a first-order // tensor) - typedef Tensor<1, n_independent_components> base_tensor_type; + typedef Tensor<1, value_type::n_independent_components> base_tensor_type; std::vector< base_tensor_type > values_in_vector_form(values.size(), base_tensor_type()); @@ -953,7 +958,7 @@ namespace FEValuesViews for (unsigned int q_point = 0; q_point < fe_values.n_quadrature_points; ++q_point) values_in_vector_form[q_point][comp] += value * *shape_value_ptr++; } else - for (unsigned int d = 0; d < n_independent_components; ++d) + for (unsigned int d = 0; d < value_type::n_independent_components; ++d) if (shape_function_data[shape_function].is_nonzero_shape_function_component[d]) { const double * shape_value_ptr = &fe_values.shape_values(shape_function_data[shape_function].row_index[d], 0); @@ -963,9 +968,9 @@ namespace FEValuesViews } // copy entries in std::vector to an array as there is no constructor // for a second order tensor that take a std::vector - double values_array[n_independent_components]; + double values_array[value_type::n_independent_components]; for (unsigned int q_point = 0; q_point < fe_values.n_quadrature_points; ++q_point) { - for (unsigned int d = 0; d < n_independent_components; d++) + for (unsigned int d = 0; d < value_type::n_independent_components; d++) values_array[d] = values_in_vector_form[q_point][d]; values[q_point] = dealii::SymmetricTensor<2, dim>(values_array); @@ -1026,7 +1031,7 @@ namespace FEValuesViews } } } else - for (unsigned int d = 0; d < n_independent_components; ++d) + for (unsigned int d = 0; d < value_type::n_independent_components; ++d) if (shape_function_data[shape_function].is_nonzero_shape_function_component[d]) { const unsigned int comp = shape_function_data[shape_function].single_nonzero_component_index; -- 2.39.5