From 3f3a9ce64ea23681f196d9c84a11844e28330937 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Mon, 26 Apr 2021 11:02:47 -0600 Subject: [PATCH] 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. --- source/fe/fe_values.cc | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) 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) -- 2.39.5