From 71dc1b84dc45d4bf80a00c98e9e37816af53008f Mon Sep 17 00:00:00 2001
From: "Dmitry Yu. Naumov" <github@naumov.de>
Date: Thu, 24 Sep 2015 23:11:13 +0000
Subject: [PATCH] [AsmL] Update dof table classes for GlobalIndex.

---
 AssemblerLib/ComponentGlobalIndexDict.h | 11 ++++++-----
 AssemblerLib/LocalToGlobalIndexMap.h    |  4 ++--
 AssemblerLib/MeshComponentMap.cpp       | 25 +++++++++++++------------
 AssemblerLib/MeshComponentMap.h         | 10 +++++-----
 4 files changed, 26 insertions(+), 24 deletions(-)

diff --git a/AssemblerLib/ComponentGlobalIndexDict.h b/AssemblerLib/ComponentGlobalIndexDict.h
index 59aba9e8216..e5fc2de61c9 100644
--- a/AssemblerLib/ComponentGlobalIndexDict.h
+++ b/AssemblerLib/ComponentGlobalIndexDict.h
@@ -22,6 +22,7 @@
 #include <boost/multi_index_container.hpp>
 
 #include "MeshLib/Location.h"
+#include "ProcessLib/NumericsConfig.h"
 
 namespace AssemblerLib
 {
@@ -38,21 +39,21 @@ struct Line
     std::size_t comp_id;
 
     // Position in global matrix or vector
-    std::size_t global_index;
+    GlobalIndexType global_index;
 
-    Line(MeshLib::Location const& l, std::size_t c, std::size_t i)
+    Line(MeshLib::Location const& l, std::size_t c, GlobalIndexType i)
     : location(l), comp_id(c), global_index(i)
     {}
 
     Line(MeshLib::Location const& l, std::size_t c)
     : location(l), comp_id(c),
-        global_index(std::numeric_limits<std::size_t>::max())
+        global_index(std::numeric_limits<GlobalIndexType>::max())
     {}
 
     explicit Line(MeshLib::Location const& l)
     : location(l),
         comp_id(std::numeric_limits<std::size_t>::max()),
-        global_index(std::numeric_limits<std::size_t>::max())
+        global_index(std::numeric_limits<GlobalIndexType>::max())
     {}
 
     friend std::ostream& operator<<(std::ostream& os, Line const& l)
@@ -112,7 +113,7 @@ typedef boost::multi_index::multi_index_container<
             boost::multi_index::ordered_non_unique
             <
                 boost::multi_index::tag<ByGlobalIndex>,
-                boost::multi_index::member<Line, std::size_t, &Line::global_index>
+                boost::multi_index::member<Line, GlobalIndexType, &Line::global_index>
             >
         >
     > ComponentGlobalIndexDict;
diff --git a/AssemblerLib/LocalToGlobalIndexMap.h b/AssemblerLib/LocalToGlobalIndexMap.h
index 0a60576cb75..aeb52880bdc 100644
--- a/AssemblerLib/LocalToGlobalIndexMap.h
+++ b/AssemblerLib/LocalToGlobalIndexMap.h
@@ -35,7 +35,7 @@ namespace AssemblerLib
 class LocalToGlobalIndexMap
 {
 public:
-    typedef MathLib::RowColumnIndices<std::size_t> RowColumnIndices;
+    typedef MathLib::RowColumnIndices<GlobalIndexType> RowColumnIndices;
     typedef RowColumnIndices::LineIndex LineIndex;
 
 public:
@@ -78,7 +78,7 @@ public:
     LineIndex rowIndices(std::size_t const mesh_item_id) const;
     LineIndex columnIndices(std::size_t const mesh_item_id) const;
 
-    std::size_t getGlobalIndex(MeshLib::Location const& l,
+    GlobalIndexType getGlobalIndex(MeshLib::Location const& l,
                                std::size_t const c) const
     {
         return _mesh_component_map.getGlobalIndex(l, c);
diff --git a/AssemblerLib/MeshComponentMap.cpp b/AssemblerLib/MeshComponentMap.cpp
index 93a867638d2..fe6cd483051 100644
--- a/AssemblerLib/MeshComponentMap.cpp
+++ b/AssemblerLib/MeshComponentMap.cpp
@@ -21,13 +21,14 @@ namespace AssemblerLib
 
 using namespace detail;
 
-std::size_t const MeshComponentMap::nop = std::numeric_limits<std::size_t>::max();
+GlobalIndexType const MeshComponentMap::nop =
+    std::numeric_limits<GlobalIndexType>::max();
 
 MeshComponentMap::MeshComponentMap(
     const std::vector<MeshLib::MeshSubsets*> &components, ComponentOrder order)
 {
     // construct dict (and here we number global_index by component type)
-    std::size_t global_index = 0;
+    GlobalIndexType global_index = 0;
     std::size_t comp_id = 0;
     for (auto c = components.cbegin(); c != components.cend(); ++c)
     {
@@ -81,9 +82,9 @@ MeshComponentMap::getSubset(std::vector<MeshLib::MeshSubsets*> const& components
     return MeshComponentMap(subset_dict);
 }
 
-void MeshComponentMap::renumberByLocation(std::size_t offset)
+void MeshComponentMap::renumberByLocation(GlobalIndexType offset)
 {
-    std::size_t global_index = offset;
+    GlobalIndexType global_index = offset;
 
     auto &m = _dict.get<ByLocation>(); // view as sorted by mesh item
     for (auto itr_mesh_item=m.begin(); itr_mesh_item!=m.end(); ++itr_mesh_item)
@@ -113,7 +114,7 @@ Line MeshComponentMap::getLine(Location const& l,
     return *itr;
 }
 
-std::size_t MeshComponentMap::getGlobalIndex(Location const& l,
+GlobalIndexType MeshComponentMap::getGlobalIndex(Location const& l,
     std::size_t const comp_id) const
 {
     auto const &m = _dict.get<ByLocationAndComponent>();
@@ -121,25 +122,25 @@ std::size_t MeshComponentMap::getGlobalIndex(Location const& l,
     return itr!=m.end() ? itr->global_index : nop;
 }
 
-std::vector<std::size_t> MeshComponentMap::getGlobalIndices(const Location &l) const
+std::vector<GlobalIndexType> MeshComponentMap::getGlobalIndices(const Location &l) const
 {
     auto const &m = _dict.get<ByLocation>();
     auto const p = m.equal_range(Line(l));
-    std::vector<std::size_t> global_indices;
+    std::vector<GlobalIndexType> global_indices;
     for (auto itr=p.first; itr!=p.second; ++itr)
         global_indices.push_back(itr->global_index);
     return global_indices;
 }
 
 template <>
-std::vector<std::size_t>
+std::vector<GlobalIndexType>
 MeshComponentMap::getGlobalIndices<ComponentOrder::BY_LOCATION>(
     std::vector<Location> const &ls) const
 {
     // Create vector of global indices sorted by location containing all
     // locations given in ls parameter.
 
-    std::vector<std::size_t> global_indices;
+    std::vector<GlobalIndexType> global_indices;
     global_indices.reserve(ls.size());
 
     auto const &m = _dict.get<ByLocation>();
@@ -154,12 +155,12 @@ MeshComponentMap::getGlobalIndices<ComponentOrder::BY_LOCATION>(
 }
 
 template <>
-std::vector<std::size_t>
+std::vector<GlobalIndexType>
 MeshComponentMap::getGlobalIndices<ComponentOrder::BY_COMPONENT>(
     std::vector<Location> const &ls) const
 {
     // vector of (Component, global Index) pairs.
-    typedef std::pair<std::size_t, std::size_t> CIPair;
+    typedef std::pair<std::size_t, GlobalIndexType> CIPair;
     std::vector<CIPair> pairs;
     pairs.reserve(ls.size());
 
@@ -181,7 +182,7 @@ MeshComponentMap::getGlobalIndices<ComponentOrder::BY_COMPONENT>(
     if (!std::is_sorted(pairs.begin(), pairs.end(), CIPairLess))
         std::stable_sort(pairs.begin(), pairs.end(), CIPairLess);
 
-    std::vector<std::size_t> global_indices;
+    std::vector<GlobalIndexType> global_indices;
     global_indices.reserve(pairs.size());
     for (auto p = pairs.cbegin(); p != pairs.cend(); ++p)
         global_indices.push_back(p->second);
diff --git a/AssemblerLib/MeshComponentMap.h b/AssemblerLib/MeshComponentMap.h
index a4a3dbfb81b..1ed5b0c1374 100644
--- a/AssemblerLib/MeshComponentMap.h
+++ b/AssemblerLib/MeshComponentMap.h
@@ -70,7 +70,7 @@ public:
     /// | Location | ComponentID | GlobalIndex |
     /// | -------- | ----------- | ----------- |
     /// | l        | comp_id     | gi          |
-    std::size_t getGlobalIndex(Location const &l, std::size_t const comp_id) const;
+    GlobalIndexType getGlobalIndex(Location const &l, std::size_t const comp_id) const;
 
     /// Global indices for all components at the given location \c l.
     ///
@@ -82,7 +82,7 @@ public:
     /// | l        | comp_id_1   | gi23        |
     /// | ...      |  ...        | ...         |
     /// | l        | comp_id_k   | gi45        |
-    std::vector<std::size_t> getGlobalIndices(const Location &l) const;
+    std::vector<GlobalIndexType> getGlobalIndices(const Location &l) const;
 
     /// Global indices for all components at all given locations \c ls ordered
     /// as required by the template parameter ORDER.
@@ -113,11 +113,11 @@ public:
     /// | ...      |  ...        | ...         |
     /// | l_n      | comp_id_n   | gi89        |
     template <ComponentOrder ORDER>
-    std::vector<std::size_t> getGlobalIndices(const std::vector<Location> &ls) const;
+    std::vector<GlobalIndexType> getGlobalIndices(const std::vector<Location> &ls) const;
 
     /// A value returned if no global index was found for the requested
     /// location/component. The value is implementation dependent.
-    static std::size_t const nop;
+    static GlobalIndexType const nop;
 
 #ifndef NDEBUG
     const detail::ComponentGlobalIndexDict& getDictionary() const
@@ -146,7 +146,7 @@ private:
     /// \return a copy of the line.
     detail::Line getLine(Location const& l, std::size_t const component_id) const;
 
-    void renumberByLocation(std::size_t offset=0);
+    void renumberByLocation(GlobalIndexType offset=0);
 
 private:
     detail::ComponentGlobalIndexDict _dict;
-- 
GitLab