From 97f6e3e81dbcefee60a08c895596de561a941680 Mon Sep 17 00:00:00 2001
From: Stephane Del Pino <stephane.delpino44@gmail.com>
Date: Fri, 6 Jul 2018 14:22:51 +0200
Subject: [PATCH] Added a set of const qualifiers

---
 src/mesh/Connectivity1D.hpp    | 12 ++++++------
 src/mesh/Connectivity2D.hpp    |  6 +++---
 src/mesh/Connectivity3D.hpp    |  6 +++---
 src/mesh/ConnectivityUtils.hpp | 23 +++++++++++++----------
 4 files changed, 25 insertions(+), 22 deletions(-)

diff --git a/src/mesh/Connectivity1D.hpp b/src/mesh/Connectivity1D.hpp
index 3bb13bab1..d0422f7b2 100644
--- a/src/mesh/Connectivity1D.hpp
+++ b/src/mesh/Connectivity1D.hpp
@@ -29,14 +29,14 @@ private:
   Kokkos::View<double*> m_inv_cell_nb_nodes;
   const Kokkos::View<const unsigned short*>& m_cell_nb_faces = m_cell_nb_nodes;
 
-  Kokkos::View<unsigned short*> m_node_nb_cells;
-  const Kokkos::View<unsigned short*>& m_face_nb_cells = m_node_nb_cells;
+  Kokkos::View<const unsigned short*> m_node_nb_cells;
+  const Kokkos::View<const unsigned short*>& m_face_nb_cells = m_node_nb_cells;
 
-  Kokkos::View<unsigned int**> m_node_cells;
-  const Kokkos::View<unsigned int**>& m_face_cells = m_node_cells;
+  Kokkos::View<const unsigned int**> m_node_cells;
+  const Kokkos::View<const unsigned int**>& m_face_cells = m_node_cells;
 
-  Kokkos::View<unsigned short**> m_node_cell_local_node;
-  const Kokkos::View<unsigned short**>& m_face_cell_local_face = m_node_cell_local_node;
+  Kokkos::View<const unsigned short**> m_node_cell_local_node;
+  const Kokkos::View<const unsigned short**>& m_face_cell_local_face = m_node_cell_local_node;
 
   size_t  m_max_nb_node_per_cell;
 
diff --git a/src/mesh/Connectivity2D.hpp b/src/mesh/Connectivity2D.hpp
index e4d8c9c0c..bf87b5b9a 100644
--- a/src/mesh/Connectivity2D.hpp
+++ b/src/mesh/Connectivity2D.hpp
@@ -34,9 +34,9 @@ class Connectivity2D
   Kokkos::View<const unsigned short*> m_cell_nb_faces;
   Kokkos::View<unsigned int**> m_cell_faces;
 
-  Kokkos::View<unsigned short*> m_node_nb_cells;
-  Kokkos::View<unsigned int**> m_node_cells;
-  Kokkos::View<unsigned short**> m_node_cell_local_node;
+  Kokkos::View<const unsigned short*> m_node_nb_cells;
+  Kokkos::View<const unsigned int**> m_node_cells;
+  Kokkos::View<const unsigned short**> m_node_cell_local_node;
 
   Kokkos::View<unsigned short*> m_face_nb_cells;
   Kokkos::View<unsigned int**> m_face_cells;
diff --git a/src/mesh/Connectivity3D.hpp b/src/mesh/Connectivity3D.hpp
index 64f1c22de..ce982d276 100644
--- a/src/mesh/Connectivity3D.hpp
+++ b/src/mesh/Connectivity3D.hpp
@@ -38,9 +38,9 @@ private:
   Kokkos::View<const unsigned int**> m_cell_faces;
   Kokkos::View<const bool**> m_cell_faces_is_reversed;
 
-  Kokkos::View<unsigned short*> m_node_nb_cells;
-  Kokkos::View<unsigned int**> m_node_cells;
-  Kokkos::View<unsigned short**> m_node_cell_local_node;
+  Kokkos::View<const unsigned short*> m_node_nb_cells;
+  Kokkos::View<const unsigned int**> m_node_cells;
+  Kokkos::View<const unsigned short**> m_node_cell_local_node;
 
   Kokkos::View<const unsigned short*> m_face_nb_cells;
   Kokkos::View<const unsigned int**> m_face_cells;
diff --git a/src/mesh/ConnectivityUtils.hpp b/src/mesh/ConnectivityUtils.hpp
index a6482b3df..3fe9e6f6a 100644
--- a/src/mesh/ConnectivityUtils.hpp
+++ b/src/mesh/ConnectivityUtils.hpp
@@ -12,9 +12,9 @@ class ConnectivityUtils
                                    const size_t& number_of_cells,
                                    size_t& max_nb_node_per_cell,
                                    size_t& number_of_nodes,
-                                   Kokkos::View<unsigned short*>& node_nb_cells,
-                                   Kokkos::View<unsigned int**>& node_cells,
-                                   Kokkos::View<unsigned short**>& node_cell_local_node)
+                                   Kokkos::View<const unsigned short*>& node_nb_cells,
+                                   Kokkos::View<const unsigned int**>& node_cells,
+                                   Kokkos::View<const unsigned short**>& node_cell_local_node)
   {
     std::map<unsigned int, std::vector<unsigned int>> node_cells_map;
     using namespace Kokkos::Experimental;
@@ -43,38 +43,41 @@ class ConnectivityUtils
 
     number_of_nodes = node_cells_map.size();
 
-    node_nb_cells = Kokkos::View<unsigned short*>("node_nb_cells", node_cells_map.size());
+    Kokkos::View<unsigned short*> built_node_nb_cells("node_nb_cells", node_cells_map.size());
     size_t max_node_cells = 0;
     for (const auto& i_cell_vector : node_cells_map) {
       const auto& [i, cells_vector] = i_cell_vector;
       const size_t nb_cells = cells_vector.size();
-      node_nb_cells[i] = nb_cells;
+      built_node_nb_cells[i] = nb_cells;
       if (nb_cells > max_node_cells) {
         max_node_cells = nb_cells;
       }
     }
+    node_nb_cells = built_node_nb_cells;
 
-    node_cells = Kokkos::View<unsigned int**>("node_cells", node_cells_map.size(), max_node_cells);
+    Kokkos::View<unsigned int**> built_node_cells("node_cells", node_cells_map.size(), max_node_cells);
     for (const auto& i_cell_vector : node_cells_map) {
       const auto& [i, cells_vector] = i_cell_vector;
       for (size_t j=0; j<cells_vector.size(); ++j) {
-        node_cells(i,j) = cells_vector[j];
+        built_node_cells(i,j) = cells_vector[j];
       }
     }
+    node_cells = built_node_cells;
 
-    node_cell_local_node = Kokkos::View<unsigned short**>("node_cell_local_node",
-                                                          node_cells_map.size(), max_node_cells);
+    Kokkos::View<unsigned short**> built_node_cell_local_node("node_cell_local_node",
+                                                              node_cells_map.size(), max_node_cells);
     Kokkos::parallel_for(number_of_nodes, KOKKOS_LAMBDA(const unsigned int& r){
         for (unsigned short J=0; J<node_nb_cells[r]; ++J) {
           const unsigned int j = node_cells(r,J);
           for (unsigned int R=0; R<cell_nb_nodes[j]; ++R) {
             if (cell_nodes(j,R) == r) {
-              node_cell_local_node(r,J)=R;
+              built_node_cell_local_node(r,J)=R;
               break;
             }
           }
         }
       });
+    node_cell_local_node = built_node_cell_local_node;
   }
 };
 
-- 
GitLab