From: Wolfgang Bangerth Date: Sat, 18 May 2024 15:32:56 +0000 (-0600) Subject: Simplify some code. X-Git-Tag: v9.6.0-rc1~255^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=370218686d7fa92d0c8b8c4ebcc04a14490137a0;p=dealii.git Simplify some code. --- diff --git a/include/deal.II/fe/fe_tools.templates.h b/include/deal.II/fe/fe_tools.templates.h index 898aea2e2b..851bc31ae7 100644 --- a/include/deal.II/fe/fe_tools.templates.h +++ b/include/deal.II/fe/fe_tools.templates.h @@ -379,23 +379,19 @@ namespace FETools const FiniteElement *fe5, const unsigned int N5) { - std::vector *> fe_list; - std::vector multiplicities; + std::vector *> fe_list = { + fe1, fe2, fe3, fe4, fe5}; + std::vector multiplicities = {N1, N2, N3, N4, N5}; - fe_list.push_back(fe1); - multiplicities.push_back(N1); - - fe_list.push_back(fe2); - multiplicities.push_back(N2); - - fe_list.push_back(fe3); - multiplicities.push_back(N3); - - fe_list.push_back(fe4); - multiplicities.push_back(N4); + // This function is occasionally called with nullptr values for the + // finite elements. Drop those again. + while ((fe_list.size() > 0) && (fe_list.back() == nullptr)) + { + Assert(multiplicities.back() == 0, ExcInternalError()); + fe_list.pop_back(); + multiplicities.pop_back(); + } - fe_list.push_back(fe5); - multiplicities.push_back(N5); return compute_restriction_is_additive_flags(fe_list, multiplicities); } @@ -621,23 +617,18 @@ namespace FETools const unsigned int N5, const bool do_tensor_product) { - std::vector *> fe_list; - std::vector multiplicities; - - fe_list.push_back(fe1); - multiplicities.push_back(N1); + std::vector *> fe_list = { + fe1, fe2, fe3, fe4, fe5}; + std::vector multiplicities = {N1, N2, N3, N4, N5}; - fe_list.push_back(fe2); - multiplicities.push_back(N2); - - fe_list.push_back(fe3); - multiplicities.push_back(N3); - - fe_list.push_back(fe4); - multiplicities.push_back(N4); - - fe_list.push_back(fe5); - multiplicities.push_back(N5); + // This function is occasionally called with nullptr values for the + // finite elements. Drop those again. + while ((fe_list.size() > 0) && (fe_list.back() == nullptr)) + { + Assert(multiplicities.back() == 0, ExcInternalError()); + fe_list.pop_back(); + multiplicities.pop_back(); + } return compute_nonzero_components(fe_list, multiplicities,