From: Timo Heister Date: Thu, 30 May 2024 20:43:26 +0000 (-0400) Subject: fix bug in FESystem degreee with 0 multiplicity X-Git-Tag: v9.6.0-rc1~216^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a3f11cfabdeaf61ee0fc2f33daae9965250470b9;p=dealii.git fix bug in FESystem degreee with 0 multiplicity Bug was introduced in #17062 --- diff --git a/include/deal.II/fe/fe_tools.templates.h b/include/deal.II/fe/fe_tools.templates.h index 91234862ca..f499d71169 100644 --- a/include/deal.II/fe/fe_tools.templates.h +++ b/include/deal.II/fe/fe_tools.templates.h @@ -157,7 +157,8 @@ namespace FETools multiplied_n_components += fes[i]->n_components() * multiplicities[i]; - degree = std::max(degree, fes[i]->tensor_degree()); + if (multiplicities[i] > 0) + degree = std::max(degree, fes[i]->tensor_degree()); } // assume conformity of the first finite element and then take away diff --git a/tests/fe/system_05.cc b/tests/fe/system_05.cc new file mode 100644 index 0000000000..d2e1adb1a7 --- /dev/null +++ b/tests/fe/system_05.cc @@ -0,0 +1,55 @@ +// ------------------------------------------------------------------------ +// +// SPDX-License-Identifier: LGPL-2.1-or-later +// Copyright (C) 2012 - 2018 by the deal.II authors +// +// This file is part of the deal.II library. +// +// Part of the source code is dual licensed under Apache-2.0 WITH +// LLVM-exception OR LGPL-2.1-or-later. Detailed license information +// governing the source code and code contributions can be found in +// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II. +// +// ------------------------------------------------------------------------ + + +// Document wrong behavior with multiplicity 0 FESystem and incorrectly reported +// degree + +#include +#include +#include + +#include + +#include "../tests.h" + +template +void +check(const FiniteElement &fe) +{ + deallog << fe.get_name() << std::endl; + deallog << "components: " << fe.n_components() << std::endl; + deallog << "blocks: " << fe.n_blocks() << std::endl; + deallog << "conforms H1: " << fe.conforms(FiniteElementData::H1) + << std::endl; + deallog << "n_base_elements: " << fe.n_base_elements() << std::endl; + + deallog << "degree: " << fe.degree << std::endl; +} + +int +main() +{ + initlog(); + + { + FESystem<2> fe(FE_Q<2>(1) ^ 2, FE_Q<2>(1), FE_Q<2>(1), FE_Q<2>(2) ^ 0); + check<2>(fe); + Assert(fe.degree == 1, ExcInternalError()); + auto copy = fe.clone(); + check<2>(*copy.get()); + Assert(fe.degree == 1, ExcInternalError()); + } + return 0; +} diff --git a/tests/fe/system_05.output b/tests/fe/system_05.output new file mode 100644 index 0000000000..b0d993b655 --- /dev/null +++ b/tests/fe/system_05.output @@ -0,0 +1,13 @@ + +DEAL::FESystem<2>[FE_Q<2>(1)^2-FE_Q<2>(1)-FE_Q<2>(1)] +DEAL::components: 4 +DEAL::blocks: 4 +DEAL::conforms H1: 1 +DEAL::n_base_elements: 3 +DEAL::degree: 1 +DEAL::FESystem<2>[FE_Q<2>(1)^2-FE_Q<2>(1)-FE_Q<2>(1)] +DEAL::components: 4 +DEAL::blocks: 4 +DEAL::conforms H1: 1 +DEAL::n_base_elements: 3 +DEAL::degree: 1