diff --git a/NumLib/DOF/ComponentGlobalIndexDict.h b/NumLib/DOF/ComponentGlobalIndexDict.h index 9a759a8288a008e02c65ca7a2a82a890ce4703a8..aa4c001b9096af5d02d688ffc831eead13fd4ec0 100644 --- a/NumLib/DOF/ComponentGlobalIndexDict.h +++ b/NumLib/DOF/ComponentGlobalIndexDict.h @@ -35,16 +35,16 @@ struct Line MeshLib::Location location; // Physical component - std::size_t comp_id; + int comp_id; // Position in global matrix or vector GlobalIndexType global_index; - Line(MeshLib::Location l, std::size_t c, GlobalIndexType i) + Line(MeshLib::Location l, int c, GlobalIndexType i) : location(std::move(l)), comp_id(c), global_index(i) {} - Line(MeshLib::Location l, std::size_t c) + Line(MeshLib::Location l, int c) : location(std::move(l)), comp_id(c), global_index(std::numeric_limits<GlobalIndexType>::max()) @@ -52,7 +52,7 @@ struct Line explicit Line(MeshLib::Location l) : location(std::move(l)), - comp_id(std::numeric_limits<std::size_t>::max()), + comp_id(std::numeric_limits<int>::max()), global_index(std::numeric_limits<GlobalIndexType>::max()) {} @@ -90,22 +90,21 @@ struct ByComponent {}; struct ByGlobalIndex {}; using ComponentGlobalIndexDict = boost::multi_index::multi_index_container< - Line, - boost::multi_index::indexed_by< - boost::multi_index::ordered_unique< - boost::multi_index::tag<ByLocationAndComponent>, - boost::multi_index::identity<Line>, - LineByLocationAndComponentComparator>, - boost::multi_index::ordered_non_unique< - boost::multi_index::tag<ByLocation>, - boost::multi_index::identity<Line>, LineByLocationComparator>, - boost::multi_index::ordered_non_unique< - boost::multi_index::tag<ByComponent>, - boost::multi_index::member<Line, std::size_t, &Line::comp_id>>, - boost::multi_index::ordered_non_unique< - boost::multi_index::tag<ByGlobalIndex>, - boost::multi_index::member<Line, GlobalIndexType, - &Line::global_index>>>>; + Line, boost::multi_index::indexed_by< + boost::multi_index::ordered_unique< + boost::multi_index::tag<ByLocationAndComponent>, + boost::multi_index::identity<Line>, + LineByLocationAndComponentComparator>, + boost::multi_index::ordered_non_unique< + boost::multi_index::tag<ByLocation>, + boost::multi_index::identity<Line>, LineByLocationComparator>, + boost::multi_index::ordered_non_unique< + boost::multi_index::tag<ByComponent>, + boost::multi_index::member<Line, int, &Line::comp_id>>, + boost::multi_index::ordered_non_unique< + boost::multi_index::tag<ByGlobalIndex>, + boost::multi_index::member<Line, GlobalIndexType, + &Line::global_index>>>>; } // namespace detail } // namespace NumLib diff --git a/NumLib/DOF/MeshComponentMap.cpp b/NumLib/DOF/MeshComponentMap.cpp index 2721cf231c75e011020b6571633df817423e4768..c75cc86bf72b0f3b8e66d17c00daff3a40c3dbc6 100644 --- a/NumLib/DOF/MeshComponentMap.cpp +++ b/NumLib/DOF/MeshComponentMap.cpp @@ -43,7 +43,7 @@ MeshComponentMap::MeshComponentMap( // construct dict (and here we number global_index by component type) std::size_t cell_index = 0; - std::size_t comp_id = 0; + int comp_id = 0; _num_global_dof = 0; _num_local_dof = 0; for (auto const& c : components) @@ -97,7 +97,7 @@ MeshComponentMap::MeshComponentMap( { // construct dict (and here we number global_index by component type) GlobalIndexType global_index = 0; - std::size_t comp_id = 0; + int comp_id = 0; for (auto const& c : components) { std::size_t const mesh_id = c.getMeshID(); @@ -148,18 +148,17 @@ void MeshComponentMap::renumberByLocation(GlobalIndexType offset) } } -std::vector<std::size_t> MeshComponentMap::getComponentIDs(const Location &l) const +std::vector<int> MeshComponentMap::getComponentIDs(const Location& l) const { auto const &m = _dict.get<ByLocation>(); auto const p = m.equal_range(Line(l)); - std::vector<std::size_t> vec_compID; + std::vector<int> vec_compID; for (auto itr=p.first; itr!=p.second; ++itr) vec_compID.push_back(itr->comp_id); return vec_compID; } -Line MeshComponentMap::getLine(Location const& l, - std::size_t const comp_id) const +Line MeshComponentMap::getLine(Location const& l, int const comp_id) const { auto const &m = _dict.get<ByLocationAndComponent>(); auto const itr = m.find(Line(l, comp_id)); @@ -168,7 +167,7 @@ Line MeshComponentMap::getLine(Location const& l, } GlobalIndexType MeshComponentMap::getGlobalIndex(Location const& l, - std::size_t const comp_id) const + int const comp_id) const { auto const &m = _dict.get<ByLocationAndComponent>(); auto const itr = m.find(Line(l, comp_id)); @@ -209,7 +208,7 @@ std::vector<GlobalIndexType> MeshComponentMap::getGlobalIndicesByComponent( std::vector<Location> const& ls) const { // vector of (Component, global Index) pairs. - using CIPair = std::pair<std::size_t, GlobalIndexType>; + using CIPair = std::pair<int, GlobalIndexType>; std::vector<CIPair> pairs; pairs.reserve(ls.size()); @@ -241,7 +240,7 @@ std::vector<GlobalIndexType> MeshComponentMap::getGlobalIndicesByComponent( GlobalIndexType MeshComponentMap::getLocalIndex( Location const& l, - std::size_t const comp_id, + int const comp_id, std::size_t const range_begin, std::size_t const range_end) const { diff --git a/NumLib/DOF/MeshComponentMap.h b/NumLib/DOF/MeshComponentMap.h index 926831e2e3ef45cc21516991a0d7358272252140..8a77ec4986160727f55172ea57bc95c410f06152 100644 --- a/NumLib/DOF/MeshComponentMap.h +++ b/NumLib/DOF/MeshComponentMap.h @@ -64,14 +64,14 @@ public: /// | l | comp_id_1 | /// | l | ... | /// | l | comp_id_n | - std::vector<std::size_t> getComponentIDs(const Location &l) const; + std::vector<int> getComponentIDs(const Location& l) const; /// Global index of the given component id at given location \c l. /// /// | Location | ComponentID | GlobalIndex | /// | -------- | ----------- | ----------- | /// | l | comp_id | gi | - GlobalIndexType getGlobalIndex(Location const &l, std::size_t const comp_id) const; + GlobalIndexType getGlobalIndex(Location const& l, int const comp_id) const; /// Global indices for all components at the given location \c l. /// @@ -134,7 +134,7 @@ public: /// When domain decomposition is not used, it is equal to getGlobalIndex(). /// The range is needed to compute the offset for non-ghost locations and /// also to map ghost locations. - GlobalIndexType getLocalIndex(Location const& l, std::size_t const comp_id, + GlobalIndexType getLocalIndex(Location const& l, int const comp_id, std::size_t const range_begin, std::size_t const range_end) const; @@ -167,7 +167,7 @@ private: /// \attention The line for the location l and component id must exist, /// the behaviour is undefined otherwise. /// \return a copy of the line. - detail::Line getLine(Location const& l, std::size_t const component_id) const; + detail::Line getLine(Location const& l, int const component_id) const; void renumberByLocation(GlobalIndexType offset=0); diff --git a/Tests/NumLib/TestMeshComponentMap.cpp b/Tests/NumLib/TestMeshComponentMap.cpp index 0b05d69c7664e56f0eaf7e5b2a76758a9f17d31f..40994292bfe29e0c6a81d6212b490891bad34d5e 100644 --- a/Tests/NumLib/TestMeshComponentMap.cpp +++ b/Tests/NumLib/TestMeshComponentMap.cpp @@ -84,7 +84,7 @@ TEST_F(NumLibMeshComponentMapTest, DISABLED_CheckOrderByComponent) ASSERT_EQ(mesh_size + 1 + i, giAtNodeForComponent(i, comp1_id)); // Test component ids of the node. - std::vector<std::size_t> const vecCompIDs = cmap->getComponentIDs( + std::vector<int> const vecCompIDs = cmap->getComponentIDs( Location(mesh->getID(), MeshItemType::Node, i)); ASSERT_EQ(2u, vecCompIDs.size()); ASSERT_EQ(0u, vecCompIDs[0]); @@ -112,7 +112,7 @@ TEST_F(NumLibMeshComponentMapTest, DISABLED_CheckOrderByLocation) ASSERT_EQ(2 * i + 1, giAtNodeForComponent(i, comp1_id)); // Test component ids of the node. - std::vector<std::size_t> const vecCompIDs = cmap->getComponentIDs( + std::vector<int> const vecCompIDs = cmap->getComponentIDs( Location(mesh->getID(), MeshItemType::Node, i)); ASSERT_EQ(2u, vecCompIDs.size()); ASSERT_EQ(0u, vecCompIDs[0]);