OGS
ComponentGlobalIndexDict.h
Go to the documentation of this file.
1
13#pragma once
14
15#include <boost/multi_index/composite_key.hpp>
16#include <boost/multi_index/member.hpp>
17#include <boost/multi_index/ordered_index.hpp>
18#include <boost/multi_index_container.hpp>
19#include <limits>
20#include <utility>
21
22#include "MeshLib/Location.h"
24
25namespace NumLib
26{
28namespace detail
29{
30struct Line
31{
33
34 // Physical component
36
37 // Position in global matrix or vector
39
41 : location(std::move(l)), comp_id(c), global_index(i)
42 {
43 }
44
46 : location(std::move(l)),
47 comp_id(c),
48 global_index(std::numeric_limits<GlobalIndexType>::max())
49 {
50 }
51
53 : location(std::move(l)),
54 comp_id(std::numeric_limits<int>::max()),
55 global_index(std::numeric_limits<GlobalIndexType>::max())
56 {
57 }
58
59 friend std::ostream& operator<<(std::ostream& os, Line const& l)
60 {
61 return os << l.location << ", " << l.comp_id << ", " << l.global_index;
62 }
63};
64
66{
67 bool operator()(Line const& a, Line const& b) const
68 {
69 return a.location < b.location;
70 }
71};
72
74{
75 bool operator()(Line const& a, Line const& b) const
76 {
77 if (a.location < b.location)
78 {
79 return true;
80 }
81 if (b.location < a.location)
82 {
83 return false;
84 }
85
86 // a.loc == b.loc
87 return a.comp_id < b.comp_id;
88 }
89};
90
92{
93};
95{
96};
98{
99};
101{
102};
103
104using ComponentGlobalIndexDict = boost::multi_index::multi_index_container<
105 Line, boost::multi_index::indexed_by<
106 boost::multi_index::ordered_unique<
107 boost::multi_index::tag<ByLocationAndComponent>,
108 boost::multi_index::identity<Line>,
110 boost::multi_index::ordered_non_unique<
111 boost::multi_index::tag<ByLocation>,
112 boost::multi_index::identity<Line>, LineByLocationComparator>,
113 boost::multi_index::ordered_non_unique<
114 boost::multi_index::tag<ByComponent>,
115 boost::multi_index::member<Line, int, &Line::comp_id>>,
116 boost::multi_index::ordered_non_unique<
117 boost::multi_index::tag<ByGlobalIndex>,
118 boost::multi_index::member<Line, GlobalIndexType,
120
121} // namespace detail
122} // namespace NumLib
GlobalMatrix::IndexType GlobalIndexType
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, int, &Line::comp_id > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< ByGlobalIndex >, boost::multi_index::member< Line, GlobalIndexType, &Line::global_index > > > > ComponentGlobalIndexDict
bool operator()(Line const &a, Line const &b) const
bool operator()(Line const &a, Line const &b) const
Line(MeshLib::Location l, int c)
friend std::ostream & operator<<(std::ostream &os, Line const &l)
Line(MeshLib::Location l, int c, GlobalIndexType i)