From 11a1d0621e00330121982bab336fd425ee105c30 Mon Sep 17 00:00:00 2001
From: Christian Engwer <christi@dune-project.org>
Date: Thu, 27 Mar 2025 12:53:11 +0100
Subject: [PATCH 1/3] add additional setSize to the BasisNodeSetupHelper

---
 dune/functions/functionspacebases/nodes.hh | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/dune/functions/functionspacebases/nodes.hh b/dune/functions/functionspacebases/nodes.hh
index 67d9d8c8..823045e2 100644
--- a/dune/functions/functionspacebases/nodes.hh
+++ b/dune/functions/functionspacebases/nodes.hh
@@ -31,6 +31,12 @@ namespace Dune {
       struct BasisNodeSetupHelper
       {
 
+        template<class Node, class size_type>
+        static void setSize(Node& node, const size_type size)
+        {
+          node.setSize(size);
+        }
+
         template<class Node, class size_type>
         static void setOffset(Node& node, const size_type offset)
         {
-- 
GitLab


From 5c1546444992d94f8442f4348c857d7e1df131ea Mon Sep 17 00:00:00 2001
From: Christian Engwer <christi@dune-project.org>
Date: Thu, 27 Mar 2025 13:14:58 +0100
Subject: [PATCH 2/3] [test] relax consistency tests

In order to support multi-domain spaces we relaxed the consistency
guarantees between leaf-nodes and the corresponding finiteElement.

If node.size() == 0 accessing finiteElement is undefined behaviour and
thus we skip nodes with size() == 0.
---
 dune/functions/functionspacebases/test/basistest.hh | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/dune/functions/functionspacebases/test/basistest.hh b/dune/functions/functionspacebases/test/basistest.hh
index 4ef8ff6e..bb568b21 100644
--- a/dune/functions/functionspacebases/test/basistest.hh
+++ b/dune/functions/functionspacebases/test/basistest.hh
@@ -260,12 +260,14 @@ Dune::TestSuite checkLocalView(const Basis& basis, const LocalView& localView, F
   std::vector<std::size_t> localIndices;
   localIndices.resize(localView.size(), 0);
   Dune::TypeTree::forEachLeafNode(localView.tree(), [&](const auto& node, auto&& treePath) {
+    if (node.size() == 0) return;
     test.check(node.size() == node.finiteElement().size())
       << "Size of leaf node and finite element are different.";
     for(std::size_t i=0; i<node.size(); ++i)
     {
       test.check(node.localIndex(i) < localView.size())
-        << "Local index exceeds localView.size().";
+        << "Local index exceeds localView.size() for leaf node " << treePath << ". "
+        << node.localIndex(i) << " <? " <<  localView.size();
       if (node.localIndex(i) < localView.size())
         ++(localIndices[node.localIndex(i)]);
     }
@@ -285,6 +287,7 @@ Dune::TestSuite checkLocalView(const Basis& basis, const LocalView& localView, F
   if (not IsContained<AllowZeroBasisFunctions, Flags...>::value)
   {
     Dune::TypeTree::forEachLeafNode(localView.tree(), [&](const auto& node, auto&& treePath) {
+      if (node.size() == 0) return;
       test.subTest(checkNonZeroShapeFunctions(node.finiteElement()));
     });
   }
@@ -517,6 +520,8 @@ Dune::TestSuite checkBasisContinuity(const Basis& basis, const LocalCheck& local
         neighborLocalView.bind(intersection.outside());
 
         Dune::TypeTree::forEachLeafNode(localView.tree(), [&](const auto& insideNode, auto&& treePath) {
+          if (insideNode.size() == 0) return;
+
           const auto& outsideNode = Dune::TypeTree::child(neighborLocalView.tree(), treePath);
 
           std::vector<std::optional<int>> insideToOutside;
-- 
GitLab


From b6030213a286619e85746f7df6c0625a426ff605 Mon Sep 17 00:00:00 2001
From: Christian Engwer <christi@dune-project.org>
Date: Thu, 27 Mar 2025 13:18:27 +0100
Subject: [PATCH 3/3] add changelog entry

---
 CHANGELOG.md | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2b32ab6f..47fa05fc 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -35,7 +35,11 @@ corresponding version of the Dune core modules.
   Hermite-type C1 elements.
 - The deprecated header `functionspacebases/sizeinfo.hh` was removed.
 - The deprecated header `functionspacebases/defaultnodetorangemap.hh` was removed.
-- The deprecated header `functionspacebases/hierarchicvectorwrapper.hh` was removed.
+- The deprecated header `functionspacebases/hierarchicvectorwrapper.hh`was removed.
+- The consistency guarantees between leaf-nodes and the corresponding
+  finiteElement got relaxed. This is necessary to add multidomain
+  support. The change is that if `node.size() == 0` accessing `finiteElement`
+  is undefined behaviour. These changes are also reflected in the updated tests.
 
 ## Release 2.10
 
-- 
GitLab