From 4fc560e7ba7543d7b72990a0e8cd8602485b6306 Mon Sep 17 00:00:00 2001
From: Stephane Del Pino <stephane.delpino44@gmail.com>
Date: Fri, 15 Jun 2018 14:20:31 +0200
Subject: [PATCH] Added constructor to Boundary

builds node list from faces and connectivity
---
 src/mesh/Boundary.hpp | 47 ++++++++++++++++++++++++++++++++-----------
 1 file changed, 35 insertions(+), 12 deletions(-)

diff --git a/src/mesh/Boundary.hpp b/src/mesh/Boundary.hpp
index e23097d56..f5164262f 100644
--- a/src/mesh/Boundary.hpp
+++ b/src/mesh/Boundary.hpp
@@ -4,12 +4,14 @@
 #include <Kokkos_Core.hpp>
 #include <RefId.hpp>
 
+#include <set>
+
 class Boundary
 {
  private:
   RefId m_ref_id;
-  Kokkos::View<unsigned int*> m_face_list;
-  Kokkos::View<unsigned int*> m_node_list;
+  Kokkos::View<const unsigned int*> m_face_id_list;
+  Kokkos::View<const unsigned int*> m_node_id_list;
 
  public:
   const RefId& refId() const
@@ -19,26 +21,47 @@ class Boundary
 
   const Kokkos::View<const unsigned int*> faceList() const
   {
-    return m_face_list;
+    return m_face_id_list;
   }
 
   const Kokkos::View<const unsigned int*> nodeList() const
   {
-    return m_node_list;
+    return m_node_id_list;
   }
 
-  Boundary(const RefId& ref_id,
-           Kokkos::View<unsigned int*> face_list)
+  template<typename ConnectivityType>
+  Boundary(const ConnectivityType& connectivity,
+           const RefId& ref_id,
+           const Kokkos::View<const unsigned int*> face_id_list)
       : m_ref_id(ref_id),
-        m_face_list(face_list)
+        m_face_id_list(face_id_list)
   {
-    ;
-  }
+    std::set<unsigned int> node_id_set;
+    const Kokkos::View<const unsigned int**> face_nodes = connectivity.faceNodes();
 
-  ~Boundary()
-  {
-    ;
+    for (unsigned int l=0; l<m_face_id_list.extent(0); ++l) {
+      for (unsigned short r=0; r<2; ++r) {
+        node_id_set.insert(face_nodes(m_face_id_list[l],r));
+      }
+    }
+
+    Kokkos::View<unsigned int*> node_id_list("node_id_list", node_id_set.size());
+    {
+      int r=0;
+      for (auto node_id : node_id_set) {
+        node_id_list[r] = node_id;
+        ++r;
+      }
+    }
+    m_node_id_list = node_id_list;
   }
+
+  Boundary& operator=(const Boundary&) = default;
+  Boundary& operator=(Boundary&&) = default;
+
+  Boundary() = default;
+  Boundary(const Boundary&) = default;
+  ~Boundary() = default;
 };
 
 #endif // BOUNDARY_HPP
-- 
GitLab