From f71f5db7b9f931cd6c9d340a3cdb182ca356f2e1 Mon Sep 17 00:00:00 2001
From: Stephane Del Pino <stephane.delpino44@gmail.com>
Date: Tue, 4 Sep 2018 18:38:42 +0200
Subject: [PATCH] Add number of item access

---
 src/mesh/Connectivity.hpp  | 14 +++++++++++---
 src/mesh/IConnectivity.hpp | 36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+), 3 deletions(-)

diff --git a/src/mesh/Connectivity.hpp b/src/mesh/Connectivity.hpp
index 0994fc9c8..b72a38abd 100644
--- a/src/mesh/Connectivity.hpp
+++ b/src/mesh/Connectivity.hpp
@@ -439,7 +439,7 @@ class Connectivity final
   }
 
   KOKKOS_INLINE_FUNCTION
-  size_t numberOfNodes() const
+  size_t numberOfNodes() const final
   {
     const auto& node_to_cell_matrix
         = this->getMatrix(ItemType::node,ItemType::cell);
@@ -447,7 +447,15 @@ class Connectivity final
   }
 
   KOKKOS_INLINE_FUNCTION
-  size_t numberOfFaces() const
+  size_t numberOfEdges() const final
+  {
+    const auto& edge_to_node_matrix
+        = this->getMatrix(ItemType::edge,ItemType::node);
+    return edge_to_node_matrix.numRows();
+  }
+
+  KOKKOS_INLINE_FUNCTION
+  size_t numberOfFaces() const final
   {
     const auto& face_to_node_matrix
         = this->getMatrix(ItemType::face,ItemType::cell);
@@ -455,7 +463,7 @@ class Connectivity final
   }
 
   KOKKOS_INLINE_FUNCTION
-  size_t numberOfCells() const
+  size_t numberOfCells() const final
   {
     const auto& cell_to_node_matrix
         = this->getMatrix(ItemType::cell,ItemType::node);
diff --git a/src/mesh/IConnectivity.hpp b/src/mesh/IConnectivity.hpp
index 49432fdea..b9da32e8d 100644
--- a/src/mesh/IConnectivity.hpp
+++ b/src/mesh/IConnectivity.hpp
@@ -10,6 +10,42 @@ struct IConnectivity
   getMatrix(const ItemType& item_type_0,
             const ItemType& item_type_1) const = 0;
 
+  virtual size_t numberOfNodes() const = 0;
+  virtual size_t numberOfEdges() const = 0;
+  virtual size_t numberOfFaces() const = 0;
+  virtual size_t numberOfCells() const = 0;
+
+  template <ItemType item_type>
+  size_t numberOf() const = delete;
+
+  template <>
+  KOKKOS_INLINE_FUNCTION
+  size_t numberOf<ItemType::node>() const
+  {
+    return this->numberOfNodes();
+  }
+
+  template <>
+  KOKKOS_INLINE_FUNCTION
+  size_t numberOf<ItemType::edge>() const
+  {
+    return this->numberOfEdges();
+  }
+
+  template <>
+  KOKKOS_INLINE_FUNCTION
+  size_t numberOf<ItemType::face>() const
+  {
+    return this->numberOfFaces();
+  }
+
+  template <>
+  KOKKOS_INLINE_FUNCTION
+  size_t numberOf<ItemType::cell>() const
+  {
+    return this->numberOfCells();
+  }
+
   IConnectivity() = default;
   IConnectivity(const IConnectivity&) = delete;
   ~IConnectivity() = default;
-- 
GitLab