From d42cf4087f250f55164e21370aaa8f3e09da5904 Mon Sep 17 00:00:00 2001
From: Dmitri Naumov <dmitri.naumov@ufz.de>
Date: Fri, 17 Sep 2021 14:14:31 +0200
Subject: [PATCH] [MeL] Make getNumberOfBaseNodes() independent of numbering.

The new implementation uses only local topology information to
distinguish base and "higher" order nodes.
---
 MeshLib/Mesh.cpp | 7 +++++++
 MeshLib/Mesh.h   | 2 +-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/MeshLib/Mesh.cpp b/MeshLib/Mesh.cpp
index b4f42137bc9..44f26b12c64 100644
--- a/MeshLib/Mesh.cpp
+++ b/MeshLib/Mesh.cpp
@@ -256,6 +256,13 @@ void Mesh::checkNonlinearNodeIDs() const
     }
 }
 
+std::size_t Mesh::getNumberOfBaseNodes() const
+{
+    return std::count_if(begin(_nodes), end(_nodes),
+                         [](auto const* const node)
+                         { return isBaseNode(*node); });
+}
+
 bool Mesh::hasNonlinearElement() const
 {
     return std::any_of(
diff --git a/MeshLib/Mesh.h b/MeshLib/Mesh.h
index eb7950aacc5..34ecbaa9f97 100644
--- a/MeshLib/Mesh.h
+++ b/MeshLib/Mesh.h
@@ -120,7 +120,7 @@ public:
     std::size_t getID() const {return _id; }
 
     /// Get the number of base nodes
-    std::size_t getNumberOfBaseNodes() const { return _n_base_nodes; }
+    std::size_t getNumberOfBaseNodes() const;
 
     /// Check if the mesh contains any nonlinear element.
     bool hasNonlinearElement() const;
-- 
GitLab