From: Wolfgang Bangerth Date: Mon, 26 Apr 2021 17:02:47 +0000 (-0600) Subject: Fix the number of entries in the FEValues view cache. X-Git-Tag: v9.3.0-rc1~172^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F12099%2Fhead;p=dealii.git Fix the number of entries in the FEValues view cache. Looking at the implementation of the FEValuesViews::Vector and similar classes, we see that they return 'spacedim' objects at a time, and similar for the tensor views. The number of entries in the cache for vectors was already keyed off 'spacedim', but for the tensors it was based on 'dim' instead. This isn't quite right. --- diff --git a/source/fe/fe_values.cc b/source/fe/fe_values.cc index e2391ee2c8..a5445c2a74 100644 --- a/source/fe/fe_values.cc +++ b/source/fe/fe_values.cc @@ -2552,15 +2552,20 @@ namespace internal // note that this is based on the dimensionality 'dim' of the manifold, // not 'spacedim' of the output vector const unsigned int n_vectors = - (fe.n_components() >= spacedim ? fe.n_components() - spacedim + 1 : 0); + (fe.n_components() >= Tensor<1, spacedim>::n_independent_components ? + fe.n_components() - Tensor<1, spacedim>::n_independent_components + + 1 : + 0); vectors.reserve(n_vectors); for (unsigned int component = 0; component < n_vectors; ++component) vectors.emplace_back(fe_values, component); // compute number of symmetric tensors in the same way as above const unsigned int n_symmetric_second_order_tensors = - (fe.n_components() >= (dim * dim + dim) / 2 ? - fe.n_components() - (dim * dim + dim) / 2 + 1 : + (fe.n_components() >= + SymmetricTensor<2, spacedim>::n_independent_components ? + fe.n_components() - + SymmetricTensor<2, spacedim>::n_independent_components + 1 : 0); symmetric_second_order_tensors.reserve(n_symmetric_second_order_tensors); for (unsigned int component = 0; @@ -2571,8 +2576,10 @@ namespace internal // compute number of symmetric tensors in the same way as above const unsigned int n_second_order_tensors = - (fe.n_components() >= dim * dim ? fe.n_components() - dim * dim + 1 : - 0); + (fe.n_components() >= Tensor<2, spacedim>::n_independent_components ? + fe.n_components() - Tensor<2, spacedim>::n_independent_components + + 1 : + 0); second_order_tensors.reserve(n_second_order_tensors); for (unsigned int component = 0; component < n_second_order_tensors; ++component)