]> https://gitweb.dealii.org/ - dealii.git/commitdiff
fix bug in FESystem degreee with 0 multiplicity 17085/head
authorTimo Heister <timo.heister@gmail.com>
Thu, 30 May 2024 20:43:26 +0000 (16:43 -0400)
committerTimo Heister <timo.heister@gmail.com>
Thu, 30 May 2024 20:51:50 +0000 (16:51 -0400)
Bug was introduced in #17062

include/deal.II/fe/fe_tools.templates.h
tests/fe/system_05.cc [new file with mode: 0644]
tests/fe/system_05.output [new file with mode: 0644]

index 91234862ca55d786812f24989e2d884939f23972..f499d71169fba915153613c3bf5fb4874023dd67 100644 (file)
@@ -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 (file)
index 0000000..d2e1adb
--- /dev/null
@@ -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 <deal.II/fe/fe_q.h>
+#include <deal.II/fe/fe_system.h>
+#include <deal.II/fe/fe_tools.h>
+
+#include <string>
+
+#include "../tests.h"
+
+template <int dim>
+void
+check(const FiniteElement<dim> &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<dim>::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 (file)
index 0000000..b0d993b
--- /dev/null
@@ -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

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.